diff --git a/core/assets/abilityBehaviors/AttackReplacementActives.json b/core/assets/abilityBehaviors/AttackReplacementActives.json new file mode 100644 index 000000000..0d985bb82 --- /dev/null +++ b/core/assets/abilityBehaviors/AttackReplacementActives.json @@ -0,0 +1,1144 @@ +{ + "abilityList": [{ + "ids": [{"id":"AHfa", "castId": "flamingarrowstarg", "autoCastOnId": "flamingarrows", "autoCastOffId": "unflamingarrows", "autoCastType": "NOAUTOCASTBEHAVIOR"}], + "type": "NORMAL_UNITTARGET", + "overrideFields": { + "ignoreCastTime": { + "type": "rawBoolean", + "value": "true" + } + }, + "reuseActions": { + "onHit": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 2 + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "if", + "condition": { + "type": "successfullyChargeResources", + "mana": { + "type": "getAbilityManaCost" + } + }, + "thenActions": [{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onModify" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + }] + }], + "onChangeAutoCast": [{ + "type": "if", + "condition": { + "type": "isAutoCastCurrentlyActive" + }, + "thenActions": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "elseActions": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "fireModifiedAttack", + "target": { + "type": "getAbilityTargetedUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + }, + "showMissOnFailure": { + "type": "not", + "condition": { + "type": "isDisabled" + } + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }] + },{ + "ids": [{"id":"Afak", "castId": "flamingattacktarg", "autoCastOnId": "flamingattack", "autoCastOffId": "unflamingattack", "autoCastType": "NOAUTOCASTBEHAVIOR"}], + "type": "INHERIT", + "parentId": "AHfa", + "reuseActions": { + "onHit": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }], + "onModify": [{ + "type": "attackModifierSetSplashFields", + "areaOfEffectFullDamage": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "areaOfEffectMediumDamage": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "areaOfEffectSmallDamage": { + "type": "f2i", + "value": { + "type": "getAbilityArea" + } + }, + "damageFactorMedium": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "damageFactorSmall": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + }] + } + },{ + "ids": [{"id":"ANba", "castId": "blackarrow", "autoCastOnId": "blackarrowon", "autoCastOffId": "blackarrowoff", "autoCastType": "NOAUTOCASTBEHAVIOR"}], + "type": "INHERIT", + "parentId": "AHfa", + "reuseActions": { + "onHit": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "MAGIC" + } + } + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getBuffedUnit" + } + } + },{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getSecondBuffId", + "defaultId": { + "type": "getWar3IDFromString", + "id": "BNdm" + } + }, + "duration": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + } + },{ + "ids": [{"id":"AHca", "castId": "coldarrowstarg", "autoCastOnId": "coldarrows", "autoCastOffId": "uncoldarrows", "autoCastType": "NOAUTOCASTBEHAVIOR"}], + "type": "INHERIT", + "parentId": "AHfa", + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "frostArrows" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "frostArrows" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "frostArrows" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "frostArrows" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "inlineConditionID", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "pass": { + "type": "getSecondBuffId" + }, + "fail": { + "type": "getFirstBuffId" + } + } + }], + "levelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onHit": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "COLD" + } + } + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + } + },{ + "ids": [{"id":"ANia", "castId": "incineratearrow", "autoCastOnId": "incineratearrowon", "autoCastOffId": "incineratearrowoff", "autoCastType": "NOAUTOCASTBEHAVIOR"}], + "type": "INHERIT", + "parentId": "AHfa", + "reuseActions": { + "explode": [{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "F" + }, + "actions": [{ + "type": "damageBurst", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "validTarget": { + "type": "isUnitEnemy", + "unit": { + "type": "getEnumUnit" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "fullDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "partialDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "partialDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + }] + }], + "onHit": [{ + "type": "if", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "thenActions": [{ + "type": "buffStoreUniqueValue", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "value2": { + "type": "getBuffUniqueValueFloat", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + } + } + } + },{ + "type": "addBonusDamageDealt", + "value": { + "type": "getBuffUniqueValueFloat", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }], + "elseActions": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }] + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "uniqueValues": { + "incinerate": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "onAddActions": [{ + "type": "setExplodesOnDeath", + "unit": { + "type": "getBuffedUnit" + }, + "explodes": { + "type": "rawBoolean", + "value": "true" + }, + "buffId": { + "type": "getFirstBuffId" + } + }], + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "explode" + } + }], + "elseActions": [{ + "type": "setExplodesOnDeath", + "unit": { + "type": "getBuffedUnit" + }, + "explodes": { + "type": "rawBoolean", + "value": "false" + }, + "buffId": { + "type": "getFirstBuffId" + } + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + } + },{ + "ids": [{"id":"AEpa", "castId": "poisonarrowstarg", "autoCastOnId": "poisonarrows", "autoCastOffId": "unpoisonarrows", "autoCastType": "NOAUTOCASTBEHAVIOR"}], + "type": "INHERIT", + "parentId": "AHfa", + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "poisonarrows" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "poisonarrows" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "poisonarrows" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "poisonarrows" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "inlineConditionID", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "pass": { + "type": "getSecondBuffId" + }, + "fail": { + "type": "getFirstBuffId" + } + } + }], + "levelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onHit": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "POISON" + } + } + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "visibilityGroup": { + "type": "id2s", + "value": { + "type": "getAlias" + } + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + },{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "showIcon": { + "type": "rawBoolean", + "value": "false" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + }, + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "nonlethal": { + "type": "not", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "POISON" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + } + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/AttackReplacementPassivesItems.json b/core/assets/abilityBehaviors/AttackReplacementPassivesItems.json new file mode 100644 index 000000000..a000aa145 --- /dev/null +++ b/core/assets/abilityBehaviors/AttackReplacementPassivesItems.json @@ -0,0 +1,1659 @@ +{ + "abilityList": [{ + "ids": [{"id":"AIva"}], + "type": "HIDDEN", + "onAddDisabledAbility": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "HPSTEAL" + } + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getAttackingUnit" + }, + "buff": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "addAttackPostDamageListener", + "unit": { + "type": "getAttackingUnit" + }, + "listener": { + "type": "getLastCreatedAttackPostDamageListener" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackPostDamageListener", + "priority": { + "type": "rawInteger", + "value": 1 + }, + "actions": [{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getAttackingUnit" + }, + "buff": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "removeAttackPostDamageListener", + "unit": { + "type": "getAttackingUnit" + }, + "listener": { + "type": "getLastCreatedAttackPostDamageListener" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAttackingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 3 + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onLevelChange": [{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getLastCreatedNonStackingStatBuff" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "recomputeStatBuffsOnUnit", + "targetUnit": { + "type": "getCastingUnit" + }, + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "HPSTEAL" + } + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"AIDB"}], + "type": "HIDDEN", + "onAddDisabledAbility": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ALLATK" + } + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkBuff" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "ENABLE_ATTACK", + "value": { + "type": "getAbilityDataAsLong", + "dataField": "E" + } + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkEnb" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "i+", + "value1": { + "type": "rawInteger", + "value": 4 + }, + "value2": { + "type": "i0IfNull", + "value": { + "type": "getItemSlot" + } + } + }, + "preLaunchModification": [{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierApplyDefaultSpeed" + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onModify" + } + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onAddAbility": [{ + "type": "createSpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "effectType": "TARGET" + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_orbEff" + }, + "valueToStore": { + "type": "getLastCreatedFX" + } + },{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkBuff" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkEnb" + } + } + },{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "enable" + } + }], + "onLevelChange": [{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkBuff" + } + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "updateStateModBuff", + "buff": { + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkEnb" + } + }, + "value": { + "type": "getAbilityDataAsLong", + "dataField": "E" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }], + "onRemoveAbility": [{ + "type": "removeEffect", + "effect": { + "type": "getStoredFXByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_orbEff" + } + } + },{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkBuff" + } + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "_atkEnb" + } + } + },{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "disable" + } + }], + "onRemoveDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "cleanup" + } + }] + },{ + "ids": [{"id":"AIcb"}], + "type": "INHERIT", + "parentId": "AIDB", + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "DEF" + } + }, + "stackingKey": { + "type": "rawString", + "value": "orbOfCorrupt" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + }], + "levelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onHit": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getLastCreatedNonStackingStatBuff" + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + } + },{ + "ids": [{"id":"AIob"}], + "type": "INHERIT", + "parentId": "AIDB", + "reuseActions": { + "onHit": [{ + "type": "addSlowBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "unit": { + "type": "getAttackedUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + } + }] + } + },{ + "ids": [{"id":"AIzb"}], + "type": "INHERIT", + "parentId": "AIDB", + "reuseActions": { + "onHit": [{ + "type": "addStunBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "unit": { + "type": "getAttackedUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + } + }] + } + },{ + "ids": [{"id":"AIfb"}], + "type": "INHERIT", + "parentId": "AIDB", + "reuseActions": { + "setup": [{ + "type": "createAttackPostDamageListener", + "priority": { + "type": "rawInteger", + "value": 1 + }, + "actions": [{ + "type": "if", + "condition": { + "type": "getStoredBooleanByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "hit" + } + }, + "thenActions": [{ + "type": "damageBurst", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getAttackedUnit" + } + }, + "validTarget": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + },{ + "type": "not", + "condition": { + "type": "isUnitEqual", + "unit1": { + "type": "getAttackedUnit" + }, + "unit2": { + "type": "getEnumUnit" + } + } + }] + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "UNIVERSAL" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "fullDamageRadius": { + "type": "getAbilityArea" + } + }], + "elseActions": [{ + "type": "if", + "condition": { + "type": "isAttackProjectile" + }, + "thenActions": [{ + "type": "damageBurst", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getAttackedUnit" + } + }, + "validTarget": { + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "UNIVERSAL" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "fullDamageRadius": { + "type": "getAbilityArea" + } + }] + }] + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "hit" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "hit" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "false" + } + }], + "onModify": [{ + "type": "attackModifierAddPostDamageListener", + "listener": { + "type": "getLastCreatedAttackPostDamageListener" + } + }], + "onHit": [{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "hit" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "true" + } + }] + } + },{ + "ids": [{"id":"AIsb"}], + "type": "INHERIT", + "parentId": "AIDB", + "reuseActions": { + "addAbility": [{ + "type": "createAbilityFromId", + "id": { + "type": "getAbilityUnitId" + } + },{ + "type": "clickDisableAbility", + "ability": { + "type": "getLastCreatedAbility" + } + },{ + "type": "if", + "condition": { + "type": "isItemAbility" + }, + "thenActions": [{ + "type": "abilitySetShowIcon", + "ability": { + "type": "getLastCreatedAbility" + }, + "show": { + "type": "rawBoolean", + "value": false + } + }] + },{ + "type": "addAbility", + "ability": { + "type": "getLastCreatedAbility" + } + }], + "removeAbility": [{ + "type": "removeAbility", + "ability": { + "type": "getLastCreatedAbility" + } + }], + "enable": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "addAbility" + } + }], + "levelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "removeAbility" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "addAbility" + } + }], + "disable": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "removeAbility" + } + }], + "onHit": [{ + "type": "if", + "condition": { + "type": "f<", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 100 + } + }, + "value2": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitHero", + "unit": { + "type": "getAttackedUnit" + } + }, + "pass": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "fail": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitSummoned", + "unit": { + "type": "getAttackedUnit" + } + }, + "pass": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "fail": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + } + }, + "thenActions": [{ + "type": "abilityAttemptToApplyEffect", + "ability": { + "type": "getLastCreatedAbility" + }, + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getAttackedUnit" + } + }] + }] + } + },{ + "ids": [{"id":"AIlb"}], + "type": "INHERIT", + "parentId": "AIDB", + "reuseActions": { + "onHit": [{ + "type": "abilityAttemptToApplyEffect", + "ability": { + "type": "getAbilityById", + "id": { + "type": "getWar3IDFromString", + "id": "AIlp" + } + }, + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getAttackedUnit" + } + }] + } + },{ + "ids": [{"id":"AIpb"}], + "type": "INHERIT", + "parentId": "AIDB", + "reuseActions": { + "setup": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getAbilityById", + "id": { + "type": "getWar3IDFromString", + "id": "Apo2" + } + } + },{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }, + "thenActions": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityUniqueValueInteger", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataD" + } + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "poisonarrows" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "poisonarrows" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityUniqueValueFloat", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataC" + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityUniqueValueInteger", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataD" + } + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "poisonarrows" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "poisonarrows" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityUniqueValueFloat", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataB" + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "inlineConditionID", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityUniqueValueInteger", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataD" + } + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "pass": { + "type": "getAbilityUniqueValueId", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "buff2" + } + }, + "fail": { + "type": "getAbilityUniqueValueId", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "buff1" + } + } + } + }] + }], + "levelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onHit": [{ + "type": "if", + "condition": { + "type": "isNull", + "value": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }] + },{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }, + "thenActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "duration": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitHeroDuration", + "unit": { + "type": "getAttackedUnit" + } + }, + "pass": { + "type": "getAbilityUniqueValueFloat", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "heroDur" + } + }, + "fail": { + "type": "getAbilityUniqueValueFloat", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dur" + } + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityUniqueValueInteger", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataD" + } + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + },{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "showIcon": { + "type": "rawBoolean", + "value": "false" + }, + "duration": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitHeroDuration", + "unit": { + "type": "getAttackedUnit" + } + }, + "pass": { + "type": "getAbilityUniqueValueFloat", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "heroDur" + } + }, + "fail": { + "type": "getAbilityUniqueValueFloat", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dur" + } + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityUniqueValueInteger", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataD" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + }, + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "nonlethal": { + "type": "not", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityUniqueValueInteger", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataD" + } + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + } + }, + "damage": { + "type": "getAbilityUniqueValueFloat", + "ability": { + "type": "getStoredAbilityByKey", + "key": { + "type": "rawString", + "value": "poisonData" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "key": { + "type": "rawString", + "value": "dataA" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "UNIVERSAL" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + } + },{ + "ids": [{"id":"Apo2"}], + "type": "HIDDEN", + "reuseActions": { + "setup": [{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "dataA" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "dataB" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "dataC" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "dataD" + }, + "valueToStore": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + } + },{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "dur" + }, + "valueToStore": { + "type": "getAbilityDuration" + } + },{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "heroDur" + }, + "valueToStore": { + "type": "getAbilityHeroDuration" + } + },{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "buff1" + }, + "valueToStore": { + "type": "getFirstBuffId" + } + },{ + "type": "abilityStoreUniqueValue", + "key": { + "type": "rawString", + "value": "buff2" + }, + "valueToStore": { + "type": "getSecondBuffId" + } + }] + }, + "onAddAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onRemoveAbility": [{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "dataA" + } + },{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "dataB" + } + },{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "dataC" + } + },{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "dataD" + } + },{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "dur" + } + },{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "heroDur" + } + },{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "buff1" + } + },{ + "type": "abilityRemoveUniqueValue", + "key": { + "type": "rawString", + "value": "buff2" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/AttackReplacementPassivesNonItem.json b/core/assets/abilityBehaviors/AttackReplacementPassivesNonItem.json new file mode 100644 index 000000000..0b668a1bf --- /dev/null +++ b/core/assets/abilityBehaviors/AttackReplacementPassivesNonItem.json @@ -0,0 +1,590 @@ +{ + "abilityList": [{ + "ids": [{"id":"AHbh"},{"id":"AOcr"},{"id":"ANdb"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }, + "thenActions": [{ + "type": "addDamageDealtMultiplier", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + },{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "attackType": { + "type": "getAttackTypeFromString", + "id": { + "type": "rawString", + "value": "SPELLS" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "MAGIC" + } + } + },{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + } + }, + "thenActions": [{ + "type": "addStunBuff", + "unit": { + "type": "getAttackedUnit" + }, + "buffId": { + "type": "inlineConditionID", + "condition": { + "type": "isNull", + "value": { + "type": "getFirstBuffId" + } + }, + "pass": { + "type": "getWar3IDFromString", + "id": "BPSE" + }, + "fail": { + "type": "getFirstBuffId" + } + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + } + }] + },{ + "type": "if", + "condition": { + "type": "rawBoolean", + "value": "false" + }, + "thenActions": [{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "crit" + }, + "valueToStore": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "if", + "condition": { + "type": "bool", + "bool": { + "type": "getAbilityDataAsBoolean", + "dataField": "E" + } + }, + "thenActions": [{ + "type": "preDamageListenerSetMiss", + "miss": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "true" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "nomiss" + }, + "valueToStore": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "createEvasionListener", + "conditions": [{ + "type": "f<", + "value1": { + "type": "randomFloat" + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 1 + }, + "preLaunchCondition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "preLaunchModification": [{ + "type": "if", + "condition": { + "type": "f<", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 100 + } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "thenActions": [{ + "type": "attackModifierAddAnimationTag", + "tag": { + "type": "rawString", + "value": "SLAM" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "isCritting" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "true" + } + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "isCritting" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "false" + } + }] + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "if", + "condition": { + "type": "getStoredBooleanByKey", + "key": { + "type": "rawString", + "value": "isCritting" + } + }, + "thenActions": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getStoredAttackPreDamageListenerByKey", + "key": { + "type": "rawString", + "value": "crit" + } + } + }] + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + },{ + "type": "addAttackPreDamageListener", + "targetUnit": { + "type": "getCastingUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "ACCURACY" + }, + "listener": { + "type": "getStoredAttackPreDamageListenerByKey", + "key": { + "type": "rawString", + "value": "nomiss" + } + } + },{ + "type": "addEvasionListener", + "targetUnit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedEvasionListener" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + },{ + "type": "removeAttackPreDamageListener", + "targetUnit": { + "type": "getCastingUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "ACCURACY" + }, + "listener": { + "type": "getStoredAttackPreDamageListenerByKey", + "key": { + "type": "rawString", + "value": "nomiss" + } + } + },{ + "type": "removeEvasionListener", + "targetUnit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedEvasionListener" + } + }] + },{ + "ids": [{"id":"ANic"}], + "type": "PASSIVE", + "reuseActions": { + "explode": [{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "F" + }, + "actions": [{ + "type": "damageBurst", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "validTarget": { + "type": "isUnitEnemy", + "unit": { + "type": "getEnumUnit" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "fullDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "partialDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "partialDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + }] + }], + "onHit": [{ + "type": "if", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "thenActions": [{ + "type": "buffStoreUniqueValue", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "value2": { + "type": "getBuffUniqueValueFloat", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + } + } + } + },{ + "type": "addBonusDamageDealt", + "value": { + "type": "getBuffUniqueValueFloat", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }], + "elseActions": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }] + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "uniqueValues": { + "incinerate": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "onAddActions": [{ + "type": "setExplodesOnDeath", + "unit": { + "type": "getBuffedUnit" + }, + "explodes": { + "type": "rawBoolean", + "value": "true" + }, + "buffId": { + "type": "getFirstBuffId" + } + }], + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "explode" + } + }], + "elseActions": [{ + "type": "setExplodesOnDeath", + "unit": { + "type": "getBuffedUnit" + }, + "explodes": { + "type": "rawBoolean", + "value": "false" + }, + "buffId": { + "type": "getFirstBuffId" + } + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 5 + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/AttackReplacementPassivesNonItemLowPriority.json b/core/assets/abilityBehaviors/AttackReplacementPassivesNonItemLowPriority.json new file mode 100644 index 000000000..dee809d16 --- /dev/null +++ b/core/assets/abilityBehaviors/AttackReplacementPassivesNonItemLowPriority.json @@ -0,0 +1,2227 @@ +{ + "abilityList": [{ + "ids": [{"id":"Acor"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "preLaunchCondition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "preLaunchModification": [{ + "type": "attackModifierAddAnimationTag", + "tag": { + "type": "rawString", + "value": "SPELL" + } + },{ + "type": "attackModifierPreventOtherModifications" + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Afrz"}], + "type": "PASSIVE", + "reuseActions": { + "setup": [{ + "type": "createStateModBuff", + "buffType": "STUN", + "value": { + "type": "rawLong", + "value": 2 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "stun" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "DISABLE_ALL" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "dAll" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "BLOCK_REPAIR", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "bRep" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "BLOCK_TRAINING" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "bTrn" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "BLOCK_CONSTRUCTION" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "bCon" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + }], + "onHit": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stateMods": [{ + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "stun" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "dAll" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "bRep" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "bTrn" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "bCon" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Aliq"}], + "type": "PASSIVE", + "reuseActions": { + "setup": [{ + "type": "createStateModBuff", + "buffType": "BLOCK_REPAIR", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "liqfire" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "liqfire" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }], + "onHit": [{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }], + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }] + },{ + "ids": [{"id":"Afbk"}], + "type": "PASSIVE", + "reuseActions": { + "burnMana": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mana" + }, + "valueToStore": { + "type": "fMin", + "value1": { + "type": "getUnitCurrentMana", + "unit": { + "type": "getAttackedUnit" + } + }, + "value2": { + "type": "argumentFloat", + "name": { + "type": "rawString", + "value": "burn" + } + } + } + },{ + "type": "subtractMp", + "unit": { + "type": "getAttackedUnit" + }, + "amount": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "mana" + } + } + },{ + "type": "addBonusDamageDealt", + "value": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "mana" + } + }, + "value2": { + "type": "argumentFloat", + "name": { + "type": "rawString", + "value": "ratio" + } + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "MAGIC" + } + } + }], + "onHit": [{ + "type": "if", + "condition": { + "type": "isUnitHero", + "unit": { + "type": "getAttackedUnit" + } + }, + "thenActions": [{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "burnMana" + }, + "arguments": { + "burn": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "ratio": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + } + }], + "elseActions": [{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "burnMana" + }, + "arguments": { + "burn": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "ratio": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + }] + },{ + "type": "damageTarget", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getAttackedUnit" + }, + "onlyDamageSummons": { + "type": "rawBoolean", + "value": "true" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAttackedUnit" + }, + "effectType": "SPECIAL" + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + },{ + "type": "or", + "conditions": [{ + "type": "i!=0", + "value": { + "type": "getUnitMaximumMp", + "unit": { + "type": "getAttackedUnit" + } + } + },{ + "type": "isUnitSummoned", + "unit": { + "type": "getAttackedUnit" + } + }] + }] + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Aven"}], + "type": "PASSIVE", + "reuseCallbacks": { + "stackingKey": { + "type": "rawString", + "value": "venSp" + } + }, + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "reuseString", + "name": { + "type": "rawString", + "value": "stackingKey" + } + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "reuseString", + "name": { + "type": "rawString", + "value": "stackingKey" + } + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "reuseString", + "name": { + "type": "rawString", + "value": "stackingKey" + } + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "reuseString", + "name": { + "type": "rawString", + "value": "stackingKey" + } + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "inlineConditionID", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "pass": { + "type": "getSecondBuffId" + }, + "fail": { + "type": "getFirstBuffId" + } + } + }], + "levelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onHit": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "visibilityGroup": { + "type": "id2s", + "value": { + "type": "getAlias" + } + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + },{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "buffId" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "showIcon": { + "type": "rawBoolean", + "value": "false" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + }, + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "nonlethal": { + "type": "not", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "POISON" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "preLaunchModification": [{ + "type": "attackModifierApplyArt" + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }] + },{ + "ids": [{"id":"Apoi"}], + "type": "INHERIT", + "parentId": "Aven", + "reuseCallbacks": { + "stackingKey": { + "type": "rawString", + "value": "poiAtk" + } + } + },{ + "ids": [{"id":"Aspo"}], + "type": "INHERIT", + "parentId": "Aven", + "reuseCallbacks": { + "stackingKey": { + "type": "rawString", + "value": "slowPo" + } + } + },{ + "ids": [{"id":"Aflk"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "damageSplash", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getAttackedUnit" + } + }, + "validTarget": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + },{ + "type": "not", + "condition": { + "type": "isUnitEqual", + "unit1": { + "type": "getAttackedUnit" + }, + "unit2": { + "type": "getEnumUnit" + } + } + }] + }, + "isAttack": { + "type": "rawBoolean", + "value": "true" + }, + "isRanged": { + "type": "isAttackRanged" + }, + "attackType": { + "type": "getAttackType" + }, + "damageType": { + "type": "getAttackDamageType" + }, + "fullDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "fullDamageRadius": { + "type": "getAbilityArea" + }, + "mediumDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "mediumDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "smallDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "smallDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "extraActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getEnumUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + }] + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Afsh"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getAttackImpactLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + },{ + "type": "damageSplash", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getAttackImpactLocation" + }, + "validTarget": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + },{ + "type": "isDefenseTypeInList", + "defenseType": { + "type": "getUnitDefenseType", + "unit": { + "type": "getEnumUnit" + } + }, + "list": [{ + "type": "getDefenseTypeFromString", + "id": { + "type": "rawString", + "value": "MEDIUM" + } + },{ + "type": "getDefenseTypeFromString", + "id": { + "type": "rawString", + "value": "NONE" + } + }] + }] + }, + "isAttack": { + "type": "rawBoolean", + "value": "true" + }, + "isRanged": { + "type": "isAttackRanged" + }, + "attackType": { + "type": "getAttackType" + }, + "damageType": { + "type": "getAttackDamageType" + }, + "fullDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "fullDamageRadius": { + "type": "getAbilityArea" + }, + "mediumDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "mediumDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "smallDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "smallDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "extraActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getEnumUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + }] + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Aroc"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "useCastId": { + "type": "rawBoolean", + "value": "false" + }, + "actions": [{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "useCastId": { + "type": "rawBoolean", + "value": "false" + }, + "priority": { + "type": "rawInteger", + "value": 10 + }, + "condition": { + "type": "isWeaponTypeEqual", + "weaponType1": { + "type": "getAttackWeaponType" + }, + "weaponType2": { + "type": "getWeaponTypeFromString", + "id": { + "type": "rawString", + "value": "MISSILE" + } + } + }, + "modification": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fired" + }, + "valueToStore": { + "type": "rawInteger", + "value": 0 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "damage" + }, + "valueToStore": { + "type": "getAttackBaseDamage" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkT" + }, + "valueToStore": { + "type": "getAttackType" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "damT" + }, + "valueToStore": { + "type": "getAttackDamageType" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "cnt" + }, + "valueToStore": { + "type": "iMin", + "value1": { + "type": "f2i", + "value": { + "type": "ceil", + "value": { + "type": "f/", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "value2": { + "type": "getAttackBaseDamage" + } + } + } + }, + "value2": { + "type": "inlineConditionInteger", + "condition": { + "type": "i>", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + }, + "value2": { + "type": "rawInteger", + "value": 0 + } + }, + "pass": { + "type": "i+", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + }, + "fail": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + } + } + } + },{ + "type": "iterateUnitsInRangeOfUnitMatchingConditionWithSort", + "originUnit": { + "type": "getAttackingUnit" + }, + "range": { + "type": "getAbilityArea" + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + },{ + "type": "not", + "condition": { + "type": "isUnitEqual", + "unit1": { + "type": "getAttackedUnit" + }, + "unit2": { + "type": "getMatchingUnit" + } + } + }] + }, + "sort": { + "type": "f2i", + "value": { + "type": "f-", + "value1": { + "type": "getDistanceBetweenUnits", + "origin": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getCompUnit1" + } + }, + "value2": { + "type": "getDistanceBetweenUnits", + "origin": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getCompUnit2" + } + } + } + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "or", + "conditions": [{ + "type": "i=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "cnt" + } + } + },{ + "type": "i<", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + }, + "value2": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "cnt" + } + } + }] + }, + "thenActions": [{ + "type": "createUnitTargetedProjectile", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getEnumUnit" + }, + "id": { + "type": "getAlias" + }, + "onHit": [{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getProjectileHitUnit" + }, + "attackType": { + "type": "getStoredAttackTypeByKey", + "key": { + "type": "rawString", + "value": "atkT" + } + }, + "damageType": { + "type": "getStoredDamageTypeByKey", + "key": { + "type": "rawString", + "value": "damT" + } + }, + "damage": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "damage" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fired" + }, + "valueToStore": { + "type": "i-", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + },{ + "type": "if", + "condition": { + "type": "i=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + } + }, + "thenActions": [{ + "type": "cleanUpCastInstance" + }] + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fired" + }, + "valueToStore": { + "type": "i+", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + }] + }] + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Abof"}], + "type": "PASSIVE", + "reuseCallbacks": { + "notTakingDamage": { + "type": "not", + "condition": { + "type": "doesUnitHaveBuffMatchingCondition", + "unit": { + "type": "getEnumUnit" + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isIdEqual", + "id1": { + "type": "getBuffAlias", + "buff": { + "type": "getMatchingBuff" + } + }, + "id2": { + "type": "getFirstBuffId" + } + },{ + "type": "f<", + "value1": { + "type": "getBuffDurationElapsed", + "buff": { + "type": "getMatchingBuff" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "curDelay" + } + }, + "value2": { + "type": "f*", + "value1": { + "type": "oneGameTick" + }, + "value2": { + "type": "rawFloat", + "value": 2 + } + } + } + }] + } + } + } + }, + "reuseActions": { + "damageUnits": [{ + "type": "damageArea", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + }, + "validTarget": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + },{ + "type": "reuseBoolean", + "name": { + "type": "rawString", + "value": "notTakingDamage" + } + }] + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + }, + "damage": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "curDamage" + } + }, + "maxDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "F" + }, + "unitSpecificDamageMod": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitBuilding", + "unit": { + "type": "getEnumUnit" + } + }, + "pass": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "fail": { + "type": "rawFloat", + "value": 1 + } + }, + "radius": { + "type": "getAbilityArea" + }, + "extraActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "duration": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "curDelay" + } + }, + "value2": { + "type": "oneGameTick" + } + } + },{ + "type": "addBuff", + "target": { + "type": "getEnumUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "onHit": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "targetLoc" + }, + "valueToStore": { + "type": "getAttackImpactLocation" + } + },{ + "type": "createGroupEffectAtLocation", + "location": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + }, + "radius": { + "type": "getAbilityArea" + }, + "id": { + "type": "getFirstEffectId" + }, + "effectType": "EFFECT" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "_gEff" + }, + "valueToStore": { + "type": "getLastCreatedFX" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "curDamage" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "curDelay" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "repeats": { + "type": "rawBoolean", + "value": "true" + }, + "delay": { + "type": "rawFloat", + "value": 0 + }, + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "damageUnits" + } + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "dmgTimer" + }, + "valueToStore": { + "type": "getLastCreatedTimer" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityHeroDuration" + }, + "actions": [{ + "type": "updateTimerTimeout", + "timer": { + "type": "getStoredTimerByKey", + "key": { + "type": "rawString", + "value": "dmgTimer" + } + }, + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "curDelay" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "curDamage" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "subDmgTimer" + }, + "valueToStore": { + "type": "getLastCreatedTimer" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDuration" + }, + "actions": [{ + "type": "removeEffect", + "effect": { + "type": "getStoredFXByKey", + "key": { + "type": "rawString", + "value": "_gEff" + } + } + },{ + "type": "killTimer", + "timer": { + "type": "getStoredTimerByKey", + "key": { + "type": "rawString", + "value": "subDmgTimer" + } + } + },{ + "type": "killTimer", + "timer": { + "type": "getStoredTimerByKey", + "key": { + "type": "rawString", + "value": "dmgTimer" + } + } + },{ + "type": "cleanUpCastInstance" + }] + }] + }, + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "useCastId": { + "type": "rawBoolean", + "value": "false" + }, + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 10 + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/AttackReplacementPassivesNonItemLowestPriority.json b/core/assets/abilityBehaviors/AttackReplacementPassivesNonItemLowestPriority.json new file mode 100644 index 000000000..3d6c3b803 --- /dev/null +++ b/core/assets/abilityBehaviors/AttackReplacementPassivesNonItemLowestPriority.json @@ -0,0 +1,837 @@ +{ + "abilityList": [{ + "ids": [{"id":"Alit"}], + "type": "HIDDEN", + "onAddDisabledAbility": [{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 11 + }, + "preLaunchModification": [{ + "type": "attackModifierApplyArt", + "applyArtIfMissing": { + "type": "rawBoolean", + "value": "true" + } + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierApplyArtAndSpeed", + "applyArtIfMissing": { + "type": "rawBoolean", + "value": "true" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAttackedUnit" + }, + "effectType": "TARGET" + },{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getLastCreatedLightningEffect" + } + }, + "thenActions": [{ + "type": "removeLightningEffect", + "effect": { + "type": "getLastCreatedLightningEffect" + } + }] + },{ + "type": "createLightningEffect", + "origin": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getAttackedUnit" + }, + "duration": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Apts"}], + "type": "PASSIVE", + "reuseActions": { + "setup": [{ + "type": "createStateModBuff", + "buffType": "INVULNERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "invulBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "MAGIC_IMMUNE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mimBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNSELECTABLE", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "selBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNENUMERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "enumBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + }], + "onHit": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getAttackImpactLocation" + }, + "facing": { + "type": "rawFloat", + "value": 225 + } + },{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getWar3IDFromString", + "id": "Bplg" + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invulBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "mimBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "selBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "enumBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 11 + }, + "modification": [{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Afra"}], + "type": "PASSIVE", + "reuseActions": { + "onHit": [{ + "type": "if", + "condition": { + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "isAttackArtillery" + } + },{ + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }] + }, + "thenActions": [{ + "type": "addSlowBuff", + "unit": { + "type": "getAttackedUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + } + }] + },{ + "type": "iterateUnitsInRangeOfLocationMatchingCondition", + "location": { + "type": "getAttackImpactLocation" + }, + "range": { + "type": "i2f", + "value": { + "type": "getAttackMaximumSplashRadius" + } + }, + "condition": { + "type": "or", + "conditions": [{ + "type": "and", + "conditions": [{ + "type": "isAttackArtillery" + },{ + "type": "isUnitEqual", + "unit1": { + "type": "getMatchingUnit" + }, + "unit2": { + "type": "getAttackedUnit" + } + },{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }] + },{ + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "isUnitEqual", + "unit1": { + "type": "getMatchingUnit" + }, + "unit2": { + "type": "getAttackedUnit" + } + } + },{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + },{ + "type": "isUnitValidSplashDamageTarget", + "unit": { + "type": "getMatchingUnit" + } + }] + }] + }, + "iterationActions": [{ + "type": "addSlowBuff", + "unit": { + "type": "getEnumUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getEnumUnit" + } + } + }] + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 11 + }, + "modification": [{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Afrb"}], + "type": "HIDDEN", + "reuseActions": { + "onHit": [{ + "type": "if", + "condition": { + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "isAttackArtillery" + } + },{ + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }] + }, + "thenActions": [{ + "type": "addSlowBuff", + "unit": { + "type": "getAttackedUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + } + }] + },{ + "type": "iterateUnitsInRangeOfLocationMatchingCondition", + "location": { + "type": "getAttackImpactLocation" + }, + "range": { + "type": "i2f", + "value": { + "type": "getAttackMaximumSplashRadius" + } + }, + "condition": { + "type": "or", + "conditions": [{ + "type": "and", + "conditions": [{ + "type": "isAttackArtillery" + },{ + "type": "isUnitEqual", + "unit1": { + "type": "getMatchingUnit" + }, + "unit2": { + "type": "getAttackedUnit" + } + },{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }] + },{ + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "isUnitEqual", + "unit1": { + "type": "getMatchingUnit" + }, + "unit2": { + "type": "getAttackedUnit" + } + } + },{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + },{ + "type": "isUnitValidSplashDamageTarget", + "unit": { + "type": "getMatchingUnit" + } + }] + }] + }, + "iterationActions": [{ + "type": "addSlowBuff", + "unit": { + "type": "getEnumUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getEnumUnit" + } + } + }] + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 11 + }, + "modification": [{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"Aspa"}], + "type": "HIDDEN", + "reuseActions": { + "onHit": [{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getAttackedUnit" + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "settings" + }, + "valueToStore": { + "type": "getCurrentAttackSettings" + } + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getWar3IDFromString", + "id": "Bspa" + }, + "duration": { + "type": "getAbilityDuration" + }, + "showIcon": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "rawBoolean", + "value": "true" + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "onRemoveActions": [{ + "type": "createUnitTargetedProjectile", + "source": { + "type": "getBuffedUnit" + }, + "target": { + "type": "getBuffCastingUnit" + }, + "settings": { + "type": "getStoredAttackSettingsByKey", + "key": { + "type": "rawString", + "value": "settings" + } + } + },{ + "type": "cleanUpCastInstance" + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "createAttackPreDamageListener", + "useCastId": { + "type": "rawBoolean", + "value": "false" + }, + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 11 + }, + "modification": [{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierSetAttackArc", + "arc": { + "type": "rawFloat", + "value": 0.0 + } + },{ + "type": "attackModifierSetAttackStartZ", + "z": { + "type": "rawFloat", + "value": 0.0 + } + },{ + "type": "attackModifierSetAttackImpactZ", + "impactZ": { + "type": "rawFloat", + "value": 0.0 + } + },{ + "type": "attackModifierSetAttackDeathTime", + "deathTime": { + "type": "rawFloat", + "value": 0.0 + } + },{ + "type": "attackModifierSetAttackHoming", + "homing": { + "type": "rawBoolean", + "value": "true" + } + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/AttackReplacementPassivesPostDamage.json b/core/assets/abilityBehaviors/AttackReplacementPassivesPostDamage.json new file mode 100644 index 000000000..afaf76778 --- /dev/null +++ b/core/assets/abilityBehaviors/AttackReplacementPassivesPostDamage.json @@ -0,0 +1,315 @@ +{ + "abilityList": [{ + "ids": [{"id":"Awar"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "createAttackPostDamageListener", + "priority": { + "type": "rawInteger", + "value": 0 + }, + "actions": [{ + "type": "createSoundEffectOnUnit", + "unit": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + } + },{ + "type": "damageBurst", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getAttackingUnit" + } + }, + "validTarget": { + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "SONIC" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "fullDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "partialDamage": { + "type": "f/", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "value2": { + "type": "rawFloat", + "value": 2.0 + } + }, + "partialDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "extraActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getEnumUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + }] + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 1 + }, + "preLaunchCondition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "preLaunchModification": [{ + "type": "if", + "condition": { + "type": "f<", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 100 + } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "thenActions": [{ + "type": "attackModifierAddAnimationTag", + "tag": { + "type": "rawString", + "value": "SLAM" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "pulving" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "true" + } + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "pulving" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "false" + } + }] + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "if", + "condition": { + "type": "getStoredBooleanByKey", + "key": { + "type": "rawString", + "value": "pulving" + } + }, + "thenActions": [{ + "type": "attackModifierAddPostDamageListener", + "listener": { + "type": "getLastCreatedAttackPostDamageListener" + } + }] + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + },{ + "ids": [{"id":"ANca"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "createAttackPostDamageListener", + "priority": { + "type": "rawInteger", + "value": 0 + }, + "actions": [{ + "type": "damageArea", + "source": { + "type": "getAttackingUnit" + }, + "target": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getAttackingUnit" + } + }, + "dist": { + "type": "getAbilityArea" + }, + "angle": { + "type": "getUnitFacing", + "unit": { + "type": "getAttackingUnit" + } + }, + "angleInDegrees": { + "type": "rawBoolean", + "value": "true" + } + }, + "validTarget": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + },{ + "type": "not", + "condition": { + "type": "isUnitEqual", + "unit1": { + "type": "getAttackedUnit" + }, + "unit2": { + "type": "getEnumUnit" + } + } + }] + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "ENHANCED" + } + }, + "damage": { + "type": "f*", + "value1": { + "type": "getFinalTotalDamageDealt" + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "radius": { + "type": "getAbilityArea" + }, + "extraActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getEnumUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + }] + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 1 + }, + "preLaunchCondition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "preLaunchModification": [{ + "type": "attackModifierAddAnimationTag", + "tag": { + "type": "rawString", + "value": "SLAM" + } + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierAddPostDamageListener", + "listener": { + "type": "getLastCreatedAttackPostDamageListener" + } + },{ + "type": "attackModifierApplyArt" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/Chains.json b/core/assets/abilityBehaviors/Chains.json new file mode 100644 index 000000000..416c64eca --- /dev/null +++ b/core/assets/abilityBehaviors/Chains.json @@ -0,0 +1,279 @@ +{ + "abilityList": [{ + "ids": [{"id":"AOcl", "castId": "chainlightning"}], + "type": "NORMAL_UNITTARGET", + "displayFields": { + "hideAreaCursor": { + "type": "rawBoolean", + "value": "true" + } + }, + "reuseCallbacks": { + "jumpCondition": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + },{ + "type": "isUnitVisible", + "unit": { + "type": "getMatchingUnit" + } + },{ + "type": "not", + "condition": { + "type": "isUnitSleeping", + "unit": { + "type": "getMatchingUnit" + } + } + }] + } + }, + "reuseActions": { + "onCast": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "amount" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }], + "onHit": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getChainUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getChainUnit" + }, + "damage": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "amount" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "LIGHTNING" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "amount" + }, + "valueToStore": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "amount" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "rawFloat", + "value": 1 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + } + }] + }, + "onEndCasting": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onCast" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "chainEffect", + "target": { + "type": "getAbilityTargetedUnit" + }, + "lightningId": { + "type": "getAlias" + }, + "bounces": { + "type": "i-", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + }, + "range": { + "type": "getAbilityArea" + }, + "bounceDelay": { + "type": "rawFloat", + "value": 0.25 + }, + "allowMultipleBouncesPerUnit": { + "type": "rawBoolean", + "value": "false" + }, + "condition": { + "type": "reuseBoolean", + "name": { + "type": "rawString", + "value": "jumpCondition" + } + }, + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + }] + }] + },{ + "ids": [{"id":"AOhw", "castId": "healingwave"}], + "type": "INHERIT", + "parentId": "AOcl", + "extraTargetConditions": [{ + "type": "reuseBooleanWithArguments", + "name": { + "type": "rawString", + "value": "targetCondition" + }, + "arguments": { + "checkUnit": { + "type": "getAbilityTargetedUnit" + } + } + }], + "reuseCallbacks": { + "targetCondition": { + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "not", + "condition": { + "type": "isUnitMaxHp", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + } + } + }, + "reason": "ALREADY_AT_FULL_HEALTH" + }, + "jumpCondition": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + },{ + "type": "reuseBooleanWithArguments", + "name": { + "type": "rawString", + "value": "targetCondition" + }, + "arguments": { + "checkUnit": { + "type": "getMatchingUnit" + } + } + },{ + "type": "isUnitVisible", + "unit": { + "type": "getMatchingUnit" + } + }] + } + }, + "reuseActions": { + "onHit": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getChainUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "heal", + "target": { + "type": "getChainUnit" + }, + "amount": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "amount" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "amount" + }, + "valueToStore": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "amount" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "rawFloat", + "value": 1 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + } + }] + } + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/DeathSummons.json b/core/assets/abilityBehaviors/DeathSummons.json new file mode 100644 index 000000000..e1fb27293 --- /dev/null +++ b/core/assets/abilityBehaviors/DeathSummons.json @@ -0,0 +1,783 @@ +{ + "abilityList": [{ + "ids": [{"id":"ANbs", "castId": "blackarrow"}], + "type": "NORMAL_UNITTARGET", + "overrideFields": { + "universalSpell": { + "type": "rawBoolean", + "value": "true" + } + }, + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "owner": { + "type": "getOwnerOfUnit", + "unit": { + "type": "getBuffCastingUnit" + } + }, + "loc": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getBuffedUnit" + } + } + },{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getSecondBuffId", + "defaultId": { + "type": "getWar3IDFromString", + "id": "BNdm" + } + }, + "duration": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + },{ + "ids": [{"id":"ANdo", "castId": "doom"}], + "type": "NORMAL_UNITTARGET", + "reuseActions": { + "setup": [{ + "type": "createStateModBuff", + "buffType": "DISABLE_SPELLS" + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "UNIVERSAL" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }], + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "owner": { + "type": "getOwnerOfUnit", + "unit": { + "type": "getBuffCastingUnit" + } + }, + "loc": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getBuffedUnit" + } + } + },{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getSecondBuffId", + "defaultId": { + "type": "getWar3IDFromString", + "id": "BNdi" + } + }, + "duration": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + },{ + "type": "cleanUpCastInstance" + }] + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }] + },{ + "ids": [{"id":"ANpa", "castId": "parasite", "autoCastOnId": "parasiteon", "autoCastOffId": "parasiteoff", "autoCastType": "FARTHESTVALID"}], + "type": "NORMAL_UNITTARGET", + "overrideFields": { + "ignoreCastTime": { + "type": "rawBoolean", + "value": "true" + } + }, + "extraTargetConditions": [{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "not", + "condition": { + "type": "isUnitSummoned", + "unit": { + "type": "getAbilityTargetedUnit" + } + } + }, + "reason": "UNABLE_TO_TARGET_SUMMONED_UNITS" + }], + "extraAutoTargetConditions": [{ + "type": "not", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + } + }], + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "parasite" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "parasite" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "inlineConditionString", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "pass": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "parasite" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getCastingUnit" + } + }] + }, + "fail": { + "type": "rawString", + "value": "parasite" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }], + "levelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createUnitTargetedProjectile", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "onHit": [{ + "type": "checkAbilityProjReaction", + "target": { + "type": "getProjectileHitUnit" + }, + "projectile": { + "type": "getReactionAbilityProjectile" + }, + "onHitActions": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getProjectileHitUnit" + }, + "onHitActions": [{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getProjectileHitUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "nonlethal": { + "type": "not", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "POISON" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }], + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "owner": { + "type": "getOwnerOfUnit", + "unit": { + "type": "getBuffCastingUnit" + } + }, + "loc": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getBuffedUnit" + } + } + },{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getSecondBuffId", + "defaultId": { + "type": "getWar3IDFromString", + "id": "BNpm" + } + }, + "duration": { + "type": "getAbilityCastTime" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + },{ + "type": "cleanUpCastInstance" + }] + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getProjectileHitUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }] + },{ + "ids": [{"id":"Asod"},{"id":"Assp"},{"id":"Aspd"}], + "type": "HIDDEN", + "onAddDisabledAbility": [{ + "type": "createDeathReplacementEffect", + "actions": [{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityDataAsID", + "dataField": "B" + }, + "loc": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getWar3IDFromString", + "id": "BFig" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "true" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + }], + "onAddAbility": [{ + "type": "addDeathReplacementEffect", + "target": { + "type": "getCastingUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "GENERALONDEATHACTIONS" + }, + "listener": { + "type": "getLastCreatedDeathReplacement" + } + }], + "onRemoveAbility": [{ + "type": "removeDeathReplacementEffect", + "target": { + "type": "getCastingUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "GENERALONDEATHACTIONS" + }, + "listener": { + "type": "getLastCreatedDeathReplacement" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/Dispels.json b/core/assets/abilityBehaviors/Dispels.json new file mode 100644 index 000000000..ee2e8102a --- /dev/null +++ b/core/assets/abilityBehaviors/Dispels.json @@ -0,0 +1,2200 @@ +{ + "abilityList": [{ + "ids": [{"id":"Adis", "castId": "dispel"},{"id":"Adch", "castId": "disenchant"},{"id":"AIdi", "castId": "itemdispelaoe"}], + "type": "NORMAL_POINTTARGET", + "reuseActions": { + "dispelLoc": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "createSoundEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + } + },{ + "type": "iterateUnitsInRangeOfLocationMatchingCondition", + "location": { + "type": "getTargetedLocation" + }, + "range": { + "type": "getAbilityArea" + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, + "iterationActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getEnumUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "if", + "condition": { + "type": "isUnitEnemy", + "unit": { + "type": "getEnumUnit" + } + }, + "thenActions": [{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getEnumUnit" + }, + "onlyDamageSummons": { + "type": "rawBoolean", + "value": "true" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + },{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getEnumUnit" + } + }, + "thenActions": [{ + "type": "if", + "condition": { + "type": "not", + "condition": { + "type": "isUnitMagicImmune", + "unit": { + "type": "getEnumUnit" + } + } + }, + "thenActions": [{ + "type": "subtractMp", + "unit": { + "type": "getEnumUnit" + }, + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }] + },{ + "type": "dispelBuffs", + "unit": { + "type": "getEnumUnit" + }, + "filter": { + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + } + }] + }] + },{ + "type": "iterateDestructablesInRangeOfLocation", + "location": { + "type": "getTargetedLocation" + }, + "range": { + "type": "getAbilityArea" + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "isDestructableValidTarget", + "target": { + "type": "getEnumDestructable" + } + }, + "thenActions": [{ + "type": "dispelDestructableBuffs", + "dest": { + "type": "getEnumDestructable" + }, + "filter": { + "type": "isDestructableBuffMagic", + "buff": { + "type": "enumDestructableBuff" + } + } + }] + }] + }] + }, + "onEndCasting": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "dispelLoc" + } + }] + },{ + "ids": [{"id":"Adtn", "castId": "detonate"}], + "type": "INHERIT", + "parentId": "Adch", + "onEndCasting": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "dispelLoc" + } + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + },{ + "type": "killUnit", + "unit": { + "type": "getCastingUnit" + } + }] + },{ + "ids": [{"id":"Aprg", "castId": "purge"}], + "type": "NORMAL_UNITTARGET", + "overrideFields": { + "dispel": { + "type": "rawBoolean", + "value": "true" + } + }, + "extraTargetConditions": [{ + "type": "or", + "conditions": [{ + "type": "notNull", + "value": { + "type": "getAbilityTargetedUnit" + } + },{ + "type": "and", + "conditions": [{ + "type": "notNull", + "value": { + "type": "getAbilityTargetedDestructable" + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "doesDestructableHaveBuffMatchingCondition", + "dest": { + "type": "getAbilityTargetedDestructable" + }, + "condition": { + "type": "isDestructableBuffMagic", + "buff": { + "type": "matchingDestructableBuff" + } + } + }, + "reason": "THAT_TREE_IS_NOT_OCCUPIED_BY_AN_OWL" + }] + }] + }], + "reuseActions": { + "purgeUnit": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "purgeUnitBuffs" + } + }] + }], + "purgeUnitBuffs": [{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getUnitLocation", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + },{ + "type": "if", + "condition": { + "type": "isUnitEnemy", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getAbilityTargetedUnit" + }, + "onlyDamageSummons": { + "type": "rawBoolean", + "value": "true" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "fMin", + "value1": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitHero", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "pass": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "fail": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + }, + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + } + } + }, + "thenActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "visibilityGroup": { + "type": "id2s", + "value": { + "type": "getAlias" + } + }, + "duration": { + "type": "fMin", + "value1": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitHero", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "pass": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "fail": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + }, + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkSpdAmt" + }, + "valueToStore": { + "type": "inlineConditionFloat", + "condition": { + "type": "i!=0", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + } + }, + "pass": { + "type": "rawFloat", + "value": -1 + }, + "fail": { + "type": "rawFloat", + "value": 0 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkSpdStep" + }, + "valueToStore": { + "type": "inlineConditionFloat", + "condition": { + "type": "i!=0", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + } + }, + "pass": { + "type": "f/", + "value1": { + "type": "rawFloat", + "value": 1 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }, + "fail": { + "type": "rawFloat", + "value": 0 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkSpdDelay" + }, + "valueToStore": { + "type": "inlineConditionFloat", + "condition": { + "type": "i!=0", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + } + }, + "pass": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "atkSpdStep" + } + }, + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + } + }, + "fail": { + "type": "rawFloat", + "value": 999999 + } + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "purge" + }, + "value": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "atkSpdAmt" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkSpdBuff" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "moveAmt" + }, + "valueToStore": { + "type": "inlineConditionFloat", + "condition": { + "type": "i!=0", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + } + }, + "pass": { + "type": "rawFloat", + "value": -1 + }, + "fail": { + "type": "rawFloat", + "value": 0 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "moveStep" + }, + "valueToStore": { + "type": "inlineConditionFloat", + "condition": { + "type": "i!=0", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + } + }, + "pass": { + "type": "f/", + "value1": { + "type": "rawFloat", + "value": 1 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "fail": { + "type": "rawFloat", + "value": 0 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "moveDelay" + }, + "valueToStore": { + "type": "inlineConditionFloat", + "condition": { + "type": "i!=0", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + } + }, + "pass": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "moveStep" + } + }, + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + } + }, + "fail": { + "type": "rawFloat", + "value": 999999 + } + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "purge" + }, + "value": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "moveAmt" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "moveBuff" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "visibilityGroup": { + "type": "id2s", + "value": { + "type": "getAlias" + } + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "stacks": { + "type": "rawBoolean", + "value": "true" + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "atkSpdBuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "moveBuff" + } + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "moveAmt" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "moveAmt" + } + }, + "value2": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "moveStep" + } + } + } + },{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "moveBuff" + } + }, + "value": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "moveAmt" + } + } + },{ + "type": "recomputeStatBuffsOnUnit", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + } + }], + "delaySeconds": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "moveDelay" + } + }, + "unique": { + "type": "rawString", + "value": "move" + } + },{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkSpdAmt" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "atkSpdAmt" + } + }, + "value2": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "atkSpdStep" + } + } + } + },{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "atkSpdBuff" + } + }, + "value": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "atkSpdAmt" + } + } + },{ + "type": "recomputeStatBuffsOnUnit", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + } + }], + "delaySeconds": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "atkSpdDelay" + } + }, + "unique": { + "type": "rawString", + "value": "atk" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + },{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "if", + "condition": { + "type": "not", + "condition": { + "type": "isUnitMagicImmune", + "unit": { + "type": "getAbilityTargetedUnit" + } + } + }, + "thenActions": [{ + "type": "subtractMp", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "F" + } + }] + },{ + "type": "dispelBuffs", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "filter": { + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + } + }] + }], + "purgeDest": [{ + "type": "dispelDestructableBuffs", + "dest": { + "type": "getAbilityTargetedDestructable" + }, + "filter": { + "type": "isDestructableBuffMagic", + "buff": { + "type": "enumDestructableBuff" + } + } + }] + }, + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "SNARED" + }], + "onEndCasting": [{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "purgeUnit" + } + }], + "elseActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "purgeDest" + } + }] + }] + },{ + "ids": [{"id":"AIlp", "castId": "itemlightningpurge"}], + "type": "INHERIT", + "parentId": "Aprg", + "overrideFields": { + "physicalSpell": { + "type": "rawBoolean", + "value": "false" + }, + "magicSpell": { + "type": "rawBoolean", + "value": "false" + } + }, + "reuseActions": { + "purgeUnit": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "purgeUnitBuffs" + } + }] + } + },{ + "ids": [{"id":"Aadm", "castId": "autodispel", "autoCastOnId": "autodispelon", "autoCastOffId": "autodispeloff", "autoCastType": "NEARESTVALID"}], + "type": "NORMAL_UNITTARGET", + "overrideFields": { + "dispel": { + "type": "rawBoolean", + "value": "true" + } + }, + "extraTargetConditions": [{ + "type": "or", + "conditions": [{ + "type": "notNull", + "value": { + "type": "getAbilityTargetedUnit" + } + },{ + "type": "and", + "conditions": [{ + "type": "notNull", + "value": { + "type": "getAbilityTargetedDestructable" + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "doesDestructableHaveBuffMatchingCondition", + "dest": { + "type": "getAbilityTargetedDestructable" + }, + "condition": { + "type": "isDestructableBuffMagic", + "buff": { + "type": "matchingDestructableBuff" + } + } + }, + "reason": "THAT_TREE_IS_NOT_OCCUPIED_BY_AN_OWL" + }] + }] + }], + "extraAutoTargetConditions": [{ + "type": "or", + "conditions": [{ + "type": "and", + "conditions": [{ + "type": "isUnitFriend", + "unit": { + "type": "getAbilityTargetedUnit" + } + },{ + "type": "doesUnitHaveBuffMatchingCondition", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "getMatchingBuff" + } + },{ + "type": "isBuffNegative", + "buff": { + "type": "getMatchingBuff" + } + }] + } + }] + },{ + "type": "and", + "conditions": [{ + "type": "isUnitEnemy", + "unit": { + "type": "getAbilityTargetedUnit" + } + },{ + "type": "doesUnitHaveBuffMatchingCondition", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "getMatchingBuff" + } + },{ + "type": "isBuffPositive", + "buff": { + "type": "getMatchingBuff" + } + }] + } + }] + }] + }], + "reuseActions": { + "purgeUnit": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "purgeUnitBuffs" + } + }] + }], + "purgeUnitBuffs": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "if", + "condition": { + "type": "isUnitEnemy", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getAbilityTargetedUnit" + }, + "onlyDamageSummons": { + "type": "rawBoolean", + "value": "true" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + },{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "if", + "condition": { + "type": "not", + "condition": { + "type": "isUnitMagicImmune", + "unit": { + "type": "getAbilityTargetedUnit" + } + } + }, + "thenActions": [{ + "type": "subtractMp", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }] + },{ + "type": "if", + "condition": { + "type": "or", + "conditions": [{ + "type": "wasAutoCast" + },{ + "type": "gameplayConstantSmartAbolishMagic" + }] + }, + "thenActions": [{ + "type": "if", + "condition": { + "type": "isUnitEnemy", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "dispelBuffs", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "filter": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + },{ + "type": "isBuffPositive", + "buff": { + "type": "enumBuff" + } + }] + } + }], + "elseActions": [{ + "type": "dispelBuffs", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "filter": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + },{ + "type": "isBuffNegative", + "buff": { + "type": "enumBuff" + } + }] + } + }] + }], + "elseActions": [{ + "type": "dispelBuffs", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "filter": { + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + } + }] + }] + }], + "purgeDest": [{ + "type": "dispelDestructableBuffs", + "dest": { + "type": "getAbilityTargetedDestructable" + }, + "filter": { + "type": "isDestructableBuffMagic", + "buff": { + "type": "enumDestructableBuff" + } + } + }] + }, + "onEndCasting": [{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getAbilityTargetedUnit" + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "purgeUnit" + } + }], + "elseActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "purgeDest" + } + }] + }] + },{ + "ids": [{"id":"Advm", "castId": "devourmagic"}], + "type": "NORMAL_POINTTARGET", + "reuseActions": { + "healProj": [{ + "type": "if", + "condition": { + "type": "isUnitEqual", + "unit1": { + "type": "getCastingUnit" + }, + "unit2": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "source" + } + } + }, + "thenActions": [{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "healEffect" + }, + "arguments": { + "buffCount": { + "type": "argumentFloat", + "name": { + "type": "rawString", + "value": "buffCnt" + } + }, + "unitCount": { + "type": "argumentBoolean", + "name": { + "type": "rawString", + "value": "unitCnt" + } + } + } + }], + "elseActions": [{ + "type": "if", + "condition": { + "type": "or", + "conditions": [{ + "type": "argumentBoolean", + "name": { + "type": "rawString", + "value": "unitCnt" + } + },{ + "type": "f>0", + "value": { + "type": "argumentFloat", + "name": { + "type": "rawString", + "value": "buffCnt" + } + } + }] + }, + "thenActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "source" + } + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "createUnitTargetedProjectile", + "source": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "source" + } + }, + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "onHit": [{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "healEffect" + }, + "arguments": { + "buffCount": { + "type": "getStoredFloatByKey", + "key": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "buffCnt" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getProjectileSourceUnit", + "proj": { + "type": "getThisProjectile" + } + } + }] + } + }, + "unitCount": { + "type": "getStoredBooleanByKey", + "key": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "unitCnt" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getProjectileSourceUnit", + "proj": { + "type": "getThisProjectile" + } + } + }] + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fired" + }, + "valueToStore": { + "type": "i-", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + },{ + "type": "if", + "condition": { + "type": "i=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + } + }, + "thenActions": [{ + "type": "cleanUpCastInstance" + }] + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "buffCnt" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "source" + } + } + }] + }, + "valueToStore": { + "type": "argumentFloat", + "name": { + "type": "rawString", + "value": "buffCnt" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "unitCnt" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "source" + } + } + }] + }, + "valueToStore": { + "type": "argumentBoolean", + "name": { + "type": "rawString", + "value": "unitCnt" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fired" + }, + "valueToStore": { + "type": "i+", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + }] + }] + }], + "healEffect": [{ + "type": "heal", + "target": { + "type": "getCastingUnit" + }, + "amount": { + "type": "f*", + "value1": { + "type": "argumentFloat", + "name": { + "type": "rawString", + "value": "buffCount" + } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "addMp", + "target": { + "type": "getCastingUnit" + }, + "amount": { + "type": "f*", + "value1": { + "type": "argumentFloat", + "name": { + "type": "rawString", + "value": "buffCount" + } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + } + },{ + "type": "if", + "condition": { + "type": "argumentBoolean", + "name": { + "type": "rawString", + "value": "unitCount" + } + }, + "thenActions": [{ + "type": "heal", + "target": { + "type": "getCastingUnit" + }, + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "addMp", + "target": { + "type": "getCastingUnit" + }, + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + }] + }, + "onEndCasting": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fired" + }, + "valueToStore": { + "type": "rawInteger", + "value": 0 + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "createSoundEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + } + },{ + "type": "iterateUnitsInRangeOfLocationMatchingCondition", + "location": { + "type": "getTargetedLocation" + }, + "range": { + "type": "getAbilityArea" + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, + "iterationActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "buffCnt" + }, + "valueToStore": { + "type": "inlineConditionFloat", + "condition": { + "type": "and", + "conditions": [{ + "type": "isUnitSummoned", + "unit": { + "type": "getEnumUnit" + } + },{ + "type": "isUnitEnemy", + "unit": { + "type": "getEnumUnit" + } + }] + }, + "pass": { + "type": "rawFloat", + "value": 1 + }, + "fail": { + "type": "rawFloat", + "value": 0 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "allyBuffCnt" + }, + "valueToStore": { + "type": "rawFloat", + "value": 0 + } + },{ + "type": "if", + "condition": { + "type": "isUnitEnemy", + "unit": { + "type": "getEnumUnit" + } + }, + "thenActions": [{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getEnumUnit" + }, + "onlyDamageSummons": { + "type": "rawBoolean", + "value": "true" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + }] + },{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getEnumUnit" + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "buffCnt" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "buffCnt" + } + }, + "value2": { + "type": "i2f", + "value": { + "type": "countBuffsOnUnitMatchingCondition", + "unit": { + "type": "getEnumUnit" + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "getMatchingBuff" + } + },{ + "type": "not", + "condition": { + "type": "isBuffAlly", + "buff": { + "type": "getMatchingBuff" + } + } + }] + } + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "allyBuffCnt" + }, + "valueToStore": { + "type": "i2f", + "value": { + "type": "countBuffsOnUnitMatchingCondition", + "unit": { + "type": "getEnumUnit" + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "getMatchingBuff" + } + },{ + "type": "isBuffAlly", + "buff": { + "type": "getMatchingBuff" + } + }] + } + } + } + },{ + "type": "dispelBuffs", + "unit": { + "type": "getEnumUnit" + }, + "filter": { + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + } + }] + },{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "healProj" + }, + "arguments": { + "source": { + "type": "getEnumUnit" + }, + "buffCnt": { + "type": "inlineConditionFloat", + "condition": { + "type": "getAbilityDataAsBoolean", + "dataField": "F" + }, + "pass": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "buffCnt" + } + }, + "fail": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "buffCnt" + } + }, + "value2": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "allyBuffCnt" + } + } + } + }, + "unitCnt": { + "type": "inlineConditionBoolean", + "condition": { + "type": "getAbilityDataAsBoolean", + "dataField": "F" + }, + "pass": { + "type": "f>0", + "value": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "buffCnt" + } + } + }, + "fail": { + "type": "f>0", + "value": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "buffCnt" + } + }, + "value2": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "allyBuffCnt" + } + } + } + } + } + } + }] + },{ + "type": "iterateDestructablesInRangeOfLocation", + "location": { + "type": "getTargetedLocation" + }, + "range": { + "type": "getAbilityArea" + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "isDestructableValidTarget", + "target": { + "type": "getEnumDestructable" + } + }, + "thenActions": [{ + "type": "dispelDestructableBuffs", + "dest": { + "type": "getEnumDestructable" + }, + "filter": { + "type": "isDestructableBuffMagic", + "buff": { + "type": "enumDestructableBuff" + } + } + }] + }] + },{ + "type": "if", + "condition": { + "type": "i=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "fired" + } + } + }, + "thenActions": [{ + "type": "cleanUpCastInstance" + }] + }] + },{ + "ids": [{"id":"AIdc", "castId": "itemchaindispel"}], + "type": "NORMAL_UNITTARGET", + "displayFields": { + "hideAreaCursor": { + "type": "rawBoolean", + "value": "true" + } + }, + "extraTargetConditions": [{ + "type": "reuseBooleanWithArguments", + "name": { + "type": "rawString", + "value": "targetCondition" + }, + "arguments": { + "checkUnit": { + "type": "getAbilityTargetedUnit" + } + } + }], + "reuseCallbacks": { + "targetCondition": { + "type": "or", + "conditions": [{ + "type": "and", + "conditions": [{ + "type": "isUnitFriend", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "doesUnitHaveBuffMatchingCondition", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "getMatchingBuff" + } + },{ + "type": "isBuffNegative", + "buff": { + "type": "getMatchingBuff" + } + }] + } + }, + "reason": "MUST_TARGET_A_FRIENDLY_UNIT_WITH_NEGATIVE_BUFFS" + }] + },{ + "type": "and", + "conditions": [{ + "type": "isUnitEnemy", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + } + },{ + "type": "or", + "conditions": [{ + "type": "and", + "conditions": [{ + "type": "f>0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "or", + "conditions": [{ + "type": "isUnitSummoned", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + } + },{ + "type": "doesUnitHaveBuffMatchingCondition", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "getMatchingBuff" + } + },{ + "type": "isBuffPositive", + "buff": { + "type": "getMatchingBuff" + } + }] + } + }] + }, + "reason": "MUST_TARGET_AN_ENEMY_UNIT_WITH_POSITIVE_BUFFS_OR_A_SUMMONED_UNIT" + }] + },{ + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "doesUnitHaveBuffMatchingCondition", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + }, + "condition": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "getMatchingBuff" + } + },{ + "type": "isBuffPositive", + "buff": { + "type": "getMatchingBuff" + } + }] + } + }, + "reason": "MUST_TARGET_AN_ENEMY_UNIT_WITH_POSITIVE_BUFFS" + }] + }] + }] + }] + }, + "jumpCondition": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + },{ + "type": "reuseBooleanWithArguments", + "name": { + "type": "rawString", + "value": "targetCondition" + }, + "arguments": { + "checkUnit": { + "type": "getMatchingUnit" + } + } + },{ + "type": "isUnitVisible", + "unit": { + "type": "getMatchingUnit" + } + }] + } + }, + "reuseActions": { + "onHit": [{ + "type": "if", + "condition": { + "type": "isUnitEnemy", + "unit": { + "type": "getProjectileHitUnit" + } + }, + "thenActions": [{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getProjectileHitUnit" + }, + "onlyDamageSummons": { + "type": "rawBoolean", + "value": "true" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + },{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getProjectileHitUnit" + } + }, + "thenActions": [{ + "type": "if", + "condition": { + "type": "not", + "condition": { + "type": "isUnitMagicImmune", + "unit": { + "type": "getProjectileHitUnit" + } + } + }, + "thenActions": [{ + "type": "subtractMp", + "unit": { + "type": "getProjectileHitUnit" + }, + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }] + },{ + "type": "if", + "condition": { + "type": "isUnitEnemy", + "unit": { + "type": "getProjectileHitUnit" + } + }, + "thenActions": [{ + "type": "dispelBuffs", + "unit": { + "type": "getProjectileHitUnit" + }, + "filter": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + },{ + "type": "isBuffPositive", + "buff": { + "type": "enumBuff" + } + }] + } + }], + "elseActions": [{ + "type": "dispelBuffs", + "unit": { + "type": "getProjectileHitUnit" + }, + "filter": { + "type": "and", + "conditions": [{ + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + },{ + "type": "isBuffNegative", + "buff": { + "type": "enumBuff" + } + }] + } + }] + }] + }] + }, + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + },{ + "type": "createUnitTargetedBouncingProjectile", + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "bounces": { + "type": "i-", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + }, + "range": { + "type": "getAbilityArea" + }, + "allowMultipleBouncesPerUnit": { + "type": "rawBoolean", + "value": "false" + }, + "condition": { + "type": "reuseBoolean", + "name": { + "type": "rawString", + "value": "jumpCondition" + } + }, + "onHit": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + }] + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/DoNothings.json b/core/assets/abilityBehaviors/DoNothings.json new file mode 100644 index 000000000..f88331aa7 --- /dev/null +++ b/core/assets/abilityBehaviors/DoNothings.json @@ -0,0 +1,176 @@ +{ + "abilityList": [{ + "ids": [{"id":"Agyb"},{"id":"Asth"},{"id":"Amgl"},{"id":"Aimp"}], + "type": "PASSIVE" + },{ + "ids": [{"id":"Aspi"}], + "type": "HIDDEN", + "onAddAbility": [{ + "type": "if", + "condition": { + "type": "unitHasResearch", + "researchId": { + "type": "getWar3IDFromString", + "id": "Rosp" + } + }, + "thenActions": [{ + "type": "createSpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "effectType": "TARGET" + }], + "elseActions": [{ + "type": "createUnitStateListener", + "onUpgradesChanged": [{ + "type": "if", + "condition": { + "type": "and", + "conditions": [{ + "type": "isNull", + "value": { + "type": "getLastCreatedFX" + } + },{ + "type": "unitHasResearch", + "researchId": { + "type": "getWar3IDFromString", + "id": "Rosp" + } + }] + }, + "thenActions": [{ + "type": "createSpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "effectType": "TARGET" + }] + }] + },{ + "type": "addUnitStateListener", + "unit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedUnitStateListener" + } + }] + }], + "onRemoveAbility": [{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getLastCreatedFX" + } + }, + "thenActions": [{ + "type": "removeEffect", + "effect": { + "type": "getLastCreatedFX" + } + }] + },{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getLastCreatedUnitStateListener" + } + }, + "thenActions": [{ + "type": "removeUnitStateListener", + "effectToRemove": { + "type": "getLastCreatedUnitStateListener" + } + }] + }] + },{ + "ids": [{"id":"Arbr"}], + "type": "HIDDEN", + "onAddAbility": [{ + "type": "if", + "condition": { + "type": "unitHasResearch", + "researchId": { + "type": "getWar3IDFromString", + "id": "Rorb" + } + }, + "thenActions": [{ + "type": "createSpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "effectType": "TARGET" + }], + "elseActions": [{ + "type": "createUnitStateListener", + "onUpgradesChanged": [{ + "type": "if", + "condition": { + "type": "and", + "conditions": [{ + "type": "isNull", + "value": { + "type": "getLastCreatedFX" + } + },{ + "type": "unitHasResearch", + "researchId": { + "type": "getWar3IDFromString", + "id": "Rorb" + } + }] + }, + "thenActions": [{ + "type": "createSpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "effectType": "TARGET" + }] + }] + },{ + "type": "addUnitStateListener", + "unit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedUnitStateListener" + } + }] + }], + "onRemoveAbility": [{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getLastCreatedFX" + } + }, + "thenActions": [{ + "type": "removeEffect", + "effect": { + "type": "getLastCreatedFX" + } + }] + },{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getLastCreatedUnitStateListener" + } + }, + "thenActions": [{ + "type": "removeUnitStateListener", + "effectToRemove": { + "type": "getLastCreatedUnitStateListener" + } + }] + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/ItemAffecting.json b/core/assets/abilityBehaviors/ItemAffecting.json new file mode 100644 index 000000000..3132711c2 --- /dev/null +++ b/core/assets/abilityBehaviors/ItemAffecting.json @@ -0,0 +1,118 @@ +{ + "abilityList": [{ + "ids": [{"id":"AIri", "castId": "itemrandomitem"}], + "type": "NORMAL_UNITTARGET", + "extraTargetConditions": [{ + "type": "and", + "conditions": [{ + "type": "notNull", + "value": { + "type": "getAbilityTargetedItem" + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "and", + "conditions": [{ + "type": "i!=0", + "value": { + "type": "getItemLevel", + "item": { + "type": "getAbilityTargetedItem" + } + } + },{ + "type": "or", + "conditions": [{ + "type": "not", + "condition": { + "type": "itemIsCharged", + "item": { + "type": "getAbilityTargetedItem" + } + } + },{ + "type": "i=", + "value1": { + "type": "getItemCharges", + "item": { + "type": "getAbilityTargetedItem" + } + }, + "value2": { + "type": "getItemMaxCharges", + "item": { + "type": "getAbilityTargetedItem" + } + } + }] + },{ + "type": "notNull", + "value": { + "type": "randomItemId", + "previousId": { + "type": "getItemType", + "item": { + "type": "getAbilityTargetedItem" + } + }, + "level": { + "type": "getItemLevel", + "item": { + "type": "getAbilityTargetedItem" + } + }, + "ignoreValidFlag": { + "type": "rawBoolean", + "value": "false" + }, + "ignoreRandomFlag": { + "type": "rawBoolean", + "value": "true" + } + } + }] + }, + "reason": "UNABLE_TO_TRANSFORM_THIS_ITEM" + }] + }], + "onEndCasting": [{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getAbilityTargetedItem" + } + }, + "thenActions": [{ + "type": "transformItem", + "item": { + "type": "getAbilityTargetedItem" + }, + "newType": { + "type": "randomItemId", + "previousId": { + "type": "getItemType", + "item": { + "type": "getAbilityTargetedItem" + } + }, + "level": { + "type": "getItemLevel", + "item": { + "type": "getAbilityTargetedItem" + } + }, + "ignoreValidFlag": { + "type": "rawBoolean", + "value": "false" + }, + "ignoreRandomFlag": { + "type": "rawBoolean", + "value": "true" + } + } + }] + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/Polymorph.json b/core/assets/abilityBehaviors/Polymorph.json new file mode 100644 index 000000000..83a438564 --- /dev/null +++ b/core/assets/abilityBehaviors/Polymorph.json @@ -0,0 +1,231 @@ +{ + "abilityList": [{ + "ids": [{"id":"Aply", "castId": "polymorph"},{"id":"AOhx", "castId": "hex"}], + "type": "NORMAL_UNITTARGET", + "extraTargetConditions": [{ + "type": "not", + "condition": { + "type": "isUnitMorphImmune", + "unit": { + "type": "getAbilityTargetedUnit" + } + } + }], + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "POLYMORPHED" + }], + "onEndCasting": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + },{ + "type": "if", + "condition": { + "type": "isMovementTypeEqual", + "movementType1": { + "type": "getUnitMovementType", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "movementType2": { + "type": "getMovementTypeFromString", + "id": { + "type": "rawString", + "value": "FLY" + } + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unitType" + }, + "valueToStore": { + "type": "getAbilityDataAsRandomIDFromList", + "dataField": "C" + } + }], + "elseActions": [{ + "type": "if", + "condition": { + "type": "isMovementTypeEqual", + "movementType1": { + "type": "getUnitMovementType", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "movementType2": { + "type": "getMovementTypeFromString", + "id": { + "type": "rawString", + "value": "FLOAT" + } + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unitType" + }, + "valueToStore": { + "type": "getAbilityDataAsRandomIDFromList", + "dataField": "E" + } + }], + "elseActions": [{ + "type": "if", + "condition": { + "type": "isMovementTypeEqual", + "movementType1": { + "type": "getUnitMovementType", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "movementType2": { + "type": "getMovementTypeFromString", + "id": { + "type": "rawString", + "value": "AMPHIBIOUS" + } + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unitType" + }, + "valueToStore": { + "type": "getAbilityDataAsRandomIDFromList", + "dataField": "D" + } + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unitType" + }, + "valueToStore": { + "type": "getAbilityDataAsRandomIDFromList", + "dataField": "B" + } + }] + }] + }] + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "showTimedLifeBar": { + "type": "rawBoolean", + "value": "true" + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }], + "onAddActions": [{ + "type": "transformUnitAppearance", + "unit": { + "type": "getBuffedUnit" + }, + "id": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "unitType" + } + } + },{ + "type": "setSpeed", + "unit": { + "type": "getBuffedUnit" + }, + "value": { + "type": "getUnitTypeSpeed", + "id": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "unitType" + } + } + } + }], + "onRemoveActions": [{ + "type": "transformUnitAppearance", + "unit": { + "type": "getBuffedUnit" + }, + "id": { + "type": "getUnitType", + "unit": { + "type": "getBuffedUnit" + } + } + },{ + "type": "setSpeed", + "unit": { + "type": "getBuffedUnit" + }, + "value": { + "type": "getUnitTypeSpeed", + "id": { + "type": "getUnitType", + "unit": { + "type": "getBuffedUnit" + } + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/RaiseDead.json b/core/assets/abilityBehaviors/RaiseDead.json index 28cc08f5e..c31ab8ffa 100644 --- a/core/assets/abilityBehaviors/RaiseDead.json +++ b/core/assets/abilityBehaviors/RaiseDead.json @@ -61,7 +61,11 @@ "onEndCasting": [{ "type": "createTimedLifeBuff", "buffId": { - "type": "getFirstBuffId" + "type": "getFirstBuffId", + "defaultId": { + "type": "getWar3IDFromString", + "id": "Brai" + } }, "duration": { "type": "getAbilityDuration" @@ -191,6 +195,19 @@ }, "reason": "THERE_ARE_NO_USABLE_CORPSES_NEARBY" }], + "extraAutoNoTargetConditions": [{ + "type": "i<", + "value1": { + "type": "getUnitQueueSize", + "queue": { + "type": "getLastCreatedUnitQueue" + } + }, + "value2": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + } + }], "extraTargetConditions": [{ "type": "setCantUseReasonOnFailure", "condition": { @@ -283,6 +300,10 @@ "buffId": { "type": "getFirstBuffId" }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "duration": { "type": "getAbilityDuration" }, @@ -416,6 +437,10 @@ "buffId": { "type": "getFirstBuffId" }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "duration": { "type": "getAbilityDuration" }, @@ -705,6 +730,10 @@ "buffId": { "type": "getFirstBuffId" }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "duration": { "type": "getAbilityDuration" }, @@ -866,6 +895,10 @@ "buffId": { "type": "getFirstBuffId" }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "duration": { "type": "getAbilityDuration" }, @@ -1021,7 +1054,7 @@ "type": "while", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "i>", "value1": { "type": "i+", @@ -1044,8 +1077,7 @@ "type": "getAbilityDataAsInteger", "dataField": "E" } - }, - "condition2": { + },{ "type": "i!=0", "value": { "type": "getUnitQueueSize", @@ -1054,7 +1086,7 @@ "name": "summons2" } } - } + }] }, "loopActions": [{ "type": "killUnit", diff --git a/core/assets/abilityBehaviors/Summons.json b/core/assets/abilityBehaviors/Summons.json new file mode 100644 index 000000000..632433751 --- /dev/null +++ b/core/assets/abilityBehaviors/Summons.json @@ -0,0 +1,1627 @@ +{ + "abilityList": [{ + "ids": [{"id":"AHwe", "castId": "waterelemental"}, + {"id":"ANwm", "castId": "wateryminion"}, + {"id":"AEsv", "castId": "spiritofvengeance"}, + {"id":"AEst", "castId": "scout"}, + {"id":"ANsw", "castId": "summonwareagle"}, + {"id":"ANsq", "castId": "summonquillbeast"}, + {"id":"ANsg", "castId": "summongrizzly"}], + "type": "NORMAL_NOTARGET", + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "dist": { + "type": "getAbilityArea" + }, + "angle": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + }, + "angleInDegrees": { + "type": "rawBoolean", + "value": "true" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getLastCreatedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + }] + }] + },{ + "ids": [{"id":"Amec", "castId": "mechanicalcritter"}], + "type": "NORMAL_NOTARGET", + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "UNAUTOATTACKABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unauto" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "HIDE_MINIMAP_ICON" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "minim" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "FALSE_OWNERSHIP", + "value": { + "type": "createOwnershipData", + "playerId": { + "type": "getNeutralPassivePlayerId" + }, + "priority": { + "type": "rawInteger", + "value": 15 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "owner" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "randomMechanicalCritterId" + }, + "loc": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "dist": { + "type": "getAbilityArea" + }, + "angle": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + }, + "angleInDegrees": { + "type": "rawBoolean", + "value": "true" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unauto" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "minim" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "owner" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getLastCreatedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + }] + }] + },{ + "ids": [{"id":"AOsf", "castId": "spiritwolf"},{"id":"AIsh", "castId": "spirittroll"}], + "type": "NORMAL_NOTARGET", + "onAddAbility": [{ + "type": "createUnitGroup", + "name": "summons" + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "iterateUnitsInGroup", + "unitGroup": { + "type": "getUnitGroupByName", + "name": "summons" + }, + "iterationActions": [{ + "type": "killUnit", + "unit": { + "type": "getEnumUnit" + } + }] + },{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "dist": { + "type": "getAbilityArea" + }, + "angle": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + }, + "angleInDegrees": { + "type": "rawBoolean", + "value": "true" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + },{ + "type": "addUnitToGroup", + "group": { + "type": "getUnitGroupByName", + "name": "summons" + }, + "unit": { + "type": "getLastCreatedUnit" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getLastCreatedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + }] + }] + },{ + "ids": [{"id":"AHpx", "castId": "summonphoenix"}], + "type": "NORMAL_NOTARGET", + "onAddDisabledAbility": [{ + "type": "createUnitGroup", + "name": "summons" + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "iterateUnitsInGroup", + "unitGroup": { + "type": "getUnitGroupByName", + "name": "summons" + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "doesUnitHaveAbilityMatchingCondition", + "unit": { + "type": "getEnumUnit" + }, + "condition": { + "type": "isIdEqual", + "id1": { + "type": "getCode", + "ability": { + "type": "getMatchingAbility" + } + }, + "id2": { + "type": "getWar3IDFromString", + "id": "Aphx" + } + } + }, + "thenActions": [{ + "type": "removeAbility", + "unit": { + "type": "getEnumUnit" + }, + "ability": { + "type": "getAbilityById", + "unit": { + "type": "getEnumUnit" + }, + "id": { + "type": "getWar3IDFromString", + "id": "Aphx" + } + } + },{ + "type": "killUnit", + "unit": { + "type": "getEnumUnit" + } + }] + }] + },{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "dist": { + "type": "getAbilityArea" + }, + "angle": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + }, + "angleInDegrees": { + "type": "rawBoolean", + "value": "true" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getCastingUnit" + } + } + },{ + "type": "setHp", + "target": { + "type": "getLastCreatedUnit" + }, + "amount": { + "type": "rawFloat", + "value": 100 + }, + "isPercent": { + "type": "rawBoolean", + "value": "true" + } + },{ + "type": "addUnitToGroup", + "group": { + "type": "getUnitGroupByName", + "name": "summons" + }, + "unit": { + "type": "getLastCreatedUnit" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getLastCreatedUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "TARGET" + }] + }] + },{ + "ids": [{"id":"AIpm", "castId": "itemplacemine"}], + "type": "NORMAL_POINTTARGET", + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getTargetedLocation" + }, + "addSummonedTag": { + "type": "rawBoolean", + "value": "false" + }, + "removeFood": { + "type": "rawBoolean", + "value": "true" + } + }] + },{ + "ids": [{"id":"Ahwd", "castId": "healingward"}], + "type": "NORMAL_POINTTARGET", + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getTargetedLocation" + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + },{ + "ids": [{"id":"AOwd", "castId": "ward"}], + "type": "NORMAL_POINTTARGET", + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getTargetedLocation" + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + },{ + "ids": [{"id":"Aeye", "castId": "evileye"}], + "type": "NORMAL_POINTTARGET", + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "INVISIBLE" + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getTargetedLocation" + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + },{ + "ids": [{"id":"Asta", "castId": "stasistrap"}], + "type": "NORMAL_POINTTARGET", + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "INVISIBLE" + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getTargetedLocation" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unit" + }, + "valueToStore": { + "type": "getLastCreatedUnit" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "actions": [{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + } + }, + "thenActions": [{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createTimer", + "timeout": { + "type": "rawFloat", + "value": 1.0 + }, + "repeats": { + "type": "rawBoolean", + "value": "true" + }, + "actions": [{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + } + }, + "thenActions": [{ + "type": "if", + "condition": { + "type": "matchingUnitExistsInRangeOfUnit", + "originUnit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + }, + "range": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + } + }, + "thenActions": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createTimer", + "timeout": { + "type": "rawFloat", + "value": 1.0 + }, + "actions": [{ + "type": "if", + "condition": { + "type": "isUnitAlive", + "unit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + } + }, + "thenActions": [{ + "type": "killUnit", + "unit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + } + },{ + "type": "iterateUnitsInRangeOfUnitMatchingCondition", + "originUnit": { + "type": "getStoredUnitByKey", + "key": { + "type": "rawString", + "value": "unit" + } + }, + "range": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, + "iterationActions": [{ + "type": "addStunBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "unit": { + "type": "getEnumUnit" + }, + "duration": { + "type": "inlineConditionFloat", + "condition": { + "type": "isUnitHero", + "unit": { + "type": "getEnumUnit" + } + }, + "pass": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "fail": { + "type": "getAbilityHeroDuration" + } + } + }] + }] + },{ + "type": "cleanUpCastInstance" + }] + },{ + "type": "killTimer", + "timer": { + "type": "getFiringTimer" + } + }] + }], + "elseActions": [{ + "type": "killTimer", + "timer": { + "type": "getFiringTimer" + } + },{ + "type": "cleanUpCastInstance" + }] + }] + }], + "elseActions": [{ + "type": "cleanUpCastInstance" + }] + }] + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getWar3IDFromString", + "id": "Bstt" + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + },{ + "ids": [{"id":"ANin", "castId": "inferno"},{"id":"AUin", "castId": "dreadlordinferno"}], + "type": "NORMAL_POINTTARGET", + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "targetLoc" + }, + "valueToStore": { + "type": "getTargetedLocation" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "actions": [{ + "type": "iterateDestructablesInRangeOfLocation", + "location": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + }, + "range": { + "type": "getAbilityArea" + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "isTree", + "dest": { + "type": "getEnumDestructable" + } + }, + "thenActions": [{ + "type": "killDestructable", + "dest": { + "type": "getEnumDestructable" + } + }] + }] + },{ + "type": "damageArea", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + }, + "validTarget": { + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FORCE" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "radius": { + "type": "getAbilityArea" + }, + "extraActions": [{ + "type": "addStunBuff", + "unit": { + "type": "getEnumUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getEnumUnit" + } + } + }] + },{ + "type": "iterateUnitsInRangeOfLocationMatchingCondition", + "location": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + }, + "range": { + "type": "getAbilityArea" + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, + "iterationActions": [] + },{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getWar3IDFromString", + "id": "BNin" + } + }, + "duration": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + },{ + "ids": [{"id":"ANdp", "castId": "darkportal"}], + "type": "NORMAL_POINTTARGET", + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "targetLoc" + }, + "valueToStore": { + "type": "getTargetedLocation" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDuration" + }, + "actions": [{ + "type": "for", + "times": { + "type": "randomInteger", + "lowerBound": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "upperBound": { + "type": "i+", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityDataAsRandomIDFromList", + "dataField": "A" + }, + "loc": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + } + }] + }] + }] + },{ + "ids": [{"id":"ANrc", "castId": "rainofchaos"}], + "type": "NORMAL_POINTTARGET", + "onAddDisabledAbility": [{ + "type": "createAbilityFromId", + "id": { + "type": "getAbilityDataAsID", + "dataField": "A" + } + },{ + "type": "prepUnownedAbilityForUse", + "ability": { + "type": "getLastCreatedAbility" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "targetLoc" + }, + "valueToStore": { + "type": "getTargetedLocation" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "iter" + }, + "valueToStore": { + "type": "rawInteger", + "value": 0 + } + },{ + "type": "beginChanneling" + }], + "onChannelTick": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "iter" + }, + "valueToStore": { + "type": "i+", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "iter" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + },{ + "type": "if", + "condition": { + "type": "i>", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "iter" + } + }, + "value2": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + } + }, + "thenActions": [{ + "type": "finishChanneling" + }], + "elseActions": [{ + "type": "abilityRunEndCastingActions", + "ability": { + "type": "getLastCreatedAbility" + }, + "targetLoc": { + "type": "randomLocationInRange", + "origin": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + }, + "range": { + "type": "getAbilityArea" + } + } + }] + }], + "delaySeconds": { + "type": "getAbilityDuration" + }, + "initialTick": { + "type": "rawBoolean", + "value": "true" + } + }], + "onEndChannel": [{ + "type": "cleanUpCastInstance" + }] + },{ + "ids": [{"id":"ANto", "castId": "tornado"}], + "type": "NORMAL_POINTTARGET", + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "INVULNERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNSELECTABLE", + "value": { + "type": "playerMaskExcludePlayers", + "players": [{ + "type": "getCastingPlayer" + }] + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNTARGETABLE", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "untar" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" + }, + "effectType": "EFFECT" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "targetLoc" + }, + "valueToStore": { + "type": "getTargetedLocation" + } + },{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "loc": { + "type": "getTargetedLocation" + } + },{ + "type": "if", + "condition": { + "type": "f>0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "getBuffIdFromCode" + } + }, + "duration": { + "type": "getAbilityDuration" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "untar" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "beginChanneling" + }], + "onChannelTick": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "finishChanneling" + }], + "delaySeconds": { + "type": "getAbilityDuration" + } + }], + "onEndChannel": [{ + "type": "killUnit", + "unit": { + "type": "getLastCreatedUnit" + } + },{ + "type": "cleanUpCastInstance" + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/TerrainDeform.json b/core/assets/abilityBehaviors/TerrainDeform.json new file mode 100644 index 000000000..ddadd849a --- /dev/null +++ b/core/assets/abilityBehaviors/TerrainDeform.json @@ -0,0 +1,2270 @@ +{ + "abilityList": [{ + "ids": [{"id":"AOeq", "castId": "earthquake"}], + "type": "NORMAL_POINTTARGET", + "displayFields": { + "areaCursorOverride": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + }, + "reuseActions": { + "onTick": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "radius" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getAbilityArea" + }, + "value2": { + "type": "f*", + "value1": { + "type": "f-", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "value2": { + "type": "getAbilityArea" + } + }, + "value2": { + "type": "f/", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "icnt" + } + }, + "value2": { + "type": "getAbilityDuration" + } + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "icnt" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "icnt" + } + }, + "value2": { + "type": "rawFloat", + "value": 1 + } + } + },{ + "type": "iterateDestructablesInRangeOfLocation", + "location": { + "type": "getTargetedLocation" + }, + "range": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "radius" + } + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "isDestructableValidTarget", + "target": { + "type": "getEnumDestructable" + } + }, + "thenActions": [{ + "type": "damageDestructable", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getEnumDestructable" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + }] + },{ + "type": "iterateUnitsInRangeOfLocationMatchingCondition", + "location": { + "type": "getTargetedLocation" + }, + "range": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "radius" + } + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "isUnitBuilding", + "unit": { + "type": "getEnumUnit" + } + }, + "thenActions": [{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getEnumUnit" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "UNIVERSAL" + } + } + }], + "elseActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "rawFloat", + "value": 2 + }, + "statBuffs": [{ + "type": "getLastCreatedNonStackingStatBuff" + }] + },{ + "type": "addBuff", + "target": { + "type": "getEnumUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + }, + "onEndCasting": [{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "beginChanneling" + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "earthquake" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "radius" + }, + "valueToStore": { + "type": "getAbilityArea" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "icnt" + }, + "valueToStore": { + "type": "rawFloat", + "value": 0 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "begun" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "delay" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }] + }], + "onChannelTick": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "if", + "condition": { + "type": "getStoredBooleanByKey", + "key": { + "type": "rawString", + "value": "begun" + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTick" + } + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "begun" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "true" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "delay" + }, + "valueToStore": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "createSpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getFirstEffectId" + }, + "effectType": "EFFECT" + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "center" + }, + "valueToStore": { + "type": "getLastCreatedFX" + } + },{ + "type": "createTerrainRippleAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "startRadius": { + "type": "getAbilityArea" + }, + "finalRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "depth": { + "type": "rawFloat", + "value": 140 + }, + "duration": { + "type": "getAbilityDuration" + }, + "period": { + "type": "rawFloat", + "value": 500 + }, + "spaceWaves": { + "type": "rawInteger", + "value": 3 + }, + "timeWaves": { + "type": "rawInteger", + "value": 2 + }, + "onlyNegative": { + "type": "rawBoolean", + "value": "true" + } + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "deform" + }, + "valueToStore": { + "type": "getLastCreatedFX" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTick" + } + }] + }], + "delaySeconds": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "delay" + } + }, + "unique": { + "type": "rawString", + "value": "iter" + } + },{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "finishChanneling" + }], + "delaySeconds": { + "type": "getAbilityDuration" + }, + "unique": { + "type": "rawString", + "value": "end" + } + }], + "onEndChannel": [{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getStoredFXByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "center" + } + } + }, + "thenActions": [{ + "type": "removeEffect", + "effect": { + "type": "getStoredFXByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "center" + } + } + }] + },{ + "type": "if", + "condition": { + "type": "notNull", + "value": { + "type": "getStoredFXByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "deform" + } + } + }, + "thenActions": [{ + "type": "removeEffect", + "effect": { + "type": "getStoredFXByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "deform" + } + } + }] + },{ + "type": "cleanUpCastInstance" + }] + },{ + "ids": [{"id":"ANvc", "castId": "volcano"}], + "type": "NORMAL_POINTTARGET", + "reuseActions": { + "fireRock": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "flyingRocks" + }, + "valueToStore": { + "type": "i+", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "flyingRocks" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + },{ + "type": "createLocationTargetedProjectile", + "source": { + "type": "getCastingUnit" + }, + "sourceLoc": { + "type": "getTargetedLocation" + }, + "target": { + "type": "argumentLocation", + "name": { + "type": "rawString", + "value": "rockTar" + } + }, + "id": { + "type": "getFirstEffectId" + }, + "onHit": [{ + "type": "iterateDestructablesInRangeOfLocation", + "location": { + "type": "getProjectileCurrentLocation" + }, + "range": { + "type": "getAbilityArea" + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "isDestructableValidTarget", + "target": { + "type": "getEnumDestructable" + } + }, + "thenActions": [{ + "type": "damageDestructable", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getEnumDestructable" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + }] + }] + },{ + "type": "damageBurst", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getProjectileCurrentLocation" + }, + "validTarget": { + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "NORMAL" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "fullDamageRadius": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "fullDamageRadius" + } + }, + "partialDamage": { + "type": "f*", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "F" + } + }, + "partialDamageRadius": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "partialDamageRadius" + } + }, + "extraActions": [{ + "type": "if", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getEnumUnit" + }, + "id": { + "type": "getSecondBuffId" + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mod" + }, + "valueToStore": { + "type": "rawFloat", + "value": 0 + } + }], + "elseActions": [{ + "type": "if", + "condition": { + "type": "isUnitBuilding", + "unit": { + "type": "getEnumUnit" + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mod" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mod" + }, + "valueToStore": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "addStunBuff", + "unit": { + "type": "getEnumUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getEnumUnit" + } + } + }] + },{ + "type": "createTimedTargetingBuff", + "buffId": { + "type": "getSecondBuffId" + }, + "duration": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "addBuff", + "target": { + "type": "getEnumUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "unitSpecificDamageMod": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "mod" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "flyingRocks" + }, + "valueToStore": { + "type": "i-", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "flyingRocks" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + },{ + "type": "if", + "condition": { + "type": "and", + "conditions": [{ + "type": "getStoredBooleanByKey", + "key": { + "type": "rawString", + "value": "finished" + } + },{ + "type": "i=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "flyingRocks" + } + } + }] + }, + "thenActions": [{ + "type": "cleanUpCastInstance" + }] + }] + }], + "calculateRockCount": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rockCount" + }, + "valueToStore": { + "type": "rawInteger", + "value": 1 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rocksPerRing" + }, + "valueToStore": { + "type": "rawInteger", + "value": 5 + } + },{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + }, + "actions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rockCount" + }, + "valueToStore": { + "type": "i+", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rockCount" + } + }, + "value2": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksPerRing" + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rocksPerRing" + }, + "valueToStore": { + "type": "i+", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksPerRing" + } + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rockCount" + }, + "valueToStore": { + "type": "iMin", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rockCount" + } + }, + "value2": { + "type": "rawInteger", + "value": 32 + } + } + }], + "generateRockLists": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "indexList" + }, + "valueToStore": { + "type": "listSorted", + "list": { + "type": "integerListOfRange", + "end": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rockCount" + } + } + }, + "sort": "RAND" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "locList" + }, + "valueToStore": { + "type": "emptyLocationList" + } + },{ + "type": "locationListAdd", + "list": { + "type": "getStoredListByKey", + "key": { + "type": "rawString", + "value": "locList" + } + }, + "location": { + "type": "createLocationFromXYOffset", + "origin": { + "type": "getTargetedLocation" + }, + "xdist": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "maxJitter" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "randomFloat" + }, + "value2": { + "type": "rawFloat", + "value": 0.5 + } + } + }, + "ydist": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "maxJitter" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "randomFloat" + }, + "value2": { + "type": "rawFloat", + "value": 0.5 + } + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rocksPerRing" + }, + "valueToStore": { + "type": "rawInteger", + "value": 5 + } + },{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "A" + }, + "actions": [{ + "type": "if", + "condition": { + "type": "i<", + "value1": { + "type": "getListSize", + "list": { + "type": "getStoredListByKey", + "key": { + "type": "rawString", + "value": "locList" + } + } + }, + "value2": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rockCount" + } + } + }, + "thenActions": [{ + "type": "for", + "times": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksPerRing" + } + }, + "unique": { + "type": "rawString", + "value": "rock" + }, + "actions": [{ + "type": "locationListAdd", + "list": { + "type": "getStoredListByKey", + "key": { + "type": "rawString", + "value": "locList" + } + }, + "location": { + "type": "modifyLocationWithXYOffset", + "origin": { + "type": "createLocationFromOffset", + "origin": { + "type": "getTargetedLocation" + }, + "dist": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "partialDamageRadius" + } + }, + "value2": { + "type": "f+", + "value1": { + "type": "f+", + "value1": { + "type": "rawFloat", + "value": 0.5 + }, + "value2": { + "type": "i2f", + "value": { + "type": "iterator" + } + } + }, + "value2": { + "type": "f*", + "value1": { + "type": "rawFloat", + "value": 0.5 + }, + "value2": { + "type": "f+", + "value1": { + "type": "rawFloat", + "value": 0.95 + }, + "value2": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 0.1 + } + } + } + } + } + }, + "angle": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "waveAngle" + } + }, + "value2": { + "type": "f*", + "value1": { + "type": "pi" + }, + "value2": { + "type": "f+", + "value1": { + "type": "i2f", + "value": { + "type": "iterator" + } + }, + "value2": { + "type": "f/", + "value1": { + "type": "f*", + "value1": { + "type": "i2f", + "value": { + "type": "iterator", + "unique": { + "type": "rawString", + "value": "rock" + } + } + }, + "value2": { + "type": "rawFloat", + "value": 2 + } + }, + "value2": { + "type": "i2f", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksPerRing" + } + } + } + } + } + } + } + }, + "xdist": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "maxJitter" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "randomFloat" + }, + "value2": { + "type": "rawFloat", + "value": 0.5 + } + } + }, + "ydist": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "maxJitter" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "randomFloat" + }, + "value2": { + "type": "rawFloat", + "value": 0.5 + } + } + } + } + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rocksPerRing" + }, + "valueToStore": { + "type": "i+", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksPerRing" + } + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }] + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rocksLeft" + }, + "valueToStore": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rockCount" + } + } + }] + }, + "onEndCasting": [{ + "type": "createTerrainBowlAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "radius": { + "type": "f*", + "value1": { + "type": "getAbilityArea" + }, + "value2": { + "type": "rawFloat", + "value": 0.5 + } + }, + "depth": { + "type": "negativeFloat", + "value": { + "type": "f*", + "value1": { + "type": "f*", + "value1": { + "type": "getAbilityArea" + }, + "value2": { + "type": "tan", + "angle": { + "type": "degToRad", + "angle": { + "type": "rawFloat", + "value": 30 + } + } + } + }, + "value2": { + "type": "rawFloat", + "value": 2 + } + } + }, + "sinkTime": { + "type": "rawFloat", + "value": 5000 + }, + "staticTime": { + "type": "f*", + "value1": { + "type": "f*", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + }, + "value2": { + "type": "rawFloat", + "value": 1000 + } + }, + "stopDuration": { + "type": "rawFloat", + "value": 500 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "deform" + }, + "valueToStore": { + "type": "getLastCreatedFX" + } + },{ + "type": "createDestructable", + "id": { + "type": "getAbilityUnitId" + }, + "location": { + "type": "getTargetedLocation" + } + },{ + "type": "createUberSplat", + "id": { + "type": "getWar3IDFromString", + "id": "NVOL" + }, + "location": { + "type": "getTargetedLocation" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "splat" + }, + "valueToStore": { + "type": "getLastCreatedFX" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "calculateRockCount" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rockBaseDelay" + }, + "valueToStore": { + "type": "f-", + "value1": { + "type": "f/", + "value1": { + "type": "f/", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "value2": { + "type": "rawFloat", + "value": 2 + } + }, + "value2": { + "type": "i2f", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rockCount" + } + } + } + }, + "value2": { + "type": "rawFloat", + "value": 0.01 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "waveDelay" + }, + "valueToStore": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rockDelay" + }, + "valueToStore": { + "type": "rawFloat", + "value": 0 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "finished" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "flyingRocks" + }, + "valueToStore": { + "type": "rawInteger", + "value": 0 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rocksLeft" + }, + "valueToStore": { + "type": "rawInteger", + "value": 0 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "partialDamageRadius" + }, + "valueToStore": { + "type": "f/", + "value1": { + "type": "getAbilityArea" + }, + "value2": { + "type": "f+", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "value2": { + "type": "rawFloat", + "value": 0.5 + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fullDamageRadius" + }, + "valueToStore": { + "type": "f/", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "partialDamageRadius" + } + }, + "value2": { + "type": "rawFloat", + "value": 2 + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "maxJitter" + }, + "valueToStore": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "fullDamageRadius" + } + }, + "value2": { + "type": "rawFloat", + "value": 0.3 + } + } + },{ + "type": "beginChanneling" + }], + "onChannelTick": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "waveAngle" + }, + "valueToStore": { + "type": "f*", + "value1": { + "type": "f*", + "value1": { + "type": "pi" + }, + "value2": { + "type": "rawFloat", + "value": 2 + } + }, + "value2": { + "type": "randomFloat" + } + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "generateRockLists" + } + },{ + "type": "resetPeriodicExecute", + "unique": { + "type": "rawString", + "value": "rock" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "waveDelay" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + }], + "delaySeconds": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "waveDelay" + } + }, + "unique": { + "type": "rawString", + "value": "wave" + } + },{ + "type": "if", + "condition": { + "type": "i!=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksLeft" + } + } + }, + "thenActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "if", + "condition": { + "type": "i=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksLeft" + } + } + }, + "thenActions": [{ + "type": "break" + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rocksLeft" + }, + "valueToStore": { + "type": "i-", + "value1": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "rocksLeft" + } + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + } + },{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "fireRock" + }, + "arguments": { + "rockTar": { + "type": "getLocationFromList", + "list": { + "type": "getStoredListByKey", + "key": { + "type": "rawString", + "value": "locList" + } + }, + "index": { + "type": "getIntegerFromList", + "list": { + "type": "getStoredSortableListByKey", + "key": { + "type": "rawString", + "value": "indexList" + } + }, + "index": { + "type": "rawInteger", + "value": 0 + } + } + } + } + },{ + "type": "sortableListRemove", + "list": { + "type": "getStoredSortableListByKey", + "key": { + "type": "rawString", + "value": "indexList" + } + }, + "index": { + "type": "rawInteger", + "value": 0 + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "rockDelay" + }, + "valueToStore": { + "type": "f*", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "rockBaseDelay" + } + }, + "value2": { + "type": "f+", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 0.5 + } + }, + "value2": { + "type": "rawFloat", + "value": 0.5 + } + } + } + }], + "delaySeconds": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "rockDelay" + } + }, + "initialTick": { + "type": "rawBoolean", + "value": "true" + }, + "unique": { + "type": "rawString", + "value": "rock" + } + }] + },{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "finishChanneling" + }], + "delaySeconds": { + "type": "f*", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + }, + "unique": { + "type": "rawString", + "value": "end" + } + }], + "onEndChannel": [{ + "type": "removeEffect", + "effect": { + "type": "getStoredFXByKey", + "key": { + "type": "rawString", + "value": "deform" + } + } + },{ + "type": "removeEffect", + "effect": { + "type": "getStoredFXByKey", + "key": { + "type": "rawString", + "value": "splat" + } + } + },{ + "type": "killDestructable", + "dest": { + "type": "getLastCreatedDestructable" + } + },{ + "type": "storeValueLocally", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "volc" + },{ + "type": "i2s", + "value": { + "type": "getCastId" + } + }] + }, + "valueToStore": { + "type": "getLastCreatedDestructable" + } + },{ + "type": "createTimer", + "timeout": { + "type": "rawFloat", + "value": 5 + }, + "actions": [{ + "type": "removeDestructable", + "dest": { + "type": "getStoredDestructableByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "volc" + },{ + "type": "i2s", + "value": { + "type": "getCastId" + } + }] + } + } + },{ + "type": "deleteStoredKey", + "key": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "volc" + },{ + "type": "i2s", + "value": { + "type": "getCastId" + } + }] + } + }] + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getFirstEffectId" + }, + "effectType": "SPECIAL" + },{ + "type": "if", + "condition": { + "type": "i=0", + "value": { + "type": "getStoredIntegerByKey", + "key": { + "type": "rawString", + "value": "flyingRocks" + } + } + }, + "thenActions": [{ + "type": "cleanUpCastInstance" + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "finished" + }, + "valueToStore": { + "type": "rawBoolean", + "value": "true" + } + }] + }] + },{ + "ids": [{"id":"AOsh", "castId": "shockwave"}], + "type": "NORMAL_POINTTARGET", + "displayFields": { + "hideAreaCursor": { + "type": "rawBoolean", + "value": "true" + } + }, + "onEndCasting": [{ + "type": "createTerrainWaveAtLocation", + "startLocation": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "dist": { + "type": "getAbilityArea" + }, + "angle": { + "type": "getAngleBetweenLocations", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "target": { + "type": "getTargetedLocation" + } + } + }, + "targetLocation": { + "type": "getTargetedLocation" + }, + "radius": { + "type": "getAbilityArea" + }, + "depth": { + "type": "rawFloat", + "value": 100 + }, + "distance": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "speed": { + "type": "getAbilityProjectileSpeed" + }, + "trailTime": { + "type": "rawInteger", + "value": 200 + } + },{ + "type": "createLocationTargetedCollisionProjectile", + "source": { + "type": "getCastingUnit" + }, + "sourceLoc": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "dist": { + "type": "getAbilityArea" + }, + "angle": { + "type": "getAngleBetweenLocations", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "target": { + "type": "getTargetedLocation" + } + } + }, + "target": { + "type": "createLocationFromOffset", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "dist": { + "type": "f+", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "value2": { + "type": "getAbilityArea" + } + }, + "angle": { + "type": "getAngleBetweenLocations", + "origin": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "target": { + "type": "getTargetedLocation" + } + } + }, + "id": { + "type": "getAlias" + }, + "startingRadius": { + "type": "getAbilityArea" + }, + "endingRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "provideCounts": { + "type": "rawBoolean", + "value": "true" + }, + "onLaunch": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "remainDmg" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }], + "onPreHits": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "dpt" + }, + "valueToStore": { + "type": "fMin", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "value2": { + "type": "f/", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "remainDmg" + } + }, + "value2": { + "type": "i2f", + "value": { + "type": "getProjectileUnitTargets" + } + } + } + } + }], + "canHitTarget": [{ + "type": "and", + "conditions": [{ + "type": "isValidTarget", + "target": { + "type": "getProjectileHitWidget" + } + },{ + "type": "isUnitEnemy", + "unit": { + "type": "getProjectileHitUnit" + } + }] + }], + "onHit": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "remainDmg" + }, + "valueToStore": { + "type": "f-", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "remainDmg" + } + }, + "value2": { + "type": "fMin", + "value1": { + "type": "getUnitCurrentHp", + "unit": { + "type": "getProjectileHitUnit" + } + }, + "value2": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "dpt" + } + } + } + } + },{ + "type": "if", + "condition": { + "type": "f>", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "dpt" + } + }, + "value2": { + "type": "rawFloat", + "value": 1 + } + }, + "thenActions": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getProjectileHitUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + },{ + "type": "damageTarget", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getProjectileHitUnit" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "SONIC" + } + }, + "damage": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "dpt" + } + } + }], + "elseActions": [] + }] + }] + },{ + "ids": [{"id":"AHtc", "castId": "thunderclap"},{"id":"ACtc", "castId": "creepthunderclap"}], + "type": "NORMAL_NOTARGET", + "overrideFields": { + "extraTargetsAllowed": [{ + "type": "rawTargetType", + "value": "ENEMIES" + }] + }, + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "slow" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "slow" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }], + "addBuff": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getEnumUnit" + } + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getEnumUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }], + "onEndCasting": [{ + "type": "createTerrainRippleAtLocation", + "location": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "radius": { + "type": "getAbilityArea" + }, + "depth": { + "type": "rawFloat", + "value": 100 + }, + "rippleCount": { + "type": "rawInteger", + "value": 1 + }, + "period": { + "type": "rawFloat", + "value": 300 + }, + "spaceWaves": { + "type": "rawInteger", + "value": 1 + }, + "timeWaves": { + "type": "rawInteger", + "value": 2 + }, + "onlyNegative": { + "type": "rawBoolean", + "value": "true" + } + },{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "damageArea", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + }, + "validTarget": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + },{ + "type": "not", + "condition": { + "type": "isUnitFriend", + "unit": { + "type": "getEnumUnit" + } + } + }] + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "SONIC" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "radius": { + "type": "getAbilityArea" + }, + "extraActions": [{ + "type": "if", + "condition": { + "type": "isUnitBuilding", + "unit": { + "type": "getEnumUnit" + } + }, + "elseActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "addBuff" + } + }] + }] + }] + },{ + "ids": [{"id":"AOws", "castId": "stomp"}], + "type": "INHERIT", + "parentId": "AHtc", + "reuseActions": { + "setupBuffs": [], + "addBuff": [{ + "type": "addStunBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "unit": { + "type": "getEnumUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getEnumUnit" + } + } + }] + } + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/Transformations.json b/core/assets/abilityBehaviors/Transformations.json index 10222ebca..6c47adcb6 100644 --- a/core/assets/abilityBehaviors/Transformations.json +++ b/core/assets/abilityBehaviors/Transformations.json @@ -11,6 +11,10 @@ "type": "rawBoolean", "value": "true" }, + "instantCast": { + "type": "rawBoolean", + "value": "true" + }, "alternateUnitId": { "type": "getAbilityUnitId" }, @@ -219,100 +223,300 @@ } } }, - "onAddDisabledAbility": [{ - "type": "if", - "condition": { - "type": "isToggleAbilityActive" - }, - "thenActions": [{ - "type": "transformedUnitAbilityAdd", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", + "reuseCallbacks": { + "defaultBuffId": { + "type": "null" + } + }, + "reuseActions": { + "storeBaseType": [{ + "type": "if", + "condition": { + "type": "isNull", "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" }, - "value2": { - "type": "rawInteger", - "value": 2 + "instanceValue": { + "type": "rawBoolean", + "value": "false" } } }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 + "thenActions": [{ + "type": "if", + "condition": { + "type": "not", + "condition": { + "type": "or", + "conditions": [{ + "type": "isUnitType", + "unit": { + "type": "getCastingUnit" + }, + "unitType": { + "type": "getAbilityDataAsID", + "dataField": "A" + } + },{ + "type": "isUnitType", + "unit": { + "type": "getCastingUnit" + }, + "unitType": { + "type": "getAbilityUnitId" + } + }] + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getUnitType", + "unit": { + "type": "getCastingUnit" + } } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "baseType" }, - "value2": { - "type": "rawInteger", - "value": 8 + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getAbilityDataAsID", + "dataField": "A" } + }] + }] + }], + "clearBaseType": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "null" + } + }] + }, + "extraCastConditions": [{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "isLocationPathableForUnitType", + "location": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" } }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" + "unitType": { + "type": "getNonCurrentTransformType", + "baseUnitId": { + "type": "inlineConditionID", + "condition": { + "type": "isNull", + "value": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } }, - "value2": { - "type": "rawInteger", - "value": 16 + "pass": { + "type": "getAbilityDataAsID", + "dataField": "A" + }, + "fail": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } } + }, + "alternateUnitId": { + "type": "getAbilityUnitId" } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" } - }], + }, + "reason": "UNABLE_TO_LAND_THERE" + }], + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ + "type": "if", + "condition": { + "type": "isToggleAbilityActive" + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "storeBaseType" + } + },{ + "type": "transformedUnitAbilityAdd", + "unit": { + "type": "getCastingUnit" + }, + "baseUnitId": { + "type": "getAbilityDataAsID", + "dataField": "A" + }, + "alternateUnitId": { + "type": "getAbilityUnitId" + }, + "immediateLanding": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "immediateTakeOff": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "permanent": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + }, + "requiresPayment": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 16 + } + } + }, + "altitudeAdjustmentDelay": { + "type": "getAbilityCastTime" + }, + "altitudeAdjustmentTime": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "landingDelayTime": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "transformTime": { + "type": "getAbilityDuration" + }, + "duration": { + "type": "getAbilityHeroDuration" + }, + "buffId": { + "type": "getFirstBuffId", + "defaultId": { + "type": "reuseID", + "name": { + "type": "rawString", + "value": "defaultBuffId" + } + } + }, + "onTransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransform" + } + },{ + "type": "attemptToReOrderPreviousBehavior" + }], + "onUntransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" + } + },{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "attemptToReOrderPreviousBehavior" + }] + }] + }], "elseActions": [] }], "onRemoveDisabledAbility": [{ @@ -321,8 +525,15 @@ "type": "getCastingUnit" }, "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } }, "alternateUnitId": { "type": "getAbilityUnitId" @@ -340,9 +551,35 @@ "value": 8 } } + }, + "onUntransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" + } + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onLevelChange" } }], - "onBeginCasting": [{ + "onEndCasting": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "storeBaseType" + } + },{ "type": "createTemporarySpellEffectOnUnit", "target": { "type": "getCastingUnit" @@ -351,14 +588,23 @@ "type": "getAlias" }, "effectType": "CASTER" + },{ + "type": "setPreventEndEvents" },{ "type": "transformUnit", "unit": { "type": "getCastingUnit" }, "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } }, "alternateUnitId": { "type": "getAbilityUnitId" @@ -437,253 +683,228 @@ "type": "getAbilityHeroDuration" }, "buffId": { - "type": "getFirstBuffId" - } + "type": "getFirstBuffId", + "defaultId": { + "type": "reuseID", + "name": { + "type": "rawString", + "value": "defaultBuffId" + } + } + }, + "onTransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransform" + } + },{ + "type": "attemptToReOrderPreviousBehavior" + }], + "onUntransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" + } + },{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "attemptToReOrderPreviousBehavior" + }] + }] },{ "type": "if", "condition": { - "type": "isTransformingToAlternate" + "type": "notNull", + "value": { + "type": "isTransformingToAlternate" + } }, "thenActions": [{ - "type": "activateToggledAbility" - }], - "elseActions": [{ - "type": "deactivateToggledAbility" + "type": "if", + "condition": { + "type": "isTransformingToAlternate" + }, + "thenActions": [{ + "type": "activateToggledAbility" + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransformExtra" + } + }], + "elseActions": [{ + "type": "deactivateToggledAbility" + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransformExtra" + } + }] }] }] },{ "ids": [{"id":"Abur", "castId": "burrow", "uncastId": "unburrow"}], - "type": "NORMAL_NOTARGET", - "displayFields": { - "toggleable": { + "type": "INHERIT", + "parentId": "Arav", + "overrideFields": { + "physicalSpell": { "type": "rawBoolean", "value": "true" - }, - "castToggleOff": { + } + }, + "reuseActions": { + "setup": [{ + "type": "createStateModBuff", + "buffType": "INVISIBLE", + "value": { + "type": "rawLong", + "value": 2 + } + }], + "onTransform": [{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + }], + "onUnTransform": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + }] + } + },{ + "ids": [{"id":"Astn", "castId": "stoneform", "uncastId": "unstoneform"}], + "type": "INHERIT", + "parentId": "Arav", + "overrideFields": { + "physicalSpell": { "type": "rawBoolean", "value": "true" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "goldCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "lumberCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } + } + }, + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "HPGEN" } }, + "stackingKey": { + "type": "getAllowStackingKey" + }, "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } + "type": "getAbilityDataAsFloat", + "dataField": "E" } - }, - "foodCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } + }], + "onTransform": [{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" }, - "value": { - "type": "i-", - "value1": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getUnitType" - } - } + "buff": { + "type": "getLastCreatedNonStackingStatBuff" } - } - }, - "overrideFields": { - "physicalSpell": { - "type": "rawBoolean", - "value": "true" - }, - "onTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } + }], + "onTransformExtra": [{ + "type": "resetCooldown" + }], + "onUnTransform": [{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" }, - "value": { - "type": "getAbilityDataAsID", - "dataField": "A" + "buff": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "offTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } + }], + "onLevelChange": [{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getLastCreatedNonStackingStatBuff" }, "value": { - "type": "getAbilityUnitId" + "type": "getAbilityDataAsFloat", + "dataField": "E" } - } + }] + } + },{ + "ids": [{"id":"Acpf", "castId": "corporealform", "uncastId": "uncorporealform"}], + "type": "INHERIT", + "parentId": "Arav", + "reuseActions": { + "setup": [{ + "type": "createStateModBuff", + "buffType": "ETHEREAL" + }], + "onTransform": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + }], + "onTransformExtra": [{ + "type": "resetCooldown" + }], + "onUnTransform": [{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + }] }, "onAddDisabledAbility": [{ - "type": "createStateModBuff", - "buffType": "INVISIBLE" + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } },{ "type": "if", "condition": { "type": "isToggleAbilityActive" }, "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "storeBaseType" + } + },{ "type": "transformedUnitAbilityAdd", "unit": { "type": "getCastingUnit" @@ -769,28 +990,56 @@ "type": "getAbilityHeroDuration" }, "buffId": { - "type": "getFirstBuffId" + "type": "getFirstBuffId", + "defaultId": { + "type": "reuseID", + "name": { + "type": "rawString", + "value": "defaultBuffId" + } + } }, "onTransformActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransform" } + },{ + "type": "attemptToReOrderPreviousBehavior" }], "onUntransformActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" + } + },{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDuration" + } + }, + "thenActions": [{ + "type": "attemptToReOrderPreviousBehavior" + }] }] }], - "elseActions": [] + "elseActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + }] }], "onRemoveDisabledAbility": [{ "type": "transformedUnitAbilityRemove", @@ -798,8 +1047,15 @@ "type": "getCastingUnit" }, "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } }, "alternateUnitId": { "type": "getAbilityUnitId" @@ -817,18 +1073,92 @@ "value": 8 } } - }, - "onUntransformActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" + } + }] + },{ + "ids": [{"id":"Aetf", "castId": "etherealform", "uncastId": "unetherealform"}], + "type": "INHERIT", + "parentId": "Arav", + "reuseActions": { + "setup": [{ + "type": "createStateModBuff", + "buffType": "ETHEREAL" + }], + "onTransform": [{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + }], + "onTransformExtra": [{ + "type": "resetCooldown" + }], + "onUnTransform": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" }, "buff": { "type": "getLastCreatedStateModBuff" } }] - }], - "onBeginCasting": [{ + } + },{ + "ids": [{"id":"Aave", "castId": "avengerform", "uncastId": "unavengerform"}], + "type": "INHERIT", + "parentId": "Arav", + "reuseActions": { + "onTransform": [{ + "type": "setMp", + "target": { + "type": "getCastingUnit" + }, + "amount": { + "type": "getUnitInitialMana", + "unit": { + "type": "getCastingUnit" + } + } + }] + } + },{ + "ids": [{"id":"ANcr", "castId": "chemicalrage"}], + "type": "INHERIT", + "parentId": "Arav", + "reuseCallbacks": { + "defaultBuffId": { + "type": "getWar3IDFromString", + "id": "BNcr" + } + }, + "reuseActions": { + "onTransform": [{ + "type": "disableAbility" + }], + "onUnTransform": [{ + "type": "enableAbility" + }] + }, + "displayFields": { + "alternateUnitId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "null" + } + } + }, + "onAddDisabledAbility": [], + "onEndCasting": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "storeBaseType" + } + },{ "type": "createTemporarySpellEffectOnUnit", "target": { "type": "getCastingUnit" @@ -837,14 +1167,23 @@ "type": "getAlias" }, "effectType": "CASTER" + },{ + "type": "setPreventEndEvents" },{ "type": "transformUnit", "unit": { "type": "getCastingUnit" }, "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } }, "alternateUnitId": { "type": "getAbilityUnitId" @@ -923,56 +1262,148 @@ "type": "getAbilityHeroDuration" }, "buffId": { - "type": "getFirstBuffId" + "type": "getFirstBuffId", + "defaultId": { + "type": "reuseID", + "name": { + "type": "rawString", + "value": "defaultBuffId" + } + } + }, + "instantTransformAtDurationEnd": { + "type": "rawBoolean", + "value": "true" + }, + "onlyTransformToAlternate": { + "type": "rawBoolean", + "value": "true" }, "onTransformActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransform" } + },{ + "type": "attemptToReOrderPreviousBehavior" }], "onUntransformActions": [{ - "type": "removeStateModBuff", + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" + } + }] + }] + },{ + "ids": [{"id":"AEme", "castId": "metamorphosis"}], + "type": "INHERIT", + "parentId": "Arav", + "reuseCallbacks": { + "defaultBuffId": { + "type": "getWar3IDFromString", + "id": "BEme" + } + }, + "displayFields": { + "toggleable": { + "type": "rawBoolean", + "value": "false" + } + }, + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MAXHP" + } + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + }], + "onTransform": [{ + "type": "addNonStackingStatBuff", "targetUnit": { "type": "getCastingUnit" }, "buff": { - "type": "getLastCreatedStateModBuff" + "type": "getLastCreatedNonStackingStatBuff" } - }] + },{ + "type": "deactivateToggledAbility" + }], + "onUnTransform": [{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedNonStackingStatBuff" + } + }], + "onLevelChange": [{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getLastCreatedNonStackingStatBuff" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + }] + }, + "onEndCasting": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "storeBaseType" + } },{ - "type": "if", - "condition": { - "type": "isTransformingToAlternate" + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" }, - "thenActions": [{ - "type": "activateToggledAbility" - }], - "elseActions": [{ - "type": "deactivateToggledAbility" - }] - }] - },{ - "ids": [{"id":"Astn", "castId": "stoneform", "uncastId": "unstoneform"}], - "type": "NORMAL_NOTARGET", - "displayFields": { - "toggleable": { - "type": "rawBoolean", - "value": "true" - }, - "castToggleOff": { - "type": "rawBoolean", - "value": "true" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "goldCost": { - "type": "i0IfFalse", - "bool": { + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "setPreventEndEvents" + },{ + "type": "transformUnit", + "unit": { + "type": "getCastingUnit" + }, + "baseUnitId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "alternateUnitId": { + "type": "getAbilityUnitId" + }, + "immediateLanding": { "type": "i2b", "value": { "type": "i&", @@ -982,55 +1413,25 @@ }, "value2": { "type": "rawInteger", - "value": 16 + "value": 2 } } }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", + "immediateTakeOff": { + "type": "i2b", + "value": { + "type": "i&", "value1": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } + "type": "getAbilityDataAsInteger", + "dataField": "B" }, "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } + "type": "rawInteger", + "value": 4 } } - } - }, - "lumberCost": { - "type": "i0IfFalse", - "bool": { + }, + "permanent": { "type": "i2b", "value": { "type": "i&", @@ -1040,1747 +1441,21 @@ }, "value2": { "type": "rawInteger", - "value": 16 + "value": 8 } } }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", + "requiresPayment": { + "type": "i2b", + "value": { + "type": "i&", "value1": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } + "type": "getAbilityDataAsInteger", + "dataField": "B" }, "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "foodCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "i-", - "value1": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getUnitType" - } - } - } - } - }, - "overrideFields": { - "physicalSpell": { - "type": "rawBoolean", - "value": "true" - }, - "onTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityDataAsID", - "dataField": "A" - } - }, - "offTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityUnitId" - } - } - }, - "onAddDisabledAbility": [{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "HPGEN" - } - }, - "stackingKey": { - "type": "getAllowStackingKey" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "E" - } - },{ - "type": "if", - "condition": { - "type": "isToggleAbilityActive" - }, - "thenActions": [{ - "type": "transformedUnitAbilityAdd", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" - }, - "onTransformActions": [{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - }], - "onUntransformActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - }] - }], - "elseActions": [] - }], - "onRemoveDisabledAbility": [{ - "type": "transformedUnitAbilityRemove", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "onUntransformActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - }] - }], - "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "E" - } - }], - "onBeginCasting": [{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getCastingUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "CASTER" - },{ - "type": "transformUnit", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" - }, - "onTransformActions": [{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - }], - "onUntransformActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - }] - },{ - "type": "if", - "condition": { - "type": "isTransformingToAlternate" - }, - "thenActions": [{ - "type": "activateToggledAbility" - },{ - "type": "resetCooldown" - }], - "elseActions": [{ - "type": "deactivateToggledAbility" - }] - }] - },{ - "ids": [{"id":"Acpf", "castId": "corporealform", "uncastId": "uncorporealform"}], - "type": "NORMAL_NOTARGET", - "displayFields": { - "toggleable": { - "type": "rawBoolean", - "value": "true" - }, - "castToggleOff": { - "type": "rawBoolean", - "value": "true" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "goldCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "lumberCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "foodCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "i-", - "value1": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getUnitType" - } - } - } - } - }, - "overrideFields": { - "onTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityDataAsID", - "dataField": "A" - } - }, - "offTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityUnitId" - } - } - }, - "onAddDisabledAbility": [{ - "type": "createStateModBuff", - "buffType": "ETHEREAL" - },{ - "type": "if", - "condition": { - "type": "isToggleAbilityActive" - }, - "thenActions": [{ - "type": "transformedUnitAbilityAdd", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" - }, - "onTransformActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }], - "onUntransformActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - }], - "elseActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - }], - "onRemoveDisabledAbility": [{ - "type": "transformedUnitAbilityRemove", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - } - }], - "onBeginCasting": [{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getCastingUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "CASTER" - },{ - "type": "transformUnit", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" - }, - "onTransformActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }], - "onUntransformActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - },{ - "type": "if", - "condition": { - "type": "isTransformingToAlternate" - }, - "thenActions": [{ - "type": "activateToggledAbility" - },{ - "type": "resetCooldown" - }], - "elseActions": [{ - "type": "deactivateToggledAbility" - }] - }] - },{ - "ids": [{"id":"Aetf", "castId": "etherealform", "uncastId": "unetherealform"}], - "type": "NORMAL_NOTARGET", - "displayFields": { - "toggleable": { - "type": "rawBoolean", - "value": "true" - }, - "castToggleOff": { - "type": "rawBoolean", - "value": "true" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "goldCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "lumberCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "foodCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "i-", - "value1": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getUnitType" - } - } - } - } - }, - "overrideFields": { - "onTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityDataAsID", - "dataField": "A" - } - }, - "offTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityUnitId" - } - } - }, - "onAddDisabledAbility": [{ - "type": "createStateModBuff", - "buffType": "ETHEREAL" - },{ - "type": "if", - "condition": { - "type": "isToggleAbilityActive" - }, - "thenActions": [{ - "type": "transformedUnitAbilityAdd", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" - }, - "onTransformActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }], - "onUntransformActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - }], - "elseActions": [] - }], - "onRemoveDisabledAbility": [{ - "type": "transformedUnitAbilityRemove", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "onUntransformActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - }], - "onBeginCasting": [{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getCastingUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "CASTER" - },{ - "type": "transformUnit", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" - }, - "onTransformActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }], - "onUntransformActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - },{ - "type": "if", - "condition": { - "type": "isTransformingToAlternate" - }, - "thenActions": [{ - "type": "activateToggledAbility" - },{ - "type": "resetCooldown" - }], - "elseActions": [{ - "type": "deactivateToggledAbility" - }] - }] - },{ - "ids": [{"id":"Aave", "castId": "avengerform", "uncastId": "unavengerform"}], - "type": "NORMAL_NOTARGET", - "displayFields": { - "toggleable": { - "type": "rawBoolean", - "value": "true" - }, - "castToggleOff": { - "type": "rawBoolean", - "value": "true" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "goldCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "lumberCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - } - } - }, - "foodCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "i-", - "value1": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getUnitType" - } - } - } - } - }, - "overrideFields": { - "physicalSpell": { - "type": "rawBoolean", - "value": "true" - }, - "onTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityDataAsID", - "dataField": "A" - } - }, - "offTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - } - }, - "value": { - "type": "getAbilityUnitId" - } - } - }, - "onAddDisabledAbility": [{ - "type": "if", - "condition": { - "type": "isToggleAbilityActive" - }, - "thenActions": [{ - "type": "transformedUnitAbilityAdd", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 + "type": "rawInteger", + "value": 16 } } }, @@ -2802,545 +1477,391 @@ "type": "getAbilityHeroDuration" }, "buffId": { - "type": "getFirstBuffId" - } - }], - "elseActions": [] - }], - "onRemoveDisabledAbility": [{ - "type": "transformedUnitAbilityRemove", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - } - }], - "onBeginCasting": [{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getCastingUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "CASTER" - },{ - "type": "transformUnit", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 8 - } - } - }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 + "type": "getFirstBuffId", + "defaultId": { + "type": "reuseID", + "name": { + "type": "rawString", + "value": "defaultBuffId" } } }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" - }, "onTransformActions": [{ - "type": "setMp", - "target": { - "type": "getCastingUnit" - }, - "amount": { - "type": "getUnitInitialMana", - "unit": { - "type": "getCastingUnit" + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransform" } - } - }] - },{ - "type": "if", - "condition": { - "type": "isTransformingToAlternate" - }, - "thenActions": [{ - "type": "activateToggledAbility" + },{ + "type": "attemptToReOrderPreviousBehavior" }], - "elseActions": [{ - "type": "deactivateToggledAbility" - }] - }] - },{ - "ids": [{"id":"AEme", "castId": "metamorphosis"}], - "type": "NORMAL_NOTARGET", - "displayFields": { - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "goldCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getUnitType" - } - } - }, - "value2": { - "type": "getUnitTypeGoldCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } + "onUntransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" } - } - } - }, - "lumberCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" } - } - }, - "value": { - "type": "iIf", - "condition": { - "type": "gameplayConstantIsRelativeUpgradeCosts" - }, - "value1": { - "type": "i-", - "value1": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } + },{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDuration" } }, - "value2": { - "type": "getUnitTypeLumberCost", - "id": { - "type": "getUnitType" - } + "thenActions": [{ + "type": "attemptToReOrderPreviousBehavior" + }] + }] + }] + },{ + "ids": [{"id":"ANrg", "castId": "robogoblin", "uncastId": "unrobogoblin"}], + "type": "INHERIT", + "parentId": "Arav", + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "STR" } }, - "value2": { - "type": "getUnitTypeLumberCost", + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "strbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } + "type": "rawString", + "value": "DEF" } - } - } - }, - "foodCost": { - "type": "i0IfFalse", - "bool": { - "type": "i2b", + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" + "type": "getAbilityDataAsFloat", + "dataField": "F" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "defbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }], + "onTransform": [{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "strbuff" }, - "value2": { - "type": "rawInteger", - "value": 16 + "instanceValue": { + "type": "rawBoolean", + "value": "false" } } - }, - "value": { - "type": "i-", - "value1": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getNonCurrentTransformType", - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - } - } + },{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" }, - "value2": { - "type": "getUnitTypeFoodCost", - "id": { - "type": "getUnitType" + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "defbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" } } - } - } - }, - "overrideFields": { - "onTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } + }], + "onUnTransform": [{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "strbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" } } - }, - "value": { - "type": "getAbilityDataAsID", - "dataField": "A" - } - }, - "offTooltipOverride": { - "type": "nullIfFalse", - "condition": { - "type": "bool", - "bool": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 16 - } + },{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "defbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" } } - }, - "value": { - "type": "getAbilityUnitId" - } - } - }, - "onAddDisabledAbility": [{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "MAXHP" + }], + "onLevelChange": [{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "strbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "E" } - }, - "stackingKey": { - "type": "getAllowStackingKey" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "E" - } - }], - "onRemoveDisabledAbility": [{ - "type": "transformedUnitAbilityRemove", - "unit": { - "type": "getCastingUnit" - }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "permanent": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" + },{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "defbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } }, - "value2": { - "type": "rawInteger", - "value": 8 + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "F" } - } - }, - "onUntransformActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } }] - }], - "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "ids": [{"id":"ANsu", "castId": "submerge", "uncastId": "unsubmerge"}], + "type": "INHERIT", + "parentId": "Abur", + "extraCastConditions": [{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "isLocationDeepWater", + "location": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } + } }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "E" - } + "reason": "UNABLE_TO_SUBMERGE_THERE" }], - "onBeginCasting": [{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getCastingUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "CASTER" - },{ - "type": "transformUnit", + "reuseActions": { + "onUnTransform": [{ + "type": "addSecondaryAnimationTag", "unit": { "type": "getCastingUnit" }, - "baseUnitId": { - "type": "getAbilityDataAsID", - "dataField": "A" - }, - "alternateUnitId": { - "type": "getAbilityUnitId" - }, - "immediateLanding": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 2 - } - } - }, - "immediateTakeOff": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" - }, - "value2": { - "type": "rawInteger", - "value": 4 - } - } + "tag": { + "type": "rawString", + "value": "SWIM" + } + }] + } + },{ + "ids": [{"id":"Acha"}], + "type": "HIDDEN", + "onAddAbility": [{ + "type": "transformUnitInstant", + "unit": { + "type": "getCastingUnit" + }, + "alternateUnitId": { + "type": "getAbilityUnitId" }, "permanent": { - "type": "i2b", + "type": "rawBoolean", + "value": "true" + }, + "keepRatios": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "ids": [{"id":"Aphx"}], + "type": "HIDDEN", + "reuseActions": { + "storeBaseType": [{ + "type": "if", + "condition": { + "type": "isNull", "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" }, - "value2": { - "type": "rawInteger", - "value": 8 + "instanceValue": { + "type": "rawBoolean", + "value": "false" } } }, - "requiresPayment": { - "type": "i2b", - "value": { - "type": "i&", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "B" + "thenActions": [{ + "type": "if", + "condition": { + "type": "not", + "condition": { + "type": "or", + "conditions": [{ + "type": "isUnitType", + "unit": { + "type": "getCastingUnit" + }, + "unitType": { + "type": "getAbilityDataAsID", + "dataField": "A" + } + },{ + "type": "isUnitType", + "unit": { + "type": "getCastingUnit" + }, + "unitType": { + "type": "getAbilityUnitId" + } + }] + } + }, + "thenActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getUnitType", + "unit": { + "type": "getCastingUnit" + } + } + }], + "elseActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "baseType" }, - "value2": { - "type": "rawInteger", - "value": 16 + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getAbilityDataAsID", + "dataField": "A" } - } - }, - "altitudeAdjustmentDelay": { - "type": "getAbilityCastTime" - }, - "altitudeAdjustmentTime": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "landingDelayTime": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "transformTime": { - "type": "getAbilityDuration" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "buffId": { - "type": "getFirstBuffId" + }] + }] + }], + "clearBaseType": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "baseType" }, - "instantTransformAtDurationEnd": { + "instanceValue": { "type": "rawBoolean", - "value": "true" + "value": "false" }, - "onTransformActions": [{ - "type": "addNonStackingStatBuff", + "valueToStore": { + "type": "null" + } + }], + "onTransform": [{ + "type": "removeStateModBuff", "targetUnit": { "type": "getCastingUnit" }, "buff": { - "type": "getLastCreatedNonStackingStatBuff" + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "invuln" + } } - }], - "onUntransformActions": [{ + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "magim" + } + } + },{ "type": "removeNonStackingStatBuff", "targetUnit": { "type": "getCastingUnit" @@ -3348,23 +1869,439 @@ "buff": { "type": "getLastCreatedNonStackingStatBuff" } - }] - }] - },{ - "ids": [{"id":"Acha"}], - "type": "HIDDEN", - "onAddAbility": [{ - "type": "transformUnitInstant", - "unit": { - "type": "getCastingUnit" + },{ + "type": "setHp", + "target": { + "type": "getListenerUnit" + }, + "amount": { + "type": "rawFloat", + "value": 100 + }, + "isPercent": { + "type": "rawBoolean", + "value": "true" + } + }], + "onUnTransform": [{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getUnitLocation", + "unit": { + "type": "getCastingUnit" + } }, - "alternateUnitId": { - "type": "getAbilityUnitId" + "id": { + "type": "getAlias" }, - "permanent": { + "effectType": "CASTER" + }] + }, + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "INVULNERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { "type": "rawBoolean", - "value": "true" + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "MAGIC_IMMUNE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "magim" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "HPGENPCT" + } + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "rawFloat", + "value": -1 + } + },{ + "type": "createDeathReplacementEffect", + "actions": [{ + "type": "if", + "condition": { + "type": "not", + "condition": { + "type": "isUnitType", + "unit": { + "type": "getCastingUnit" + }, + "unitType": { + "type": "getAbilityUnitId" + } + } + }, + "thenActions": [{ + "type": "setReviving" + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "invuln" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "magim" + } + } + },{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "setHp", + "target": { + "type": "getCastingUnit" + }, + "amount": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "storeBaseType" + } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "sendStartCastingEvents" + },{ + "type": "transformUnit", + "unit": { + "type": "getCastingUnit" + }, + "baseUnitId": { + "type": "getStoredIDByKey", + "key": { + "type": "rawString", + "value": "baseType" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + }, + "alternateUnitId": { + "type": "getAbilityUnitId" + }, + "immediateLanding": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "immediateTakeOff": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "permanent": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + }, + "requiresPayment": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 16 + } + } + }, + "altitudeAdjustmentDelay": { + "type": "getAbilityCastTime" + }, + "altitudeAdjustmentTime": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "landingDelayTime": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "transformTime": { + "type": "getAbilityDuration" + }, + "duration": { + "type": "getAbilityHeroDuration" + }, + "buffId": { + "type": "getWar3IDFromString", + "id": "Bphx" + }, + "onTransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransform" + } + }], + "onUntransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" + } + }] + },{ + "type": "forceBeginCreatedBehavior" + }] + }] + },{ + "type": "if", + "condition": { + "type": "isUnitType", + "unit": { + "type": "getCastingUnit" + }, + "unitType": { + "type": "getAbilityUnitId" + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "storeBaseType" + } + },{ + "type": "transformedUnitAbilityAdd", + "unit": { + "type": "getCastingUnit" + }, + "baseUnitId": { + "type": "getAbilityDataAsID", + "dataField": "A" + }, + "alternateUnitId": { + "type": "getAbilityUnitId" + }, + "immediateLanding": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 2 + } + } + }, + "immediateTakeOff": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 4 + } + } + }, + "permanent": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + }, + "requiresPayment": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "B" + }, + "value2": { + "type": "rawInteger", + "value": 16 + } + } + }, + "altitudeAdjustmentDelay": { + "type": "getAbilityCastTime" + }, + "altitudeAdjustmentTime": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "landingDelayTime": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "transformTime": { + "type": "getAbilityDuration" + }, + "duration": { + "type": "getAbilityHeroDuration" + }, + "buffId": { + "type": "getWar3IDFromString", + "id": "Bphx" + }, + "onTransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onTransform" + } + }], + "onUntransformActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnTransform" + } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "clearBaseType" + } + }] + }] + }], + "onAddAbility": [{ + "type": "addDeathReplacementEffect", + "target": { + "type": "getCastingUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "PHOENIXREVIVE" + }, + "listener": { + "type": "getLastCreatedDeathReplacement" + } + }], + "onRemoveAbility": [{ + "type": "removeDeathReplacementEffect", + "target": { + "type": "getCastingUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "PHOENIXREVIVE" + }, + "listener": { + "type": "getLastCreatedDeathReplacement" + } }] }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/activeBuffs.json b/core/assets/abilityBehaviors/activeBuffs.json new file mode 100644 index 000000000..7e36d1dd6 --- /dev/null +++ b/core/assets/abilityBehaviors/activeBuffs.json @@ -0,0 +1,1167 @@ +{ + "abilityList": [{ + "ids": [{"id":"Absk", "castId": "berserk"}], + "type": "NORMAL_NOTARGET", + "displayFields": { + "castlessNoTarget": { + "type": "rawBoolean", + "value": "true" + } + }, + "overrideFields": { + "physicalSpell": { + "type": "rawBoolean", + "value": "false" + }, + "magicSpell": { + "type": "rawBoolean", + "value": "false" + } + }, + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "berserk" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "berserk" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + },{ + "type": "createDamageTakenModificationListener", + "actions": [{ + "type": "multiplyDamageTakenMultiplier", + "multiplier": { + "type": "f+", + "value1": { + "type": "rawFloat", + "value": 1 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + }] + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getCastingUnit" + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }], + "onAddActions": [{ + "type": "addDamageTakenModificationListener", + "targetUnit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedDamageTakenModificationListener" + } + }], + "onRemoveActions": [{ + "type": "removeDamageTakenModificationListener", + "targetUnit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedDamageTakenModificationListener" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"AHav", "castId": "avatar"}], + "type": "NORMAL_NOTARGET", + "displayFields": { + "castlessNoTarget": { + "type": "rawBoolean", + "value": "true" + } + }, + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "DEF" + } + }, + "stackingKey": { + "type": "rawString", + "value": "avatar" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "defbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MAXHP" + } + }, + "stackingKey": { + "type": "rawString", + "value": "avatar" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "hpbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ALLATK" + } + }, + "stackingKey": { + "type": "rawString", + "value": "avatar" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "MAGIC_IMMUNE" + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + },{ + "type": "createDamageTakenModificationListener", + "actions": [{ + "type": "if", + "condition": { + "type": "isAttackTypeEqual", + "attackType1": { + "type": "getTriggeringAttackType" + }, + "attackType2": { + "type": "getAttackTypeFromString", + "id": { + "type": "rawString", + "value": "SPELLS" + } + } + }, + "thenActions": [{ + "type": "multiplyDamageTakenMultiplier", + "multiplier": { + "type": "f-", + "value1": { + "type": "rawFloat", + "value": 1 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + } + }], + "elseActions": [] + }] + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getWar3IDFromString", + "id": "BHav" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getCastingUnit" + } + }, + "showTimedLifeBar": { + "type": "rawBoolean", + "value": "true" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "defbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "hpbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "atkbuff" + } + }], + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }], + "onAddActions": [{ + "type": "disableAbility" + },{ + "type": "dispelBuffs", + "filter": { + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + } + },{ + "type": "multiplyUnitScale", + "unit": { + "type": "getBuffedUnit" + }, + "value": { + "type": "rawFloat", + "value": "1.5" + } + },{ + "type": "addSecondaryAnimationTag", + "unit": { + "type": "getBuffedUnit" + }, + "tag": { + "type": "rawString", + "value": "ALTERNATE" + } + },{ + "type": "playAnimation", + "unit": { + "type": "getBuffedUnit" + }, + "tag": { + "type": "rawString", + "value": "MORPH" + } + },{ + "type": "queueAnimation", + "unit": { + "type": "getBuffedUnit" + }, + "tag": { + "type": "rawString", + "value": "STAND" + } + },{ + "type": "addDamageTakenModificationListener", + "targetUnit": { + "type": "getBuffedUnit" + }, + "listener": { + "type": "getLastCreatedDamageTakenModificationListener" + } + }], + "onRemoveActions": [{ + "type": "enableAbility" + },{ + "type": "multiplyUnitScale", + "unit": { + "type": "getBuffedUnit" + }, + "value": { + "type": "rawFloat", + "value": "0.66666666666667" + } + },{ + "type": "removeSecondaryAnimationTag", + "unit": { + "type": "getBuffedUnit" + }, + "tag": { + "type": "rawString", + "value": "ALTERNATE" + } + },{ + "type": "playAnimation", + "unit": { + "type": "getBuffedUnit" + }, + "tag": { + "type": "rawString", + "value": "MORPH" + } + },{ + "type": "queueAnimation", + "unit": { + "type": "getBuffedUnit" + }, + "tag": { + "type": "rawString", + "value": "STAND" + } + },{ + "type": "removeDamageTakenModificationListener", + "targetUnit": { + "type": "getBuffedUnit" + }, + "listener": { + "type": "getLastCreatedDamageTakenModificationListener" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"Auhf", "castId": "unholyfrenzy"}], + "type": "NORMAL_UNITTARGET", + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "unholyfrenzy" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "positive": { + "type": "isUnitShareSpells", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "statBuffs": [{ + "type": "getLastCreatedNonStackingStatBuff" + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "DEATH" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"AUfu", "castId": "frostarmor", "autoCastOnId": "frostarmoron", "autoCastOffId": "frostarmoroff", "autoCastType": "ATTACKINGENEMY"}, + {"id":"AUfa", "castId": "frostarmor"}], + "type": "NORMAL_UNITTARGET", + "extraAutoTargetConditions": [{ + "type": "not", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + } + }], + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "DEF" + } + }, + "stackingKey": { + "type": "rawString", + "value": "frostarmor" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + },{ + "type": "createDamageTakenListener", + "actions": [{ + "type": "if", + "condition": { + "type": "and", + "conditions": [{ + "type": "isTriggeringDamageAnAttack" + },{ + "type": "not", + "condition": { + "type": "isTriggeringDamageRanged" + } + },{ + "type": "not", + "condition": { + "type": "isUnitMagicImmune", + "unit": { + "type": "getDamagingUnit" + } + } + }] + }, + "thenActions": [{ + "type": "addSlowBuff", + "unit": { + "type": "getDamagingUnit" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getDamagingUnit" + } + } + }] + }] + }], + "onEndCasting": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "statBuffs": [{ + "type": "getLastCreatedNonStackingStatBuff" + }], + "onAddActions": [{ + "type": "addDamageTakenListener", + "targetUnit": { + "type": "getBuffedUnit" + }, + "listener": { + "type": "getLastCreatedDamageTakenListener" + } + }], + "onRemoveActions": [{ + "type": "removeDamageTakenListener", + "targetUnit": { + "type": "getBuffedUnit" + }, + "listener": { + "type": "getLastCreatedDamageTakenListener" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"Ablo", "castId": "bloodlust", "autoCastOnId": "bloodluston", "autoCastOffId": "bloodlustoff", "autoCastType": "ATTACKINGENEMY"}], + "type": "NORMAL_UNITTARGET", + "extraAutoTargetConditions": [{ + "type": "not", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + } + }], + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "bloodlust" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "bloodlust" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }], + "onEndCasting": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + }], + "onAddActions": [{ + "type": "multiplyUnitScale", + "unit": { + "type": "getBuffedUnit" + }, + "value": { + "type": "f+", + "value1": { + "type": "rawFloat", + "value": 1.0 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + }], + "onRemoveActions": [{ + "type": "multiplyUnitScale", + "unit": { + "type": "getBuffedUnit" + }, + "value": { + "type": "f/", + "value1": { + "type": "rawFloat", + "value": 1.0 + }, + "value2": { + "type": "f+", + "value1": { + "type": "rawFloat", + "value": 1.0 + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"Afzy", "castId": "frenzy", "autoCastOnId": "frenzyon", "autoCastOffId": "frenzyoff", "autoCastType": "NOTARGET"}], + "type": "NORMAL_NOTARGET", + "extraAutoNoTargetConditions": [{ + "type": "isCurrentBehaviorCategoryInList", + "list": ["ATTACK"] + },{ + "type": "not", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + } + }], + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "bloodlust" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "bloodlust" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }], + "onEndCasting": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"AHds", "castId": "divineshield", "uncastId": "undivineshield"}], + "type": "NORMAL_NOTARGET", + "displayFields": { + "castlessNoTarget": { + "type": "rawBoolean", + "value": "true" + }, + "toggleable": { + "type": "and", + "conditions": [{ + "type": "getAbilityDataAsBoolean", + "dataField": "A" + },{ + "type": "gameplayConstantCanDisableDivineShield" + }] + }, + "castToggleOff": { + "type": "rawBoolean", + "value": "false" + } + }, + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "INVULNERABLE" + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getCastingUnit" + } + }, + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }], + "onAddActions": [{ + "type": "if", + "condition": { + "type": "and", + "conditions": [{ + "type": "getAbilityDataAsBoolean", + "dataField": "A" + },{ + "type": "gameplayConstantCanDisableDivineShield" + }] + }, + "elseActions": [{ + "type": "disableAbility" + }] + },{ + "type": "dispelBuffs", + "filter": { + "type": "isBuffMagic", + "buff": { + "type": "enumBuff" + } + } + }], + "onRemoveActions": [{ + "type": "enableAbility" + }] + },{ + "type": "addBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }], + "onDeactivate": [{ + "type": "removeBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/activeDebuffs.json b/core/assets/abilityBehaviors/activeDebuffs.json new file mode 100644 index 000000000..ae028fa07 --- /dev/null +++ b/core/assets/abilityBehaviors/activeDebuffs.json @@ -0,0 +1,647 @@ +{ + "abilityList": [{ + "ids": [{"id":"Acri", "castId": "cripple"}], + "type": "NORMAL_UNITTARGET", + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "cripple" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "cripple" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ALLATKPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "cripple" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "atkbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"ANht", "castId": "howlofterror"}], + "type": "NORMAL_NOTARGET", + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ALLATKPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "howlofterror" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "DEF" + } + }, + "stackingKey": { + "type": "rawString", + "value": "howlofterror" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "defbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "HPGEN" + } + }, + "stackingKey": { + "type": "rawString", + "value": "howlofterror" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "hpbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MPGEN" + } + }, + "stackingKey": { + "type": "rawString", + "value": "howlofterror" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mpbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "iterateUnitsInRangeOfUnitMatchingCondition", + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, + "iterationActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getEnumUnit" + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "atkbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "defbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "hpbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mpbuff" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getEnumUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }], + "originUnit": { + "type": "getCastingUnit" + }, + "range": { + "type": "getAbilityArea" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"ANso", "castId": "soulburn"}], + "type": "NORMAL_UNITTARGET", + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ALLATKPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "soulburn" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "soulburn" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "soulburn" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + },{ + "type": "createStateModBuff", + "buffType": "DISABLE_SPELLS" + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "atkbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + }], + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + } + }], + "delaySeconds": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors/auras.json b/core/assets/abilityBehaviors/auras.json index a457a693c..6a929bdf3 100644 --- a/core/assets/abilityBehaviors/auras.json +++ b/core/assets/abilityBehaviors/auras.json @@ -110,16 +110,6 @@ "percentageBooleanField": "B" }] } - },{ - "ids": [{"id":"AIva"}], - "type": "TEMPLATE", - "templateFields": { - "templateType": "PASSIVE_STATS", - "statBuffsFromDataFields": [{ - "type": "HPSTEAL", - "dataField": "A" - }] - } },{ "ids": [{"id":"AIas"}], "type": "TEMPLATE", diff --git a/core/assets/abilityBehaviors/generalPassives.json b/core/assets/abilityBehaviors/generalPassives.json index 4d50baef8..3ab0fd204 100644 --- a/core/assets/abilityBehaviors/generalPassives.json +++ b/core/assets/abilityBehaviors/generalPassives.json @@ -91,7 +91,7 @@ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "isDamageTypeEqual", "damageType1": { "type": "getTriggeringDamageType" @@ -103,8 +103,7 @@ "value": "NORMAL" } } - }, - "condition2": { + },{ "type": "not", "condition": { "type": "bool", @@ -112,7 +111,7 @@ "type": "isTriggeringDamageRanged" } } - } + }] }, "thenActions": [{ "type": "multiplyDamageTakenMultiplier", @@ -224,221 +223,6 @@ "type": "getLastCreatedBuff" } }] - },{ - "ids": [{"id":"AHbh"},{"id":"AOcr"},{"id":"ANdb"}], - "type": "PASSIVE", - "onAddAbility": [{ - "type": "createAttackPreDamageListener", - "actions": [{ - "type": "if", - "condition": { - "type": "and", - "condition1": { - "type": "isUnitValidTarget", - "target": { - "type": "getAttackedUnit" - } - }, - "condition2": { - "type": "f<", - "value1": { - "type": "randomBoundedFloat", - "bound": { - "type": "rawFloat", - "value": 100 - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - } - }, - "thenActions": [{ - "type": "if", - "condition": { - "type": "f!=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - }, - "thenActions": [{ - "type": "addDamageDealtMultiplier", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - - }], - "elseActions": [] - },{ - "type": "addBonusDamageDealt", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - } - },{ - "type": "addStunBuff", - "target": { - "type": "getAttackedUnit" - }, - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityDuration", - "target": { - "type": "getAttackedUnit" - } - } - },{ - "type": "setStacking", - "allowStacking": { - "type": "rawBoolean", - "value": "false" - }, - "allowSamePriorityStacking": { - "type": "rawBoolean", - "value": "false" - } - }], - "elseActions": [] - }] - },{ - "type": "addAttackPreDamageListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "priority": { - "type": "rawPriority", - "priority": "CRITBASH" - }, - "listener": { - "type": "getLastCreatedAttackPreDamageListener" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "crit" - }, - "valueToStore": { - "type": "getLastCreatedAttackPreDamageListener" - } - },{ - "type": "createAttackPreDamageListener", - "actions": [{ - "type": "if", - "condition": { - "type": "bool", - "bool": { - "type": "getAbilityDataAsBoolean", - "dataField": "E" - } - }, - "thenActions": [{ - "type": "preDamageListenerSetMiss", - "miss": { - "type": "rawBoolean", - "value": "false" - } - },{ - "type": "setStacking", - "allowStacking": { - "type": "rawBoolean", - "value": "true" - }, - "allowSamePriorityStacking": { - "type": "rawBoolean", - "value": "false" - } - }], - "elseActions": [] - }] - },{ - "type": "addAttackPreDamageListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "priority": { - "type": "rawPriority", - "priority": "ACCURACY" - }, - "listener": { - "type": "getLastCreatedAttackPreDamageListener" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "nomiss" - }, - "valueToStore": { - "type": "getLastCreatedAttackPreDamageListener" - } - },{ - "type": "createEvasionListener", - "conditions": [{ - "type": "f<", - "value1": { - "type": "randomFloat" - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - } - }] - },{ - "type": "addEvasionListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getLastCreatedEvasionListener" - } - }], - "onRemoveAbility": [{ - "type": "removeAttackPreDamageListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "priority": { - "type": "rawPriority", - "priority": "CRITBASH" - }, - "listener": { - "type": "getStoredAttackPreDamageListenerByKey", - "key": { - "type": "rawString", - "value": "crit" - } - } - },{ - "type": "removeAttackPreDamageListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "priority": { - "type": "rawPriority", - "priority": "ACCURACY" - }, - "listener": { - "type": "getStoredAttackPreDamageListenerByKey", - "key": { - "type": "rawString", - "value": "nomiss" - } - } - },{ - "type": "removeEvasionListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getLastCreatedEvasionListener" - } - }] },{ "ids": [{"id":"AEev"}], "type": "PASSIVE", @@ -531,9 +315,9 @@ "value": "true" } },{ - "type": "removeSpellEffect", - "effectToRemove": { - "type": "getLastCreatedSpellEffect" + "type": "removeEffect", + "effect": { + "type": "getLastCreatedFX" } }, { "type": "finishReincarnating" @@ -576,12 +360,11 @@ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "isItemAbility" - }, - "condition2": { + },{ "type": "itemHasCharges" - } + }] }, "thenActions": [{ "type": "setReincarnating" @@ -660,9 +443,9 @@ }], "elseActions": [] },{ - "type": "removeSpellEffect", - "effectToRemove": { - "type": "getLastCreatedSpellEffect" + "type": "removeEffect", + "effect": { + "type": "getLastCreatedFX" } }, { "type": "finishReincarnating" @@ -1074,7 +857,7 @@ "type": "if", "condition": { "type": "isNewBehaviorCategoryInList", - "list": ["ATTACK","SPELL"] + "list": ["ATTACK","SPELL","BUILD"] }, "thenActions": [{ "type": "removeBuff", @@ -1167,9 +950,9 @@ }] }], "onRemoveAbility": [{ - "type": "removeSpellEffect", - "effectToRemove": { - "type": "getLastCreatedSpellEffect" + "type": "removeEffect", + "effect": { + "type": "getLastCreatedFX" } },{ "type": "removeBuff", @@ -1739,7 +1522,8 @@ },{ "ids": [{"id":"Agyv"},{"id":"Adts"},{"id":"Adet"},{"id":"Abdt"},{"id":"Atru"}], "type": "PASSIVE", - "onAddAbility": [{ + "reuseActions": { + "setup": [{ "type": "createStateModBuff", "buffType": "DETECTOR", "value": { @@ -1755,22 +1539,89 @@ "type": "getAbilityCastRange" } } - },{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" + }], + "detect": [{ + "type": "createSpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "effectType": "CASTER" + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + }], + "undetect": [{ + "type": "removeEffect", + "effect": { + "type": "getLastCreatedFX" + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedStateModBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onAddAbility": [{ + "type": "if", + "condition": { + "type": "isUnitConstructing" + }, + "thenActions": [{ + "type": "createWidgetEvent", + "eventType": "EVENT_UNIT_CONSTRUCT_FINISH", + "widget": { + "type": "u2w", + "unit": { + "type": "getCastingUnit" + } + }, + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "detect" + } + },{ + "type": "unregisterWidgetEvent", + "event": { + "type": "getLastCreatedWidgetEvent" + } + }] + },{ + "type": "registerWidgetEvent", + "event": { + "type": "getLastCreatedWidgetEvent" + } + }], + "elseActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "detect" } + }] }], "onRemoveAbility": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "undetect" } }] },{ @@ -1834,12 +1685,12 @@ "value": "false" }, "valueToStore": { - "type": "getLastCreatedSpellEffect" + "type": "getLastCreatedFX" } }] },{ "type": "createSubroutine", - "key": { + "name": { "type": "rawString", "value": "removeOrb" }, @@ -1899,8 +1750,8 @@ "value": "false" } },{ - "type": "removeSpellEffect", - "effectToRemove": { + "type": "removeEffect", + "effect": { "type": "getStoredFXByKey", "key": { "type": "catStrings", @@ -2054,7 +1905,7 @@ "value": "false" }, "valueToStore": { - "type": "getLastCreatedSpellEffect" + "type": "getLastCreatedFX" } },{ "type": "break" @@ -2073,7 +1924,7 @@ } }, "thenActions": [{ - "type": "removeTimer", + "type": "killTimer", "timer": { "type": "getStoredTimerByKey", "key": { @@ -2115,7 +1966,7 @@ }, "thenActions": [{ "type": "runSubroutine", - "key": { + "name": { "type": "rawString", "value": "removeOrb" }, @@ -2133,7 +1984,7 @@ }, "thenActions": [{ "type": "runSubroutine", - "key": { + "name": { "type": "rawString", "value": "removeOrb" }, @@ -2229,7 +2080,7 @@ } }], "onRemoveAbility": [{ - "type": "removeTimer", + "type": "killTimer", "timer": { "type": "getStoredTimerByKey", "key": { @@ -2250,5 +2101,522 @@ "type": "getLastCreatedBehaviorChangeListener" } }] + },{ + "ids": [{"id":"Aamk"}], + "type": "PASSIVE", + "onAddDisabledAbility": [{ + "type": "abilitySetShowIcon", + "ability": { + "type": "getThisAbility" + }, + "show": { + "type": "not", + "condition": { + "type": "getAbilityDataAsBoolean", + "dataField": "D" + } + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "AGI" + } + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "agibuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "INT" + } + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "intbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "STR" + } + }, + "stackingKey": { + "type": "getAllowStackingKey" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "strbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }], + "onAddAbility": [{ + "type": "abilitySetShowIcon", + "ability": { + "type": "getThisAbility" + }, + "show": { + "type": "not", + "condition": { + "type": "getAbilityDataAsBoolean", + "dataField": "D" + } + } + },{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "agibuff" + } + } + },{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "intbuff" + } + } + },{ + "type": "addNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "strbuff" + } + } + }], + "onLevelChange": [{ + "type": "abilitySetShowIcon", + "ability": { + "type": "getThisAbility" + }, + "show": { + "type": "not", + "condition": { + "type": "getAbilityDataAsBoolean", + "dataField": "D" + } + } + },{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "agibuff" + } + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "intbuff" + } + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "strbuff" + } + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "recomputeStatBuffsOnUnit", + "targetUnit": { + "type": "getCastingUnit" + }, + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "AGI" + } + } + },{ + "type": "recomputeStatBuffsOnUnit", + "targetUnit": { + "type": "getCastingUnit" + }, + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "INT" + } + } + },{ + "type": "recomputeStatBuffsOnUnit", + "targetUnit": { + "type": "getCastingUnit" + }, + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "STR" + } + } + }], + "onRemoveAbility": [{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "agibuff" + } + } + },{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "intbuff" + } + } + },{ + "type": "removeNonStackingStatBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "strbuff" + } + } + }] + },{ + "ids": [{"id":"Aloc"}], + "type": "HIDDEN", + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "INVULNERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNENUMERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unenum" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNSELECTABLE", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNTARGETABLE", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "untar" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + }], + "onAddAbility": [{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unenum" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "untar" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }], + "onRemoveAbility": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unenum" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "untar" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }] }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/humanHeroActives.json b/core/assets/abilityBehaviors/humanHeroActives.json index 2eb6585cb..f3248f471 100644 --- a/core/assets/abilityBehaviors/humanHeroActives.json +++ b/core/assets/abilityBehaviors/humanHeroActives.json @@ -2,35 +2,68 @@ "abilityList": [{ "ids": [{"id":"AHfs", "castId": "flamestrike"}], "type": "NORMAL_POINTTARGET", - "onBeginCasting": [{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "targetLoc" + "overrideFields": { + "ignoreCastTime": { + "type": "rawBoolean", + "value": "true" + } + }, + "reuseCallbacks": { + "notTakingDamage": { + "type": "not", + "condition": { + "type": "doesUnitHaveBuffMatchingCondition", + "unit": { + "type": "getEnumUnit" }, - "valueToStore": { - "type": "getTargetedLocation" + "condition": { + "type": "and", + "conditions": [{ + "type": "isIdEqual", + "id1": { + "type": "getBuffAlias", + "buff": { + "type": "getMatchingBuff" + } + }, + "id2": { + "type": "getFirstBuffId" + } + },{ + "type": "f<", + "value1": { + "type": "getBuffDurationElapsed", + "buff": { + "type": "getMatchingBuff" + } + }, + "value2": { + "type": "f-", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "curDelay" + } + }, + "value2": { + "type": "f*", + "value1": { + "type": "oneGameTick" + }, + "value2": { + "type": "rawFloat", + "value": 2 + } + } + } + }] } - },{ - "type": "createTemporarySpellEffectAtLocation", - "location": { - "type": "getTargetedLocation" - }, - "id": { - "type": "getAlias" - }, - "effectType": "EFFECT" - }], - "onEndCasting": [{ - "type": "createTemporarySpellEffectAtLocation", - "location": { - "type": "getTargetedLocation" - }, - "id": { - "type": "getAlias" - }, - "effectType": "SPECIAL" - },{ + } + } + }, + "reuseActions": { + "damageDest": [{ "type": "iterateDestructablesInRangeOfLocation", "location": { "type": "getTargetedLocation" @@ -58,614 +91,394 @@ "type": "rawFloat", "value": 512 } - }], - "elseActions": [] - }] - },{ - "type": "createTimer", - "timeout": { - "type": "rawFloat", - "value": 0.33 - }, - "repeats": { - "type": "rawBoolean", - "value": "true" - }, - "delay": { - "type": "rawFloat", - "value": 0 - }, - "actions": [{ - "type": "for", - "times": { - "type": "rawInteger", - "value": 10 - }, - "actions": [{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "randAngle" - }, - "valueToStore": { - "type": "randomBoundedFloat", - "bound": { - "type": "f*", - "value1": { - "type": "pi" - }, - "value2": { - "type": "rawFloat", - "value": 2 - } - } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "randDist" - }, - "valueToStore": { - "type": "f*", - "value1": { - "type": "randomFloat" - }, - "value2": { - "type": "getAbilityArea" - } - } - },{ - "type": "createTemporarySpellEffectAtPoint", - "x": { - "type": "f+", - "value1": { - "type": "getLocationX", - "location": { - "type": "getStoredLocationByKey", - "key": { - "type": "rawString", - "value": "targetLoc" - } - } - }, - "value2": { - "type": "f*", - "value1": { - "type": "cos", - "angle": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "randAngle" - } - } - }, - "value2": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "randDist" - } - } - } - }, - "y": { - "type": "f+", - "value1": { - "type": "getLocationY", - "location": { - "type": "getStoredLocationByKey", - "key": { - "type": "rawString", - "value": "targetLoc" - } - } - }, - "value2": { - "type": "f*", - "value1": { - "type": "sin", - "angle": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "randAngle" - } - } - }, - "value2": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "randDist" - } - } - } - }, - "id": { - "type": "getFirstEffectId" - }, - "effectType": "EFFECT" - }] + }] }] - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "artTimer" - }, - "valueToStore": { - "type": "getLastCreatedTimer" - } - },{ - "type": "createTimer", - "timeout": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - }, - "repeats": { - "type": "rawBoolean", - "value": "true" - }, - "delay": { - "type": "rawFloat", - "value": 0 - }, - "actions": [{ - "type": "storeValueLocally", + }], + "damageUnits": [{ + "type": "damageArea", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getStoredLocationByKey", "key": { "type": "rawString", - "value": "damageDealt" - }, - "valueToStore": { - "type": "fMin", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - }, - "value2": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - }, - "value2": { - "type": "i2f", - "value": { - "type": "countUnitsInRangeOfLocation", - "location": { - "type": "getStoredLocationByKey", - "key": { - "type": "rawString", - "value": "targetLoc" - } - }, - "range": { - "type": "getAbilityArea" - } - } - } + "value": "targetLoc" + } + }, + "validTarget": { + "type": "and", + "conditions": [{ + "type": "isUnitValidTarget", + "target": { + "type": "getEnumUnit" + } + },{ + "type": "reuseBoolean", + "name": { + "type": "rawString", + "value": "notTakingDamage" } + }] + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" } - },{ - "type": "storeValueLocally", + }, + "damage": { + "type": "getStoredFloatByKey", "key": { "type": "rawString", - "value": "buildingDamageDealt" - }, - "valueToStore": { - "type": "f*", - "value1": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "damageDealt" - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "E" - } + "value": "curDamage" } - },{ - "type": "iterateUnitsInRangeOfLocationMatchingCondition", - "location": { - "type": "getStoredLocationByKey", - "key": { - "type": "rawString", - "value": "targetLoc" - } - }, - "range": { - "type": "getAbilityArea" - }, + }, + "maxDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "F" + }, + "unitSpecificDamageMod": { + "type": "inlineConditionFloat", "condition": { - "type": "isUnitValidTarget", - "target": { - "type": "getMatchingUnit" + "type": "isUnitBuilding", + "unit": { + "type": "getEnumUnit" } }, - "iterationActions": [{ - "type": "createTimedArtBuff", - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - },{ - "type": "addNonStackingDisplayBuff", - "target": { - "type": "getEnumUnit" - }, - "key": { - "type": "rawString", - "value": "flamestrike" - }, - "buff": { - "type": "getLastCreatedBuff" - } - },{ - "type": "if", - "condition": { - "type": "isUnitBuilding", - "unit": { - "type": "getEnumUnit" + "pass": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, + "fail": { + "type": "rawFloat", + "value": 1 + } + }, + "radius": { + "type": "getAbilityArea" + }, + "extraActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "duration": { + "type": "f+", + "value1": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "curDelay" } }, - "thenActions": [{ - "type": "damageTarget", - "source": { - "type": "getCastingUnit" - }, - "target": { - "type": "getEnumUnit" - }, - "damageType": { - "type": "getDamageTypeFromString", - "id": { - "type": "rawString", - "value": "FIRE" - } - }, - "damage": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "buildingDamageDealt" - } - } - }], - "elseActions": [{ - "type": "damageTarget", - "source": { - "type": "getCastingUnit" - }, - "target": { - "type": "getEnumUnit" - }, - "damageType": { - "type": "getDamageTypeFromString", - "id": { - "type": "rawString", - "value": "FIRE" - } - }, - "damage": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "damageDealt" - } - } - }] - }] - }] + "value2": { + "type": "oneGameTick" + } + } + },{ + "type": "addBuff", + "target": { + "type": "getEnumUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }, + "onEndCasting": [{ + "type": "beginChanneling" },{ "type": "storeValueLocally", "key": { "type": "rawString", - "value": "mainDmgTimer" + "value": "targetLoc" }, "valueToStore": { - "type": "getLastCreatedTimer" + "type": "getTargetedLocation" } },{ - "type": "createTimer", - "timeout": { - "type": "getAbilityHeroDuration" + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getTargetedLocation" + }, + "id": { + "type": "getAlias" }, - "actions": [{ - "type": "removeTimer", - "timer": { - "type": "getStoredTimerByKey", + "effectType": "EFFECT" + }], + "onChannelTick": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "createTemporarySpellEffectAtLocation", + "location": { + "type": "getStoredLocationByKey", + "key": { + "type": "rawString", + "value": "targetLoc" + } + }, + "id": { + "type": "getAlias" + }, + "effectType": "SPECIAL" + },{ + "type": "createGroupEffectAtLocation", + "location": { + "type": "getStoredLocationByKey", "key": { "type": "rawString", - "value": "mainDmgTimer" + "value": "targetLoc" } + }, + "radius": { + "type": "getAbilityArea" + }, + "id": { + "type": "getFirstEffectId" + }, + "effectType": "EFFECT" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "_gEff" + }, + "valueToStore": { + "type": "getLastCreatedFX" } - }] - },{ - "type": "createTimer", - "timeout": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - }, - "repeats": { - "type": "rawBoolean", - "value": "true" - }, - "delay": { - "type": "f+", - "value1": { + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "damageDest" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "curDamage" + }, + "valueToStore": { "type": "getAbilityDataAsFloat", - "dataField": "D" + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "curDelay" }, - "value2": { - "type": "getAbilityHeroDuration" + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "B" } - }, - "actions": [{ - "type": "storeValueLocally", - "key": { + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "repeats": { + "type": "rawBoolean", + "value": "true" + }, + "delay": { + "type": "rawFloat", + "value": 0 + }, + "actions": [{ + "type": "runReuseAction", + "name": { "type": "rawString", - "value": "damageDealt" - }, - "valueToStore": { - "type": "fMin", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - }, - "value2": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - }, - "value2": { - "type": "i2f", - "value": { - "type": "countUnitsInRangeOfLocation", - "location": { - "type": "getStoredLocationByKey", - "key": { - "type": "rawString", - "value": "targetLoc" - } - }, - "range": { - "type": "getAbilityArea" - } - } - } - } + "value": "damageUnits" } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "buildingDamageDealt" - }, - "valueToStore": { - "type": "f*", - "value1": { - "type": "getStoredFloatByKey", + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "dmgTimer" + }, + "valueToStore": { + "type": "getLastCreatedTimer" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityHeroDuration" + }, + "actions": [{ + "type": "updateTimerTimeout", + "timer": { + "type": "getStoredTimerByKey", "key": { "type": "rawString", - "value": "damageDealt" + "value": "dmgTimer" } }, - "value2": { + "timeout": { "type": "getAbilityDataAsFloat", - "dataField": "E" + "dataField": "D" } - } - },{ - "type": "iterateUnitsInRangeOfLocationMatchingCondition", - "location": { - "type": "getStoredLocationByKey", + },{ + "type": "storeValueLocally", "key": { "type": "rawString", - "value": "targetLoc" + "value": "curDelay" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "D" } - }, - "range": { - "type": "getAbilityArea" - }, - "condition": { - "type": "isUnitValidTarget", - "target": { - "type": "getMatchingUnit" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "curDamage" + }, + "valueToStore": { + "type": "getAbilityDataAsFloat", + "dataField": "C" } - }, - "iterationActions": [{ - "type": "createTimedArtBuff", - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityDataAsFloat", - "dataField": "D" + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "subDmgTimer" + }, + "valueToStore": { + "type": "getLastCreatedTimer" + } + },{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDuration" + }, + "actions": [{ + "type": "removeEffect", + "effect": { + "type": "getStoredFXByKey", + "key": { + "type": "rawString", + "value": "_gEff" } - },{ - "type": "addNonStackingDisplayBuff", - "target": { - "type": "getEnumUnit" - }, + } + },{ + "type": "killTimer", + "timer": { + "type": "getStoredTimerByKey", "key": { "type": "rawString", - "value": "flamestrike" - }, - "buff": { - "type": "getLastCreatedBuff" + "value": "subDmgTimer" } - },{ - "type": "if", - "condition": { - "type": "isUnitBuilding", - "unit": { - "type": "getEnumUnit" - - } - }, - "thenActions": [{ - "type": "damageTarget", - "source": { - "type": "getCastingUnit" - }, - "target": { - "type": "getEnumUnit" - }, - "damageType": { - "type": "getDamageTypeFromString", - "id": { - "type": "rawString", - "value": "FIRE" - } - }, - "damage": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "buildingDamageDealt" - } - } - }], - "elseActions": [{ - "type": "damageTarget", - "source": { - "type": "getCastingUnit" - }, - "target": { - "type": "getEnumUnit" - }, - "damageType": { - "type": "getDamageTypeFromString", - "id": { - "type": "rawString", - "value": "FIRE" - } - }, - "damage": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "damageDealt" - } - } - }] - }] - }] - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "subDmgTimer" - }, - "valueToStore": { - "type": "getLastCreatedTimer" - } - },{ - "type": "createTimer", - "timeout": { - "type": "getAbilityDuration" - }, - "actions": [{ - "type": "removeTimer", - "timer": { - "type": "getStoredTimerByKey", - "key": { - "type": "rawString", - "value": "artTimer" } - } - },{ - "type": "removeTimer", - "timer": { - "type": "getStoredTimerByKey", - "key": { - "type": "rawString", - "value": "subDmgTimer" + },{ + "type": "killTimer", + "timer": { + "type": "getStoredTimerByKey", + "key": { + "type": "rawString", + "value": "dmgTimer" + } } - } - },{ - "type": "cleanUpCastInstance" - }] + },{ + "type": "cleanUpCastInstance" + }] + },{ + "type": "finishChanneling" + }], + "delaySeconds": { + "type": "getAbilityCastTime" + } }] },{ "ids": [{"id":"AHbn", "castId": "banish"}], "type": "NORMAL_UNITTARGET", - "onAddAbility": [{ - "type": "createStateModBuff", - "buffType": "ETHEREAL" - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { "type": "rawString", - "value": "ATKSPD" - } - }, - "stackingKey": { - "type": "rawString", - "value": "slow" - }, - "value": { - "type": "negativeFloat", + "value": "slow" + }, "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "asbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { + },{ + "type": "storeValueLocally", + "key": { "type": "rawString", - "value": "MVSPDPCT" + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "stackingKey": { - "type": "rawString", - "value": "slow" - }, - "value": { - "type": "negativeFloat", + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "slow" + }, "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } } - } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddAbility": [{ + "type": "createStateModBuff", + "buffType": "ETHEREAL" },{ - "type": "storeValueLocally", - "key": { + "type": "runReuseAction", + "name": { "type": "rawString", - "value": "mvbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" + "value": "setupBuffs" } }], "onEndCasting": [{ @@ -693,87 +506,35 @@ "type": "getAbilityTargetedUnit" } }, - "onAddActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" + "positive": { + "type": "isUnitShareSpells", + "unit": { + "type": "getAbilityTargetedUnit" + } + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } + "key": { + "type": "rawString", + "value": "mvbuff" } },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } + "key": { + "type": "rawString", + "value": "asbuff" } }], - "onRemoveActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - } + "stateMods": [{ + "type": "getLastCreatedStateModBuff" }] },{ "type": "addBuff", @@ -786,45 +547,11 @@ }] }], "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - }, - "value": { - "type": "negativeFloat", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - }, - "value": { - "type": "negativeFloat", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - } + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } }] }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/humanUnitActives.json b/core/assets/abilityBehaviors/humanUnitActives.json index b47647447..f41cfc966 100644 --- a/core/assets/abilityBehaviors/humanUnitActives.json +++ b/core/assets/abilityBehaviors/humanUnitActives.json @@ -14,72 +14,81 @@ } } }], - "onAddAbility": [{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { "type": "rawString", - "value": "ATKSPD" - } - }, - "stackingKey": { - "type": "rawString", - "value": "slow" - }, - "value": { - "type": "negativeFloat", + "value": "slow" + }, "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "asbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { + },{ + "type": "storeValueLocally", + "key": { "type": "rawString", - "value": "MVSPDPCT" + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "stackingKey": { - "type": "rawString", - "value": "slow" - }, - "value": { - "type": "negativeFloat", + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "slow" + }, "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "mvbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } }], "onEndCasting": [{ "type": "checkAbilityEffectReaction", @@ -106,70 +115,29 @@ "type": "getAbilityTargetedUnit" } }, - "onAddActions": [{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - } - }], - "onRemoveActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } + "key": { + "type": "rawString", + "value": "mvbuff" } },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } + "key": { + "type": "rawString", + "value": "asbuff" } }] },{ @@ -183,45 +151,11 @@ }] }], "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - }, - "value": { - "type": "negativeFloat", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - }, - "value": { - "type": "negativeFloat", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - } + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } }] },{ "ids": [{"id":"Amls", "castId": "magicleash"}], @@ -669,20 +603,41 @@ }] }] },{ - "ids": [{"id":"Ahea", "castId": "heal", "autoCastOnId": "healon", "autoCastOffId": "healoff", "autoCastType": "NEARESTVALID"}], + "ids": [{"id":"Ahea", "castId": "heal", "autoCastOnId": "healon", "autoCastOffId": "healoff", "autoCastType": "NEARESTVALID"},{"id":"Anhe", "castId": "heal", "autoCastOnId": "healon", "autoCastOffId": "healoff", "autoCastType": "NEARESTVALID"}], "type": "NORMAL_UNITTARGET", + "overrideFields": { + "universalSpell": { + "type": "rawBoolean", + "value": "true" + } + }, "extraTargetConditions": [{ - "type": "setCantUseReasonOnFailure", - "condition": { - "type": "not", + "type": "setCantUseReasonOnFailure", "condition": { - "type": "isUnitMaxHp", - "unit": { - "type": "getAbilityTargetedUnit" + "type": "not", + "condition": { + "type": "isUnitMaxHp", + "unit": { + "type": "getAbilityTargetedUnit" + } } - } - }, - "reason": "ALREADY_AT_FULL_HEALTH" + }, + "reason": "ALREADY_AT_FULL_HEALTH" + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "not", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + } + }, + "reason": "TARGET_IS_ALREADY_BEING_HEALED" }], "onEndCasting": [{ "type": "checkAbilityEffectReaction", @@ -714,6 +669,10 @@ }, "duration": { "type": "getAbilityCooldown" + }, + "dispellable": { + "type": "rawBoolean", + "value": "false" } },{ "type": "addBuff", @@ -740,96 +699,105 @@ } } }], - "onAddAbility": [{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ALLATKPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "innerFire" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "storeValueLocally", + "key": { "type": "rawString", - "value": "ALLATKPCT" + "value": "atkbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "stackingKey": { - "type": "rawString", - "value": "innerFire" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "atkbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "DEF" + } + }, + "stackingKey": { "type": "rawString", - "value": "DEF" + "value": "innerFire" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" } - }, - "stackingKey": { - "type": "rawString", - "value": "innerFire" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "defbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { + },{ + "type": "storeValueLocally", + "key": { "type": "rawString", - "value": "HPGEN" + "value": "defbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "stackingKey": { - "type": "rawString", - "value": "innerFire" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "hpbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "HPGEN" + } + }, + "stackingKey": { + "type": "rawString", + "value": "innerFire" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "hpbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, + "onAddAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } }], "onEndCasting": [{ "type": "checkAbilityEffectReaction", @@ -847,102 +815,35 @@ "type": "getAbilityTargetedUnit" } }, - "onAddActions": [{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "atkbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "hpbuff" - } - } - }], - "onRemoveActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "atkbuff" - } + "key": { + "type": "rawString", + "value": "atkbuff" } },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } + "key": { + "type": "rawString", + "value": "defbuff" } },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "hpbuff" - } + "key": { + "type": "rawString", + "value": "hpbuff" } }] },{ @@ -956,56 +857,11 @@ }] }], "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "atkbuff" - } - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "hpbuff" - } - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - } + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } }] },{ "ids": [{"id":"Aivs", "castId": "invisibility"}], @@ -1499,7 +1355,7 @@ "type": "if", "condition": { "type": "isNewBehaviorCategoryInList", - "list": ["ATTACK","SPELL"] + "list": ["ATTACK","SPELL","BUILD"] }, "thenActions": [{ "type": "removeBuff", diff --git a/core/assets/abilityBehaviors/itemSimple.json b/core/assets/abilityBehaviors/itemSimple.json index efa3acada..8a1de76d7 100644 --- a/core/assets/abilityBehaviors/itemSimple.json +++ b/core/assets/abilityBehaviors/itemSimple.json @@ -40,7 +40,7 @@ "dataField": "A" } }, - "player": { + "playerDetectedData": { "type": "playerToStateModValue", "player": { "type": "getOwnerOfUnit", @@ -84,41 +84,574 @@ "type": "getEnumUnit" } }, - "onAddActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, + "stacks": { + "type": "rawBoolean", + "value": "true" + }, + "visibilityGroup": { + "type": "id2s", + "value": { + "type": "getAlias" + } + }, + "stateMods": [{ + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "detected" + } + }] + },{ + "type": "addBuff", + "target": { + "type": "getEnumUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + },{ + "ids": [{"id":"AIrg", "castId": "itemregeneration"}], + "type": "NORMAL_FLEXTARGET", + "overrideFields": { + "universalSpell": { + "type": "rawBoolean", + "value": "true" + } + }, + "specialFields": { + "targetedSpell": [{ + "type": "not", + "condition": { + "type": "bool", + "bool": { + "type": "getAbilityDataAsBoolean", + "dataField": "D" + } + } + }] + }, + "reuseActions": { + "doUnitEffect": [{ + "type": "createTimedTickingPausedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "effectUnit" + } + } + }, + "dispellable": { + "type": "reuseBoolean", + "name": { + "type": "rawString", + "value": "isMagic" + } + }, + "onAddActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "hpPerSec" + }, + "valueToStore": { + "type": "f/", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getBuffedUnit" + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mpPerSec" + }, + "valueToStore": { + "type": "f/", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "B" }, - "buff": { - "type": "getStoredStateModBuffByKey", - "key": { - "type": "rawString", - "value": "detected" + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getBuffedUnit" } } + } + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "heal", + "target": { + "type": "getBuffedUnit" + }, + "amount": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "hpPerSec" + } + } + },{ + "type": "addMp", + "target": { + "type": "getBuffedUnit" + }, + "amount": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "mpPerSec" + } + } }], - "onRemoveActions": [{ - "type": "removeStateModBuff", - "targetUnit": { + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { "type": "getBuffedUnit" + } + } + }], + "onRemoveActions": [{ + "type": "runSubroutine", + "name": { + "type": "rawString", + "value": "onRemoveActions" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "true" + } + + }] + },{ + "type": "addNonStackingDisplayBuff", + "target": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "effectUnit" + } + }, + "buff": { + "type": "getLastCreatedBuff" + }, + "key": { + "type": "getCodeAsString" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "argumentString", + "name": { + "type": "rawString", + "value": "regenBuffKey" + } + }, + "valueToStore": { + "type": "getLastCreatedBuff" + } + },{ + "type": "if", + "condition": { + "type": "bool", + "bool": { + "type": "getAbilityDataAsBoolean", + "dataField": "E" + } + }, + "thenActions": [{ + "type": "createDamageTakenListener", + "actions": [{ + "type": "removeDamageTakenListener", + "targetUnit": { + "type": "getListenerUnit" + }, + "listener": { + "type": "getStoredDamageTakenListenerByKey", + "key": { + "type": "argumentString", + "name": { + "type": "rawString", + "value": "breakHealKey" + } + } + } + + },{ + "type": "removeBuff", + "target": { + "type": "getListenerUnit" + }, + "buff": { + "type": "getStoredBuffByKey", + "key": { + "type": "argumentString", + "name": { + "type": "rawString", + "value": "regenBuffKey" + } + } + } + }] + },{ + "type": "addDamageTakenListener", + "targetUnit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "effectUnit" + } + }, + "listener": { + "type": "getLastCreatedDamageTakenListener" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "argumentString", + "name": { + "type": "rawString", + "value": "breakHealKey" + } + }, + "valueToStore": { + "type": "getLastCreatedDamageTakenListener" + } + }], + "elseActions": [] + } + ] + }, + "reuseCallbacks": { + "isMagic": { + "type": "rawBoolean", + "value": "false" + }, + "isMax": { + "type": "not", + "condition": { + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "or", + "conditions": [{ + "type": "f=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "not", + "condition": { + "type": "isUnitMaxMp", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } + } + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "i>", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } }, - "buff": { - "type": "getStoredStateModBuffByKey", - "key": { - "type": "rawString", - "value": "detected" + "reason": "ALREADY_AT_FULL_MANA" + }] + } + },{ + "type": "not", + "condition": { + "type": "or", + "conditions": [{ + "type": "f=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "not", + "condition": { + "type": "isUnitMaxHp", + "unit": { + "type": "argumentUnit", + "name": { + "type": "rawString", + "value": "checkUnit" + } } } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "iOdd", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + } + }, + "reason": "ALREADY_AT_FULL_HEALTH" + }] + } + }] + } + } + }, + "extraCastConditions": [{ + "type": "or", + "conditions": [{ + "type": "isFlexAbilityTargeted" + },{ + "type": "or", + "conditions": [{ + "type": "f!=0", + "value": { + "type": "getAbilityArea" + } + },{ + "type": "reuseBooleanWithArguments", + "name": { + "type": "rawString", + "value": "isMax" + }, + "arguments": { + "checkUnit": { + "type": "getCastingUnit" + } + } + }] + }] + }], + "extraTargetConditions": [{ + "type": "reuseBooleanWithArguments", + "name": { + "type": "rawString", + "value": "isMax" + }, + "arguments": { + "checkUnit": { + "type": "getAbilityTargetedUnit" + } + } + }], + "onEndCasting": [{ + "type": "if", + "condition": { + "type": "isFlexAbilityTargeted" + }, + "thenActions": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createSubroutine", + "name": { + "type": "rawString", + "value": "onRemoveActions" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "true" + }, + "actions": [{ + "type": "cleanUpCastInstance" }] },{ - "type": "addBuff", - "target": { - "type": "getEnumUnit" + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "doUnitEffect" }, - "buff": { - "type": "getLastCreatedBuff" + "arguments": { + "effectUnit": { + "type": "getAbilityTargetedUnit" + }, + "regenBuffKey": { + "type": "rawString", + "value": "regenBuff" + }, + "breakHealKey": { + "type": "rawString", + "value": "breakHeal" + } + } + }], + "elseActions": [] + }], + "elseActions": [{ + "type": "if", + "condition": { + "type": "f>", + "value1": { + "type": "getAbilityArea" + }, + "value2": { + "type": "rawFloat", + "value": 0 + } + }, + "thenActions": [{ + "type": "iterateUnitsInRangeOfUnitMatchingCondition", + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" + } + }, + "iterationActions": [{ + "type": "if", + "condition": { + "type": "reuseBooleanWithArguments", + "name": { + "type": "rawString", + "value": "isMax" + }, + "arguments": { + "checkUnit": { + "type": "getEnumUnit" + } + } + }, + "thenActions": [{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "doUnitEffect" + }, + "arguments": { + "effectUnit": { + "type": "getEnumUnit" + }, + "regenBuffKey": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "regenBuff" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getEnumUnit" + } + }] + }, + "breakHealKey": { + "type": "catStrings", + "stringList": [{ + "type": "rawString", + "value": "breakHeal" + },{ + "type": "getUnitHandleAsString", + "unit": { + "type": "getListenerUnit" + } + }] + } + } + }], + "elseActions": [] + }], + "originUnit": { + "type": "getCastingUnit" + }, + "range": { + "type": "getAbilityArea" + } + },{ + "type": "createTimer", + "timeout": { + "type": "f+", + "value1": { + "type": "fMax", + "value1": { + "type": "getAbilityDuration" + }, + "value2": { + "type": "getAbilityHeroDuration" + } + }, + "value2": { + "type": "rawFloat", + "value": 1 + } + }, + "actions": [{ + "type": "cleanUpCastInstance" + }] + }], + "elseActions": [{ + "type": "createSubroutine", + "name": { + "type": "rawString", + "value": "onRemoveActions" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "true" + }, + "actions": [{ + "type": "cleanUpCastInstance" + }] + },{ + "type": "runReuseActionWithArguments", + "name": { + "type": "rawString", + "value": "doUnitEffect" + }, + "arguments": { + "effectUnit": { + "type": "getCastingUnit" + }, + "regenBuffKey": { + "type": "rawString", + "value": "regenBuff" + }, + "breakHealKey": { + "type": "rawString", + "value": "breakHeal" + } } }] + }] }] }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/neutralHeroUnitActives.json b/core/assets/abilityBehaviors/neutralHeroUnitActives.json index 4e1c320c2..cf89b1fc2 100644 --- a/core/assets/abilityBehaviors/neutralHeroUnitActives.json +++ b/core/assets/abilityBehaviors/neutralHeroUnitActives.json @@ -13,7 +13,7 @@ } }, "onAddAbility": [{ - "type": "createFinalDamageTakenModificationListener", + "type": "createDamageTakenModificationListener", "actions": [{ "type": "storeValueLocally", "key": { @@ -21,7 +21,7 @@ "value": "maxAbsorb" }, "valueToStore": { - "type": "f/", + "type": "f*", "value1": { "type": "getUnitCurrentMana", "unit": { @@ -40,7 +40,7 @@ "value1": { "type": "f*", "value1": { - "type": "getTotalDamageDealt" + "type": "getRawTotalDamageDealt" }, "value2": { "type": "getAbilityDataAsFloat", @@ -78,15 +78,15 @@ }], "elseActions": [{ "type": "subtractMp", - "target": { + "unit": { "type": "getListenerUnit" }, "amount": { - "type": "f*", + "type": "f/", "value1": { "type": "f*", "value1": { - "type": "getTotalDamageDealt" + "type": "getRawTotalDamageDealt" }, "value2": { "type": "getAbilityDataAsFloat", @@ -103,7 +103,7 @@ "amount": { "type": "f*", "value1": { - "type": "getTotalDamageDealt" + "type": "getRawTotalDamageDealt" }, "value2": { "type": "getAbilityDataAsFloat", @@ -135,12 +135,12 @@ "type": "getLastCreatedBuff" } },{ - "type": "addFinalDamageTakenModificationListener", - "target": { + "type": "addDamageTakenModificationListener", + "targetUnit": { "type": "getCastingUnit" }, "listener": { - "type": "getLastCreatedFinalDamageTakenModificationListener" + "type": "getLastCreatedDamageTakenModificationListener" } }], "onDeactivate": [{ @@ -152,17 +152,86 @@ "type": "getLastCreatedBuff" } },{ - "type": "removeFinalDamageTakenModificationListener", - "target": { + "type": "removeDamageTakenModificationListener", + "targetUnit": { "type": "getCastingUnit" }, "listener": { - "type": "getLastCreatedFinalDamageTakenModificationListener" + "type": "getLastCreatedDamageTakenModificationListener" } }] },{ "ids": [{"id":"ANsi", "castId": "silence"}], "type": "NORMAL_POINTTARGET", + "overrideFields": { + "extraTargetsAllowed": [{ + "type": "rawTargetType", + "value": "NOTSELF" + }] + }, + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "silence" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "silence" + }, + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }] + }, "onAddAbility": [{ "type": "createAttackPreDamageListener", "actions": [{ @@ -193,64 +262,10 @@ "elseActions": [] }] },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "ATKSPD" - } - }, - "stackingKey": { + "type": "runReuseAction", + "name": { "type": "rawString", - "value": "silence" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "asbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "MVSPDPCT" - } - }, - "stackingKey": { - "type": "rawString", - "value": "silence" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "mvbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" + "value": "setupBuffs" } },{ "type": "createStateModBuff", @@ -316,9 +331,6 @@ "valueToStore": { "type": "getLastCreatedStateModBuff" } - },{ - "type": "addTargetAllowed", - "targetType": "NOTSELF" }], "onEndCasting": [{ "type": "createTemporarySpellEffectAtLocation", @@ -354,6 +366,31 @@ "type": "getEnumUnit" } }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }], "onAddActions": [{ "type": "addAttackPreDamageListener", "targetUnit": { @@ -366,38 +403,6 @@ "listener": { "type": "getLastCreatedAttackPreDamageListener" } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - } },{ "type": "if", "condition": { @@ -559,38 +564,6 @@ "listener": { "type": "getLastCreatedAttackPreDamageListener" } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - } },{ "type": "removeStateModBuff", "targetUnit": { @@ -665,44 +638,6 @@ "type": "getLastCreatedBuff" } }] - }], - "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - } - },{ - "type": "addTargetAllowed", - "targetType": "NOTSELF" }] }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/nightElfHeroUnitActives.json b/core/assets/abilityBehaviors/nightElfHeroUnitActives.json index 4dbb60482..a7222b75e 100644 --- a/core/assets/abilityBehaviors/nightElfHeroUnitActives.json +++ b/core/assets/abilityBehaviors/nightElfHeroUnitActives.json @@ -2,6 +2,12 @@ "abilityList": [{ "ids": [{"id":"AEsh", "castId": "shadowstrike"}], "type": "NORMAL_UNITTARGET", + "overrideFields": { + "ignoreCastTime": { + "type": "rawBoolean", + "value": "true" + } + }, "onEndCasting": [{ "type": "createUnitTargetedProjectile", "source": { @@ -37,6 +43,10 @@ "type": "getProjectileHitUnit" } }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, "onAddActions": [{ "type": "damageTarget", "source": { @@ -45,16 +55,16 @@ "target": { "type": "getBuffedUnit" }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + }, "damageType": { "type": "getDamageTypeFromString", "id": { "type": "rawString", - "value": "SHADOW_STRIKE" + "value": "SLOW_POISON" } - }, - "damage": { - "type": "getAbilityDataAsFloat", - "dataField": "E" } },{ "type": "createNumericFloatingTextOnUnit", @@ -276,33 +286,25 @@ "value": "slowDur" } }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, "showIcon": { "type": "rawBoolean", "value": "false" }, - "onAddActions": [{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "key": { - "type": "rawString", - "value": "atkSpdBuff" - } + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "atkSpdBuff" } },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "key": { - "type": "rawString", - "value": "moveBuff" - } + "type": "getStoredNonStackingStatBuffByKey", + "key": { + "type": "rawString", + "value": "moveBuff" } }], "onTickActions": [{ @@ -412,31 +414,6 @@ "type": "rawString", "value": "slow" } - }], - "onRemoveActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "key": { - "type": "rawString", - "value": "moveBuff" - } - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "key": { - "type": "rawString", - "value": "atkSpdBuff" - } - } }] },{ "type": "addBuff", diff --git a/core/assets/abilityBehaviors/nightElfUnitActives.json b/core/assets/abilityBehaviors/nightElfUnitActives.json index 56cabc205..d4251f00c 100644 --- a/core/assets/abilityBehaviors/nightElfUnitActives.json +++ b/core/assets/abilityBehaviors/nightElfUnitActives.json @@ -2,1256 +2,319 @@ "abilityList": [{ "ids": [{"id":"Aroa", "castId": "roar"},{"id":"ANbr", "castId": "battleroar"}], "type": "NORMAL_NOTARGET", - "onAddAbility": [{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "ALLATKPCT" - } - }, - "stackingKey": { - "type": "rawString", - "value": "roar" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "atkbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "DEF" - } - }, - "stackingKey": { - "type": "rawString", - "value": "roar" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "defbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "HPGEN" - } - }, - "stackingKey": { - "type": "rawString", - "value": "roar" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "hpbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "MPGEN" - } - }, - "stackingKey": { - "type": "rawString", - "value": "roar" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "mpbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - }], - "onEndCasting": [{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getCastingUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "CASTER" - },{ - "type": "iterateUnitsInRangeOfUnitMatchingCondition", - "condition": { - "type": "isUnitValidTarget", - "target": { - "type": "getMatchingUnit" - } - }, - "iterationActions": [{ - "type": "createTimedBuff", - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityDuration", - "target": { - "type": "getEnumUnit" - } - }, - "onAddActions": [{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "atkbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "hpbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mpbuff" - } - } - }], - "onRemoveActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "atkbuff" - } - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "hpbuff" - } - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mpbuff" - } - } - }] - },{ - "type": "addBuff", - "target": { - "type": "getEnumUnit" - }, - "buff": { - "type": "getLastCreatedBuff" + "reuseActions": { + "setupBuffs": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ALLATKPCT" } - }], - "originUnit": { - "type": "getCastingUnit" - }, - "range": { - "type": "getAbilityArea" - } - }], - "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" }, - "key": { + "stackingKey": { "type": "rawString", - "value": "atkbuff" - } - }, - "value": { - "type": "negativeFloat", + "value": "roar" + }, "value": { "type": "getAbilityDataAsFloat", "dataField": "A" } - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "atkbuff" + }, "instanceValue": { "type": "rawBoolean", "value": "false" }, - "key": { - "type": "rawString", - "value": "defbuff" + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "value": { - "type": "negativeFloat", + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "DEF" + } + }, + "stackingKey": { + "type": "rawString", + "value": "roar" + }, "value": { "type": "getAbilityDataAsFloat", "dataField": "B" } - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "defbuff" + }, "instanceValue": { "type": "rawBoolean", "value": "false" }, - "key": { - "type": "rawString", - "value": "hpbuff" + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "value": { - "type": "negativeFloat", + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "HPGEN" + } + }, + "stackingKey": { + "type": "rawString", + "value": "roar" + }, "value": { "type": "getAbilityDataAsFloat", "dataField": "C" } - } - },{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "hpbuff" + }, "instanceValue": { "type": "rawBoolean", "value": "false" }, - "key": { - "type": "rawString", - "value": "mpbuff" + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - }, - "value": { - "type": "negativeFloat", + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MPGEN" + } + }, + "stackingKey": { + "type": "rawString", + "value": "roar" + }, "value": { "type": "getAbilityDataAsFloat", "dataField": "D" } - } - }] - },{ - "ids": [{"id":"Arej", "castId": "rejuvination"},{"id":"AIrg", "castId": "itemregeneration"}], - "type": "NORMAL_FLEXTARGET", - "specialFields": { - "targetedSpell": [{ - "type": "not", - "condition": { - "type": "bool", - "bool": { - "type": "getAbilityDataAsBoolean", - "dataField": "D" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mpbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" } - } }] }, - "extraCastConditions": [{ - "type": "or", - "condition1": { - "type": "isFlexAbilityTargeted" - }, - "condition2": { - "type": "or", - "condition1": { - "type": "f!=0", - "value": { - "type": "getAbilityArea" - } - }, - "condition2": { - "type": "not", - "condition": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "or", - "condition1": { - "type": "f=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - }, - "condition2": { - "type": "or", - "condition1": { - "type": "not", - "condition": { - "type": "isUnitMaxMp", - "unit": { - "type": "getCastingUnit" - } - } - }, - "condition2": { - "type": "setCantUseReasonOnFailure", - "condition": { - "type": "i>", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "C" - }, - "value2": { - "type": "rawInteger", - "value": 1 - } - }, - "reason": "ALREADY_AT_FULL_MANA" - } - } - } - }, - "condition2": { - "type": "not", - "condition": { - "type": "or", - "condition1": { - "type": "f=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - }, - "condition2": { - "type": "or", - "condition1": { - "type": "not", - "condition": { - "type": "isUnitMaxHp", - "unit": { - "type": "getCastingUnit" - } - } - }, - "condition2": { - "type": "setCantUseReasonOnFailure", - "condition": { - "type": "iOdd", - "value": { - "type": "getAbilityDataAsInteger", - "dataField": "C" - } - }, - "reason": "ALREADY_AT_FULL_HEALTH" - } - } - } - } - } - } - } - }], - "extraTargetConditions": [{ - "type": "not", - "condition": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "or", - "condition1": { - "type": "f=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - }, - "condition2": { - "type": "or", - "condition1": { - "type": "not", - "condition": { - "type": "isUnitMaxMp", - "unit": { - "type": "getAbilityTargetedUnit" - } - } - }, - "condition2": { - "type": "setCantUseReasonOnFailure", - "condition": { - "type": "i>", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "C" - }, - "value2": { - "type": "rawInteger", - "value": 1 - } - }, - "reason": "ALREADY_AT_FULL_MANA" - } - } - } - }, - "condition2": { - "type": "not", - "condition": { - "type": "or", - "condition1": { - "type": "f=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - }, - "condition2": { - "type": "or", - "condition1": { - "type": "not", - "condition": { - "type": "isUnitMaxHp", - "unit": { - "type": "getAbilityTargetedUnit" - } - } - }, - "condition2": { - "type": "setCantUseReasonOnFailure", - "condition": { - "type": "iOdd", - "value": { - "type": "getAbilityDataAsInteger", - "dataField": "C" - } - }, - "reason": "ALREADY_AT_FULL_HEALTH" - } - } - } - } + "onAddAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" } }], "onEndCasting": [{ - "type": "if", - "condition": { - "type": "isFlexAbilityTargeted" - }, - "thenActions": [{ - "type": "checkAbilityEffectReaction", + "type": "createTemporarySpellEffectOnUnit", "target": { - "type": "getAbilityTargetedUnit" + "type": "getCastingUnit" }, - "onHitActions": [{ - "type": "createTimedTickingPausedBuff", - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityDuration", - "target": { - "type": "getAbilityTargetedUnit" - } - }, - "onAddActions": [{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "hpPerSec" - }, - "valueToStore": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - }, - "value2": { - "type": "getAbilityDuration", - "target": { - "type": "getBuffedUnit" - } - } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "mpPerSec" - }, - "valueToStore": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - }, - "value2": { - "type": "getAbilityDuration", - "target": { - "type": "getBuffedUnit" - } - } - } - }], - "onTickActions": [{ - "type": "periodicExecute", - "periodicActions": [{ - "type": "heal", - "target": { - "type": "getBuffedUnit" - }, - "amount": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "hpPerSec" - } - } - },{ - "type": "addMp", - "target": { - "type": "getBuffedUnit" - }, - "amount": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "mpPerSec" - } - } - }], - "delaySeconds": { - "type": "rawFloat", - "value": 1 - }, - "unique": { - "type": "getUnitHandleAsString", - "unit": { - "type": "getBuffedUnit" - } - } - }], - "onRemoveActions": [{ - "type": "cleanUpCastInstance" - }] - },{ - "type": "addNonStackingDisplayBuff", - "target": { - "type": "getAbilityTargetedUnit" - }, - "buff": { - "type": "getLastCreatedBuff" - }, - "key": { - "type": "getCodeAsString" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "regenBuff" - }, - "valueToStore": { - "type": "getLastCreatedBuff" - } - },{ - "type": "if", - "condition": { - "type": "bool", - "bool": { - "type": "getAbilityDataAsBoolean", - "dataField": "E" - } - }, - "thenActions": [{ - "type": "createDamageTakenListener", - "actions": [{ - "type": "removeDamageTakenListener", - "targetUnit": { - "type": "getListenerUnit" - }, - "listener": { - "type": "getStoredDamageTakenListenerByKey", - "key": { - "type": "rawString", - "value": "breakHeal" - } - } - - },{ - "type": "removeBuff", - "target": { - "type": "getListenerUnit" - }, - "buff": { - "type": "getStoredBuffByKey", - "key": { - "type": "rawString", - "value": "regenBuff" - } - } - }] - },{ - "type": "addDamageTakenListener", - "targetUnit": { - "type": "getAbilityTargetedUnit" - }, - "listener": { - "type": "getLastCreatedDamageTakenListener" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "breakHeal" - }, - "valueToStore": { - "type": "getLastCreatedDamageTakenListener" - } - }] - }], - "elseActions": [] - }], - "elseActions": [{ - "type": "if", + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "iterateUnitsInRangeOfUnitMatchingCondition", "condition": { - "type": "f>", - "value1": { - "type": "getAbilityArea" - }, - "value2": { - "type": "rawFloat", - "value": 0 + "type": "isUnitValidTarget", + "target": { + "type": "getMatchingUnit" } }, - "thenActions": [{ - "type": "iterateUnitsInRangeOfUnitMatchingCondition", - "condition": { - "type": "isUnitValidTarget", - "target": { - "type": "getMatchingUnit" - } - }, - "iterationActions": [{ - "type": "if", - "condition": { - "type": "not", - "condition": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "or", - "condition1": { - "type": "f=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - }, - "condition2": { - "type": "or", - "condition1": { - "type": "not", - "condition": { - "type": "isUnitMaxMp", - "unit": { - "type": "getEnumUnit" - } - } - }, - "condition2": { - "type": "setCantUseReasonOnFailure", - "condition": { - "type": "i>", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "C" - }, - "value2": { - "type": "rawInteger", - "value": 1 - } - }, - "reason": "ALREADY_AT_FULL_MANA" - } - } - } - }, - "condition2": { - "type": "not", - "condition": { - "type": "or", - "condition1": { - "type": "f=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - }, - "condition2": { - "type": "or", - "condition1": { - "type": "not", - "condition": { - "type": "isUnitMaxHp", - "unit": { - "type": "getEnumUnit" - } - } - }, - "condition2": { - "type": "setCantUseReasonOnFailure", - "condition": { - "type": "iOdd", - "value": { - "type": "getAbilityDataAsInteger", - "dataField": "C" - } - }, - "reason": "ALREADY_AT_FULL_HEALTH" - } - } - } - } - } - }, - "thenActions": [{ - "type": "createTimedTickingPausedBuff", - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityDuration", - "target": { - "type": "getEnumUnit" - } - }, - "onAddActions": [{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "hpPerSec" - }, - "valueToStore": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - }, - "value2": { - "type": "getAbilityDuration", - "target": { - "type": "getBuffedUnit" - } - } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "mpPerSec" - }, - "valueToStore": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - }, - "value2": { - "type": "getAbilityDuration", - "target": { - "type": "getBuffedUnit" - } - } - } - }], - "onTickActions": [{ - "type": "periodicExecute", - "periodicActions": [{ - "type": "heal", - "target": { - "type": "getBuffedUnit" - }, - "amount": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "hpPerSec" - } - } - },{ - "type": "addMp", - "target": { - "type": "getBuffedUnit" - }, - "amount": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "mpPerSec" - } - } - }], - "delaySeconds": { - "type": "rawFloat", - "value": 1 - }, - "unique": { - "type": "getUnitHandleAsString", - "unit": { - "type": "getBuffedUnit" - } - } - }] - },{ - "type": "addNonStackingDisplayBuff", - "target": { - "type": "getEnumUnit" - }, - "buff": { - "type": "getLastCreatedBuff" - }, - "key": { - "type": "getCodeAsString" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "catStrings", - "stringList": [{ - "type": "rawString", - "value": "regenBuff" - },{ - "type": "getUnitHandleAsString", - "unit": { - "type": "getEnumUnit" - } - }] - }, - "valueToStore": { - "type": "getLastCreatedBuff" - } - },{ - "type": "if", - "condition": { - "type": "bool", - "bool": { - "type": "getAbilityDataAsBoolean", - "dataField": "E" - } - }, - "thenActions": [{ - "type": "createDamageTakenListener", - "actions": [{ - "type": "removeDamageTakenListener", - "targetUnit": { - "type": "getListenerUnit" - }, - "listener": { - "type": "getStoredDamageTakenListenerByKey", - "key": { - "type": "catStrings", - "stringList": [{ - "type": "rawString", - "value": "breakHeal" - },{ - "type": "getUnitHandleAsString", - "unit": { - "type": "getListenerUnit" - } - }] - } - } - - },{ - "type": "removeBuff", - "target": { - "type": "getListenerUnit" - }, - "buff": { - "type": "getStoredBuffByKey", - "key": { - "type": "catStrings", - "stringList": [{ - "type": "rawString", - "value": "regenBuff" - },{ - "type": "getUnitHandleAsString", - "unit": { - "type": "getListenerUnit" - } - }] - } - } - }] - },{ - "type": "addDamageTakenListener", - "targetUnit": { - "type": "getEnumUnit" - }, - "listener": { - "type": "getLastCreatedDamageTakenListener" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "catStrings", - "stringList": [{ - "type": "rawString", - "value": "breakHeal" - },{ - "type": "getUnitHandleAsString", - "unit": { - "type": "getEnumUnit" - } - }] - }, - "valueToStore": { - "type": "getLastCreatedDamageTakenListener" - } - }], - "elseActions": [] - }], - "elseActions": [] - }], - "originUnit": { - "type": "getCastingUnit" - }, - "range": { - "type": "getAbilityArea" - } - },{ - "type": "createTimer", - "timeout": { - "type": "f+", - "value1": { - "type": "fMax", - "value1": { - "type": "getAbilityDuration" - }, - "value2": { - "type": "getAbilityHeroDuration" - } - }, - "value2": { - "type": "rawFloat", - "value": 1 - } - }, - "actions": [{ - "type": "cleanUpCastInstance" - }] - }], - "elseActions": [{ - "type": "createTimedTickingPausedBuff", + "iterationActions": [{ + "type": "createTimedBuff", "buffId": { "type": "getFirstBuffId" }, "duration": { "type": "getAbilityDuration", "target": { - "type": "getCastingUnit" + "type": "getEnumUnit" } }, - "onAddActions": [{ - "type": "storeValueLocally", + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, "key": { "type": "rawString", - "value": "hpPerSec" - }, - "valueToStore": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - }, - "value2": { - "type": "getAbilityDuration", - "target": { - "type": "getBuffedUnit" - } - } + "value": "atkbuff" } },{ - "type": "storeValueLocally", + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, "key": { "type": "rawString", - "value": "mpPerSec" + "value": "defbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "valueToStore": { - "type": "f/", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - }, - "value2": { - "type": "getAbilityDuration", - "target": { - "type": "getBuffedUnit" - } - } + "key": { + "type": "rawString", + "value": "hpbuff" } - }], - "onTickActions": [{ - "type": "periodicExecute", - "periodicActions": [{ - "type": "heal", - "target": { - "type": "getBuffedUnit" - }, - "amount": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "hpPerSec" - } - } - },{ - "type": "addMp", - "target": { - "type": "getBuffedUnit" - }, - "amount": { - "type": "getStoredFloatByKey", - "key": { - "type": "rawString", - "value": "mpPerSec" - } - } - }], - "delaySeconds": { - "type": "rawFloat", - "value": 1 + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" }, - "unique": { - "type": "getUnitHandleAsString", - "unit": { - "type": "getBuffedUnit" - } + "key": { + "type": "rawString", + "value": "mpbuff" } - }], - "onRemoveActions": [{ - "type": "cleanUpCastInstance" }] },{ - "type": "addNonStackingDisplayBuff", + "type": "addBuff", "target": { - "type": "getCastingUnit" + "type": "getEnumUnit" }, "buff": { "type": "getLastCreatedBuff" - }, - "key": { - "type": "getCodeAsString" } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "regenBuff" - }, - "valueToStore": { - "type": "getLastCreatedBuff" + }], + "originUnit": { + "type": "getCastingUnit" + }, + "range": { + "type": "getAbilityArea" + } + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + }] + },{ + "ids": [{"id":"Arej", "castId": "rejuvination"}], + "type": "INHERIT", + "parentId": "AIrg", + "extraCastConditions": [{ + "type": "or", + "conditions": [{ + "type": "isFlexAbilityTargeted" + },{ + "type": "f!=0", + "value": { + "type": "getAbilityArea" + } + },{ + "type": "not", + "condition": { + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "or", + "conditions": [{ + "type": "f=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "not", + "condition": { + "type": "isUnitMaxMp", + "unit": { + "type": "getCastingUnit" + } + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "i>", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + }, + "reason": "ALREADY_AT_FULL_MANA" + }] } },{ - "type": "if", + "type": "not", "condition": { - "type": "bool", - "bool": { - "type": "getAbilityDataAsBoolean", - "dataField": "E" - } - }, - "thenActions": [{ - "type": "createDamageTakenListener", - "actions": [{ - "type": "removeDamageTakenListener", - "targetUnit": { - "type": "getListenerUnit" - }, - "listener": { - "type": "getStoredDamageTakenListenerByKey", - "key": { - "type": "rawString", - "value": "breakHeal" - } - } - - },{ - "type": "removeBuff", - "target": { - "type": "getListenerUnit" - }, - "buff": { - "type": "getStoredBuffByKey", - "key": { - "type": "rawString", - "value": "regenBuff" - } - } - }] + "type": "or", + "conditions": [{ + "type": "f=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } },{ - "type": "addDamageTakenListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getLastCreatedDamageTakenListener" + "type": "not", + "condition": { + "type": "isUnitMaxHp", + "unit": { + "type": "getCastingUnit" + } } },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "breakHeal" + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "iOdd", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + } }, - "valueToStore": { - "type": "getLastCreatedDamageTakenListener" - } - }], - "elseActions": [] - }] + "reason": "ALREADY_AT_FULL_HEALTH" + }] + } + }] + } }] - }] + }], + "reuseCallbacks": { + "isMagic": { + "type": "rawBoolean", + "value": "true" + } + } },{ "ids": [{"id":"Acoa", "castId": "mounthippogryph"}], "type": "NORMAL_PAIRING", @@ -1539,7 +602,8 @@ } } }], - "onAddAbility": [{ + "reuseActions": { + "setupBuffs": [{ "type": "createNonStackingStatBuff", "buffType": { "type": "getNonStackingStatBuffTypeFromString", @@ -1559,19 +623,14 @@ "dataField": "A" } } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "defbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } + }] + }, + "onAddAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } }], "onEndCasting": [{ "type": "checkAbilityEffectReaction", @@ -1579,6 +638,25 @@ "type": "getAbilityTargetedUnit" }, "onHitActions": [{ + "type": "createStateModBuff", + "buffType": "DETECTED", + "value": { + "type": "createDetectedData", + "detectionLevel": { + "type": "rawInteger", + "value": 127 + }, + "playerDetectedData": { + "type": "playerToStateModValue", + "player": { + "type": "getOwnerOfUnit", + "unit": { + "type": "getCastingUnit" + } + } + } + } + },{ "type": "createTimedBuff", "buffId": { "type": "getFirstBuffId" @@ -1589,23 +667,17 @@ "type": "getAbilityTargetedUnit" } }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getLastCreatedNonStackingStatBuff" + }], + "stateMods": [{ + "type": "getLastCreatedStateModBuff" + }], "onAddActions": [{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } - } - },{ "type": "createUnitVisionModifier", "unit": { "type": "getBuffedUnit" @@ -1629,86 +701,22 @@ "valueToStore": { "type": "getLastCreatedVisionModifier" } - },{ - "type": "createStateModBuff", - "buffType": "DETECTED", - "value": { - "type": "createDetectedData", - "detectionLevel": { - "type": "rawInteger", - "value": 127 - }, - "player": { - "type": "playerToStateModValue", - "player": { - "type": "getOwnerOfUnit", - "unit": { - "type": "getBuffCastingUnit" - } - } - } - } - },{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "detected" - }, - "valueToStore": { - "type": "getLastCreatedStateModBuff" - } }], "onRemoveActions": [{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } - } - },{ - "type": "removeVisionModifier", - "modifier": { - "type": "getStoredVisionModifierByKey", - "key": { - "type": "rawString", - "value": "vision" - } - }, - "player": { - "type": "getOwnerOfUnit", - "unit": { - "type": "getBuffCastingUnit" - } + "type": "removeVisionModifier", + "modifier": { + "type": "getStoredVisionModifierByKey", + "key": { + "type": "rawString", + "value": "vision" } - },{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredStateModBuffByKey", - "key": { - "type": "rawString", - "value": "detected" - } + }, + "player": { + "type": "getOwnerOfUnit", + "unit": { + "type": "getBuffCastingUnit" } + } }] },{ "type": "addBuff", @@ -1721,24 +729,10 @@ }] }], "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "defbuff" - } - }, - "value": { - "type": "negativeFloat", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" } }] },{ diff --git a/core/assets/abilityBehaviors/orcHeroActives.json b/core/assets/abilityBehaviors/orcHeroActives.json index fdfbbe61f..f3463a281 100644 --- a/core/assets/abilityBehaviors/orcHeroActives.json +++ b/core/assets/abilityBehaviors/orcHeroActives.json @@ -8,10 +8,8 @@ "value": "true" } }, - "onAddAbility": [{ - "type": "createStateModBuff", - "buffType": "INVISIBLE" - },{ + "reuseActions": { + "setupBuffs": [{ "type": "createNonStackingStatBuff", "buffType": { "type": "getNonStackingStatBuffTypeFromString", @@ -28,26 +26,362 @@ "type": "getAbilityDataAsFloat", "dataField": "B" } + }], + "addStateMods": [{ + "type": "changeAttackActionToMovement" + },{ + "type": "addBehaviorChangeListener", + "unit": { + "type": "getBuffedUnit" + }, + "listener": { + "type": "getLastCreatedBehaviorChangeListener" + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invisBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "dcstBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "datkBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }], + "removeStateMods": [{ + "type": "removeBehaviorChangeListener", + "unit": { + "type": "getBuffedUnit" + }, + "listener": { + "type": "getLastCreatedBehaviorChangeListener" + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invisBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "dcstBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getBuffedUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "datkBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" + } + },{ + "type": "createStateModBuff", + "buffType": "INVISIBLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "invisBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "DISABLE_AUTO_CAST" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "dcstBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "DISABLE_AUTO_ATTACK" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "datkBuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "if", + "condition": { + "type": "bool", + "bool": { + "type": "getAbilityDataAsBoolean", + "dataField": "D" + } + }, + "thenActions": [{ + "type": "preDamageListenerSetMiss", + "miss": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "true" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "nomiss" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FORCE" + } + } + },{ + "type": "lockDamageModifications" + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 0 + }, + "preLaunchModification": [{ + "type": "if", + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "thenActions": [{ + "type": "attackModifierAddAnimationTag", + "tag": { + "type": "rawString", + "value": "SLAM" + } + },{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + }], + "elseActions": [{ + "type": "removeBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }], + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "removeBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + },{ + "type": "createBehaviorChangeListener", + "actions": [{ + "type": "if", + "condition": { + "type": "isNewBehaviorCategoryInList", + "list": ["SPELL"] + }, + "thenActions": [{ + "type": "removeBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] }], "onLevelChange": [{ - "type": "updateNonStackingStatBuff", - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - }, - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setupBuffs" } }], "onEndCasting": [{ - "type": "createTimedBuff", - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityHeroDuration" - }, - "onAddActions": [{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityHeroDuration" + }, + "statBuffs": [{ + "type": "getLastCreatedNonStackingStatBuff" + }], + "onAddActions": [{ + "type": "disableAbility" + },{ + "type": "setUnitMovementTypeNoCollision", + "unit": { + "type": "getBuffedUnit" + } + },{ + "type": "addAttackModifier", + "unit": { + "type": "getBuffedUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + },{ + "type": "addAttackPreDamageListener", + "targetUnit": { + "type": "getBuffedUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "ACCURACY" + }, + "listener": { + "type": "getStoredAttackPreDamageListenerByKey", + "key": { + "type": "rawString", + "value": "nomiss" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ "type": "if", "condition": { "type": "f!=0", @@ -57,167 +391,138 @@ } }, "thenActions": [{ - "type": "createTimer", - "timeout": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - }, - "actions": [{ - "type": "setUnitMovementTypeNoCollision", - "unit": { - "type": "getBuffedUnit" - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "addStateMods" } }] + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "fadeTimer" + }, + "valueToStore": { + "type": "getLastCreatedTimer" + } },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "fadeTimer" + "type": "setUnitFadeTimer", + "targetUnit": { + "type": "getBuffedUnit" }, - "valueToStore": { + "timer": { "type": "getLastCreatedTimer" } - },{ - "type": "setUnitFadeTimer", - "targetUnit": { - "type": "getBuffedUnit" - }, - "timer": { - "type": "getLastCreatedTimer" - } }], "elseActions": [{ - "type": "setUnitMovementTypeNoCollision", - "unit": { - "type": "getBuffedUnit" - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - }], - "onRemoveActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "addStateMods" + } + }] + }], + "onRemoveActions": [{ + "type": "enableAbility" + },{ + "type": "setUnitMovementTypeNoCollision", + "unit": { + "type": "getBuffedUnit" + }, + "active": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "removeAttackModifier", + "unit": { + "type": "getBuffedUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + },{ + "type": "removeAttackPreDamageListener", + "targetUnit": { + "type": "getBuffedUnit" + }, + "priority": { + "type": "rawPriority", + "priority": "ACCURACY" + }, + "listener": { + "type": "getStoredAttackPreDamageListenerByKey", + "key": { + "type": "rawString", + "value": "nomiss" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "if", + "condition": { + "type": "f!=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "thenActions": [{ "type": "if", "condition": { - "type": "f!=0", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "A" + "type": "isTimerActive", + "timer": { + "type": "getStoredTimerByKey", + "key": { + "type": "rawString", + "value": "fadeTimer" + } } }, "thenActions": [{ - "type": "if", - "condition": { - "type": "isTimerActive", - "timer": { - "type": "getStoredTimerByKey", - "key": { - "type": "rawString", - "value": "fadeTimer" - } - } - }, - "thenActions": [{ - "type": "removeTimer", - "timer": { - "type": "getStoredTimerByKey", - "key": { - "type": "rawString", - "value": "fadeTimer" - } + "type": "removeTimer", + "timer": { + "type": "getStoredTimerByKey", + "key": { + "type": "rawString", + "value": "fadeTimer" } - }], - "elseActions": [{ - "type": "setUnitMovementTypeNoCollision", - "unit": { - "type": "getBuffedUnit" - }, - "active": { - "type": "rawBoolean", - "value": "false" - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] + } }], "elseActions": [{ - "type": "setUnitMovementTypeNoCollision", - "unit": { - "type": "getBuffedUnit" - }, - "active": { - "type": "rawBoolean", - "value": "false" - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - }] - }] - },{ - "type": "addBuff", - "target": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedBuff" - } - }] + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "removeStateMods" + } + }] + }], + "elseActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "removeStateMods" + } + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/reactions.json b/core/assets/abilityBehaviors/reactions.json index 112f44c6c..38b569c25 100644 --- a/core/assets/abilityBehaviors/reactions.json +++ b/core/assets/abilityBehaviors/reactions.json @@ -8,18 +8,17 @@ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "not", "condition": { "type": "isOnCooldown" } - }, - "condition2": { + },{ "type": "isUnitEnemy", "unit": { "type": "getReactionAbilityCastingUnit" } - } + }] }, "thenActions": [{ "type": "reactionPreventHit" @@ -51,18 +50,17 @@ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "not", "condition": { "type": "isOnCooldown" } - }, - "condition2": { + },{ "type": "isUnitEnemy", "unit": { "type": "getReactionAbilityCastingUnit" } - } + }] }, "thenActions": [{ "type": "reactionPreventHit" @@ -333,7 +331,7 @@ "type": "if", "condition": { "type": "or", - "condition1": { + "conditions": [{ "type": "isAttackTypeEqual", "attackType1": { "type": "getTriggeringAttackType" @@ -345,8 +343,7 @@ "value": "MAGIC" } } - }, - "condition2": { + },{ "type": "isAttackTypeEqual", "attackType1": { "type": "getTriggeringAttackType" @@ -358,7 +355,7 @@ "value": "SPELLS" } } - } + }] }, "thenActions": [{ "type": "multiplyDamageTakenMultiplier", @@ -458,52 +455,43 @@ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "gameplayConstantIsDefendCanDeflect" - }, - "condition2": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "bool", - "bool": { - "type": "isProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } + },{ + "type": "not", + "condition": { + "type": "bool", + "bool": { + "type": "isProjectileReflected", + "projectile": { + "type": "getReactionAttackProjectile" } } + } + },{ + "type": "f<", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "G" }, - "condition2": { - "type": "and", - "condition1": { - "type": "f<", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "G" - }, - "value2": { - "type": "rawFloat", - "value": 1 - } - }, - "condition2": { - "type": "f<", - "value1": { - "type": "randomBoundedFloat", - "bound": { - "type": "rawFloat", - "value": 100 - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - } + "value2": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "f<", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 100 } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "F" } - } + }] }, "thenActions": [{ "type": "reactionPreventHit" @@ -569,7 +557,7 @@ "type": "if", "condition": { "type": "or", - "condition1": { + "conditions": [{ "type": "isAttackTypeEqual", "attackType1": { "type": "getReactionAttackProjectileAttackType" @@ -581,8 +569,7 @@ "value": "MAGIC" } } - }, - "condition2": { + },{ "type": "isAttackTypeEqual", "attackType1": { "type": "getReactionAttackProjectileAttackType" @@ -594,58 +581,49 @@ "value": "SPELLS" } } - } + }] }, "thenActions": [{ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "gameplayConstantIsDefendCanDeflect" - }, - "condition2": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "bool", - "bool": { - "type": "isProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } + },{ + "type": "not", + "condition": { + "type": "bool", + "bool": { + "type": "isProjectileReflected", + "projectile": { + "type": "getReactionAttackProjectile" } } + } + },{ + "type": "f<", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "H" }, - "condition2": { - "type": "and", - "condition1": { - "type": "f<", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "H" - }, - "value2": { - "type": "rawFloat", - "value": 1 - } - }, - "condition2": { - "type": "f<", - "value1": { - "type": "randomBoundedFloat", - "bound": { - "type": "rawFloat", - "value": 100 - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - } + "value2": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "f<", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 100 } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "F" } - } + }] }, "thenActions": [{ "type": "reactionPreventHit" @@ -780,6 +758,12 @@ } }, "onAddAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + },{ "type": "createNonStackingStatBuff", "buffType": { "type": "getNonStackingStatBuffTypeFromString", @@ -860,7 +844,7 @@ "type": "if", "condition": { "type": "or", - "condition1": { + "conditions": [{ "type": "isAttackTypeEqual", "attackType1": { "type": "getTriggeringAttackType" @@ -872,8 +856,7 @@ "value": "MAGIC" } } - }, - "condition2": { + },{ "type": "isAttackTypeEqual", "attackType1": { "type": "getTriggeringAttackType" @@ -885,7 +868,7 @@ "value": "SPELLS" } } - } + }] }, "thenActions": [{ "type": "multiplyDamageTakenMultiplier", @@ -969,52 +952,43 @@ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "gameplayConstantIsDefendCanDeflect" - }, - "condition2": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "bool", - "bool": { - "type": "isProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } + },{ + "type": "not", + "condition": { + "type": "bool", + "bool": { + "type": "isProjectileReflected", + "projectile": { + "type": "getReactionAttackProjectile" } } + } + },{ + "type": "f<", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "G" }, - "condition2": { - "type": "and", - "condition1": { - "type": "f<", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "G" - }, - "value2": { - "type": "rawFloat", - "value": 1 - } - }, - "condition2": { - "type": "f<", - "value1": { - "type": "randomBoundedFloat", - "bound": { - "type": "rawFloat", - "value": 100 - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - } + "value2": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "f<", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 100 } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "F" } - } + }] }, "thenActions": [{ "type": "reactionPreventHit" @@ -1080,7 +1054,7 @@ "type": "if", "condition": { "type": "or", - "condition1": { + "conditions": [{ "type": "isAttackTypeEqual", "attackType1": { "type": "getReactionAttackProjectileAttackType" @@ -1092,8 +1066,7 @@ "value": "MAGIC" } } - }, - "condition2": { + },{ "type": "isAttackTypeEqual", "attackType1": { "type": "getReactionAttackProjectileAttackType" @@ -1105,58 +1078,49 @@ "value": "SPELLS" } } - } + }] }, "thenActions": [{ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "gameplayConstantIsDefendCanDeflect" - }, - "condition2": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "bool", - "bool": { - "type": "isProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } + },{ + "type": "not", + "condition": { + "type": "bool", + "bool": { + "type": "isProjectileReflected", + "projectile": { + "type": "getReactionAttackProjectile" } } + } + },{ + "type": "f<", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "H" }, - "condition2": { - "type": "and", - "condition1": { - "type": "f<", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "H" - }, - "value2": { - "type": "rawFloat", - "value": 1 - } - }, - "condition2": { - "type": "f<", - "value1": { - "type": "randomBoundedFloat", - "bound": { - "type": "rawFloat", - "value": 100 - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - } + "value2": { + "type": "rawFloat", + "value": 1 + } + },{ + "type": "f<", + "value1": { + "type": "randomBoundedFloat", + "bound": { + "type": "rawFloat", + "value": 100 } + }, + "value2": { + "type": "getAbilityDataAsFloat", + "dataField": "F" } - } + }] }, "thenActions": [{ "type": "reactionPreventHit" @@ -1225,6 +1189,21 @@ "type": "rawString", "value": "DEFEND" } + },{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onDefend" + } },{ "type": "addNonStackingStatBuff", "targetUnit": { @@ -1319,6 +1298,12 @@ "type": "rawString", "value": "DEFEND" } + },{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onUnDefend" + } },{ "type": "removeNonStackingStatBuff", "targetUnit": { @@ -1406,660 +1391,31 @@ }] },{ "ids": [{"id":"Amdf", "castId": "magicdefense", "uncastId": "magicundefense"}], - "type": "NORMAL_NOTARGET", - "displayFields": { - "toggleable": { - "type": "rawBoolean", - "value": "true" - }, - "castlessNoTarget": { - "type": "rawBoolean", - "value": "true" - } - }, - "onAddAbility": [{ + "type": "INHERIT", + "parentId": "Adef", + "reuseActions": { + "setup": [{ "type": "createStateModBuff", "buffType": "MAGIC_IMMUNE" - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "ATKSPD" - } - }, - "stackingKey": { - "type": "rawString", - "value": "defend" - }, - "value": { - "type": "negativeFloat", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "D" - } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "asbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" - } - },{ - "type": "createNonStackingStatBuff", - "buffType": { - "type": "getNonStackingStatBuffTypeFromString", - "id": { - "type": "rawString", - "value": "MVSPDPCT" - } - }, - "stackingKey": { - "type": "rawString", - "value": "defend" - }, - "value": { - "type": "negativeFloat", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "C" - } - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "mvbuff" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" + }], + "onDefend": [{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" }, - "valueToStore": { - "type": "getLastCreatedNonStackingStatBuff" + "buff": { + "type": "getLastCreatedStateModBuff" } - },{ - "type": "createAttackPreDamageListener", - "actions": [{ - "type": "addDamageDealtMultiplier", - "value": { - "type": "getAbilityDataAsFloat", - "dataField": "B" - } - }] - },{ - "type": "createDamageTakenModificationListener", - "actions": [{ - "type": "if", - "condition": { - "type": "or", - "condition1": { - "type": "isAttackTypeEqual", - "attackType1": { - "type": "getTriggeringAttackType" - }, - "attackType2": { - "type": "getAttackTypeFromString", - "id": { - "type": "rawString", - "value": "MAGIC" - } - } - }, - "condition2": { - "type": "isAttackTypeEqual", - "attackType1": { - "type": "getTriggeringAttackType" - }, - "attackType2": { - "type": "getAttackTypeFromString", - "id": { - "type": "rawString", - "value": "SPELLS" - } - } - } - }, - "thenActions": [{ - "type": "multiplyDamageTakenMultiplier", - "multiplier": { - "type": "getAbilityDataAsFloat", - "dataField": "E" - } - }], - "elseActions": [] - }] - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "sMod" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" + }], + "onUnDefend": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" }, - "valueToStore": { - "type": "getLastCreatedDamageTakenModificationListener" + "buff": { + "type": "getLastCreatedStateModBuff" } - },{ - "type": "createDamageTakenModificationListener", - "actions": [{ - "type": "if", - "condition": { - "type": "isAttackTypeEqual", - "attackType1": { - "type": "getTriggeringAttackType" - }, - "attackType2": { - "type": "getAttackTypeFromString", - "id": { - "type": "rawString", - "value": "PIERCE" - } - } - }, - "thenActions": [{ - "type": "multiplyDamageTakenMultiplier", - "multiplier": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - }], - "elseActions": [] - }] - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "pMod" - }, - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "valueToStore": { - "type": "getLastCreatedDamageTakenModificationListener" - } - },{ - "type": "createAttackProjReactionListener", - "actions": [{ - "type": "if", - "condition": { - "type": "isAttackTypeEqual", - "attackType1": { - "type": "getReactionAttackProjectileAttackType" - }, - "attackType2": { - "type": "getAttackTypeFromString", - "id": { - "type": "rawString", - "value": "PIERCE" - } - } - }, - "thenActions": [{ - "type": "if", - "condition": { - "type": "and", - "condition1": { - "type": "gameplayConstantIsDefendCanDeflect" - }, - "condition2": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "bool", - "bool": { - "type": "isProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } - } - } - }, - "condition2": { - "type": "and", - "condition1": { - "type": "f<", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "G" - }, - "value2": { - "type": "rawFloat", - "value": 1 - } - }, - "condition2": { - "type": "f<", - "value1": { - "type": "randomBoundedFloat", - "bound": { - "type": "rawFloat", - "value": 100 - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - } - } - } - } - }, - "thenActions": [{ - "type": "reactionPreventHit" - },{ - "type": "setProjectileDone", - "projectile": { - "type": "getReactionAttackProjectile" - }, - "done": { - "type": "rawBoolean", - "value": "false" - } - },{ - "type": "setProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } - },{ - "type": "setProjectileTarget", - "projectile": { - "type": "getReactionAttackProjectile" - }, - "target": { - "type": "getAttackingUnit" - } - },{ - "type": "damageTarget", - "source": { - "type": "getAttackingUnit" - }, - "target": { - "type": "getListenerUnit" - }, - "damageType": { - "type": "getDamageTypeFromString", - "id": { - "type": "rawString", - "value": "NORMAL" - } - }, - "attackType": { - "type": "getAttackTypeFromString", - "id": { - "type": "rawString", - "value": "PIERCE" - } - }, - "damage": { - "type": "f*", - "value1": { - "type": "getReactionAttackProjectileDamage" - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "G" - } - } - }], - "elseActions": [] - }], - "elseActions": [] - },{ - "type": "if", - "condition": { - "type": "or", - "condition1": { - "type": "isAttackTypeEqual", - "attackType1": { - "type": "getReactionAttackProjectileAttackType" - }, - "attackType2": { - "type": "getAttackTypeFromString", - "id": { - "type": "rawString", - "value": "MAGIC" - } - } - }, - "condition2": { - "type": "isAttackTypeEqual", - "attackType1": { - "type": "getReactionAttackProjectileAttackType" - }, - "attackType2": { - "type": "getAttackTypeFromString", - "id": { - "type": "rawString", - "value": "SPELLS" - } - } - } - }, - "thenActions": [{ - "type": "if", - "condition": { - "type": "and", - "condition1": { - "type": "gameplayConstantIsDefendCanDeflect" - }, - "condition2": { - "type": "and", - "condition1": { - "type": "not", - "condition": { - "type": "bool", - "bool": { - "type": "isProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } - } - } - }, - "condition2": { - "type": "and", - "condition1": { - "type": "f<", - "value1": { - "type": "getAbilityDataAsFloat", - "dataField": "H" - }, - "value2": { - "type": "rawFloat", - "value": 1 - } - }, - "condition2": { - "type": "f<", - "value1": { - "type": "randomBoundedFloat", - "bound": { - "type": "rawFloat", - "value": 100 - } - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "F" - } - } - } - } - }, - "thenActions": [{ - "type": "reactionPreventHit" - },{ - "type": "setProjectileDone", - "projectile": { - "type": "getReactionAttackProjectile" - }, - "done": { - "type": "rawBoolean", - "value": "false" - } - },{ - "type": "setProjectileReflected", - "projectile": { - "type": "getReactionAttackProjectile" - } - },{ - "type": "setProjectileTarget", - "projectile": { - "type": "getReactionAttackProjectile" - }, - "target": { - "type": "getAttackingUnit" - } - },{ - "type": "damageTarget", - "source": { - "type": "getAttackingUnit" - }, - "target": { - "type": "getListenerUnit" - }, - "damageType": { - "type": "getDamageTypeFromString", - "id": { - "type": "rawString", - "value": "NORMAL" - } - }, - "attackType": { - "type": "getReactionAttackProjectileAttackType" - }, - "damage": { - "type": "f*", - "value1": { - "type": "getReactionAttackProjectileDamage" - }, - "value2": { - "type": "getAbilityDataAsFloat", - "dataField": "H" - } - } - }], - "elseActions": [] - }], - "elseActions": [] - }] - }], - "onActivate": [{ - "type": "addSecondaryAnimationTag", - "unit": { - "type": "getCastingUnit" - }, - "tag": { - "type": "rawString", - "value": "DEFEND" - } - },{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - } - },{ - "type": "addNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - } - },{ - "type": "addAttackPreDamageListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "priority": { - "type": "rawPriority", - "priority": "STACKING" - }, - "listener": { - "type": "getLastCreatedAttackPreDamageListener" - } - },{ - "type": "addDamageTakenModificationListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getStoredDamageTakenModificationListenerByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "pMod" - } - } - },{ - "type": "addDamageTakenModificationListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getStoredDamageTakenModificationListenerByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "sMod" - } - } - },{ - "type": "addAttackProjReactionListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getLastCreatedAttackProjReactionListener" - } - }], - "onDeactivate": [{ - "type": "removeSecondaryAnimationTag", - "unit": { - "type": "getCastingUnit" - }, - "tag": { - "type": "rawString", - "value": "DEFEND" - } - },{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getLastCreatedStateModBuff" - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "mvbuff" - } - } - },{ - "type": "removeNonStackingStatBuff", - "targetUnit": { - "type": "getCastingUnit" - }, - "buff": { - "type": "getStoredNonStackingStatBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "asbuff" - } - } - },{ - "type": "removeAttackPreDamageListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "priority": { - "type": "rawPriority", - "priority": "STACKING" - }, - "listener": { - "type": "getLastCreatedAttackPreDamageListener" - } - },{ - "type": "removeDamageTakenModificationListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getStoredDamageTakenModificationListenerByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "pMod" - } - } - },{ - "type": "removeDamageTakenModificationListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getStoredDamageTakenModificationListenerByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "sMod" - } - } - },{ - "type": "removeAttackProjReactionListener", - "targetUnit": { - "type": "getCastingUnit" - }, - "listener": { - "type": "getLastCreatedAttackProjReactionListener" - } - }] + }] + } }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/undeadHeroUnitActives.json b/core/assets/abilityBehaviors/undeadHeroUnitActives.json index c880b5c11..3d6940908 100644 --- a/core/assets/abilityBehaviors/undeadHeroUnitActives.json +++ b/core/assets/abilityBehaviors/undeadHeroUnitActives.json @@ -58,43 +58,24 @@ "type": "getAbilityDataAsFloat", "dataField": "A" }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "showIcon": { "type": "rawBoolean", "value": "false" }, - "onAddActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredStateModBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "invuln" - } - } - }], - "onRemoveActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredStateModBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "invuln" - } - } + "stateMods": [{ + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "invuln" + } }] },{ "type": "addBuff", @@ -115,23 +96,22 @@ "type": "getAbilityTargetedUnit" } }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "stateMods": [{ + "type": "getStoredStateModBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "sleep" + } + }], "onAddActions": [{ - "type": "addStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredStateModBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "sleep" - } - } - },{ "type": "createDamageTakenListener", "actions": [{ "type": "removeDamageTakenListener", @@ -178,23 +158,7 @@ } }], "onRemoveActions": [{ - "type": "removeStateModBuff", - "targetUnit": { - "type": "getBuffedUnit" - }, - "buff": { - "type": "getStoredStateModBuffByKey", - "instanceValue": { - "type": "rawBoolean", - "value": "false" - }, - "key": { - "type": "rawString", - "value": "sleep" - } - } - },{ - "type": "cleanUpCastInstance" + "type": "cleanUpCastInstance" }] },{ "type": "addBuff", @@ -216,7 +180,7 @@ }] }] },{ - "ids": [{"id":"AUcs", "castId": "carrionswarm"},{"id":"AOsh", "castId": "shockwave"}], + "ids": [{"id":"AUcs", "castId": "carrionswarm"}], "type": "NORMAL_POINTTARGET", "displayFields": { "hideAreaCursor": { @@ -336,18 +300,17 @@ }], "canHitTarget": [{ "type": "and", - "condition1": { + "conditions": [{ "type": "isValidTarget", "target": { "type": "getProjectileHitWidget" } - }, - "condition2": { + },{ "type": "isUnitEnemy", "unit": { "type": "getProjectileHitUnit" } - } + }] }], "onHit": [{ "type": "storeValueLocally", @@ -414,25 +377,24 @@ "target": { "type": "getProjectileHitUnit" }, - "damageType": { - "type": "getDamageTypeFromString", - "id": { - "type": "rawString", - "value": "DISEASE" - } - }, "damage": { "type": "getStoredFloatByKey", "key": { "type": "rawString", "value": "dpt" } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "SONIC" + } } }], "elseActions": [] }] }] - },{ "ids": [{"id":"AUim", "castId": "impale"}], "type": "NORMAL_POINTTARGET", @@ -633,6 +595,14 @@ "buffId": { "type": "getFirstBuffId" }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "artType": "EFFECT", "duration": { "type": "getAbilityDataAsFloat", @@ -792,16 +762,16 @@ "target": { "type": "getBuffedUnit" }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, "damageType": { "type": "getDamageTypeFromString", "id": { "type": "rawString", - "value": "MAGIC" + "value": "FORCE" } - }, - "damage": { - "type": "getAbilityDataAsFloat", - "dataField": "C" } },{ "type": "if", @@ -819,6 +789,14 @@ "buffId": { "type": "getFirstBuffId" }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "duration": { "type": "getAbilityDuration", "target": { @@ -879,6 +857,5 @@ } }] }] - }] } \ No newline at end of file diff --git a/core/assets/abilityBehaviors/undeadUnitActives.json b/core/assets/abilityBehaviors/undeadUnitActives.json index f7fa96aba..44d950e2c 100644 --- a/core/assets/abilityBehaviors/undeadUnitActives.json +++ b/core/assets/abilityBehaviors/undeadUnitActives.json @@ -43,13 +43,12 @@ "type": "setCantUseReasonOnFailure", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "isUnitValidTarget", "target": { "type": "getAbilityTargetedUnit" } - }, - "condition2": { + },{ "type": "not", "condition": { "type": "doesUnitHaveBuff", @@ -60,7 +59,7 @@ "type": "getAlias" } } - } + }] }, "reason": "THERE_ARE_NO_USABLE_CORPSES_NEARBY" }], @@ -298,6 +297,12 @@ },{ "ids": [{"id":"Arpl", "castId": "replenishlife", "autoCastOnId": "replenishlifeon", "autoCastOffId": "replenishlifeoff", "autoCastType": "NOTARGET"}], "type": "NORMAL_NOTARGET", + "overrideFields": { + "ignoreCastTime": { + "type": "rawBoolean", + "value": "true" + } + }, "specialFields": { "bufferManaRequired": { "type": "i*", @@ -317,220 +322,25 @@ } } }, - "extraAutoNoTargetConditions": [{ - "type": "matchingUnitExistsInRangeOfUnit", - "originUnit": { - "type": "getCastingUnit" - }, - "range": { - "type": "getAbilityArea" - }, - "conditions": [{ - "type": "and", - "condition1": { - "type": "isUnitValidTarget", - "target": { - "type": "getMatchingUnit" - } - }, - "condition2": { - "type": "not", - "condition": { - "type": "isUnitMaxHp", - "unit": { - "type": "getMatchingUnit" - } - } - } - }] - }], - "onEndCasting": [{ - "type": "createTemporarySpellEffectOnUnit", + "reuseActions": { + "effect": [{ + "type": "heal", "target": { - "type": "getCastingUnit" + "type": "getEnumUnit" }, - "id": { - "type": "getAlias" - }, - "effectType": "CASTER" - },{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getCastingUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "SPECIAL" - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "cnt" - }, - "valueToStore": { - "type": "rawInteger", - "value": 0 + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "A" } - },{ - "type": "iterateUnitsInRangeOfUnitMatchingCondition", - "originUnit": { - "type": "getCastingUnit" - }, - "range": { - "type": "getAbilityArea" - }, - "condition": { - "type": "and", - "condition1": { - "type": "isUnitValidTarget", - "target": { - "type": "getMatchingUnit" - } - }, - "condition2": { - "type": "not", - "condition": { - "type": "isUnitMaxHp", - "unit": { - "type": "getMatchingUnit" - } - } - } - }, - "iterationActions": [{ - "type": "if", - "condition": { - "type": "i<", - "value1": { - "type": "getStoredIntegerByKey", - "key": { - "type": "rawString", - "value": "cnt" - } - }, - "value2": { - "type": "getAbilityCastTimeAsInteger" - } - }, - "thenActions": [{ - "type": "if", - "condition": { - "type": "and", - "condition1": { - "type": "i!=0", - "value": { - "type": "getStoredIntegerByKey", - "key": { - "type": "rawString", - "value": "cnt" - } - } - }, - "condition2": { - "type": "i<", - "value1": { - "type": "getStoredIntegerByKey", - "key": { - "type": "rawString", - "value": "cnt" - } - }, - "value2": { - "type": "getAbilityDataAsInteger", - "dataField": "E" - } - } - }, - "thenActions": [{ - "type": "subtractMp", - "target": { - "type": "getCastingUnit" - }, - "amount": { - "type": "i2f", - "value": { - "type": "getAbilityManaCost" - } - } - }], - "elseActions": [] - },{ - "type": "heal", - "target": { - "type": "getEnumUnit" - }, - "amount": { - "type": "getAbilityDataAsFloat", - "dataField": "A" - } - },{ - "type": "createTemporarySpellEffectOnUnit", - "target": { - "type": "getEnumUnit" - }, - "id": { - "type": "getAlias" - }, - "effectType": "TARGET" - },{ - "type": "createTimedBuff", - "buffId": { - "type": "getFirstBuffId" - }, - "duration": { - "type": "getAbilityDuration" - } - },{ - "type": "addBuff", - "target": { - "type": "getEnumUnit" - }, - "buff": { - "type": "getLastCreatedBuff" - } - },{ - "type": "storeValueLocally", - "key": { - "type": "rawString", - "value": "cnt" - }, - "valueToStore": { - "type": "i+", - "value1": { - "type": "getStoredIntegerByKey", - "key": { - "type": "rawString", - "value": "cnt" - } - }, - "value2": { - "type": "rawInteger", - "value": 1 - } - } - }], - "elseActions": [] - }] }] - },{ - "ids": [{"id":"Arpm", "castId": "replenishmana", "autoCastOnId": "replenishmanaon", "autoCastOffId": "replenishmanaoff", "autoCastType": "NOTARGET"}], - "type": "NORMAL_NOTARGET", - "specialFields": { - "bufferManaRequired": { - "type": "i*", - "value1": { - "type": "getAbilityManaCost" - }, - "value2": { - "type": "i-", - "value1": { - "type": "getAbilityDataAsInteger", - "dataField": "E" - }, - "value2": { - "type": "rawInteger", - "value": 1 + }, + "reuseCallbacks": { + "checkValidTarget": { + "type": "not", + "condition": { + "type": "isUnitMaxHp", + "unit": { + "type": "getMatchingUnit" } } } @@ -543,24 +353,21 @@ "range": { "type": "getAbilityArea" }, - "conditions": [{ + "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "isUnitValidTarget", "target": { "type": "getMatchingUnit" } - }, - "condition2": { - "type": "not", - "condition": { - "type": "isUnitMaxMp", - "unit": { - "type": "getMatchingUnit" - } + },{ + "type": "reuseBoolean", + "name": { + "type": "rawString", + "value": "checkValidTarget" } - } - }] + }] + } }], "onEndCasting": [{ "type": "createTemporarySpellEffectOnUnit", @@ -600,21 +407,18 @@ }, "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "isUnitValidTarget", "target": { "type": "getMatchingUnit" } - }, - "condition2": { - "type": "not", - "condition": { - "type": "isUnitMaxMp", - "unit": { - "type": "getMatchingUnit" - } + },{ + "type": "reuseBoolean", + "name": { + "type": "rawString", + "value": "checkValidTarget" } - } + }] }, "iterationActions": [{ "type": "if", @@ -635,7 +439,7 @@ "type": "if", "condition": { "type": "and", - "condition1": { + "conditions": [{ "type": "i!=0", "value": { "type": "getStoredIntegerByKey", @@ -644,8 +448,7 @@ "value": "cnt" } } - }, - "condition2": { + },{ "type": "i<", "value1": { "type": "getStoredIntegerByKey", @@ -658,11 +461,11 @@ "type": "getAbilityDataAsInteger", "dataField": "E" } - } + }] }, "thenActions": [{ "type": "subtractMp", - "target": { + "unit": { "type": "getCastingUnit" }, "amount": { @@ -674,13 +477,10 @@ }], "elseActions": [] },{ - "type": "addMp", - "target": { - "type": "getEnumUnit" - }, - "amount": { - "type": "getAbilityDataAsFloat", - "dataField": "B" + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "effect" } },{ "type": "createTemporarySpellEffectOnUnit", @@ -696,6 +496,10 @@ "buffId": { "type": "getFirstBuffId" }, + "dispellable": { + "type": "rawBoolean", + "value": "false" + }, "duration": { "type": "getAbilityDuration" } @@ -731,6 +535,33 @@ "elseActions": [] }] }] + },{ + "ids": [{"id":"Arpm", "castId": "replenishmana", "autoCastOnId": "replenishmanaon", "autoCastOffId": "replenishmanaoff", "autoCastType": "NOTARGET"}], + "type": "INHERIT", + "parentId": "Arpl", + "reuseActions": { + "effect": [{ + "type": "addMp", + "target": { + "type": "getEnumUnit" + }, + "amount": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + }] + }, + "reuseCallbacks": { + "checkValidTarget": { + "type": "not", + "condition": { + "type": "isUnitMaxMp", + "unit": { + "type": "getMatchingUnit" + } + } + } + } },{ "ids": [{"id":"Acrs", "castId": "curse", "autoCastOnId": "curseon", "autoCastOffId": "curseoff", "autoCastType": "ATTACKINGALLY"}], "type": "NORMAL_UNITTARGET", @@ -786,6 +617,10 @@ "buffId": { "type": "getFirstBuffId" }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, "duration": { "type": "getAbilityDuration", "target": { diff --git a/core/assets/abilityBehaviors_compatibility/incineratePassive.json b/core/assets/abilityBehaviors_compatibility/incineratePassive.json new file mode 100644 index 000000000..fd09b79f7 --- /dev/null +++ b/core/assets/abilityBehaviors_compatibility/incineratePassive.json @@ -0,0 +1,267 @@ +{ + "abilityList": [{ + "ids": [{"id":"ANic"}], + "type": "PASSIVE", + "reuseActions": { + "explode": [{ + "type": "createTimer", + "timeout": { + "type": "getAbilityDataAsFloat", + "dataField": "F" + }, + "actions": [{ + "type": "damageBurst", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "validTarget": { + "type": "isUnitEnemy", + "unit": { + "type": "getEnumUnit" + } + }, + "damageType": { + "type": "getDamageTypeFromString", + "id": { + "type": "rawString", + "value": "FIRE" + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "fullDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + }, + "partialDamage": { + "type": "getAbilityDataAsFloat", + "dataField": "D" + }, + "partialDamageRadius": { + "type": "getAbilityDataAsFloat", + "dataField": "E" + } + }] + }], + "onHit": [{ + "type": "if", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "thenActions": [{ + "type": "buffStoreUniqueValue", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + }, + "valueToStore": { + "type": "f+", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "value2": { + "type": "getBuffUniqueValueFloat", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + } + } + } + },{ + "type": "addBonusDamageDealt", + "value": { + "type": "getBuffUniqueValueFloat", + "buff": { + "type": "getBuffById", + "unit": { + "type": "getAttackedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + }, + "key": { + "type": "rawString", + "value": "incinerate" + } + } + }], + "elseActions": [{ + "type": "addBonusDamageDealt", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }] + },{ + "type": "createTimedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAttackedUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "uniqueValues": { + "incinerate": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }, + "onAddActions": [{ + "type": "setExplodesOnDeath", + "unit": { + "type": "getBuffedUnit" + }, + "explodes": { + "type": "rawBoolean", + "value": "true" + }, + "buffId": { + "type": "getFirstBuffId" + } + }], + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "explode" + } + }], + "elseActions": [{ + "type": "setExplodesOnDeath", + "unit": { + "type": "getBuffedUnit" + }, + "explodes": { + "type": "rawBoolean", + "value": "false" + }, + "buffId": { + "type": "getFirstBuffId" + } + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getAttackedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }, + "onAddDisabledAbility": [{ + "type": "createAttackPreDamageListener", + "actions": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "onHit" + } + },{ + "type": "setStacking", + "allowStacking": { + "type": "rawBoolean", + "value": "false" + }, + "allowSamePriorityStacking": { + "type": "rawBoolean", + "value": "false" + } + }] + },{ + "type": "createAttackModifier", + "priority": { + "type": "rawInteger", + "value": 1 + }, + "condition": { + "type": "isUnitValidTarget", + "target": { + "type": "getAttackedUnit" + } + }, + "modification": [{ + "type": "attackModifierAddPreDamageListener", + "listener": { + "type": "getLastCreatedAttackPreDamageListener" + } + },{ + "type": "attackModifierApplyArt" + },{ + "type": "attackModifierPreventOtherModifications" + }] + }], + "onAddAbility": [{ + "type": "addAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }], + "onRemoveAbility": [{ + "type": "removeAttackModifier", + "unit": { + "type": "getCastingUnit" + }, + "modifier": { + "type": "getLastCreatedAttackModifier" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors_compatibility/locust.json b/core/assets/abilityBehaviors_compatibility/locust.json new file mode 100644 index 000000000..0895cb1e3 --- /dev/null +++ b/core/assets/abilityBehaviors_compatibility/locust.json @@ -0,0 +1,219 @@ +{ + "abilityList": [{ + "ids": [{"id":"Aloc"}], + "type": "HIDDEN", + "onAddDisabledAbility": [{ + "type": "createStateModBuff", + "buffType": "INVULNERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNENUMERABLE" + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unenum" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNSELECTABLE", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createStateModBuff", + "buffType": "UNTARGETABLE", + "value": { + "type": "playerMaskAllPlayers" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "untar" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedStateModBuff" + } + },{ + "type": "createUnitStateListener", + "onHideStateChanged": [{ + "type": "if", + "condition": { + "type": "isUnitHidden", + "unit": { + "type": "getCastingUnit" + } + }, + "thenActions": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unenum" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "removeUnitStateListener", + "unit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedUnitStateListener" + } + }] + }] + }], + "onAddAbility": [{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unenum" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "unsel" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "untar" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + },{ + "type": "addUnitStateListener", + "unit": { + "type": "getCastingUnit" + }, + "listener": { + "type": "getLastCreatedUnitStateListener" + } + }], + "onRemoveAbility": [{ + "type": "removeStateModBuff", + "targetUnit": { + "type": "getCastingUnit" + }, + "buff": { + "type": "getStoredStateModBuffByKey", + "key": { + "type": "rawString", + "value": "invuln" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + } + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors_compatibility/parasite.json b/core/assets/abilityBehaviors_compatibility/parasite.json new file mode 100644 index 000000000..926cd2288 --- /dev/null +++ b/core/assets/abilityBehaviors_compatibility/parasite.json @@ -0,0 +1,368 @@ +{ + "abilityList": [{ + "ids": [{"id":"ANpa", "castId": "parasite", "autoCastOnId": "parasiteon", "autoCastOffId": "parasiteoff", "autoCastType": "FARTHESTVALID"}], + "type": "NORMAL_UNITTARGET", + "overrideFields": { + "ignoreCastTime": { + "type": "rawBoolean", + "value": "true" + } + }, + "extraTargetConditions": [{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "not", + "condition": { + "type": "isUnitSummoned", + "unit": { + "type": "getAbilityTargetedUnit" + } + } + }, + "reason": "UNABLE_TO_TARGET_SUMMONED_UNITS" + }], + "extraAutoTargetConditions": [{ + "type": "not", + "condition": { + "type": "doesUnitHaveBuff", + "unit": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getFirstBuffId" + } + } + }], + "reuseActions": { + "setup": [{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "MVSPDPCT" + } + }, + "stackingKey": { + "type": "rawString", + "value": "parasite" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mvbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + },{ + "type": "createNonStackingStatBuff", + "buffType": { + "type": "getNonStackingStatBuffTypeFromString", + "id": { + "type": "rawString", + "value": "ATKSPD" + } + }, + "stackingKey": { + "type": "rawString", + "value": "parasite" + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "asbuff" + }, + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "valueToStore": { + "type": "getLastCreatedNonStackingStatBuff" + } + }], + "levelChange": [{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "C" + } + } + },{ + "type": "updateNonStackingStatBuff", + "buff": { + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }, + "value": { + "type": "negativeFloat", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + } + }] + }, + "onAddDisabledAbility": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "setup" + } + }], + "onEndCasting": [{ + "type": "createTemporarySpellEffectOnUnit", + "target": { + "type": "getCastingUnit" + }, + "id": { + "type": "getAlias" + }, + "effectType": "CASTER" + },{ + "type": "createUnitTargetedProjectile", + "source": { + "type": "getCastingUnit" + }, + "target": { + "type": "getAbilityTargetedUnit" + }, + "id": { + "type": "getAlias" + }, + "onHit": [{ + "type": "checkAbilityProjReaction", + "target": { + "type": "getProjectileHitUnit" + }, + "projectile": { + "type": "getReactionAbilityProjectile" + }, + "onHitActions": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getProjectileHitUnit" + }, + "onHitActions": [{ + "type": "if", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 7 + } + } + }, + "elseActions": [{ + "type": "createTimedTickingBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getProjectileHitUnit" + } + }, + "positive": { + "type": "rawBoolean", + "value": "false" + }, + "magic": { + "type": "rawBoolean", + "value": "false" + }, + "statBuffs": [{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "mvbuff" + } + },{ + "type": "getStoredNonStackingStatBuffByKey", + "instanceValue": { + "type": "rawBoolean", + "value": "false" + }, + "key": { + "type": "rawString", + "value": "asbuff" + } + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "damageTarget", + "source": { + "type": "getBuffCastingUnit" + }, + "target": { + "type": "getBuffedUnit" + }, + "nonlethal": { + "type": "not", + "condition": { + "type": "i2b", + "value": { + "type": "i&", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "D" + }, + "value2": { + "type": "rawInteger", + "value": 8 + } + } + } + }, + "damage": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }], + "onRemoveActions": [{ + "type": "if", + "condition": { + "type": "isUnitDead", + "unit": { + "type": "getBuffedUnit" + } + }, + "thenActions": [{ + "type": "for", + "times": { + "type": "getAbilityDataAsInteger", + "dataField": "E" + }, + "actions": [{ + "type": "createUnit", + "id": { + "type": "getAbilityUnitId" + }, + "owner": { + "type": "getOwnerOfUnit", + "unit": { + "type": "getBuffCastingUnit" + } + }, + "loc": { + "type": "getUnitLocation", + "unit": { + "type": "getBuffedUnit" + } + }, + "facing": { + "type": "getUnitFacing", + "unit": { + "type": "getBuffedUnit" + } + } + },{ + "type": "createTimedLifeBuff", + "buffId": { + "type": "getSecondBuffId" + }, + "duration": { + "type": "getAbilityCastTime" + }, + "explode": { + "type": "rawBoolean", + "value": "false" + } + },{ + "type": "addBuff", + "target": { + "type": "getLastCreatedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + },{ + "type": "cleanUpCastInstance" + }] + }] + }] + },{ + "type": "addBuff", + "target": { + "type": "getProjectileHitUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + } + }] + }] + }] + }] + }], + "onLevelChange": [{ + "type": "runReuseAction", + "name": { + "type": "rawString", + "value": "levelChange" + } + }] + }] +} \ No newline at end of file diff --git a/core/assets/abilityBehaviors_compatibility/rejuvenation.json b/core/assets/abilityBehaviors_compatibility/rejuvenation.json new file mode 100644 index 000000000..3f5beb2b8 --- /dev/null +++ b/core/assets/abilityBehaviors_compatibility/rejuvenation.json @@ -0,0 +1,251 @@ +{ + "abilityList": [{ + "ids": [{"id":"Arej", "castId": "rejuvination"}], + "type": "NORMAL_UNITTARGET", + "extraTargetConditions": [{ + "type": "not", + "condition": { + "type": "and", + "conditions": [{ + "type": "not", + "condition": { + "type": "or", + "conditions": [{ + "type": "f=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + } + },{ + "type": "not", + "condition": { + "type": "isUnitMaxMp", + "unit": { + "type": "getAbilityTargetedUnit" + } + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "i>", + "value1": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + }, + "value2": { + "type": "rawInteger", + "value": 1 + } + }, + "reason": "ALREADY_AT_FULL_MANA" + }] + } + },{ + "type": "not", + "condition": { + "type": "or", + "conditions": [{ + "type": "f=0", + "value": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + } + },{ + "type": "not", + "condition": { + "type": "isUnitMaxHp", + "unit": { + "type": "getAbilityTargetedUnit" + } + } + },{ + "type": "setCantUseReasonOnFailure", + "condition": { + "type": "iOdd", + "value": { + "type": "getAbilityDataAsInteger", + "dataField": "C" + } + }, + "reason": "ALREADY_AT_FULL_HEALTH" + }] + } + }] + } + }], + "onEndCasting": [{ + "type": "checkAbilityEffectReaction", + "target": { + "type": "getAbilityTargetedUnit" + }, + "onHitActions": [{ + "type": "createTimedTickingPausedBuff", + "buffId": { + "type": "getFirstBuffId" + }, + "duration": { + "type": "getAbilityDuration", + "target": { + "type": "getAbilityTargetedUnit" + } + }, + "onAddActions": [{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "hpPerSec" + }, + "valueToStore": { + "type": "f/", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "A" + }, + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getBuffedUnit" + } + } + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "mpPerSec" + }, + "valueToStore": { + "type": "f/", + "value1": { + "type": "getAbilityDataAsFloat", + "dataField": "B" + }, + "value2": { + "type": "getAbilityDuration", + "target": { + "type": "getBuffedUnit" + } + } + } + }], + "onTickActions": [{ + "type": "periodicExecute", + "periodicActions": [{ + "type": "heal", + "target": { + "type": "getBuffedUnit" + }, + "amount": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "hpPerSec" + } + } + },{ + "type": "addMp", + "target": { + "type": "getBuffedUnit" + }, + "amount": { + "type": "getStoredFloatByKey", + "key": { + "type": "rawString", + "value": "mpPerSec" + } + } + }], + "delaySeconds": { + "type": "rawFloat", + "value": 1 + }, + "unique": { + "type": "getUnitHandleAsString", + "unit": { + "type": "getBuffedUnit" + } + } + }], + "onRemoveActions": [{ + "type": "cleanUpCastInstance" + }] + },{ + "type": "addNonStackingDisplayBuff", + "target": { + "type": "getAbilityTargetedUnit" + }, + "buff": { + "type": "getLastCreatedBuff" + }, + "key": { + "type": "getCodeAsString" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "regenBuff" + }, + "valueToStore": { + "type": "getLastCreatedBuff" + } + },{ + "type": "if", + "condition": { + "type": "bool", + "bool": { + "type": "getAbilityDataAsBoolean", + "dataField": "E" + } + }, + "thenActions": [{ + "type": "createDamageTakenListener", + "actions": [{ + "type": "removeDamageTakenListener", + "targetUnit": { + "type": "getListenerUnit" + }, + "listener": { + "type": "getStoredDamageTakenListenerByKey", + "key": { + "type": "rawString", + "value": "breakHeal" + } + } + + },{ + "type": "removeBuff", + "target": { + "type": "getListenerUnit" + }, + "buff": { + "type": "getStoredBuffByKey", + "key": { + "type": "rawString", + "value": "regenBuff" + } + } + }] + },{ + "type": "addDamageTakenListener", + "targetUnit": { + "type": "getAbilityTargetedUnit" + }, + "listener": { + "type": "getLastCreatedDamageTakenListener" + } + },{ + "type": "storeValueLocally", + "key": { + "type": "rawString", + "value": "breakHeal" + }, + "valueToStore": { + "type": "getLastCreatedDamageTakenListener" + } + }] + }], + "elseActions": [] + }] + }] +} \ No newline at end of file diff --git a/core/assets/warsmash.ini b/core/assets/warsmash.ini index 809aa4dbf..d1b82f4f6 100644 --- a/core/assets/warsmash.ini +++ b/core/assets/warsmash.ini @@ -64,4 +64,11 @@ InputHotkeyMode=1 // using RoC Beta MDX assets with TFT format converted textures while activating // this setting, meaning that it probably won't work for you unless you know // what you're doing. -ParseReignOfChaosBetaModelsInstead=0 \ No newline at end of file +ParseReignOfChaosBetaModelsInstead=0 + +// Some abilities can be loaded in compatibility mode to more closely mirror the +// way those abilities work in War3. This usually involves causing those abilities +// to act in stranger or less predictable ways. +// +// The setting can be a list of IDs, or just "all" to load all possible abilities +AbilityCompatibility=Aloc,ANpa diff --git a/core/src/com/etheller/warsmash/parsers/jass/Jass2.java b/core/src/com/etheller/warsmash/parsers/jass/Jass2.java index ab6569e48..7a73cb927 100644 --- a/core/src/com/etheller/warsmash/parsers/jass/Jass2.java +++ b/core/src/com/etheller/warsmash/parsers/jass/Jass2.java @@ -95,6 +95,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.RenderDestructable; import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.RenderSpellEffect; import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.RenderUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.RenderWidget; import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.ability.AbilityDataUI; import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.ability.IconUI; import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.ability.ItemUI; @@ -138,31 +139,33 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.jass.CAbilityTypeJassDefinition; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.jass.CodeJassValueBehaviorExpr; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.GetABAbilityByRawcodeVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABPermanentPassiveBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTargetingBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedArtBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTargetingBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTickingBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTickingPausedBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTickingPostDeathBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event.ABTimeOfDayEvent; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.jass.ABActionJass; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.jass.ABConditionJass; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderDupe; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParser; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABCollisionProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.ABTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABPermanentPassiveBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTargetingBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedArtBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTargetingBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTickingBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTickingPausedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTickingPostDeathBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABMapLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.jass.ABActionJass; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.jass.ABConditionJass; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderDupe; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParser; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABCollisionProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABGetABAbilityByRawcodeVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.ai.AIDifficulty; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; @@ -172,6 +175,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.jass.CBehaviorJass; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.jass.CRangedBehaviorJass; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CGenericDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; @@ -284,22 +288,19 @@ public static CommonEnvironment loadCommon(final DataSource dataSource, final Vi || lowerCasePath.startsWith(lowerCaseDirectoryPathLinux)) { try { readJassFile(dataSource, jassProgramVisitor, realPath); - } - catch (final Exception e) { + } catch (final Exception e) { e.printStackTrace(); JassLog.report(e); } } } - } - else { + } else { readJassFile(dataSource, jassProgramVisitor, jassFilePath); } } try { jassProgramVisitor.initialize(); - } - catch (final Exception e) { + } catch (final Exception e) { JassLog.report(e); new RuntimeException(e); } @@ -315,8 +316,7 @@ private static void readJassFile(final DataSource dataSource, final JassProgram final SmashJassParser smashJassParser = new SmashJassParser(reader); smashJassParser.scanAndParse(jassFile, jassProgramVisitor); } - } - catch (final Exception e) { + } catch (final Exception e) { e.printStackTrace(); JassLog.report(e); } @@ -350,22 +350,19 @@ public static ConfigEnvironment loadConfig(final DataSource dataSource, final Vi || lowerCasePath.startsWith(lowerCaseDirectoryPathLinux)) { try { readJassFile(dataSource, jassProgramVisitor, realPath); - } - catch (final Exception e) { + } catch (final Exception e) { e.printStackTrace(); JassLog.report(e); } } } - } - else { + } else { readJassFile(dataSource, jassProgramVisitor, jassFilePath); } } try { jassProgramVisitor.initialize(); - } - catch (final Exception e) { + } catch (final Exception e) { JassLog.report(e); new RuntimeException(e); } @@ -385,15 +382,13 @@ public static JUIEnvironment loadJUI(final DataSource dataSource, final Viewport final SmashJassParser smashJassParser = new SmashJassParser(reader); smashJassParser.scanAndParse(jassFile, jassProgramVisitor); } - } - catch (final Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } try { jassProgramVisitor.initialize(); - } - catch (final Exception e) { + } catch (final Exception e) { JassLog.report(e); new RuntimeException(e); } @@ -449,8 +444,7 @@ public JUIEnvironment(final JassProgram jassProgramVisitor, final DataSource dat final String tocFileName = arguments.get(0).visit(StringJassValueVisitor.getInstance()); try { JUIEnvironment.this.gameUI.loadTOCFile(tocFileName); - } - catch (final IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } return BooleanJassValue.TRUE; @@ -825,7 +819,10 @@ private CommonEnvironment(final JassProgram jassProgramVisitor, final DataSource final Double timeout = arguments.get(1).visit(RealJassValueVisitor.getInstance()); final boolean periodic = arguments.get(2).visit(BooleanJassValueVisitor.getInstance()); final CodeJassValue handlerFunc = nullable(arguments, 3, CodeJassValueVisitor.getInstance()); - if ((timer != null) && !timer.isRunning()) { + if ((timer != null) && timer.isRunning()) { + timer.pause(simulation); + } + if ((timer != null)) { timer.setTimeoutTime(timeout.floatValue()); timer.setRepeats(periodic); timer.setHandlerFunc(handlerFunc); @@ -1005,11 +1002,11 @@ public JassValue call(final List arguments, final GlobalScope globalS int abilityHandleId = 0; AbilityPointTarget targetAsPoint = new AbilityPointTarget(whichLocation.x, whichLocation.y); for (final CAbility ability : whichUnit.getAbilities()) { - ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, activationReceiver); if (activationReceiver.isOk()) { final PointAbilityTargetCheckReceiver targetReceiver = PointAbilityTargetCheckReceiver.INSTANCE; - ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, false, targetAsPoint, targetReceiver.reset()); if (targetReceiver.getTarget() != null) { targetAsPoint = targetReceiver.getTarget(); @@ -1038,11 +1035,12 @@ public JassValue call(final List arguments, final GlobalScope globalS AbilityPointTarget targetAsPoint = new AbilityPointTarget((float) whichLocationX, (float) whichLocationY); for (final CAbility ability : whichUnit.getAbilities()) { - ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, activationReceiver); + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, + activationReceiver); if (activationReceiver.isOk()) { final PointAbilityTargetCheckReceiver targetReceiver = PointAbilityTargetCheckReceiver.INSTANCE; - ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, targetAsPoint, - targetReceiver.reset()); + ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, false, + targetAsPoint, targetReceiver.reset()); if (targetReceiver.getTarget() != null) { targetAsPoint = targetReceiver.getTarget(); abilityHandleId = ability.getHandleId(); @@ -1073,11 +1071,11 @@ public JassValue call(final List arguments, final GlobalScope globalS final int orderId = OrderIdUtils.getOrderId(orderString); int abilityHandleId = 0; for (final CAbility ability : whichUnit.getAbilities()) { - ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, activationReceiver); if (activationReceiver.isOk()) { final CWidgetAbilityTargetCheckReceiver targetReceiver = CWidgetAbilityTargetCheckReceiver.INSTANCE; - ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, false, whichTarget, targetReceiver.reset()); if (targetReceiver.getTarget() != null) { whichTarget = targetReceiver.getTarget(); @@ -1104,11 +1102,11 @@ public JassValue call(final List arguments, final GlobalScope globalS final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; int abilityHandleId = 0; for (final CAbility ability : whichUnit.getAbilities()) { - ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, activationReceiver); if (activationReceiver.isOk()) { final CWidgetAbilityTargetCheckReceiver targetReceiver = CWidgetAbilityTargetCheckReceiver.INSTANCE; - ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, false, whichTarget, targetReceiver.reset()); if (targetReceiver.getTarget() != null) { whichTarget = targetReceiver.getTarget(); @@ -1135,13 +1133,13 @@ public JassValue call(final List arguments, final GlobalScope globalS final int orderId = OrderIdUtils.getOrderId(orderString); int abilityHandleId = 0; for (final CAbility ability : whichUnit.getAbilities()) { - ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, activationReceiver); if (activationReceiver.isOk()) { final BooleanAbilityTargetCheckReceiver targetReceiver = BooleanAbilityTargetCheckReceiver .getInstance(); ability.checkCanTargetNoTarget(CommonEnvironment.this.simulation, whichUnit, orderId, - targetReceiver.reset()); + false, targetReceiver.reset()); if (targetReceiver.isTargetable()) { abilityHandleId = ability.getHandleId(); } @@ -1163,13 +1161,43 @@ public JassValue call(final List arguments, final GlobalScope globalS final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; int abilityHandleId = 0; for (final CAbility ability : whichUnit.getAbilities()) { - ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, + activationReceiver); + if (activationReceiver.isOk()) { + final BooleanAbilityTargetCheckReceiver targetReceiver = BooleanAbilityTargetCheckReceiver + .getInstance(); + ability.checkCanTargetNoTarget(CommonEnvironment.this.simulation, whichUnit, orderId, + false, targetReceiver.reset()); + if (targetReceiver.isTargetable()) { + abilityHandleId = ability.getHandleId(); + } + } + } + defaultPlayerUnitOrderExecutor.issueImmediateOrder(whichUnit.getHandleId(), abilityHandleId, + orderId, false); + return BooleanJassValue.of(abilityHandleId != 0); + }); + + jassProgramVisitor.getJassNativeManager().createNative("UnitUseItem", + (arguments, globalScope, triggerScope) -> { + final CUnit whichUnit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); + if (whichUnit == null) { + return BooleanJassValue.FALSE; + } + final CItem item = arguments.get(1).visit(ObjectJassValueVisitor.getInstance()); + final CPlayerUnitOrderExecutor defaultPlayerUnitOrderExecutor = CommonEnvironment.this.simulation + .getDefaultPlayerUnitOrderExecutor(whichUnit.getPlayerIndex()); + final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; + final int orderId = OrderIdUtils.getOrderId("itemuse" + String.format("%02d", item.getContainedInventory().getSlot(item))); + int abilityHandleId = 0; + for (final CAbility ability : whichUnit.getAbilities()) { + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, activationReceiver); if (activationReceiver.isOk()) { final BooleanAbilityTargetCheckReceiver targetReceiver = BooleanAbilityTargetCheckReceiver .getInstance(); ability.checkCanTargetNoTarget(CommonEnvironment.this.simulation, whichUnit, orderId, - targetReceiver.reset()); + false, targetReceiver.reset()); if (targetReceiver.isTargetable()) { abilityHandleId = ability.getHandleId(); } @@ -1179,6 +1207,75 @@ public JassValue call(final List arguments, final GlobalScope globalS orderId, false); return BooleanJassValue.of(abilityHandleId != 0); }); + final JassFunction unitUseItemTarget = (arguments, globalScope, triggerScope) -> { + final CUnit whichUnit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); + if (whichUnit == null) { + return BooleanJassValue.FALSE; + } + final CItem item = arguments.get(1).visit(ObjectJassValueVisitor.getInstance()); + CWidget whichTarget = arguments.get(2).visit(ObjectJassValueVisitor.getInstance()); + final CPlayerUnitOrderExecutor defaultPlayerUnitOrderExecutor = CommonEnvironment.this.simulation + .getDefaultPlayerUnitOrderExecutor(whichUnit.getPlayerIndex()); + final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; + final int orderId = OrderIdUtils.getOrderId("itemuse" + String.format("%02d", item.getContainedInventory().getSlot(item))); + int abilityHandleId = 0; + for (final CAbility ability : whichUnit.getAbilities()) { + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, + activationReceiver); + if (activationReceiver.isOk()) { + final CWidgetAbilityTargetCheckReceiver targetReceiver = CWidgetAbilityTargetCheckReceiver.INSTANCE; + ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, false, + whichTarget, targetReceiver.reset()); + if (targetReceiver.getTarget() != null) { + whichTarget = targetReceiver.getTarget(); + abilityHandleId = ability.getHandleId(); + } + } + } + if (abilityHandleId != 0) { + defaultPlayerUnitOrderExecutor.issueTargetOrder(whichUnit.getHandleId(), abilityHandleId, + orderId, whichTarget.getHandleId(), false); + } + return BooleanJassValue.of(abilityHandleId != 0); + }; + jassProgramVisitor.getJassNativeManager().createNative("UnitUseItemTarget", unitUseItemTarget); + jassProgramVisitor.getJassNativeManager().createNative("UnitUseItemDestructable", unitUseItemTarget); + jassProgramVisitor.getJassNativeManager().createNative("UnitUseItemPointLoc", + (arguments, globalScope, triggerScope) -> { + final CUnit whichUnit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); + if (whichUnit == null) { + return BooleanJassValue.FALSE; + } + final CItem item = arguments.get(1).visit(ObjectJassValueVisitor.getInstance()); + final AbilityPointTarget whichLocation = arguments.get(2) + .visit(ObjectJassValueVisitor.getInstance()); + final CPlayerUnitOrderExecutor defaultPlayerUnitOrderExecutor = CommonEnvironment.this.simulation + .getDefaultPlayerUnitOrderExecutor(whichUnit.getPlayerIndex()); + final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; + final int orderId = OrderIdUtils.getOrderId("itemuse" + String.format("%02d", item.getContainedInventory().getSlot(item))); + int abilityHandleId = 0; + AbilityPointTarget targetAsPoint = new AbilityPointTarget(whichLocation.x, whichLocation.y); + for (final CAbility ability : whichUnit.getAbilities()) { + ability.checkCanUse(CommonEnvironment.this.simulation, whichUnit, orderId, false, + activationReceiver); + if (activationReceiver.isOk()) { + final PointAbilityTargetCheckReceiver targetReceiver = PointAbilityTargetCheckReceiver.INSTANCE; + ability.checkCanTarget(CommonEnvironment.this.simulation, whichUnit, orderId, false, + targetAsPoint, targetReceiver.reset()); + if (targetReceiver.getTarget() != null) { + targetAsPoint = targetReceiver.getTarget(); + abilityHandleId = ability.getHandleId(); + } + } + } + if (abilityHandleId != 0) { + defaultPlayerUnitOrderExecutor.issuePointOrder(whichUnit.getHandleId(), abilityHandleId, + orderId, targetAsPoint.x, targetAsPoint.y, false); + } + return BooleanJassValue.of(abilityHandleId != 0); + }); + + jassProgramVisitor.getJassNativeManager().createNative("UnitDamageTarget", (arguments, globalScope, triggerScope) -> { final CUnit whichUnit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); @@ -1200,8 +1297,9 @@ public JassValue call(final List arguments, final GlobalScope globalS if (damageType == null) { damageType = CDamageType.UNKNOWN; } - target.damage(CommonEnvironment.this.simulation, whichUnit, attack, ranged, attackType, - damageType, weaponType.name(), (float) amount); + target.damage(CommonEnvironment.this.simulation, whichUnit, + new CGenericDamageFlags(attack, ranged), attackType, damageType, + weaponType.name(), (float) amount); return BooleanJassValue.TRUE; } } @@ -1510,8 +1608,7 @@ public boolean call(final CUnit unit) { globalScope.runThreadUntilCompletion(globalScope.createThread(callback, CommonTriggerExecutionScope.enumScope(triggerScope, unit))); } - } - catch (final Exception e) { + } catch (final Exception e) { throw new JassException(globalScope, "Exception during ForGroup", e); } } @@ -1650,8 +1747,7 @@ public boolean call(final CUnit unit) { globalScope.runThreadUntilCompletion(globalScope.createThread(callback, CommonTriggerExecutionScope.enumScope(triggerScope, player))); } - } - catch (final Exception e) { + } catch (final Exception e) { throw new JassException(globalScope, "Exception during ForForce", e); } return null; @@ -3058,8 +3154,7 @@ public void remove() { final float value = arguments.get(2).visit(RealJassValueVisitor.getInstance()).floatValue(); if (whichUnit != null) { whichUnit.setUnitState(CommonEnvironment.this.simulation, whichUnitState, value); - } - else { + } else { System.err.println("got SetUnitState(null," + whichUnitState + "," + value + ") call (skipping because unit is null)"); } @@ -3800,8 +3895,7 @@ public void remove() { alliedPlayer.getFogOfWar().setFogStateRect(pathingGrid, whichRect, whichState); } } - } - else { + } else { player.getFogOfWar().setFogStateRect(pathingGrid, whichRect, whichState); } @@ -3826,8 +3920,7 @@ public void remove() { whichState); } } - } - else { + } else { player.getFogOfWar().setFogStateRadius(pathingGrid, centerX, centerY, radius, whichState); } @@ -3854,8 +3947,7 @@ public void remove() { whichState); } } - } - else { + } else { player.getFogOfWar().setFogStateRadius(pathingGrid, centerX, centerY, radius, whichState); } @@ -3903,8 +3995,7 @@ public void remove() { } } return new HandleJassValue(fogmodifierType, new CFogModifierJassMulti(modifiers)); - } - else { + } else { player.addFogModifer(this.simulation, fogModifier, afterUnits); return new HandleJassValue(fogmodifierType, new CFogModifierJassSingle(player.getId(), fogModifier)); @@ -3935,8 +4026,7 @@ public void remove() { } } return new HandleJassValue(fogmodifierType, new CFogModifierJassMulti(modifiers)); - } - else { + } else { player.addFogModifer(this.simulation, fogModifier, afterUnits); return new HandleJassValue(fogmodifierType, new CFogModifierJassSingle(player.getId(), fogModifier)); @@ -3968,8 +4058,7 @@ public void remove() { } } return new HandleJassValue(fogmodifierType, new CFogModifierJassMulti(modifiers)); - } - else { + } else { player.addFogModifer(this.simulation, fogModifier, afterUnits); return new HandleJassValue(fogmodifierType, new CFogModifierJassSingle(player.getId(), fogModifier)); @@ -4106,8 +4195,7 @@ public JassValue call(final List arguments, final GlobalScope globalS try { war3MapViewer.load(filename.trim(), war3MapViewer.mapPathSolver, war3MapViewer.solverParams); - } - catch (final Exception exc) { + } catch (final Exception exc) { System.err.println("Preload(\"" + filename + "\") failed!"); exc.printStackTrace(); } @@ -4312,8 +4400,7 @@ public JassValue call(final List arguments, final GlobalScope globalS CommonEnvironment.this.simulation.getHandleIdAllocator().createId())); // TODO below code is very stupid!! return IntegerJassValue.of(1); - } - else { + } else { final int newLevel = ability.getLevel() + 1; ability.setLevel(CommonEnvironment.this.simulation, whichWidget, newLevel); return IntegerJassValue.of(newLevel); @@ -4376,8 +4463,7 @@ public JassValue call(final List arguments, final GlobalScope globalS timer.setRepeats(false); timer.setTimeoutTime(seconds.floatValue()); timer.start(this.simulation); - } - else { + } else { throw new JassException(globalScope, "Needs to sleep " + seconds + " but no thread was found", null); } @@ -4404,8 +4490,7 @@ public JassValue call(final List arguments, final GlobalScope globalS timer.setRepeats(false); timer.setTimeoutTime(seconds); timer.start(this.simulation); - } - else { + } else { throw new JassException(globalScope, "Needs to sleep " + seconds + " but no thread was found", null); } @@ -4456,8 +4541,7 @@ public JassValue call(final List arguments, final GlobalScope globalS if (attachmentPoint != null) { return new HandleJassValue(effectType, war3MapViewer.spawnSpellEffectOnUnitEx(target, new War3ID(rawcode), whichEffectType, 0, attachmentPoint)); - } - else { + } else { return new HandleJassValue(effectType, war3MapViewer.spawnSpellEffectOnUnitEx(target, new War3ID(rawcode), whichEffectType, 0)); } @@ -5072,6 +5156,15 @@ public JassValue call(final List arguments, final GlobalScope globalS return new HandleJassValue(unitType, ((CommonTriggerExecutionScope) triggerScope).getKillingUnit()); }); + jassProgramVisitor.getJassNativeManager().createNative("GetEventDamageSource", + (arguments, globalScope, triggerScope) -> { + return new HandleJassValue(unitType, + ((CommonTriggerExecutionScope) triggerScope).getDamageSource()); + }); + jassProgramVisitor.getJassNativeManager().createNative("GetEventDamage", + (arguments, globalScope, triggerScope) -> { + return RealJassValue.of(((CommonTriggerExecutionScope) triggerScope).getDamageTaken()); + }); jassProgramVisitor.getJassNativeManager().createNative("GetTriggerUnit", (arguments, globalScope, triggerScope) -> { return new HandleJassValue(unitType, @@ -5087,8 +5180,7 @@ public JassValue call(final List arguments, final GlobalScope globalS final CWidget triggerWidget = ((CommonTriggerExecutionScope) triggerScope).getTriggerWidget(); if (triggerWidget instanceof CDestructable) { return new HandleJassValue(destructableType, triggerWidget); - } - else { + } else { return new HandleJassValue(destructableType, null); } }); @@ -5229,12 +5321,10 @@ public JassValue call(final List arguments, final GlobalScope globalS if (rallyPoint != null) { x = rallyPoint.getX(); y = rallyPoint.getY(); - } - else { + } else { x = y = 0; } - } - else { + } else { x = y = 0; } return new HandleJassValue(locationType, @@ -5268,12 +5358,10 @@ public HandleJassValue accept(final CItem target) { return unitType.getNullValue(); } }); - } - else { + } else { rallyUnit = unitType.getNullValue(); } - } - else { + } else { rallyUnit = unitType.getNullValue(); } return rallyUnit; @@ -5306,12 +5394,10 @@ public HandleJassValue accept(final CItem target) { return destructableType.getNullValue(); } }); - } - else { + } else { rallyDest = destructableType.getNullValue(); } - } - else { + } else { rallyDest = destructableType.getNullValue(); } return rallyDest; @@ -5322,8 +5408,7 @@ public HandleJassValue accept(final CItem target) { int orderId; if ((whichUnit != null) && (whichUnit.getCurrentOrder() != null)) { orderId = whichUnit.getCurrentOrder().getOrderId(); - } - else { + } else { orderId = 0; } return IntegerJassValue.of(orderId); @@ -5525,8 +5610,7 @@ public HandleJassValue accept(final CItem target) { if (triggerScope instanceof CommonTriggerExecutionScope) { return new HandleJassValue(timerType, ((CommonTriggerExecutionScope) triggerScope).getExpiringTimer()); - } - else { + } else { return new HandleJassValue(timerType, null); } }); @@ -6362,8 +6446,7 @@ public HandleJassValue accept(final CItem target) { try { globalScope.runThreadUntilCompletion(globalScope.createThread(callback, CommonTriggerExecutionScope.enumFileScope(triggerScope, realPath))); - } - catch (final Exception e) { + } catch (final Exception e) { throw new JassException(globalScope, "Exception during ForFiles", e); } } @@ -6399,7 +6482,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AbilityTypeLevelDataAddTargetAllowed", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); final CTargetType targetType = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); @@ -6411,7 +6494,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("AbilityTypeLevelDataRemoveTargetAllowed", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); final CTargetType targetType = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); @@ -6424,14 +6507,14 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("ConvertDataFieldLetter", (arguments, globalScope, triggerScope) -> { final int i = arguments.get(0).visit(IntegerJassValueVisitor.getInstance()); - return new HandleJassValue(datafieldletterType, DataFieldLetter.VALUES[i]); + return new HandleJassValue(datafieldletterType, ABDataFieldLetter.VALUES[i]); }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataReal", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); - final DataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); + final ABDataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); if ((levelData != null) && (dataField != null)) { final String data = levelData.get(level).getData().get(dataField.getIndex()); if (data.equals("-") || data.isEmpty()) { @@ -6443,10 +6526,10 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataInteger", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); - final DataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); + final ABDataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); if ((levelData != null) && (dataField != null)) { final String data = levelData.get(level).getData().get(dataField.getIndex()); if (data.equals("-") || data.isEmpty()) { @@ -6458,10 +6541,10 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataAsID", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); - final DataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); + final ABDataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); if ((levelData != null) && (dataField != null)) { final String data = levelData.get(level).getData().get(dataField.getIndex()); if (data.equals("-") || data.isEmpty()) { @@ -6473,10 +6556,10 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataBoolean", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); - final DataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); + final ABDataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); if ((levelData != null) && (dataField != null)) { final String data = levelData.get(level).getData().get(dataField.getIndex()); if (data.equals("-") || data.isEmpty()) { @@ -6488,10 +6571,10 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataString", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); - final DataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); + final ABDataFieldLetter dataField = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); if ((levelData != null) && (dataField != null)) { final String data = levelData.get(level).getData().get(dataField.getIndex()); if (data.isEmpty()) { @@ -6503,7 +6586,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataFirstBuffId", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); if (levelData != null) { @@ -6517,7 +6600,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataDurationNormal", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); if (levelData != null) { @@ -6527,7 +6610,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataDurationHero", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); if (levelData != null) { @@ -6537,7 +6620,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelDataCastTime", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); if (levelData != null) { @@ -6547,7 +6630,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetAbilityTypeLevelUnitID", (arguments, globalScope, triggerScope) -> { - final List levelData = nullable(arguments, 0, + final List levelData = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); if (levelData != null) { @@ -6562,9 +6645,9 @@ public HandleJassValue accept(final CItem target) { (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.get(childKey); if (object != null) { return new StringJassValue((String) object); @@ -6576,9 +6659,9 @@ public HandleJassValue accept(final CItem target) { (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.get(childKey); if (object != null) { return IntegerJassValue.of((Integer) object); @@ -6590,9 +6673,9 @@ public HandleJassValue accept(final CItem target) { (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.get(childKey); if (object != null) { return BooleanJassValue.of((Boolean) object); @@ -6617,7 +6700,7 @@ public HandleJassValue accept(final CItem target) { // TODO below is overwriting what already exists jassProgramVisitor.getJassNativeManager().createNative("GetLocalStoreLocationHandle", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); Object object = localStore.get(childKey); @@ -6633,7 +6716,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetLocalStoreHandle", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object unwrappedHandleUnderlyingJavaObject = nullable(arguments, 2, @@ -6646,9 +6729,9 @@ public HandleJassValue accept(final CItem target) { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final String value = nullable(arguments, 2, StringJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.put(childKey, value); return BooleanJassValue.of(object != null); } @@ -6659,9 +6742,9 @@ public HandleJassValue accept(final CItem target) { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Integer value = arguments.get(2).visit(IntegerJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.put(childKey, value); return BooleanJassValue.of(object != null); } @@ -6672,9 +6755,9 @@ public HandleJassValue accept(final CItem target) { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Boolean value = arguments.get(2).visit(BooleanJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.put(childKey, value); return BooleanJassValue.of(object != null); } @@ -6684,9 +6767,9 @@ public HandleJassValue accept(final CItem target) { (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); return BooleanJassValue.of(localStore.containsKey(childKey)); } return BooleanJassValue.FALSE; @@ -6694,10 +6777,10 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("FlushParentAbilityUserData", (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; if (ability != null) { - final Map localStore = ability.getLocalStore(); + final ABLocalDataStore localStore = ability.getLocalStore(); localStore.clear(); } } @@ -6707,9 +6790,9 @@ public HandleJassValue accept(final CItem target) { (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); return BooleanJassValue.of(localStore.remove(childKey) != null); } return BooleanJassValue.FALSE; @@ -6718,11 +6801,11 @@ public HandleJassValue accept(final CItem target) { // ===== local store ===== jassProgramVisitor.getJassNativeManager().createNative("CreateLocalStore", (arguments, globalScope, triggerScope) -> { - return new HandleJassValue(localstoreType, new HashMap()); + return new HandleJassValue(localstoreType, new ABMapLocalDataStore(CommonEnvironment.this.simulation)); }); jassProgramVisitor.getJassNativeManager().createNative("GetLocalStoreString", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object object = localStore.get(childKey); @@ -6733,7 +6816,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetLocalStoreInteger", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object object = localStore.get(childKey); @@ -6747,7 +6830,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetLocalStoreReal", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object object = localStore.get(childKey); @@ -6758,7 +6841,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetLocalStoreCode", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object object = localStore.get(childKey); @@ -6769,7 +6852,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("GetLocalStoreBoolean", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object object = localStore.get(childKey); @@ -6780,7 +6863,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetLocalStoreString", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final String value = nullable(arguments, 2, StringJassValueVisitor.getInstance()); @@ -6789,7 +6872,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetLocalStoreInteger", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Integer value = arguments.get(2).visit(IntegerJassValueVisitor.getInstance()); @@ -6798,7 +6881,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetLocalStoreReal", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final float value = arguments.get(2).visit(RealJassValueVisitor.getInstance()).floatValue(); @@ -6807,7 +6890,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetLocalStoreBoolean", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Boolean value = arguments.get(2).visit(BooleanJassValueVisitor.getInstance()); @@ -6816,7 +6899,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetLocalStoreCode", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final CodeJassValue value = arguments.get(2).visit(CodeJassValueVisitor.getInstance()); @@ -6825,14 +6908,14 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("LocalStoreContainsKey", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); return BooleanJassValue.of(localStore.containsKey(childKey)); }); final JassFunction flushParentLocalStore = (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); localStore.clear(); return null; }; @@ -6840,7 +6923,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("DestroyLocalStore", flushParentLocalStore); jassProgramVisitor.getJassNativeManager().createNative("FlushChildLocalStore", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); return BooleanJassValue.of(localStore.remove(childKey) != null); @@ -6848,7 +6931,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("LocalStoreCleanUpCastInstance", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); final Set keySet = new HashSet<>(localStore.keySet()); @@ -6862,9 +6945,9 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("GetAbilityLocalStore", (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); return new HandleJassValue(localstoreType, localStore); } return localstoreType.getNullValue(); @@ -6880,14 +6963,14 @@ public HandleJassValue accept(final CItem target) { // Ability Builder Configuration jassProgramVisitor.getJassNativeManager().createNative("CreateAbilityBuilderConfiguration", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration emptyConfiguration = new AbilityBuilderConfiguration( - new AbilityBuilderParser(), new AbilityBuilderDupe()); + final ABAbilityBuilderConfiguration emptyConfiguration = new ABAbilityBuilderConfiguration( + new ABAbilityBuilderParser(), new ABAbilityBuilderDupe()); return new HandleJassValue(abilitybuilderconfigurationType, emptyConfiguration); }); jassProgramVisitor.getJassNativeManager().createNative("SetABConfCastId", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String castId = nullable(arguments, 1, StringJassValueVisitor.getInstance()); @@ -6896,7 +6979,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetABConfUncastId", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String castId = nullable(arguments, 1, StringJassValueVisitor.getInstance()); @@ -6905,7 +6988,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetABConfAutoCastOnId", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String castId = nullable(arguments, 1, StringJassValueVisitor.getInstance()); @@ -6914,7 +6997,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetABConfAutoCastOffId", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String castId = nullable(arguments, 1, StringJassValueVisitor.getInstance()); @@ -6923,7 +7006,7 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetABConfAutoCastType", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final AutocastType whichAutocastType = nullable(arguments, 1, ObjectJassValueVisitor.getInstance()); @@ -6933,9 +7016,9 @@ public HandleJassValue accept(final CItem target) { }); jassProgramVisitor.getJassNativeManager().createNative("SetABConfType", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); - final AbilityBuilderType whichType = nullable(arguments, 1, + final ABAbilityBuilderType whichType = nullable(arguments, 1, ObjectJassValueVisitor.getInstance()); abConf.setType(whichType); @@ -6949,13 +7032,13 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("ConvertABConfType", (arguments, globalScope, triggerScope) -> { final int i = arguments.get(0).visit(IntegerJassValueVisitor.getInstance()); - return new HandleJassValue(abconftypeType, AbilityBuilderType.VALUES[i]); + return new HandleJassValue(abconftypeType, ABAbilityBuilderType.VALUES[i]); }); // ==Begin section of generated code (these were all the same and not created // manually)=== jassProgramVisitor.getJassNativeManager().createNative("AddABConfAddAbilityAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -6971,7 +7054,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfAddDisabledAbilityAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -6987,7 +7070,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfRemoveAbilityAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7003,7 +7086,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfRemoveDisabledAbilityAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7019,7 +7102,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfDeathPreCastAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7035,7 +7118,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfCancelPreCastAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7051,7 +7134,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfOrderIssuedAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7067,7 +7150,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfActivateAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7083,7 +7166,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfDeactivateAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7099,7 +7182,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfLevelChangeAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7115,7 +7198,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfBeginCastingAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7131,7 +7214,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfEndCastingAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7147,7 +7230,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfChannelTickAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7163,7 +7246,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("AddABConfEndChannelAction", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderConfiguration abConf = nullable(arguments, 0, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CodeJassValue callback = nullable(arguments, 1, CodeJassValueVisitor.getInstance()); if ((abConf != null) && (callback != null)) { @@ -7181,7 +7264,7 @@ public HandleJassValue accept(final CItem target) { jassProgramVisitor.getJassNativeManager().createNative("RegisterABConf", (arguments, globalScope, triggerScope) -> { final int rawcode = arguments.get(0).visit(IntegerJassValueVisitor.getInstance()); - final AbilityBuilderConfiguration abConf = nullable(arguments, 1, + final ABAbilityBuilderConfiguration abConf = nullable(arguments, 1, ObjectJassValueVisitor.getInstance()); this.simulation.getAbilityData().registerAbilityBuilderType(new War3ID(rawcode), abConf); return null; @@ -7251,8 +7334,7 @@ public HandleJassValue accept(final CItem target) { // the remove(CBuff) function being independent from remove(CAbility). // The difference is probably dumb. unit.remove(this.simulation, (CBuff) ability); - } - else { + } else { unit.remove(this.simulation, ability); } return null; @@ -7399,8 +7481,8 @@ public void remove() { final JassFunction endUnitAbilityCooldown = (arguments, globalScope, triggerScope) -> { final CUnit theUnit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); final int aliasId = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); - final AbilityBuilderAbility abil = theUnit - .getAbility(GetABAbilityByRawcodeVisitor.getInstance().reset(new War3ID(aliasId))); + final ABAbilityBuilderAbility abil = theUnit + .getAbility(ABGetABAbilityByRawcodeVisitor.getInstance().reset(new War3ID(aliasId))); if (abil != null) { abil.resetCooldown(this.simulation, theUnit); } @@ -7412,7 +7494,7 @@ public void remove() { jassProgramVisitor.getJassNativeManager().createNative("EndAbilityCooldown", (arguments, globalScope, triggerScope) -> { final CUnit unit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); - final AbilityBuilderAbility ability = arguments.get(1) + final ABAbilityBuilderAbility ability = arguments.get(1) .visit(ObjectJassValueVisitor.getInstance()); ability.resetCooldown(this.simulation, unit); return null; @@ -7436,8 +7518,8 @@ public void remove() { final CUnit theUnit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); final int aliasIdRawcode = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); final War3ID aliasId = new War3ID(aliasIdRawcode); - final AbilityBuilderAbility abil = theUnit - .getAbility(GetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); + final ABAbilityBuilderAbility abil = theUnit + .getAbility(ABGetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); if (abil != null) { abil.startCooldown(this.simulation, theUnit); } @@ -7448,8 +7530,8 @@ public void remove() { (arguments, globalScope, triggerScope) -> { final CUnit unit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); final CAbility ability = arguments.get(1).visit(ObjectJassValueVisitor.getInstance()); - if (ability instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility abilityBuilderAbility = (AbilityBuilderAbility) ability; + if (ability instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility abilityBuilderAbility = (ABAbilityBuilderAbility) ability; abilityBuilderAbility.startCooldown(this.simulation, unit); } return null; @@ -7490,7 +7572,7 @@ public void remove() { jassProgramVisitor.getJassNativeManager().createNative("AbilityActivate", (arguments, globalScope, triggerScope) -> { final CUnit unit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); - final AbilityBuilderActiveAbility ability = arguments.get(1) + final ABAbilityBuilderActiveAbility ability = arguments.get(1) .visit(ObjectJassValueVisitor.getInstance()); ability.activate(this.simulation, unit); return null; @@ -7499,7 +7581,7 @@ public void remove() { jassProgramVisitor.getJassNativeManager().createNative("AbilityDeactivate", (arguments, globalScope, triggerScope) -> { final CUnit unit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); - final AbilityBuilderActiveAbility ability = arguments.get(1) + final ABAbilityBuilderActiveAbility ability = arguments.get(1) .visit(ObjectJassValueVisitor.getInstance()); ability.deactivate(this.simulation, unit); return null; @@ -7514,7 +7596,7 @@ public void remove() { jassProgramVisitor.getJassNativeManager().createNative("SetAbilityCastRange", (arguments, globalScope, triggerScope) -> { - final AbilityBuilderActiveAbility ability = arguments.get(0) + final ABAbilityBuilderActiveAbility ability = arguments.get(0) .visit(ObjectJassValueVisitor.getInstance()); final float range = arguments.get(1).visit(RealJassValueVisitor.getInstance()).floatValue(); ability.setCastRange(range); @@ -7525,7 +7607,7 @@ public void remove() { (arguments, globalScope, triggerScope) -> { int argIndex = 0; final CUnit casterUnit = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, argIndex++, + final ABLocalDataStore localStore = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(argIndex++).visit(IntegerJassValueVisitor.getInstance()); @@ -7578,7 +7660,7 @@ public void remove() { (arguments, globalScope, triggerScope) -> { int argIndex = 0; final CUnit casterUnit = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, argIndex++, + final ABLocalDataStore localStore = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(argIndex++).visit(IntegerJassValueVisitor.getInstance()); @@ -7615,7 +7697,7 @@ public void remove() { (arguments, globalScope, triggerScope) -> { int argIndex = 0; final CUnit casterUnit = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, argIndex++, + final ABLocalDataStore localStore = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(argIndex++).visit(IntegerJassValueVisitor.getInstance()); @@ -7676,7 +7758,7 @@ public void remove() { (arguments, globalScope, triggerScope) -> { int argIndex = 0; final CUnit casterUnit = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, argIndex++, + final ABLocalDataStore localStore = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(argIndex++).visit(IntegerJassValueVisitor.getInstance()); @@ -7726,7 +7808,7 @@ public void remove() { (arguments, globalScope, triggerScope) -> { int argIndex = 0; final CUnit casterUnit = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, argIndex++, + final ABLocalDataStore localStore = nullable(arguments, argIndex++, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(argIndex++).visit(IntegerJassValueVisitor.getInstance()); @@ -7879,14 +7961,16 @@ public void remove() { final CEffectType artType = nullable(arguments, 4, ObjectJassValueVisitor.getInstance()); final boolean showFx = arguments.get(5).visit(BooleanJassValueVisitor.getInstance()); final boolean playSfx = arguments.get(6).visit(BooleanJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 7, + final ABLocalDataStore localStore = nullable(arguments, 7, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(8).visit(IntegerJassValueVisitor.getInstance()); + final boolean leveled = arguments.get(9).visit(BooleanJassValueVisitor.getInstance()); + final boolean positive = arguments.get(10).visit(BooleanJassValueVisitor.getInstance()); final ABPermanentPassiveBuff ability = new ABPermanentPassiveBuff( CommonEnvironment.this.simulation.getHandleIdAllocator().createId(), - new War3ID(buffRawcode), localStore, ABActionJass.wrap(onAddAction), - ABActionJass.wrap(onRemoveAction), showIcon, castId); + new War3ID(buffRawcode), null, null, localStore, ABActionJass.wrap(onAddAction), + ABActionJass.wrap(onRemoveAction), showIcon, castId, leveled, positive); if (artType != null) { ability.setArtType(artType); } @@ -7899,10 +7983,12 @@ public void remove() { jassProgramVisitor.getJassNativeManager().createNative("CreateTargetingBuff", (arguments, globalScope, triggerScope) -> { final int buffRawcode = arguments.get(0).visit(IntegerJassValueVisitor.getInstance()); + final ABLocalDataStore localStore = nullable(arguments, 1, + ObjectJassValueVisitor.getInstance()); final CBuff ability = new ABTargetingBuff( CommonEnvironment.this.simulation.getHandleIdAllocator().createId(), - new War3ID(buffRawcode)); + new War3ID(buffRawcode), localStore, null, null); return new HandleJassValue(buffType, ability); }); @@ -7913,10 +7999,15 @@ public void remove() { final float duration = arguments.get(1).visit(RealJassValueVisitor.getInstance()).floatValue(); final boolean showIcon = arguments.get(2).visit(BooleanJassValueVisitor.getInstance()); final CEffectType artType = nullable(arguments, 3, ObjectJassValueVisitor.getInstance()); + final boolean leveled = arguments.get(4).visit(BooleanJassValueVisitor.getInstance()); + final boolean positive = arguments.get(5).visit(BooleanJassValueVisitor.getInstance()); + final boolean dispellable = arguments.get(6).visit(BooleanJassValueVisitor.getInstance()); + final ABLocalDataStore localStore = nullable(arguments, 7, + ObjectJassValueVisitor.getInstance()); final ABTimedArtBuff ability = new ABTimedArtBuff( - this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), duration, - showIcon); + this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), localStore, + null, null, duration, showIcon, leveled, positive, dispellable); if (artType != null) { ability.setArtType(artType); } @@ -7933,14 +8024,17 @@ public void remove() { final CodeJassValue onExpireAction = nullable(arguments, 5, CodeJassValueVisitor.getInstance()); final boolean showIcon = arguments.get(6).visit(BooleanJassValueVisitor.getInstance()); final CEffectType artType = nullable(arguments, 7, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 8, + final ABLocalDataStore localStore = nullable(arguments, 8, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(9).visit(IntegerJassValueVisitor.getInstance()); + final boolean leveled = arguments.get(10).visit(BooleanJassValueVisitor.getInstance()); + final boolean positive = arguments.get(11).visit(BooleanJassValueVisitor.getInstance()); + final boolean dispellable = arguments.get(12).visit(BooleanJassValueVisitor.getInstance()); final ABTimedBuff ability = new ABTimedBuff(this.simulation.getHandleIdAllocator().createId(), - new War3ID(buffRawcode), duration, showTimedLifeBar, localStore, + new War3ID(buffRawcode), localStore, null, null, duration, showTimedLifeBar, ABActionJass.wrap(onAddAction), ABActionJass.wrap(onRemoveAction), - ABActionJass.wrap(onExpireAction), showIcon, castId); + ABActionJass.wrap(onExpireAction), showIcon, castId, leveled, positive, dispellable); ability.setArtType(artType); return new HandleJassValue(buffType, ability); @@ -7961,9 +8055,12 @@ public void remove() { (arguments, globalScope, triggerScope) -> { final int buffRawcode = arguments.get(0).visit(IntegerJassValueVisitor.getInstance()); final float duration = arguments.get(1).visit(RealJassValueVisitor.getInstance()).floatValue(); + final ABLocalDataStore localStore = nullable(arguments, 2, + ObjectJassValueVisitor.getInstance()); final CBuff ability = new ABTimedTargetingBuff( - this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), duration); + this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), localStore, null, + null, duration); return new HandleJassValue(buffType, ability); }); @@ -7978,15 +8075,18 @@ public void remove() { final CodeJassValue onTickAction = nullable(arguments, 6, CodeJassValueVisitor.getInstance()); final boolean showIcon = arguments.get(7).visit(BooleanJassValueVisitor.getInstance()); final CEffectType artType = nullable(arguments, 8, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 9, + final ABLocalDataStore localStore = nullable(arguments, 9, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(10).visit(IntegerJassValueVisitor.getInstance()); + final boolean leveled = arguments.get(11).visit(BooleanJassValueVisitor.getInstance()); + final boolean positive = arguments.get(12).visit(BooleanJassValueVisitor.getInstance()); + final boolean dispellable = arguments.get(13).visit(BooleanJassValueVisitor.getInstance()); final ABTimedTickingBuff ability = new ABTimedTickingBuff( - this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), duration, - showTimedLifeBar, localStore, ABActionJass.wrap(onAddAction), + this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), localStore, null, + null, duration, showTimedLifeBar, ABActionJass.wrap(onAddAction), ABActionJass.wrap(onRemoveAction), ABActionJass.wrap(onExpireAction), - ABActionJass.wrap(onTickAction), showIcon, castId); + ABActionJass.wrap(onTickAction), showIcon, castId, leveled, positive, dispellable); ability.setArtType(artType); return new HandleJassValue(buffType, ability); @@ -8002,15 +8102,18 @@ public void remove() { final CodeJassValue onTickAction = nullable(arguments, 6, CodeJassValueVisitor.getInstance()); final boolean showIcon = arguments.get(7).visit(BooleanJassValueVisitor.getInstance()); final CEffectType artType = nullable(arguments, 8, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 9, + final ABLocalDataStore localStore = nullable(arguments, 9, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(10).visit(IntegerJassValueVisitor.getInstance()); + final boolean leveled = arguments.get(11).visit(BooleanJassValueVisitor.getInstance()); + final boolean positive = arguments.get(12).visit(BooleanJassValueVisitor.getInstance()); + final boolean dispellable = arguments.get(13).visit(BooleanJassValueVisitor.getInstance()); final ABTimedTickingPausedBuff ability = new ABTimedTickingPausedBuff( - this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), duration, - showTimedLifeBar, localStore, ABActionJass.wrap(onAddAction), + this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), localStore, null, + null, duration, showTimedLifeBar, ABActionJass.wrap(onAddAction), ABActionJass.wrap(onRemoveAction), ABActionJass.wrap(onExpireAction), - ABActionJass.wrap(onTickAction), showIcon, castId); + ABActionJass.wrap(onTickAction), showIcon, castId, leveled, positive, dispellable); ability.setArtType(artType); return new HandleJassValue(buffType, ability); @@ -8026,15 +8129,18 @@ public void remove() { final CodeJassValue onTickAction = nullable(arguments, 6, CodeJassValueVisitor.getInstance()); final boolean showIcon = arguments.get(7).visit(BooleanJassValueVisitor.getInstance()); final CEffectType artType = nullable(arguments, 8, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 9, + final ABLocalDataStore localStore = nullable(arguments, 9, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(10).visit(IntegerJassValueVisitor.getInstance()); + final boolean leveled = arguments.get(11).visit(BooleanJassValueVisitor.getInstance()); + final boolean positive = arguments.get(12).visit(BooleanJassValueVisitor.getInstance()); + final boolean dispellable = arguments.get(13).visit(BooleanJassValueVisitor.getInstance()); final ABTimedTickingPostDeathBuff ability = new ABTimedTickingPostDeathBuff( - this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), duration, - showTimedLifeBar, localStore, ABActionJass.wrap(onAddAction), + this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), localStore, null, + null, duration, showTimedLifeBar, ABActionJass.wrap(onAddAction), ABActionJass.wrap(onRemoveAction), ABActionJass.wrap(onExpireAction), - ABActionJass.wrap(onTickAction), showIcon, castId); + ABActionJass.wrap(onTickAction), showIcon, castId, leveled, positive, dispellable); ability.setArtType(artType); return new HandleJassValue(buffType, ability); @@ -8069,7 +8175,7 @@ public void remove() { final CUnit casterUnit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final int buffRawcode = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); final int level = arguments.get(2).visit(IntegerJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 3, + final ABLocalDataStore localStore = nullable(arguments, 3, ObjectJassValueVisitor.getInstance()); final CodeJassValue onAddAction = nullable(arguments, 4, CodeJassValueVisitor.getInstance()); final CodeJassValue onRemoveAction = nullable(arguments, 5, CodeJassValueVisitor.getInstance()); @@ -8079,7 +8185,7 @@ public void remove() { final CDestructableBuff ability = new ABDestructableBuff( this.simulation.getHandleIdAllocator().createId(), new War3ID(buffRawcode), level, localStore, ABActionJass.wrap(onAddAction), ABActionJass.wrap(onRemoveAction), - ABActionJass.wrap(onDeathAction), castId, casterUnit); + ABActionJass.wrap(onDeathAction), castId, casterUnit, true); return new HandleJassValue(destructablebuffType, ability); }); @@ -8092,11 +8198,11 @@ public void remove() { final float endTime = arguments.get(2).visit(RealJassValueVisitor.getInstance()).floatValue(); final String equalityId = nullable(arguments, 3, StringJassValueVisitor.getInstance()); final CUnit casterUnit = nullable(arguments, 4, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 5, + final ABLocalDataStore localStore = nullable(arguments, 5, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(6).visit(IntegerJassValueVisitor.getInstance()); - final ABTimeOfDayEvent abTimeOfDayEvent = new ABTimeOfDayEvent(this.simulation, casterUnit, + final ABTimeOfDayEvent abTimeOfDayEvent = new ABTimeOfDayEvent(casterUnit, localStore, castId, ABActionJass.wrap(actions), startTime, endTime, equalityId); return new HandleJassValue(abtimeofdayeventType, abTimeOfDayEvent); @@ -8332,7 +8438,7 @@ public void remove() { (arguments, globalScope, triggerScope) -> { final CUnit targetUnit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CUnit casterUnit = nullable(arguments, 1, ObjectJassValueVisitor.getInstance()); - final List levelData = nullable(arguments, 2, + final List levelData = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(3).visit(IntegerJassValueVisitor.getInstance()); final boolean targetedEffect = arguments.get(4).visit(BooleanJassValueVisitor.getInstance()); @@ -8372,7 +8478,7 @@ public void remove() { (arguments, globalScope, triggerScope) -> { final CWidget targetUnit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final CUnit casterUnit = nullable(arguments, 1, ObjectJassValueVisitor.getInstance()); - final List levelData = nullable(arguments, 2, + final List levelData = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); final int level = arguments.get(3).visit(IntegerJassValueVisitor.getInstance()); if (targetUnit != null) { @@ -8807,14 +8913,14 @@ public boolean call(final CUnit unit) { (arguments, globalScope, triggerScope) -> { final CUnit unit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final NonStackingStatBuff buff = arguments.get(1).visit(ObjectJassValueVisitor.getInstance()); - unit.addNonStackingStatBuff(buff); + unit.addNonStackingStatBuff(simulation, buff); return null; }); jassProgramVisitor.getJassNativeManager().createNative("RemoveUnitNonStackingStatBonus", (arguments, globalScope, triggerScope) -> { final CUnit unit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final NonStackingStatBuff buff = arguments.get(1).visit(ObjectJassValueVisitor.getInstance()); - unit.removeNonStackingStatBuff(buff); + unit.removeNonStackingStatBuff(simulation, buff); return null; }); jassProgramVisitor.getJassNativeManager().createNative("RecomputeStatBonusesOnUnit", @@ -8822,7 +8928,11 @@ public boolean call(final CUnit unit) { final CUnit unit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final NonStackingStatBuffType whichBuffType = arguments.get(1) .visit(ObjectJassValueVisitor.getInstance()); - unit.computeDerivedFields(whichBuffType); + if (whichBuffType.isHeroStat()) { + unit.computeDerivedHeroFields(simulation, whichBuffType); + } else { + unit.computeDerivedFields(whichBuffType); + } return null; }); jassProgramVisitor.getJassNativeManager().createNative("UpdateNonStackingStatBonus", @@ -8897,7 +9007,7 @@ public boolean call(final CUnit unit) { final CodeJassValue threadFunction = arguments.get(0).visit(CodeJassValueVisitor.getInstance()); final CUnit casterUnit = nullable(arguments, 1, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 2, + final ABLocalDataStore localStore = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(3).visit(IntegerJassValueVisitor.getInstance()); @@ -8909,7 +9019,7 @@ public boolean call(final CUnit unit) { jassProgramVisitor.getJassNativeManager().createNative("CreateABTimer", (arguments, globalScope, triggerScope) -> { final CUnit casterUnit = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); - final Map localStore = nullable(arguments, 1, + final ABLocalDataStore localStore = nullable(arguments, 1, ObjectJassValueVisitor.getInstance()); final int castId = arguments.get(2).visit(IntegerJassValueVisitor.getInstance()); final CodeJassValue threadFunction = nullable(arguments, 3, CodeJassValueVisitor.getInstance()); @@ -9150,9 +9260,9 @@ private static void registerAbilityUserDataHandleNatives(final JassProgram jassP (arguments, globalScope, triggerScope) -> { final CAbility abilityFromHandle = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.get(childKey); if (object != null) { return new HandleJassValue(handleType, object); @@ -9166,9 +9276,9 @@ private static void registerAbilityUserDataHandleNatives(final JassProgram jassP final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object unwrappedHandleUnderlyingJavaObject = nullable(arguments, 2, ObjectJassValueVisitor.getInstance()); - if (abilityFromHandle instanceof AbilityBuilderAbility) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) abilityFromHandle; - final Map localStore = ability.getLocalStore(); + if (abilityFromHandle instanceof ABAbilityBuilderAbility) { + final ABAbilityBuilderAbility ability = (ABAbilityBuilderAbility) abilityFromHandle; + final ABLocalDataStore localStore = ability.getLocalStore(); final Object object = localStore.put(childKey, unwrappedHandleUnderlyingJavaObject); return BooleanJassValue.of(object != null); } @@ -9177,7 +9287,7 @@ private static void registerAbilityUserDataHandleNatives(final JassProgram jassP jassProgramVisitor.getJassNativeManager().createNative("GetLocalStore" + nameSuffix + "Handle", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object object = localStore.get(childKey); @@ -9188,7 +9298,7 @@ private static void registerAbilityUserDataHandleNatives(final JassProgram jassP }); jassProgramVisitor.getJassNativeManager().createNative("SetLocalStore" + nameSuffix + "Handle", (arguments, globalScope, triggerScope) -> { - final Map localStore = nullable(arguments, 0, + final ABLocalDataStore localStore = nullable(arguments, 0, ObjectJassValueVisitor.getInstance()); final String childKey = nullable(arguments, 1, StringJassValueVisitor.getInstance()); final Object unwrappedHandleUnderlyingJavaObject = nullable(arguments, 2, @@ -9204,8 +9314,7 @@ public void main() { final JassThread abilitiesThread = this.jassProgramVisitor.getGlobals().createThread("abilities_main", Collections.emptyList(), TriggerExecutionScope.EMPTY); this.jassProgramVisitor.getGlobals().queueThread(abilitiesThread); - } - catch (final Exception exc) { + } catch (final Exception exc) { new JassException(this.jassProgramVisitor.getGlobals(), "Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc) .printStackTrace(); @@ -9214,8 +9323,7 @@ public void main() { final JassThread mainThread = this.jassProgramVisitor.getGlobals().createThread("main", Collections.emptyList(), TriggerExecutionScope.EMPTY); this.jassProgramVisitor.getGlobals().queueThread(mainThread); - } - catch (final Exception exc) { + } catch (final Exception exc) { throw new JassException(this.jassProgramVisitor.getGlobals(), "Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc); } @@ -9396,8 +9504,7 @@ public void config() { final JassThread configThread = this.jassProgramVisitor.getGlobals().createThread("config", Collections.emptyList(), TriggerExecutionScope.EMPTY); this.jassProgramVisitor.getGlobals().runThreadUntilCompletion(configThread); - } - catch (final Exception exc) { + } catch (final Exception exc) { throw new JassException(this.jassProgramVisitor.getGlobals(), "Exception on Line " + this.jassProgramVisitor.getGlobals().getLineNumber(), exc); } @@ -9594,8 +9701,7 @@ public static void registerRandomNatives(final JassProgram jassProgramVisitor, f if (lowBound > highBound) { if (highBound >= 0) { lowBound = highBound; - } - else { + } else { highBound = lowBound; } } @@ -9622,8 +9728,7 @@ private static void doPreloadScript(final DataSource dataSource, final Viewport smashJassParser.scanAndParse(filename, jassProgramVisitor); } jassProgramVisitor.initialize(); - } - catch (final Exception e) { + } catch (final Exception e) { e.printStackTrace(); JassLog.report(e); } @@ -9634,8 +9739,7 @@ private static void doPreloadScript(final DataSource dataSource, final Viewport final JassThread preloadThread = jassProgramVisitor.getGlobals().createThread(mainFunction, Collections.emptyList(), TriggerExecutionScope.EMPTY); jassProgramVisitor.getGlobals().queueThread(preloadThread); - } - catch (final Exception e) { + } catch (final Exception e) { throw new JassException(jassProgramVisitor.getGlobals(), "Unable to run: " + filename, e); } } @@ -10327,8 +10431,7 @@ public static void registerTypingNatives(final JassProgram jassProgramVisitor, f final int i = arguments.get(0).visit(IntegerJassValueVisitor.getInstance()); if (i < CAttackTypeJass.VALUES.length) { return new HandleJassValue(attacktypeType, CAttackTypeJass.VALUES[i]); - } - else { + } else { return new HandleJassValue(attacktypeType, null); } }); @@ -10459,8 +10562,7 @@ public static void registerConversionAndStringNatives(final JassProgram jassProg try { final int intValue = Integer.parseInt(s); return IntegerJassValue.of(intValue); - } - catch (final Exception exc) { + } catch (final Exception exc) { return IntegerJassValue.of(0); } }); @@ -10469,8 +10571,7 @@ public static void registerConversionAndStringNatives(final JassProgram jassProg try { final double parsedValue = Double.parseDouble(s); return RealJassValue.of(parsedValue); - } - catch (final Exception exc) { + } catch (final Exception exc) { return RealJassValue.of(0); } }); diff --git a/core/src/com/etheller/warsmash/parsers/jass/scope/CommonTriggerExecutionScope.java b/core/src/com/etheller/warsmash/parsers/jass/scope/CommonTriggerExecutionScope.java index be0edadd7..2f36b6438 100644 --- a/core/src/com/etheller/warsmash/parsers/jass/scope/CommonTriggerExecutionScope.java +++ b/core/src/com/etheller/warsmash/parsers/jass/scope/CommonTriggerExecutionScope.java @@ -1,7 +1,5 @@ package com.etheller.warsmash.parsers.jass.scope; -import java.util.Map; - import com.etheller.interpreter.ast.scope.TriggerExecutionScope; import com.etheller.interpreter.ast.scope.trigger.Trigger; import com.etheller.warsmash.util.War3ID; @@ -14,7 +12,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.COrderButton; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.COrderButton.JassOrderButtonType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayerJass; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.region.CRegion; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; @@ -90,8 +89,10 @@ public class CommonTriggerExecutionScope extends TriggerExecutionScope { private JassOrderButtonType spellAbilityTargetType; // Warsmash only private COrderButton spellAbilityOrderCommandCard; // Warsmash only private String enumFilePath; // Warsmash only - private Map triggerLocalStore; // warsmash only + private ABLocalDataStore triggerLocalStore; // warsmash only private int triggerCastId; // Warsmash only + private float damageTaken; + private CUnit damageSource; private JassGameEventsWar3 triggerEventId; @@ -172,6 +173,8 @@ private void copyFrom(final CommonTriggerExecutionScope parentScope) { this.enumFilePath = parentScope.enumFilePath; this.triggerLocalStore = parentScope.triggerLocalStore; this.triggerEventId = parentScope.triggerEventId; + this.damageTaken = parentScope.damageTaken; + this.damageSource = parentScope.damageSource; } public CUnit getEnumUnit() { @@ -446,7 +449,7 @@ public String getEnumFilePath() { return this.enumFilePath; } - public Map getTriggerLocalStore() { + public ABLocalDataStore getTriggerLocalStore() { return this.triggerLocalStore; } @@ -454,6 +457,14 @@ public int getTriggerCastId() { return this.triggerCastId; } + public float getDamageTaken() { + return this.damageTaken; + } + + public CUnit getDamageSource() { + return this.damageSource; + } + public static CommonTriggerExecutionScope filterScope(final TriggerExecutionScope parentScope, final CUnit filterUnit) { final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(parentScope.getTriggeringTrigger(), @@ -544,6 +555,16 @@ public static CommonTriggerExecutionScope unitLeaveRegionScope(final JassGameEve return scope; } + public static CommonTriggerExecutionScope simpleUnitScope(final JassGameEventsWar3 triggerEventId, + final Trigger trigger, final CUnit unit, final CPlayerJass player) { + final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY); + scope.triggeringUnit = unit; + scope.triggeringPlayer = player; + scope.triggerWidget = unit; + scope.triggerEventId = triggerEventId; + return scope; + } + public static CommonTriggerExecutionScope playerHeroLevelScope(final JassGameEventsWar3 triggerEventId, final Trigger trigger, final CUnit hero) { final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY); @@ -677,6 +698,16 @@ public static CommonTriggerExecutionScope unitConstructFinishScope(final JassGam return scope; } + public static CommonTriggerExecutionScope unitConstructCancelScope(final JassGameEventsWar3 triggerEventId, + final Trigger trigger, final CUnit cancelledStructure, final CUnit constructingUnit) { + final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY); + scope.triggerWidget = cancelledStructure; + scope.triggeringUnit = cancelledStructure; + scope.cancelledStructure = cancelledStructure; + scope.triggerEventId = triggerEventId; + return scope; + } + public static CommonTriggerExecutionScope unitTrainFinishScope(final JassGameEventsWar3 triggerEventId, final Trigger trigger, final CUnit trainingUnit, final CUnit trainedUnit) { final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY); @@ -752,6 +783,15 @@ public static CommonTriggerExecutionScope unitSpellPointScope(final JassGameEven return scope; } + public static CommonTriggerExecutionScope unitDamageTakenScope(final JassGameEventsWar3 triggerEventId, + final Trigger trigger, final CUnit damagedUnit, final CUnit source, final float damage) { + final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(trigger, TriggerExecutionScope.EMPTY); + scope.damageTaken = damage; + scope.damageSource = source; + scope.triggeringUnit = damagedUnit; + return scope; + } + public static CommonTriggerExecutionScope unitSpellNoTargetScope(final JassGameEventsWar3 triggerEventId, final Trigger trigger, final CAbility spellAbility, final CUnit spellAbilityUnit, final War3ID spellAbilityId) { @@ -889,7 +929,7 @@ public static CommonTriggerExecutionScope jassAbilityBasicScope(final CAbility s return scope; } - public static TriggerExecutionScope abilityBuilder(final CUnit caster, final Map localStore, + public static TriggerExecutionScope abilityBuilder(final CUnit caster, final ABLocalDataStore localStore, final int castId) { final CommonTriggerExecutionScope scope = new CommonTriggerExecutionScope(null, TriggerExecutionScope.EMPTY); scope.spellAbilityUnit = caster; @@ -898,12 +938,16 @@ public static TriggerExecutionScope abilityBuilder(final CUnit caster, final Map scope.triggerCastId = castId; // TODO: below: makes it easier on the outside, but it still is very bad for // performance - scope.spellTargetUnit = (CUnit) localStore.get(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - scope.spellTargetItem = (CItem) localStore.get(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId); - scope.spellTargetDestructable = (CDestructable) localStore - .get(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId); - scope.spellTargetPoint = (AbilityPointTarget) localStore.get(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + castId); - scope.spellAbility = (CAbility) localStore.get(ABLocalStoreKeys.ABILITY); + scope.spellTargetUnit = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), CUnit.class); + scope.spellTargetItem = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId), CItem.class); + scope.spellTargetDestructable = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId), CDestructable.class); + scope.spellTargetPoint = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, castId), + AbilityPointTarget.class); + scope.spellAbility = localStore.originAbility; scope.spellAbilityId = (War3ID) localStore.get(ABLocalStoreKeys.ALIAS); return scope; } diff --git a/core/src/com/etheller/warsmash/parsers/w3x/w3e/Corner.java b/core/src/com/etheller/warsmash/parsers/w3x/w3e/Corner.java index a8c5ae40d..251efe276 100644 --- a/core/src/com/etheller/warsmash/parsers/w3x/w3e/Corner.java +++ b/core/src/com/etheller/warsmash/parsers/w3x/w3e/Corner.java @@ -83,6 +83,10 @@ public void save(final LittleEndianDataOutputStream stream) throws IOException { ParseUtils.writeUInt8(stream, (short) ((this.cliffVariation << 5) | this.groundVariation)); ParseUtils.writeUInt8(stream, (short) ((this.cliffTexture << 4) + this.layerHeight)); } + + public void setGroundHeight(float groundHeight) { + this.groundHeight = groundHeight; + } public float getGroundHeight() { return this.groundHeight; diff --git a/core/src/com/etheller/warsmash/util/WarsmashConstants.java b/core/src/com/etheller/warsmash/util/WarsmashConstants.java index 1503fc85d..767624fc8 100644 --- a/core/src/com/etheller/warsmash/util/WarsmashConstants.java +++ b/core/src/com/etheller/warsmash/util/WarsmashConstants.java @@ -59,9 +59,12 @@ public class WarsmashConstants { public static String[] JASS_FILE_LIST = { "Scripts\\common.j", "Scripts\\Blizzard.j", "Scripts\\war3map.j" }; public static final float GAME_SPEED_TIME_FACTOR = 0.5f; + public static final int ONGOING_BEHAVIOR_NOTIFICATION_TICKS = (int) (0.5f / SIMULATION_STEP_TIME); public static final boolean SHOW_FPS = true; + public static List ABILITY_COMPATIBILITY = null; + public static void loadConstants(final GameObject emulatorConstants, final DataTable warsmashIni) { MAX_PLAYERS = emulatorConstants.getFieldValue("MaxPlayers"); GAME_VERSION = emulatorConstants.getFieldValue("GameVersion"); @@ -103,6 +106,7 @@ public static void loadConstants(final GameObject emulatorConstants, final DataT } } RACE_MANAGER.build(); + ABILITY_COMPATIBILITY = emulatorConstants.getFieldAsList("AbilityCompatibility"); } public static final String getGameId() { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java index 0b44d8f26..f9cd74426 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java @@ -133,6 +133,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackInstant; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackMissile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityCollisionProjectileListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; @@ -140,7 +141,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectileMissile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CCollisionProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CJassProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CPsuedoProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CPseudoProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.config.War3MapConfig; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; @@ -495,8 +496,7 @@ public GenericResource loadMapGeneric(final String path, final FetchDataTypeName final LoadGenericCallback callback) { if (this.mapMpq == null) { return this.loadGeneric(path, dataType, callback); - } - else { + } else { return this.loadGeneric(path, dataType, callback, this.dataSource); } } @@ -507,8 +507,7 @@ public static War3Map beginLoadingMap(final DataSource gameDataSource, final Str final File mapFile = new File(mapFilePath); if (mapFile.exists()) { return new War3Map(gameDataSource, mapFile); - } - else { + } else { throw new IllegalArgumentException("No such map file: " + mapFilePath); } } @@ -525,8 +524,7 @@ public WTS preloadWTS(final War3Map map) { try { this.preloadedWTS = Warcraft3MapObjectData.loadWTS(map); return this.preloadedWTS; - } - catch (final IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } } @@ -563,8 +561,7 @@ public SimulationRenderComponentLightning createLightning(final War3ID lightning source.setLifeSpanRemaining(duration); target.setLifeSpanRemaining(duration); } - } - else { + } else { source.setLifeSpanRemaining(lightningEffectModel.getDuration()); target.setLifeSpanRemaining(lightningEffectModel.getDuration()); } @@ -619,8 +616,7 @@ public void spawnFxOnOrigin(final RenderUnit renderUnit, final String heroLevelU if ((index != -1) && false) { final MdxNode attachment = renderUnit.instance.getAttachment(index); modelInstance.setParent(attachment); - } - else { + } else { modelInstance.setLocation(renderUnit.location); } @@ -655,8 +651,7 @@ private void loadSounds() { public void loadAfterUI() throws IOException { if (this.unitsAndItemsLoaded) { loadUnitsAndItems(this.allObjectData, this.lastLoadedMapInformation); - } - else { + } else { throw new IllegalStateException("transcription of JS has not loaded a map and has no JS async promises"); } @@ -736,14 +731,12 @@ private void loadDoodadsAndDestructibles(final Warcraft3MapRuntimeObjectData mod pathingTextureImage = TgaFile.readTGA(pathingTexture, this.mapMpq.getResourceAsStream(pathingTexture)); this.filePathToPathingMap.put(pathingTexture.toLowerCase(), pathingTextureImage); - } - catch (final Exception exc) { + } catch (final Exception exc) { exc.printStackTrace(); } } } - } - else { + } else { pathingTextureImage = null; } if (pathingTextureImage != null) { @@ -856,8 +849,7 @@ private void createDestructableOrDoodad(final War3ID doodadId, final Warcraft3Ma if (row != null) { createNewDestructable(doodadId, row, doodadVariation, location, facingRadians, lifePercent, scale); } - } - else { + } else { createDoodad(row, doodadVariation, location, facingRadians, scale); } } @@ -886,15 +878,13 @@ private MdxModel getDoodadModel(final int doodadVariation, final GameObject row) String path; if (this.mapMpq.has(fileVar)) { path = fileVar; - } - else { + } else { path = file; } MdxModel model; if (this.mapMpq.has(path)) { model = (MdxModel) load(path, this.mapPathSolver, this.solverParams); - } - else { + } else { model = (MdxModel) load(fileVar, this.mapPathSolver, this.solverParams); } return model; @@ -944,7 +934,6 @@ private void loadUnitsAndItems(final Warcraft3MapRuntimeObjectData modifications throws IOException { final War3Map mpq = this.mapMpq; this.unitsReady = false; - this.renderUnitTypeData = new RenderUnitTypeData(modifications.getUnits(), mpq, this, this.unitAckSoundsTable, this.terrain.uberSplatTable); this.renderItemTypeData = new RenderItemTypeData(modifications.getItems(), mpq, this, this.miscData); @@ -962,15 +951,12 @@ private void loadUnitsAndItems(final Warcraft3MapRuntimeObjectData modifications final int customTeamColor = unit.getCustomTeamColor(); final float unitAngle = unit.getAngle(); final int editorConfigHitPointPercent = unit.getHitpoints(); + final int editorConfigManaAmount = unit.getMana(); final CWidget widgetCreated = createNewUnit(modifications, unitId, unitX, unitY, playerIndex, - customTeamColor, unitAngle); + customTeamColor, unitAngle, editorConfigHitPointPercent, editorConfigManaAmount); if (widgetCreated instanceof CUnit) { final CUnit unitCreated = (CUnit) widgetCreated; - if (editorConfigHitPointPercent > 0) { - unitCreated.setLife(this.simulation, - unitCreated.getMaximumLife() * (editorConfigHitPointPercent / 100f)); - } if (unit.getGoldAmount() != 0) { unitCreated.setGold(unit.getGoldAmount()); } @@ -987,6 +973,12 @@ private void loadUnitsAndItems(final Warcraft3MapRuntimeObjectData modifications private CWidget createNewUnit(final Warcraft3MapRuntimeObjectData modifications, final War3ID unitId, float unitX, float unitY, final int playerIndex, int customTeamColor, final float unitAngle) { + return createNewUnit(modifications, unitId, unitX, unitY, playerIndex, customTeamColor, unitAngle, -1, -1); + } + + private CWidget createNewUnit(final Warcraft3MapRuntimeObjectData modifications, final War3ID unitId, float unitX, + float unitY, final int playerIndex, int customTeamColor, final float unitAngle, + int editorConfigHitPointPercent, int editorConfigManaAmount) { Splat buildingUberSplat = null; SplatMover buildingUberSplatDynamicIngame = null; BufferedImage buildingPathingPixelMap = null; @@ -996,8 +988,7 @@ private CWidget createNewUnit(final Warcraft3MapRuntimeObjectData modifications, if (sloc.equals(unitId)) { // path = "Objects\\StartLocation\\StartLocation.mdx"; this.startLocations[playerIndex] = new Vector2(unitX, unitY); - } - else { + } else { final RenderUnitType renderUnitType = this.renderUnitTypeData.get(unitId); if (renderUnitType == null) { final RenderItemType renderItemType = this.renderItemTypeData.get(unitId); @@ -1014,24 +1005,21 @@ private CWidget createNewUnit(final Warcraft3MapRuntimeObjectData modifications, renderItem.shadow = createUnitShadow(renderItemType.getRenderShadowType(), unitX, unitY); return simulationItem; - } - else { + } else { System.err.println("Unknown unit ID: " + unitId); } - } - else { + } else { buildingPathingPixelMap = renderUnitType.getBuildingPathingPixelMap(); final float angle = (float) Math.toDegrees(unitAngle); final CUnit simulationUnit = this.simulation.internalCreateUnit(unitId, playerIndex, unitX, unitY, - angle, buildingPathingPixelMap); + angle, buildingPathingPixelMap, editorConfigHitPointPercent, editorConfigManaAmount); unitX = simulationUnit.getX(); unitY = simulationUnit.getY(); if (!renderUnitType.isAllowCustomTeamColor() || (customTeamColor == -1)) { if (renderUnitType.getTeamColor() != -1) { customTeamColor = renderUnitType.getTeamColor(); - } - else { + } else { customTeamColor = this.simulation.getPlayer(playerIndex).getColor(); } } @@ -1043,8 +1031,7 @@ private CWidget createNewUnit(final Warcraft3MapRuntimeObjectData modifications, if (texturePath != null) { if (this.unitsReady) { buildingUberSplatDynamicIngame = addUberSplatIngame(unitX, unitY, texturePath, s); - } - else { + } else { if (!this.terrain.splats.containsKey(texturePath)) { this.terrain.splats.put(texturePath, new Splat()); } @@ -1115,16 +1102,14 @@ public BufferedImage loadPathingTexture(final String pathingTexture) { if (pathingTexture.toLowerCase().endsWith(".tga")) { buildingPathingPixelMap = TgaFile.readTGA(pathingTexture, this.mapMpq.getResourceAsStream(pathingTexture)); - } - else { + } else { try (InputStream stream = this.mapMpq.getResourceAsStream(pathingTexture)) { buildingPathingPixelMap = ImageIO.read(stream); System.out.println("LOADING BLP PATHING: " + pathingTexture); } } this.filePathToPathingMap.put(pathingTexture.toLowerCase(), buildingPathingPixelMap); - } - catch (final Exception exc) { + } catch (final Exception exc) { System.err.println("Failure to get pathing: " + exc.getClass() + ":" + exc.getMessage()); } } @@ -1184,8 +1169,7 @@ public void update() { this.updateTime -= WarsmashConstants.SIMULATION_STEP_TIME; this.simulation.update(); this.gameTurnManager.turnCompleted(this.simulation.getGameTurnTick()); - } - else { + } else { if (this.updateTime > (WarsmashConstants.SIMULATION_STEP_TIME * 3)) { this.gameTurnManager.framesSkipped(this.updateTime / WarsmashConstants.SIMULATION_STEP_TIME); this.updateTime = 0; @@ -1304,12 +1288,13 @@ public void doSelectUnit(final List units) { path += ".blp"; } if (unit instanceof RenderUnit) { - final int selectedUnitPlayerIndex = ((RenderUnit) unit).getSimulationUnit().getPlayerIndex(); + final int selectedUnitPlayerIndex = ((RenderUnit) unit).getSimulationUnit().getFakePlayerIndex(); final CPlayer localPlayer = this.simulation.getPlayer(this.localPlayerIndex); if (!localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.PASSIVE)) { allyKey = "e:"; - } - else if (localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.SHARED_CONTROL)) { + } else if (localPlayer.hasAlliance(((RenderUnit) unit).getSimulationUnit().getPlayerIndex(), + CAllianceType.SHARED_CONTROL) + || localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.SHARED_CONTROL)) { allyKey = "f:"; } } @@ -1327,8 +1312,7 @@ else if (localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.SHARED_C if (unit.getInstance().hidden()) { splatInstance.hide(); } - } - else { + } else { if (!splats.containsKey(path)) { splats.put(path, new Splat()); } @@ -1424,12 +1408,12 @@ public void showUnitMouseOverHighlight(final RenderWidget unit) { } if (unit instanceof RenderUnit) { final CUnit simulationUnit = ((RenderUnit) unit).getSimulationUnit(); - final int selectedUnitPlayerIndex = simulationUnit.getPlayerIndex(); + final int selectedUnitPlayerIndex = simulationUnit.getFakePlayerIndex(); final CPlayer localPlayer = this.simulation.getPlayer(this.localPlayerIndex); if (!localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.PASSIVE)) { allyKey = "e:"; - } - else if (localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.SHARED_CONTROL)) { + } else if (localPlayer.hasAlliance(simulationUnit.getPlayerIndex(), CAllianceType.SHARED_CONTROL) + || localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.SHARED_CONTROL)) { allyKey = "f:"; } } @@ -1447,8 +1431,7 @@ else if (localPlayer.hasAlliance(selectedUnitPlayerIndex, CAllianceType.SHARED_C if (unit.getInstance().hidden()) { splatInstance.hide(); } - } - else { + } else { if (!splats.containsKey(path)) { splats.put(path, new Splat()); } @@ -1517,8 +1500,7 @@ public void getClickLocation(final Vector3 out, final int screenX, final int scr if (intersectWithWater) { RenderMathUtils.intersectRayTriangles(gdxRayHeap, this.terrain.softwareWaterAndGroundMesh.vertices, this.terrain.softwareWaterAndGroundMesh.indices, 3, out); - } - else { + } else { RenderMathUtils.intersectRayTriangles(gdxRayHeap, this.terrain.softwareGroundMesh.vertices, this.terrain.softwareGroundMesh.indices, 3, out); } @@ -1527,8 +1509,7 @@ public void getClickLocation(final Vector3 out, final int screenX, final int scr this.walkableObjectsTree.intersect(rectangleHeap, this.walkablesIntersectionFinder.reset(gdxRayHeap)); if (this.walkablesIntersectionFinder.found) { out.set(this.walkablesIntersectionFinder.intersection); - } - else { + } else { final float oldZ = out.z; out.z = Math.max(getWalkableRenderHeight(out.x, out.y), this.terrain.getGroundHeight(out.x, out.y)); @@ -1585,8 +1566,7 @@ public RenderWidget rayPickUnit(final float x, final float y, final CWidgetFilte if (intersectionHeap.z > groundHeight) { if ((entity == null) && !unit.isIntersectedOnMeshAlways()) { entity = unit; - } - else { + } else { if (instance.intersectRayWithMeshSlow(gdxRayHeap, intersectionHeap)) { if (intersectionHeap.z > this.terrain.getGroundHeight(intersectionHeap.x, intersectionHeap.y)) { @@ -1615,11 +1595,9 @@ public Object call(final InputStream data) { stringBuilder.append(line); stringBuilder.append("\n"); } - } - catch (final UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); - } - catch (final IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } return new MappedData(stringBuilder.toString()); @@ -1639,11 +1617,9 @@ public Object call(final InputStream data) { stringBuilder.append(line); stringBuilder.append("\n"); } - } - catch (final UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); - } - catch (final IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } return stringBuilder.toString(); @@ -1771,8 +1747,7 @@ public String blp(String iconPath) { public SceneLightManager createLightManager(final boolean simple) { if (simple) { return new W3xScenePortraitLightManager(this, this.lightDirection); - } - else { + } else { return new W3xSceneWorldLightManager(this); } } @@ -2014,8 +1989,7 @@ public List getEffectAttachmentUIList(final War3ID alias, fi default: throw new IllegalArgumentException("Unsupported effect type: " + effectType); } - } - else { + } else { final BuffUI buffUI = War3MapViewer.this.abilityDataUI.getBuffUI(alias); if (buffUI != null) { switch (effectType) { @@ -2029,13 +2003,12 @@ public List getEffectAttachmentUIList(final War3ID alias, fi effectAttachmentUI = buffUI.getSpecialArt(); break; case MISSILE: - effectAttachmentUI = buffUI.getMissileArt(); + effectAttachmentUI = new ArrayList<>(buffUI.getMissileArt()); break; default: throw new IllegalArgumentException("Unsupported effect type: " + effectType); } - } - else { + } else { return null; } } @@ -2068,8 +2041,7 @@ public EffectAttachmentUI getEffectAttachmentUI(final War3ID alias, final CEffec default: throw new IllegalArgumentException("Unsupported effect type: " + effectType); } - } - else { + } else { final BuffUI buffUI = War3MapViewer.this.abilityDataUI.getBuffUI(alias); if (buffUI != null) { switch (effectType) { @@ -2088,8 +2060,7 @@ public EffectAttachmentUI getEffectAttachmentUI(final War3ID alias, final CEffec default: throw new IllegalArgumentException("Unsupported effect type: " + effectType); } - } - else { + } else { return null; } } @@ -2119,8 +2090,7 @@ public RenderSpellEffect addSpecialEffectTarget(final String modelName, final CW + "\", attachPointName=\"" + attachPointNames + "\""); if (WarsmashConstants.ENABLE_DEBUG) { throw nullPointerException; - } - else { + } else { nullPointerException.printStackTrace(); } } @@ -2153,15 +2123,13 @@ public RenderSpellEffect addSpecialEffectTarget(final String modelName, final CW final MdxNode attachment = renderUnit.instance.getAttachment(index); modelInstance.setParent(attachment); modelInstance.setLocation(0, 0, 0); - } - else { + } else { // TODO This is not consistent with War3, is it? Should look nice though. modelInstance.setLocation(renderUnit.location); yaw = (float) Math.toRadians(renderUnit.getSimulationUnit().getFacing()); } } - } - else { + } else { modelInstance.setLocation(0, 0, 0); } modelInstance.setScene(War3MapViewer.this.worldScene); @@ -2173,14 +2141,67 @@ public RenderSpellEffect addSpecialEffectTarget(final String modelName, final CW War3MapViewer.this.projectiles.add(renderAttackInstant); return renderAttackInstant; } - } - else if (targetWidget instanceof CItem) { + } else if (targetWidget instanceof CItem) { // TODO this is stupid api, who would do this? throw new UnsupportedOperationException("API for addSpecialEffectTarget() on item is NYI"); - } - else if (targetWidget instanceof CDestructable) { - // TODO this is stupid api, who would do this? - throw new UnsupportedOperationException("API for addSpecialEffectTarget() on destructable is NYI"); + } else if (targetWidget instanceof CDestructable) { + if (attachPointNames.isEmpty() || ((attachPointNames.size() == 1) && attachPointNames.get(0).isEmpty())) { + attachPointNames = ORIGIN_STRING_LIST; + } + final RenderDestructable renderDest = War3MapViewer.this.destructableToRenderPeer.get(targetWidget); + + if (renderDest == null) { + final NullPointerException nullPointerException = new NullPointerException( + "renderDest is null! targetWidget is \"" + + ((CDestructable) targetWidget).getDestType().getName() + "\", attachPointName=\"" + + attachPointNames + "\""); + if (WarsmashConstants.ENABLE_DEBUG) { + throw nullPointerException; + } else { + nullPointerException.printStackTrace(); + } + } + final MdxModel spawnedEffectModel = loadModelMdx(modelName); + if (spawnedEffectModel != null) { + final MdxComplexInstance modelInstance = (MdxComplexInstance) spawnedEffectModel.addInstance(); + if (renderDest != null) { + { + final MdxModel model = (MdxModel) renderDest.instance.model; + int index = -1; + int bestFitAttachmentNameLength = Integer.MAX_VALUE; + for (int i = 0; i < model.attachments.size(); i++) { + final Attachment attachment = model.attachments.get(i); + boolean match = true; + for (final String attachmentPointNameToken : attachPointNames) { + if (!attachment.getName().contains(attachmentPointNameToken)) { + match = false; + } + } + final int attachmentNameLength = attachment.getName().length(); + if (match && (attachmentNameLength < bestFitAttachmentNameLength)) { + index = i; + bestFitAttachmentNameLength = attachmentNameLength; + } + } + if (index != -1) { + modelInstance.detach(); + final MdxNode attachment = renderDest.getInstance().getAttachment(index); + modelInstance.setParent(attachment); + modelInstance.setLocation(0, 0, 0); + } else { + // TODO This is not consistent with War3, is it? Should look nice though. + modelInstance.setLocation(renderDest.getX(), renderDest.getY(), 0); + } + } + } else { + modelInstance.setLocation(0, 0, 0); + } + modelInstance.setScene(War3MapViewer.this.worldScene); + final RenderSpellEffect renderAttackInstant = new RenderSpellEffect(modelInstance, War3MapViewer.this, + 0, RenderSpellEffect.DEFAULT_ANIMATION_QUEUE, SequenceUtils.EMPTY); + War3MapViewer.this.projectiles.add(renderAttackInstant); + return renderAttackInstant; + } } return null; } @@ -2215,8 +2236,7 @@ public static MdxModel loadModelMdx(final DataSource dataSource, final ModelView final String mdxPath = mdx(path); if (dataSource.has(mdxPath)) { return (MdxModel) modelViewer.load(mdxPath, pathSolver, solverParams); - } - else { + } else { final String mdlPath = mdl(mdxPath); if (dataSource.has(mdlPath)) { return (MdxModel) modelViewer.load(mdlPath, pathSolver, solverParams); @@ -2249,8 +2269,7 @@ public void setBlight(float whichLocationX, float whichLocationY, final float ra final GroundTexture currentTex = this.terrain.groundTextures.get(corner.getGroundTexture()); if (currentTex.isBuildable()) { changedData |= corner.setBlight(blighted); - } - else { + } else { continue; } @@ -2325,23 +2344,20 @@ private MapLoader(final War3Map war3Map, final War3MapW3i w3iFile, final int loc dataSources.add(compoundDataSource); if (WarsmashConstants.FIX_FLAT_FILES_TILESET_LOADING) { dataSources.add(new SubdirDataSource(compoundDataSource, this.tileset + ".mpq/")); - } - else { + } else { try (InputStream mapStream = compoundDataSource.getResourceAsStream(this.tileset + ".mpq")) { if (mapStream == null) { dataSources.add(new SubdirDataSource(compoundDataSource, this.tileset + ".mpq/")); dataSources.add(new SubdirDataSource(compoundDataSource, "_tilesets/" + this.tileset + ".w3mod/")); - } - else { + } else { final byte[] mapData = IOUtils.toByteArray(mapStream); sbc = new SeekableInMemoryByteChannel(mapData); final DataSource internalMpqContentsDataSource = new MpqDataSource(new MPQArchive(sbc), sbc); dataSources.add(internalMpqContentsDataSource); } - } - catch (final IOException exc) { + } catch (final IOException exc) { dataSources.add(new SubdirDataSource(compoundDataSource, this.tileset + ".mpq/")); dataSources.add( new SubdirDataSource(compoundDataSource, "_tilesets/" + this.tileset + ".w3mod/")); @@ -2354,15 +2370,13 @@ private MapLoader(final War3Map war3Map, final War3MapW3i w3iFile, final int loc // Custom data dataSources.add(new SubdirDataSource(compoundDataSource, "Custom_V" + WarsmashConstants.GAME_VERSION + "\\")); - } - else { + } else { // Melee data dataSources.add(new SubdirDataSource(compoundDataSource, "Melee_V" + WarsmashConstants.GAME_VERSION + "\\")); } this.tilesetSource = new CompoundDataSource(dataSources); - } - catch (final MPQException e) { + } catch (final MPQException e) { throw new RuntimeException(e); } }); @@ -2423,8 +2437,7 @@ private MapLoader(final War3Map war3Map, final War3MapW3i w3iFile, final int loc if (War3MapViewer.this.preloadedWTS != null) { War3MapViewer.this.allObjectData = War3MapViewer.this.mapMpq .readModifications(War3MapViewer.this.preloadedWTS); - } - else { + } else { War3MapViewer.this.allObjectData = War3MapViewer.this.mapMpq.readModifications(); } }); @@ -2438,16 +2451,21 @@ private MapLoader(final War3Map war3Map, final War3MapW3i w3iFile, final int loc new SimulationRenderController() { private final Map keyToCombatSound = new HashMap<>(); + @Override + public char getTileset() { + return War3MapViewer.this.solverParams.tileset; + } + @Override public CAttackProjectile createAttackProjectile(final CSimulation simulation, final float launchX, final float launchY, final float launchFacing, final CUnit source, final CUnitAttackMissile unitAttack, final AbilityTarget target, - final float damage, final int bounceIndex, - final CUnitAttackListener attackListener) { + final float damage, final int bounceIndex, final CUnitAttackListener attackListener, + final CUnitAttackSettings settings) { final War3ID typeId = source.getTypeId(); - final int projectileSpeed = unitAttack.getProjectileSpeed(); - final float projectileArc = unitAttack.getProjectileArc(); - final String missileArt = unitAttack.getProjectileArt(); + final int projectileSpeed = settings.getProjectileSpeed(); + final float projectileArc = settings.getProjectileArc(); + final String missileArt = settings.getProjectileArt(); final float projectileLaunchX = simulation.getUnitData().getProjectileLaunchX(typeId); final float projectileLaunchY = simulation.getUnitData().getProjectileLaunchY(typeId); final float projectileLaunchZ = simulation.getUnitData().getProjectileLaunchZ(typeId); @@ -2461,10 +2479,11 @@ public CAttackProjectile createAttackProjectile(final CSimulation simulation, - (projectileLaunchX * cosFacing); final float height = War3MapViewer.this.terrain.getGroundHeight(x, y) - + source.getFlyHeight() + projectileLaunchZ; + + (settings.getZ() != null ? settings.getZ() + : (source.getFlyHeight() + projectileLaunchZ)); final CAttackProjectile simulationAttackProjectile = new CAttackProjectileMissile(x, y, projectileSpeed, target, source, damage, unitAttack, bounceIndex, - attackListener); + attackListener, settings); final MdxModel model = loadModelMdx(missileArt); if (model != null) { @@ -2473,14 +2492,19 @@ public CAttackProjectile createAttackProjectile(final CSimulation simulation, modelInstance.setScene(War3MapViewer.this.worldScene); if (bounceIndex == 0) { SequenceUtils.randomBirthSequence(modelInstance); - } - else { + } else { SequenceUtils.randomStandSequence(modelInstance); } modelInstance.setLocation(x, y, height); final RenderProjectile renderAttackProjectile = new RenderProjectile( simulationAttackProjectile, modelInstance, height, projectileArc, War3MapViewer.this); + if (settings.getImpactZ() != null) { + renderAttackProjectile.setImpactZ(War3MapViewer.this, settings.getImpactZ()); + } + if (settings.getArtDeathTime() != null) { + renderAttackProjectile.setDeathTime(settings.getArtDeathTime()); + } War3MapViewer.this.projectiles.add(renderAttackProjectile); } @@ -2491,15 +2515,16 @@ public CAttackProjectile createAttackProjectile(final CSimulation simulation, @Override public CAbilityProjectile createProjectile(final CSimulation cSimulation, final float launchX, final float launchY, final float launchFacing, - final float projectileSpeed, final boolean homing, final CUnit source, + final Float projectileSpeed, final Boolean homing, final CUnit source, final War3ID spellAlias, final AbilityTarget target, final CAbilityProjectileListener projectileListener) { final War3ID typeId = source.getTypeId(); final AbilityUI spellDataUI = War3MapViewer.this.abilityDataUI.getUI(spellAlias); final EffectAttachmentUIMissile abilityMissileArt = spellDataUI.getMissileArt(0); - final String modelPath = abilityMissileArt == null ? "" - : abilityMissileArt.getModelPath(); final float projectileArc = abilityMissileArt == null ? 0 : abilityMissileArt.getArc(); + final float pSpeed = projectileSpeed == null ? abilityMissileArt.getSpeed() + : projectileSpeed; + final boolean pHome = homing == null ? abilityMissileArt.isHoming() : homing; final String missileArt = abilityMissileArt == null ? "" : abilityMissileArt.getModelPath(); final float projectileLaunchX = War3MapViewer.this.simulation.getUnitData() @@ -2519,6 +2544,54 @@ public CAbilityProjectile createProjectile(final CSimulation cSimulation, final float height = War3MapViewer.this.terrain.getGroundHeight(x, y) + source.getFlyHeight() + projectileLaunchZ; + final CAbilityProjectile simulationAbilityProjectile = new CAbilityProjectile(x, y, + pSpeed, target, pHome, source, projectileListener); + + final MdxModel model = loadModelMdx(missileArt); + final MdxComplexInstance modelInstance = (MdxComplexInstance) model.addInstance(); + + final RenderUnit renderPeer = getRenderPeer(source); + modelInstance.setTeamColor(renderPeer.playerIndex); + modelInstance.setScene(War3MapViewer.this.worldScene); + SequenceUtils.randomBirthSequence(modelInstance); + modelInstance.setLocation(x, y, height); + final RenderProjectile renderProjectile = new RenderProjectile( + simulationAbilityProjectile, modelInstance, height, projectileArc, + War3MapViewer.this); + + War3MapViewer.this.projectiles.add(renderProjectile); + + return simulationAbilityProjectile; + } + + @Override + public CAbilityProjectile createProjectile(final CSimulation cSimulation, + final float launchX, final float launchY, final float launchFacing, + final CUnit source, final CUnitAttackSettings settings, final AbilityTarget target, + final CAbilityProjectileListener projectileListener) { + final War3ID typeId = source.getTypeId(); + final int projectileSpeed = settings.getProjectileSpeed(); + final float projectileArc = settings.getProjectileArc(); + final String missileArt = settings.getProjectileArt(); + final boolean homing = settings.isProjectileHomingEnabled(); + final float projectileLaunchX = War3MapViewer.this.simulation.getUnitData() + .getProjectileLaunchX(typeId); + final float projectileLaunchY = War3MapViewer.this.simulation.getUnitData() + .getProjectileLaunchY(typeId); + final float projectileLaunchZ = War3MapViewer.this.simulation.getUnitData() + .getProjectileLaunchZ(typeId); + + final float facing = launchFacing; + final float sinFacing = (float) Math.sin(facing); + final float cosFacing = (float) Math.cos(facing); + final float x = launchX + (projectileLaunchY * cosFacing) + + (projectileLaunchX * sinFacing); + final float y = (launchY + (projectileLaunchY * sinFacing)) + - (projectileLaunchX * cosFacing); + + final float height = War3MapViewer.this.terrain.getGroundHeight(x, y) + + (settings.getZ() != null ? settings.getZ() + : (source.getFlyHeight() + projectileLaunchZ)); final CAbilityProjectile simulationAbilityProjectile = new CAbilityProjectile(x, y, projectileSpeed, target, homing, source, projectileListener); @@ -2533,6 +2606,13 @@ public CAbilityProjectile createProjectile(final CSimulation cSimulation, final RenderProjectile renderProjectile = new RenderProjectile( simulationAbilityProjectile, modelInstance, height, projectileArc, War3MapViewer.this); + if (settings.getImpactZ() != null) { + System.err.println("Setting impact Z to: " + settings.getImpactZ()); + renderProjectile.setImpactZ(War3MapViewer.this, settings.getImpactZ()); + } + if (settings.getArtDeathTime() != null) { + renderProjectile.setDeathTime(settings.getArtDeathTime()); + } War3MapViewer.this.projectiles.add(renderProjectile); @@ -2590,7 +2670,7 @@ public CJassProjectile createJassProjectile(final CSimulation cSimulation, @Override public CCollisionProjectile createCollisionProjectile(final CSimulation cSimulation, final float launchX, final float launchY, final float launchFacing, - final float projectileSpeed, final boolean homing, final CUnit source, + final Float projectileSpeed, final Boolean homing, final CUnit source, final War3ID spellAlias, final AbilityTarget target, final int maxHits, final int hitsPerTarget, final float startingRadius, final float finalRadius, final float collisionInterval, @@ -2600,6 +2680,9 @@ public CCollisionProjectile createCollisionProjectile(final CSimulation cSimulat final AbilityUI spellDataUI = War3MapViewer.this.abilityDataUI.getUI(spellAlias); final EffectAttachmentUIMissile abilityMissileArt = spellDataUI.getMissileArt(0); final float projectileArc = abilityMissileArt == null ? 0 : abilityMissileArt.getArc(); + final float pSpeed = projectileSpeed == null ? abilityMissileArt.getSpeed() + : projectileSpeed; + final boolean pHome = homing == null ? abilityMissileArt.isHoming() : homing; final String missileArt = abilityMissileArt == null ? "" : abilityMissileArt.getModelPath(); final float projectileLaunchX = War3MapViewer.this.simulation.getUnitData() @@ -2620,7 +2703,7 @@ public CCollisionProjectile createCollisionProjectile(final CSimulation cSimulat final float height = War3MapViewer.this.terrain.getGroundHeight(x, y) + source.getFlyHeight() + projectileLaunchZ; final CCollisionProjectile simulationAbilityProjectile = new CCollisionProjectile(x, y, - projectileSpeed, target, homing, source, maxHits, hitsPerTarget, startingRadius, + pSpeed, target, pHome, source, maxHits, hitsPerTarget, startingRadius, finalRadius, collisionInterval, projectileListener, provideCounts); final MdxModel model = loadModelMdx(missileArt); @@ -2643,7 +2726,7 @@ public CCollisionProjectile createCollisionProjectile(final CSimulation cSimulat } @Override - public CPsuedoProjectile createPseudoProjectile(final CSimulation cSimulation, + public CPseudoProjectile createPseudoProjectile(final CSimulation cSimulation, final float launchX, final float launchY, final float launchFacing, final float projectileSpeed, final float projectileStepInterval, final int projectileArtSkip, final boolean homing, final CUnit source, @@ -2667,7 +2750,7 @@ public CPsuedoProjectile createPseudoProjectile(final CSimulation cSimulation, final float y = (launchY + (projectileLaunchY * sinFacing)) - (projectileLaunchX * cosFacing); - final CPsuedoProjectile simulationAbilityProjectile = new CPsuedoProjectile(x, y, + final CPseudoProjectile simulationAbilityProjectile = new CPseudoProjectile(x, y, projectileSpeed, projectileStepInterval, projectileArtSkip, target, homing, source, spellAlias, effectType, effectArtIndex, maxHits, hitsPerTarget, startingRadius, finalRadius, projectileListener, provideCounts); @@ -2751,6 +2834,35 @@ public SimulationRenderComponentLightning createAbilityLightning( renderPeerTarget, duration); } + @Override + public SimulationRenderComponent createStaticUberSplat(final float x, final float y, + final War3ID uberId) { + if (uberId != null) { + final Element uberSplatInfo = War3MapViewer.this.terrain.uberSplatTable + .get(uberId.asStringValue()); + if (uberSplatInfo != null) { + String uberSplatTexturePath = uberSplatInfo.getField("Dir") + "\\" + + uberSplatInfo.getField("file") + ".blp"; + float uberSplatScaleValue = uberSplatInfo.getFieldFloatValue("Scale"); + final SplatMover buildingUberSplatDynamicIngame = War3MapViewer.this.terrain + .addUberSplat(uberSplatTexturePath, x, y, 1, uberSplatScaleValue, false, + false, false, false); + return new SimulationRenderComponent() { + @Override + public void remove() { + buildingUberSplatDynamicIngame.destroy(Gdx.gl30, + War3MapViewer.this.terrain.centerOffset); + } + }; + } + } + return new SimulationRenderComponent() { + @Override + public void remove() { + } + }; + } + @Override public void spawnDamageSound(final CWidget damagedDestructable, final String weaponSound, final String armorType) { @@ -2932,15 +3044,29 @@ public CItem createItem(final CSimulation simulation, final War3ID typeId, final .getBuildingAngle())); } + @Override + public void updateItemModel(CItem item) { + RenderItem ri = War3MapViewer.this.getRenderPeer(item); + RenderItemType rit = War3MapViewer.this.renderItemTypeData.get(item.getTypeId()); + if (ri != null && rit != null) { + ri.updateItemModel(War3MapViewer.this, rit); + } + } + @Override public void spawnDeathExplodeEffect(final CUnit source, final War3ID explodesOnDeathBuffId) { final RenderUnit renderUnit = War3MapViewer.this.unitToRenderPeer.get(source); MdxComplexInstance modelInstance = null; if (explodesOnDeathBuffId != null) { - final EffectAttachmentUI effectAttachmentUI = getEffectAttachmentUI( - explodesOnDeathBuffId, CEffectType.EFFECT, 0); - final String modelPath = effectAttachmentUI.getModelPath(); + EffectAttachmentUI effectAttachmentUI = getEffectAttachmentUI(explodesOnDeathBuffId, + CEffectType.EFFECT, 0); + String modelPath = effectAttachmentUI.getModelPath(); + if (modelPath == null || modelPath.isEmpty()) { + effectAttachmentUI = getEffectAttachmentUI(explodesOnDeathBuffId, + CEffectType.SPECIAL, 0); + modelPath = effectAttachmentUI.getModelPath(); + } final MdxModel spawnedEffectModel = loadModelMdx(modelPath); if (spawnedEffectModel != null) { modelInstance = (MdxComplexInstance) spawnedEffectModel.addInstance(); @@ -3144,7 +3270,8 @@ public void unitRepositioned(final CUnit cUnit) { } @Override - public void unitUpdatedType(final CUnit simulationUnit, final War3ID typeId) { + public void unitUpdatedType(final CUnit simulationUnit, final War3ID typeId, + final boolean updatePortrait) { final RenderUnit renderPeer = War3MapViewer.this.unitToRenderPeer.get(simulationUnit); final RenderUnitType typeData = getUnitTypeData(typeId); @@ -3171,9 +3298,24 @@ public void unitUpdatedType(final CUnit simulationUnit, final War3ID typeId) { renderPeer.resetRenderUnit(War3MapViewer.this, unitX, unitY, unitZ, customTeamColor /* renderPeer.playerIndex */, simulationUnit, typeData, - buildingShadowInstance, War3MapViewer.this.selectionCircleScaleFactor, - typeData.getAnimationWalkSpeed(), typeData.getAnimationRunSpeed(), - typeData.getScalingValue()); + updatePortrait, buildingShadowInstance, + War3MapViewer.this.selectionCircleScaleFactor, typeData.getAnimationWalkSpeed(), + typeData.getAnimationRunSpeed(), typeData.getScalingValue()); + } + + @Override + public void changeUnitScale(final CUnit unit, final float scale, final boolean multiplier) { + final RenderUnit renderPeer = War3MapViewer.this.unitToRenderPeer.get(unit); + if (multiplier) { + renderPeer.selectionScale *= scale; + Vector3 newScale = new Vector3(renderPeer.instance.localScale); + newScale.scl(scale); + renderPeer.instance.setScale(new float[] { newScale.x, newScale.y, newScale.z }); + } else { + renderPeer.selectionScale = scale; + renderPeer.instance.setScale(new float[] { scale, scale, scale }); + } + } @Override @@ -3245,17 +3387,16 @@ public TextTag spawnTextTag(final CUnit unit, final TextTagConfigType configType final Vector3 unitPosition; if (renderPeer != null) { unitPosition = new Vector3(renderPeer.location); - } - else if (unit != null) { + } else if (unit != null) { // try to fudge it and spawn in place of stale unit unitPosition = new Vector3(unit.getX(), unit.getY(), War3MapViewer.this.terrain.getGroundHeight(unit.getX(), unit.getY())); - } - else { + } else { unitPosition = new Vector3(0, 0, 0); } - final TextTag textTag = new TextTag(unitPosition, new Vector2(0, 60f), message, - textTagConfig.getColor(), textTagConfig.getLifetime(), + final TextTag textTag = new TextTag(unitPosition, + new Vector2(textTagConfig.getVelocity()[0], textTagConfig.getVelocity()[1]), + message, textTagConfig.getColor(), textTagConfig.getLifetime(), textTagConfig.getFadeStart(), textTagConfig.getHeight(), BUILTIN_TEXT_TAG_REPORTED_HANDLE_ID); War3MapViewer.this.textTags.add(textTag); @@ -3312,7 +3453,8 @@ public SimulationRenderComponent spawnAbilitySoundEffect(final CUnit caster, final War3ID alias) { final RenderUnit renderPeer = War3MapViewer.this.unitToRenderPeer.get(caster); final AbilityUI abilityUi = War3MapViewer.this.abilityDataUI.getUI(alias); - if ((abilityUi == null) || (abilityUi.getEffectSound() == null)) { + if ((renderPeer == null) || (abilityUi == null) + || (abilityUi.getEffectSound() == null)) { return SimulationRenderComponent.DO_NOTHING; } final long soundId = War3MapViewer.this.uiSounds.getSound(abilityUi.getEffectSound()) @@ -3336,7 +3478,8 @@ public SimulationRenderComponent loopAbilitySoundEffect(final CUnit caster, final War3ID alias) { final RenderUnit renderPeer = War3MapViewer.this.unitToRenderPeer.get(caster); final AbilityUI abilityUi = War3MapViewer.this.abilityDataUI.getUI(alias); - if ((abilityUi == null) || (abilityUi.getEffectSound() == null)) { + if ((renderPeer == null) || (abilityUi == null) + || (abilityUi.getEffectSound() == null)) { return SimulationRenderComponent.DO_NOTHING; } final long soundId = War3MapViewer.this.uiSounds @@ -3358,7 +3501,6 @@ public void remove() { @Override public void stopAbilitySoundEffect(final CUnit caster, final War3ID alias) { - final RenderUnit renderPeer = War3MapViewer.this.unitToRenderPeer.get(caster); final AbilityUI abilityUi = War3MapViewer.this.abilityDataUI.getUI(alias); if (abilityUi.getEffectSoundLooped() != null) { // TODO below this probably stops all instances of the sound, which is silly @@ -3367,6 +3509,30 @@ public void stopAbilitySoundEffect(final CUnit caster, final War3ID alias) { } } + @Override + public SimulationRenderComponent spawnAbilitySoundEffect(final float x, float y, + final War3ID alias, final boolean looping) { + final AbilityUI abilityUi = War3MapViewer.this.abilityDataUI.getUI(alias); + final String soundName = looping ? abilityUi.getEffectSoundLooped() + : abilityUi.getEffectSound(); + if ((abilityUi == null) || (soundName == null)) { + return SimulationRenderComponent.DO_NOTHING; + } + final long soundId = War3MapViewer.this.uiSounds.getSound(soundName).play( + War3MapViewer.this.worldScene.audioContext, x, y, + War3MapViewer.this.terrain.getGroundHeight(x, y)); + if (soundId == -1) { + return SimulationRenderComponent.DO_NOTHING; + } + return new SimulationRenderComponent() { + @Override + public void remove() { + War3MapViewer.this.uiSounds.getSound(soundName).stop(soundId); + ; + } + }; + } + @Override public void unitPreferredSelectionReplacement(final CUnit oldUnit, final CUnit newUnit) { final RenderUnit oldRenderPeer = War3MapViewer.this.unitToRenderPeer.get(oldUnit); @@ -3381,6 +3547,36 @@ public void setBlight(final float x, final float y, final float radius, War3MapViewer.this.setBlight(x, y, radius, blighted); } + @Override + public int[] getTerrainModBufferSize(float x, float y, float width, float height) { + return War3MapViewer.this.terrain.getTerrainModBufferSize(x, y, width, height); + } + + @Override + public int[] getTerrainModBufferSize(float centerX, float centerY, float radius) { + return War3MapViewer.this.terrain.getTerrainModBufferSize(centerX, centerY, radius); + } + + @Override + public void adjustTerrain(int[] rect, float[] modBuffer) { + War3MapViewer.this.terrain.updateGroundBuffer(rect, modBuffer); + } + + @Override + public void adjustTerrain(float x, float y, float i) { + War3MapViewer.this.terrain.updateGroundBuffer(x, y, i); + } + + @Override + public float getTerrainSpaceX(final float x) { + return War3MapViewer.this.terrain.getTerrainSpaceX(x); + } + + @Override + public float getTerrainSpaceY(final float y) { + return War3MapViewer.this.terrain.getTerrainSpaceY(y); + } + @Override public int getTerrainHeight(final float x, final float y) { final RenderCorner corner = War3MapViewer.this.terrain.getCorner(x, y); @@ -3415,8 +3611,7 @@ public void changeUnitPlayerColor(CUnit unit, int previousColor, int newColor) { War3MapViewer.this.walkableObjectsTree = new Quadtree<>(War3MapViewer.this.terrain.getEntireMap()); if (War3MapViewer.this.doodadsAndDestructiblesLoaded) { loadDoodadsAndDestructibles(War3MapViewer.this.allObjectData, w3iFile); - } - else { + } else { throw new IllegalStateException( "transcription of JS has not loaded a map and has no JS async promises"); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java index c8931c29c..fe1cf0795 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java @@ -136,9 +136,10 @@ public class Terrain { private final int[] mapBounds; private final float[] shaderMapBounds; private final int[] mapSize; + public FloatBuffer renderGroundBuffer; public final SoftwareGroundMesh softwareGroundMesh; public final SoftwareWaterAndGroundMesh softwareWaterAndGroundMesh; - private final int testArrayBuffer; + private int testArrayBuffer; private final int testElementBuffer; private boolean initShadowsFinished = false; private byte[] staticShadowData; @@ -201,8 +202,7 @@ public Terrain(final War3MapW3e w3eFile, final War3MapWpm terrainPathing, final this.waterHeightOffset = waterInfo.getFieldFloatValue("height"); this.waterTextureCount = waterInfo.getFieldValue("numTex"); this.waterIncreasePerFrame = waterInfo.getFieldValue("texRate"); - } - else { + } else { this.waterHeightOffset = 0; this.waterTextureCount = 0; this.waterIncreasePerFrame = 0; @@ -440,8 +440,9 @@ public Terrain(final War3MapW3e w3eFile, final War3MapWpm terrainPathing, final this.testArrayBuffer = gl.glGenBuffer(); gl.glBindBuffer(GL30.GL_ARRAY_BUFFER, this.testArrayBuffer); - gl.glBufferData(GL30.GL_ARRAY_BUFFER, this.softwareGroundMesh.vertices.length, - RenderMathUtils.wrap(this.softwareGroundMesh.vertices), GL30.GL_STATIC_DRAW); + this.renderGroundBuffer = RenderMathUtils.wrap(this.softwareGroundMesh.vertices); + gl.glBufferData(GL30.GL_ARRAY_BUFFER, this.softwareGroundMesh.vertices.length, this.renderGroundBuffer, + GL30.GL_STATIC_DRAW); this.testElementBuffer = gl.glGenBuffer(); // gl.glBindBuffer(GL30.GL_ELEMENT_ARRAY_BUFFER, this.testElementBuffer); @@ -614,18 +615,15 @@ private void updateCliffMeshes(final Rectangle area) throws IOException { final int bottomRightCliffTex = bottomRight.getCliffTexture(); if (bottomRightCliffTex == 15) { bottomLeftCliffTex -= 14; - } - else { + } else { bottomLeftCliffTex = bottomRightCliffTex; foundTexture = true; } - } - else { + } else { bottomLeftCliffTex = topRightCliffTex; foundTexture = true; } - } - else { + } else { bottomLeftCliffTex = topLeftCliffTex; foundTexture = true; } @@ -653,20 +651,16 @@ private void updateCliffMeshes(final Rectangle area) throws IOException { if (DISALLOW_HEIGHT_3_RAMPS) { if (rampBlockedByCliff) { invalidRamp = true; - } - else if (topLeftHeight > 1) { + } else if (topLeftHeight > 1) { invalidRamp = true; topLeft.setRamp(0); - } - else if (topRightHeight > 1) { + } else if (topRightHeight > 1) { invalidRamp = true; topRight.setRamp(0); - } - else if (bottomRightHeight > 1) { + } else if (bottomRightHeight > 1) { invalidRamp = true; bottomRight.setRamp(0); - } - else if (bottomLeftHeight > 1) { + } else if (bottomLeftHeight > 1) { invalidRamp = true; bottomLeft.setRamp(0); } @@ -795,8 +789,7 @@ public void removeTerrainCell(final int i, final int j) { uploadGroundTexture(); try { updateCliffMeshes(new Rectangle(i - 1, j - 1, 1, 1)); // TODO does this work? - } - catch (final IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } } @@ -810,8 +803,7 @@ public void flushRemovedTerrainCells() { uploadGroundTexture(); try { updateCliffMeshes(new Rectangle(0, 0, this.columns - 1, this.rows - 1)); - } - catch (final IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } } @@ -925,19 +917,15 @@ public short getVariation(final int groundTexture, final int variation) { if (texture.extended) { if (variation <= 15) { return (short) (16 + variation); - } - else if (variation == 16) { + } else if (variation == 16) { return 15; - } - else { + } else { return 0; } - } - else { + } else { if (variation == 0) { return 0; - } - else { + } else { return 15; } } @@ -1462,8 +1450,7 @@ public float getGroundHeight(final float x, final float y) { if ((sqX + sqY) < 1) { height = bottomLeft + ((bottomRight - bottomLeft) * sqX) + ((topLeft - bottomLeft) * sqY); - } - else { + } else { height = topRight + ((bottomRight - topRight) * (1 - sqY)) + ((topLeft - topRight) * (1 - sqX)); } @@ -1473,6 +1460,10 @@ public float getGroundHeight(final float x, final float y) { return 0; } + public float getTerrainSpaceX(float x) { + return (x - this.centerOffset[0]) / 128.0f; + } + public int get128CellX(final float x) { final float userCellSpaceX = (x - this.centerOffset[0]) / 128.0f; final int cellX = (int) userCellSpaceX; @@ -1483,6 +1474,10 @@ public float get128WorldCoordinateFromCellX(final int cellX) { return (cellX * 128.0f) + this.centerOffset[0]; } + public float getTerrainSpaceY(float y) { + return (y - this.centerOffset[1]) / 128.0f; + } + public int get128CellY(final float y) { final float userCellSpaceY = (y - this.centerOffset[1]) / 128.0f; final int cellY = (int) userCellSpaceY; @@ -1523,8 +1518,7 @@ public float getWaterHeight(final float x, final float y) { if ((sqX + sqY) < 1) { height = bottomLeft + ((bottomRight - bottomLeft) * sqX) + ((topLeft - bottomLeft) * sqY); - } - else { + } else { height = topRight + ((bottomRight - topRight) * (1 - sqY)) + ((topLeft - topRight) * (1 - sqX)); } @@ -1649,8 +1643,7 @@ private SoftwareWaterAndGroundMesh(final float waterHeightOffset, final float[] if (waterExistsData[groundCornerHeightIndex] != 0) { height = Math.max(groundCornerHeights[groundCornerHeightIndex], waterHeights[groundCornerHeightIndex] + waterHeightOffset); - } - else { + } else { height = groundCornerHeights[groundCornerHeightIndex]; } this.vertices[(instanceId * 4 * 3) + (vertexId * 3)] = ((vPositionX + x) * 128f) @@ -1722,8 +1715,7 @@ private static char getRampLetter(final int layerHeightOffset, final boolean isR default: throw new IllegalArgumentException("Invalid ramp"); } - } - else { + } else { return (char) ('A' + layerHeightOffset); } } @@ -1767,4 +1759,45 @@ public void setWaterBaseColor(float red, float green, float blue, float alpha) { this.minShallowColorApplied[i] = this.minShallowColor[i] * rgba[i]; } } + + private static Rectangle tempRect = new Rectangle(); + + public void updateGroundBuffer(float x, float y, float i) { + int nodeX = get128CellX(x); + int nodeY = get128CellY(y); + final int instanceId = (nodeY * (columns - 1)) + nodeX; + final int vertexZ = (instanceId * 4 * 3) + (0 * 3) + 2; + softwareGroundMesh.vertices[vertexZ] = softwareGroundMesh.vertices[vertexZ] + i; + this.corners[nodeX][nodeY].setGroundHeight(this.corners[nodeX][nodeY].getGroundHeight() + i / 512); + this.updateGroundHeights(tempRect.set(nodeX, nodeY, 1, 1)); + } + + public int[] getTerrainModBufferSize(float x, float y, float width, float height) { + return new int[] { Math.min(this.rows - 1, Math.max(0, get128CellX(x))), + Math.min(this.columns - 1, Math.max(0, get128CellY(y))), + Math.min(this.rows - 1, Math.max(0, get128CellX(x + width)+1)), + Math.min(this.columns - 1, Math.max(0, get128CellY(y + height)+1)) }; + } + + public int[] getTerrainModBufferSize(float centerX, float centerY, float radius) { + return getTerrainModBufferSize(centerX - radius, centerY - radius, radius * 2, radius * 2); + } + + public void updateGroundBuffer(int[] rect, float[] modBuffer) { + updateGroundBuffer(rect[0], rect[1], rect[2]-rect[0] + 1, rect[3]-rect[1] + 1, modBuffer); + } + + public void updateGroundBuffer(int x, int y, int width, int height, float[] modBuffer) { + for (int j = (int) y; j < (y + height); j++) { + for (int i = (int) x; i < (x + width); i++) { + final int vertexZ = (((j * (columns - 1)) + i) * 4 * 3) + 2; + softwareGroundMesh.vertices[vertexZ] = softwareGroundMesh.vertices[vertexZ] + + modBuffer[(i - x) + (j - y) * width]; + this.corners[i][j].setGroundHeight( + this.corners[i][j].getGroundHeight() + modBuffer[(i - x) + (j - y) * width] / 512); + } + } + this.updateGroundHeights(tempRect.set(x, y, width, height)); + + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderDoodad.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderDoodad.java index 30d45a1bf..aef174ca4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderDoodad.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderDoodad.java @@ -31,6 +31,7 @@ public class RenderDoodad { private static final String DOODAD_COLOR_BLUE = "vertB"; // replaced from 'dvb1' private CFogState fogState; + private byte lastFogStateColor; private final float[] vertexColorBase; private final float[] vertexColorFogged; @@ -101,8 +102,16 @@ public RenderDoodad(final War3MapViewer map, final MdxModel model, final GameObj this.instance = instance; this.row = row; - this.fogState = CFogState.MASKED; - ((MdxComplexInstance) instance).setVertexColor(VERTEX_COLOR_BLACK); + final CPlayerFogOfWar fogOfWar = map.getFogOfWar(); + final PathingGrid pathingGrid = map.simulation.getPathingGrid(); + final int fogOfWarIndexX = pathingGrid.getFogOfWarIndexX(this.x); + final int fogOfWarIndexY = pathingGrid.getFogOfWarIndexY(this.y); + this.fogState = fogOfWar.getFogState(map.simulation, fogOfWarIndexX, fogOfWarIndexY); + this.lastFogStateColor = this.fogState.getMask(); + for (int i = 0; i < this.vertexColorBase.length; i++) { + VERTEX_COLOR_HEAP[i] = (this.vertexColorBase[i] * (255 - (this.lastFogStateColor & 0xFF))) / 255f; + } + ((MdxComplexInstance) this.instance).setVertexColor(VERTEX_COLOR_HEAP); } @@ -121,7 +130,6 @@ public PrimaryTag getAnimation() { return PrimaryTag.STAND; } - private byte lastFogStateColor = 0; public void updateFog(final War3MapViewer war3MapViewer) { final CPlayerFogOfWar fogOfWar = war3MapViewer.getFogOfWar(); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderItem.java index b0c4eaa1c..02249662b 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderItem.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderItem.java @@ -16,10 +16,11 @@ public class RenderItem implements RenderWidget { private final CItem simulationItem; - public final MdxComplexInstance instance; + public MdxComplexInstance instance; public final float[] location = new float[3]; + public final float angle; public float radius; - public final MdxModel portraitModel; + public MdxModel portraitModel; public SplatMover shadow; public SplatMover selectionCircle; public SplatMover selectionPreviewHighlight; @@ -32,6 +33,7 @@ public RenderItem(final War3MapViewer map, RenderItemType itemType, final float this.simulationItem = simulationItem; final MdxComplexInstance instance = (MdxComplexInstance) itemType.getModel().addInstance(); + this.angle = angle; this.location[0] = x; this.location[1] = y; this.location[2] = z; @@ -50,6 +52,27 @@ public RenderItem(final War3MapViewer map, RenderItemType itemType, final float this.instance = instance; } + + public void updateItemModel(final War3MapViewer map, RenderItemType itemType) { + this.instance.detach(); + this.portraitModel.detach(); + + this.portraitModel = itemType.getPortraitModel(); + final MdxComplexInstance instance = (MdxComplexInstance) itemType.getModel().addInstance(); + instance.move(this.location); + instance.rotate(new Quaternion().setFromAxisRad(RenderMathUtils.VEC3_UNIT_Z, this.angle)); + instance.setScene(map.worldScene); + + if (itemType != null) { + final Vector3 tintingColor = itemType.getTintingColor(); + instance.setVertexColor(new float[] { tintingColor.x, tintingColor.y, tintingColor.z }); + instance.uniformScale(itemType.getModelScale()); + + this.radius = 1 * 36; + } + + this.instance = instance; + } @Override public MdxComplexInstance getInstance() { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderProjectile.java index 7e84516b8..372dc3d67 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderProjectile.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderProjectile.java @@ -13,8 +13,6 @@ import com.etheller.warsmash.viewer5.handlers.w3x.War3MapViewer; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetWidgetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; public class RenderProjectile implements RenderEffect { @@ -29,12 +27,13 @@ public class RenderProjectile implements RenderEffect { private final float arcPeakHeight; private float totalTravelDistance; - private final float targetHeight; + private float targetHeight; private float yaw; private float pitch; private boolean done = false; + private float deathTime; private float deathTimeElapsed; public RenderProjectile(final CProjectile simulationProjectile, final MdxComplexInstance modelInstance, @@ -65,6 +64,15 @@ public RenderProjectile(final CProjectile simulationProjectile, final MdxComplex this.targetHeight = (war3MapViewer.terrain.getGroundHeight(targetX, targetY) + flyHeight + impactZ); this.arcPeakHeight = arc * startingDistance; this.yaw = (float) StrictMath.atan2(dyToTarget, dxToTarget); + this.deathTime = war3MapViewer.simulation.getGameplayConstants().getBulletDeathTime(); + } + + public void setDeathTime(float time) { + this.deathTime = time; + } + + public void setImpactZ(final War3MapViewer war3MapViewer, float impactZ) { + this.targetHeight = (war3MapViewer.terrain.getGroundHeight(this.simulationProjectile.getTargetX(), this.simulationProjectile.getTargetY()) + impactZ); } @Override @@ -131,7 +139,7 @@ public boolean updateAnimations(final War3MapViewer war3MapViewer, final float d war3MapViewer.worldScene.instanceMoved(this.modelInstance, this.x, this.y); final boolean everythingDone = this.simulationProjectile.isDone() && (this.modelInstance.sequenceEnded - || (this.deathTimeElapsed >= war3MapViewer.simulation.getGameplayConstants().getBulletDeathTime())); + || (this.deathTimeElapsed >= this.deathTime)); if (everythingDone) { war3MapViewer.worldScene.removeInstance(this.modelInstance); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderSpellEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderSpellEffect.java index 139bf7fcd..f20200fe4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderSpellEffect.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderSpellEffect.java @@ -88,6 +88,7 @@ public void setAnimations(final PrimaryTag[] animations, final boolean killWhenD this.animationQueueIndex = 0; setKillWhenDone(killWhenDone); applySequence(); + this.animationQueueIndex++; } public void setKillWhenDone(final boolean killWhenDone) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderUnit.java index 07b14903a..f9a033d63 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderUnit.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderUnit.java @@ -77,16 +77,18 @@ public RenderUnit(final War3MapViewer map, final float x, final float y, final f final float selectionCircleScaleFactor, final float animationWalkSpeed, final float animationRunSpeed, final float scalingValue) { this.simulationUnit = simulationUnit; - resetRenderUnit(map, x, y, z, playerIndex, simulationUnit, typeData, buildingShadow, selectionCircleScaleFactor, - animationWalkSpeed, animationRunSpeed, scalingValue); + resetRenderUnit(map, x, y, z, playerIndex, simulationUnit, typeData, true, buildingShadow, + selectionCircleScaleFactor, animationWalkSpeed, animationRunSpeed, scalingValue); } public void resetRenderUnit(final War3MapViewer map, final float x, final float y, final float z, - final int playerIndex, final CUnit simulationUnit, final RenderUnitType typeData, + final int playerIndex, final CUnit simulationUnit, final RenderUnitType typeData, boolean updatePortrait, final BuildingShadow buildingShadow, final float selectionCircleScaleFactor, final float animationWalkSpeed, final float animationRunSpeed, final float scalingValue) { - this.portraitModel = typeData.getPortraitModel(); + if (updatePortrait) { + this.portraitModel = typeData.getPortraitModel(); + } this.typeData = typeData; this.specialArtModel = typeData.getSpecialArtModel(); if (this.buildingShadowInstance != null) { @@ -184,8 +186,7 @@ public void updateAnimations(final War3MapViewer map) { } this.instance.hide(); return; - } - else { + } else { this.instance.show(); if (wasHidden) { if (this.selectionCircle != null) { @@ -215,8 +216,7 @@ public void updateAnimations(final War3MapViewer map) { // where they actually are this.location[0] += (speedDelta * simDx) / distanceToSimulation; this.location[1] += (speedDelta * simDy) / distanceToSimulation; - } - else { + } else { this.location[0] = simulationX; this.location[1] = simulationY; } @@ -228,7 +228,7 @@ public void updateAnimations(final War3MapViewer map) { boolean swimming = (movementType == MovementType.AMPHIBIOUS) && PathingGrid.isPathingFlag(terrainPathing, PathingGrid.PathingType.SWIMMABLE) && !PathingGrid.isPathingFlag(terrainPathing, PathingGrid.PathingType.WALKABLE); - final boolean invisible = this.simulationUnit.getInvisLevels() > 0; + final boolean invisible = (this.simulationUnit.getInvisLevels() & 1) > 0; final boolean working = this.simulationUnit.getBuildQueueTypes()[0] != null; final float groundHeightTerrain = map.terrain.getGroundHeight(this.location[0], this.location[1]); float groundHeightTerrainAndWater; @@ -238,8 +238,7 @@ public void updateAnimations(final War3MapViewer map) { if (standingOnWater) { groundHeightTerrainAndWater = Math.max(groundHeightTerrain, map.terrain.getWaterHeight(this.location[0], this.location[1])); - } - else { + } else { // land units will have their feet pass under the surface of the water groundHeightTerrainAndWater = groundHeightTerrain; } @@ -247,8 +246,7 @@ public void updateAnimations(final War3MapViewer map) { // boats cant go on bridges groundHeight = groundHeightTerrainAndWater; currentWalkableUnder = null; - } - else { + } else { currentWalkableUnder = map.getHighestWalkableUnder(this.location[0], this.location[1]); War3MapViewer.gdxRayHeap.set(this.location[0], this.location[1], 4096, 0, 0, -8192); if ((currentWalkableUnder != null) @@ -257,8 +255,7 @@ public void updateAnimations(final War3MapViewer map) { && (War3MapViewer.intersectionHeap.z > groundHeightTerrainAndWater)) { groundHeight = War3MapViewer.intersectionHeap.z; swimming = false; // Naga Royal Guard should slither across a bridge, not swim in rock - } - else { + } else { groundHeight = groundHeightTerrainAndWater; currentWalkableUnder = null; } @@ -268,8 +265,7 @@ public void updateAnimations(final War3MapViewer map) { if (this.unitAnimationListenerImpl.addSecondaryTag(AnimationTokens.SecondaryTag.SWIM)) { changedAnimationProperties = true; } - } - else if (!swimming && this.swimming) { + } else if (!swimming && this.swimming) { if (this.unitAnimationListenerImpl.removeSecondaryTag(AnimationTokens.SecondaryTag.SWIM)) { changedAnimationProperties = true; } @@ -278,8 +274,7 @@ else if (!swimming && this.swimming) { if (this.unitAnimationListenerImpl.addSecondaryTag(AnimationTokens.SecondaryTag.WORK)) { changedAnimationProperties = true; } - } - else if (!working && this.working) { + } else if (!working && this.working) { if (this.unitAnimationListenerImpl.removeSecondaryTag(AnimationTokens.SecondaryTag.WORK)) { changedAnimationProperties = true; } @@ -291,12 +286,10 @@ else if (!working && this.working) { if (invisible && !this.invisible) { // turn invisible instantly colorNeedsUpdate = true; - } - else if (!invisible && this.invisible) { + } else if (!invisible && this.invisible) { // show instantly colorNeedsUpdate = true; - } - else if ((this.simulationUnit.getFadeTimer() != null) && this.simulationUnit.getFadeTimer().isRunning()) { + } else if ((this.simulationUnit.getFadeTimer() != null) && this.simulationUnit.getFadeTimer().isRunning()) { colorNeedsUpdate = true; } this.invisible = invisible; @@ -314,15 +307,13 @@ else if ((this.simulationUnit.getFadeTimer() != null) && this.simulationUnit.get this.unitAnimationListenerImpl.playAnimation(true, PrimaryTag.DEATH, SequenceUtils.EMPTY, 1.0f, true); removeSplats(map); } - } - else if (building != this.building) { + } else if (building != this.building) { if (building) { if (this.shadow != null) { this.shadow.hide(); } createBuildingDecalSplats(map); - } - else { + } else { if (this.shadow != null) { this.shadow.show(map.terrain.centerOffset); } @@ -334,13 +325,11 @@ else if (building != this.building) { if (this.simulationUnit.getUnitType().isHero()) { this.unitAnimationListenerImpl.playAnimationWithDuration(true, PrimaryTag.DISSIPATE, SequenceUtils.EMPTY, this.simulationUnit.getEndingDecayTime(map.simulation), true); - } - else { + } else { this.unitAnimationListenerImpl.playAnimationWithDuration(true, PrimaryTag.DECAY, SequenceUtils.BONE, this.simulationUnit.getEndingDecayTime(map.simulation), true); } - } - else if (corpse && !this.corpse) { + } else if (corpse && !this.corpse) { this.unitAnimationListenerImpl.playAnimationWithDuration(true, PrimaryTag.DECAY, SequenceUtils.FLESH, map.simulation.getGameplayConstants().getDecayTime(), true); } @@ -377,8 +366,7 @@ else if (corpse && !this.corpse) { - ((this.orientationInterpolation.getEndingAccelCutoff() - absoluteFacingDeltaRadians) / this.orientationInterpolation.getEndingAccelCutoff())) * (this.orientationInterpolation.getMaxVelocity()) * turningSign; - } - else { + } else { acceleration = this.orientationInterpolation.getStartingAcceleration() * turningSign; this.currentTurnVelocity = this.currentTurnVelocity + acceleration; } @@ -421,8 +409,7 @@ else if (corpse && !this.corpse) { rollSampleBackwardY); rollSampleGroundHeight2 = getGroundHeightSample(groundHeight, currentWalkableUnder, rollSampleForwardX, rollSampleForwardY); - } - else { + } else { final float pitchGroundHeight1 = map.terrain.getGroundHeight(pitchSampleBackwardX, pitchSampleBackwardY); final float pitchGroundHeight2 = map.terrain.getGroundHeight(pitchSampleForwardX, pitchSampleForwardY); final float rollGroundHeight1 = map.terrain.getGroundHeight(rollSampleBackwardX, rollSampleBackwardY); @@ -436,8 +423,7 @@ else if (corpse && !this.corpse) { map.terrain.getWaterHeight(rollSampleBackwardX, rollSampleBackwardY)); rollSampleGroundHeight2 = Math.max(rollGroundHeight2, map.terrain.getWaterHeight(rollSampleForwardX, rollSampleForwardY)); - } - else { + } else { pitchSampleGroundHeight1 = pitchGroundHeight1; pitchSampleGroundHeight2 = pitchGroundHeight2; rollSampleGroundHeight1 = rollGroundHeight1; @@ -530,8 +516,7 @@ private float getGroundHeightSample(final float groundHeight, final MdxComplexIn if (currentWalkableUnder.intersectRayWithCollision(War3MapViewer.gdxRayHeap, War3MapViewer.intersectionHeap, true, true)) { sampleGroundHeight = War3MapViewer.intersectionHeap.z; - } - else { + } else { sampleGroundHeight = groundHeight; } return sampleGroundHeight; @@ -622,7 +607,8 @@ public void assignSelectionPreviewHighlight(final SplatMover t) { @Override public boolean isSelectable(final CSimulation simulation, final int byPlayer) { - return this.simulationUnit.isVisible(simulation, byPlayer); // later needs locust + return this.simulationUnit.isVisible(simulation, byPlayer) + && this.simulationUnit.isSelectable(simulation, byPlayer); } @Override @@ -695,8 +681,7 @@ private void updateColor(final War3MapViewer map) { float finalAlpha = this.currentColor[3]; if (this.invisible) { finalAlpha *= 0.5f; - } - else { + } else { final CTimer fadeTimer = this.simulationUnit.getFadeTimer(); if ((fadeTimer != null) && fadeTimer.isRunning()) { final float fadeAmount = map.getRemainingSecondsForRender(fadeTimer) / fadeTimer.getTimeoutTime(); @@ -753,8 +738,7 @@ public void addAnimationProperties(final String properties, final boolean add) { changedAnimProps = true; } } - } - else { + } else { for (final AnimationTokens.SecondaryTag tag : secondaryTags) { if (this.unitAnimationListenerImpl.removeSecondaryTag(tag)) { changedAnimProps = true; @@ -772,8 +756,7 @@ public void lockTargetFacing(final String boneNameString, final RenderUnit rende if ("head".equals(boneNameString.toLowerCase())) { this.unitAnimationListenerImpl.lockHeadFacing(renderPeerTarget.instance, new Vector3(offsetX, offsetY, offsetZ)); - } - else if ("turret".equals(boneNameString.toLowerCase())) { + } else if ("turret".equals(boneNameString.toLowerCase())) { this.unitAnimationListenerImpl.lockTurretFacing(renderPeerTarget.instance, new Vector3(offsetX, offsetY, offsetZ)); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderWidget.java index 823d6b519..ee39bc32f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderWidget.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/RenderWidget.java @@ -225,6 +225,16 @@ public void queueAnimation(final PrimaryTag animationName, final EnumSet LightningEffectList = Arrays @@ -300,11 +304,14 @@ public AbilityDataUI(final Warcraft3MapRuntimeObjectData allObjectData, final Ga : Arrays.asList(effectAttach); effectArt.add(new EffectAttachmentUI(modelPath, attachmentPoints)); } - final List missileArt = new ArrayList<>(); + final List missileArt = new ArrayList<>(); final List missileArtPaths = Arrays .asList(abilityTypeData.getFieldAsString(BUFF_MISSILE_ART, 0).split(",")); + final float missileArc = abilityTypeData.getFieldAsFloat(MISSILE_ARC, 0); + final float missileSpeed = abilityTypeData.getFieldAsFloat(MISSILE_SPEED, 0); + final boolean missileHoming = abilityTypeData.getFieldAsBoolean(MISSILE_HOMING, 0); for (final String missileArtPath : missileArtPaths) { - missileArt.add(new EffectAttachmentUI(missileArtPath, Collections.emptyList())); + missileArt.add(new EffectAttachmentUIMissile(missileArtPath, Collections.emptyList(), missileArc, missileSpeed, missileHoming)); } final String effectSound = abilityTypeData.getFieldAsString(BUFF_ABILITY_EFFECT_SOUND, 0); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/BuffUI.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/BuffUI.java index d75dae4bb..d974a55e7 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/BuffUI.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/BuffUI.java @@ -7,13 +7,13 @@ public class BuffUI { private final List targetArt; private final List specialArt; private final List effectArt; - private final List missileArt; + private final List missileArt; private final String effectSound; private final String effectSoundLooped; public BuffUI(final IconUI onIconUI, final List targetArt, final List specialArt, final List effectArt, - final List missileArt, final String effectSound, final String effectSoundLooped) { + final List missileArt, final String effectSound, final String effectSoundLooped) { this.onIconUI = onIconUI; this.targetArt = targetArt; this.specialArt = specialArt; @@ -39,7 +39,7 @@ public EffectAttachmentUI getEffectArt(final int index) { return AbilityUI.tryGet(this.effectArt, index); } - public EffectAttachmentUI getMissileArt(final int index) { + public EffectAttachmentUIMissile getMissileArt(final int index) { return AbilityUI.tryGet(this.missileArt, index); } @@ -63,7 +63,7 @@ public List getEffectArt() { return effectArt; } - public List getMissileArt() { + public List getMissileArt() { return missileArt; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/EffectAttachmentUIMissile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/EffectAttachmentUIMissile.java index 943bfff6d..ec8054b70 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/EffectAttachmentUIMissile.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/ability/EffectAttachmentUIMissile.java @@ -9,13 +9,25 @@ public class EffectAttachmentUIMissile extends EffectAttachmentUI { private float arc; + private float speed; + private boolean homing; - public EffectAttachmentUIMissile(String modelPath, List attachmentPoint, float arc) { + public EffectAttachmentUIMissile(String modelPath, List attachmentPoint, float arc, float speed, boolean homing) { super(modelPath, attachmentPoint); this.arc = arc; + this.speed = speed; + this.homing = homing; } public float getArc() { return arc; } + + public float getSpeed() { + return speed; + } + + public boolean isHoming() { + return homing; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandButtonListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandButtonListener.java index a2404c01a..b458ddfe8 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandButtonListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandButtonListener.java @@ -39,7 +39,7 @@ void commandButton(int buttonPositionX, int buttonPositionY, Texture icon, int a char hotkey, int goldCost, int lumberCost, int foodCost, int manaCost, float cooldownRemaining, float cooldownMax, int numberOverlay); - void buff(Texture icon, int level, String tip, String uberTip); + void buff(Texture icon, int level, String tip, String uberTip, boolean positive, boolean leveled); void timedLifeBar(int level, String toolTip, float durationRemaining, float durationMax); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandCardPopulatingAbilityVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandCardPopulatingAbilityVisitor.java index 5e115d574..59320fd75 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandCardPopulatingAbilityVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/rendersim/commandbuttons/CommandCardPopulatingAbilityVisitor.java @@ -1,5 +1,8 @@ package com.etheller.warsmash.viewer5.handlers.w3x.rendersim.commandbuttons; +import java.util.HashSet; +import java.util.Set; + import com.badlogic.gdx.graphics.Texture; import com.etheller.warsmash.parsers.fdf.GameUI; import com.etheller.warsmash.util.War3ID; @@ -45,7 +48,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; @@ -66,6 +69,7 @@ public class CommandCardPopulatingAbilityVisitor implements CAbilityVisitor buffVisibleGroups; public CommandCardPopulatingAbilityVisitor reset(final CSimulation game, final GameUI gameUI, final CUnit unit, final CommandButtonListener commandButtonListener, final AbilityDataUI abilityDataUI, @@ -80,13 +84,15 @@ public CommandCardPopulatingAbilityVisitor reset(final CSimulation game, final G this.localPlayerIndex = localPlayerIndex; this.hasStop = false; this.hasCancel = false; + this.buffVisibleGroups = new HashSet<>(); this.previewCallback.setup(this.game.getUnitData(), this.game.getUpgradeData(), this.gameUI.getTemplates()); return this; } @Override - public Void accept(final AbilityBuilderActiveAbility ability) { - if ((this.menuBaseOrderId == 0) && ability.isIconShowing()) { + public Void accept(final ABAbilityBuilderActiveAbility ability) { + if ((this.menuBaseOrderId == 0 || this.menuBaseOrderId == ability.getIconVisibleMenuId()) + && ability.isIconShowing()) { final AbilityUI ui = this.abilityDataUI.getUI(ability.getAlias()); final boolean autoCastOn = ability.isAutoCastOn(); if (ability.isSeparateOnAndOff()) { @@ -95,16 +101,15 @@ public Void accept(final AbilityBuilderActiveAbility ability) { addCommandButton(ability, ui.getOnIconUI(ability.getLevel() - 1), ability.getHandleId(), ability.getBaseOrderId(), autoCastOn ? ability.getAutoCastOffOrderId() : ability.getAutoCastOnOrderId(), autoCastOn, - false, ability.getUIGoldCost(), ability.getUILumberCost(), ability.getUIFoodCost(), - ability.getUIManaCost(), ability.getUsesRemaining()); - } - else { + ability.isMenuAbility(), ability.getUIGoldCost(), ability.getUILumberCost(), + ability.getUIFoodCost(), ability.getUIManaCost(), ability.getUsesRemaining()); + } else { addCommandButton(ability, ui.getOnIconUI(ability.getLevel() - 1), resolveUnknownIcon(onTt, false, ability.getLevel() - 1), ability.getHandleId(), ability.getBaseOrderId(), autoCastOn ? ability.getAutoCastOffOrderId() : ability.getAutoCastOnOrderId(), autoCastOn, - false, ability.getUIGoldCost(), ability.getUILumberCost(), ability.getUIFoodCost(), - ability.getUIManaCost(), ability.getUsesRemaining()); + ability.isMenuAbility(), ability.getUIGoldCost(), ability.getUILumberCost(), + ability.getUIFoodCost(), ability.getUIManaCost(), ability.getUsesRemaining()); } final War3ID offTt = ability.getOffTooltipOverride(); @@ -112,25 +117,22 @@ public Void accept(final AbilityBuilderActiveAbility ability) { addCommandButton(ability, ui.getOffIconUI(ability.getLevel() - 1), ability.getHandleId(), ability.getOffOrderId(), autoCastOn ? ability.getAutoCastOffOrderId() : ability.getAutoCastOnOrderId(), autoCastOn, - false, ability.getUIGoldCost(), ability.getUILumberCost(), ability.getUIFoodCost(), - ability.getUIManaCost(), -1); - } - else { + ability.isMenuAbility(), ability.getUIGoldCost(), ability.getUILumberCost(), + ability.getUIFoodCost(), ability.getUIManaCost(), -1); + } else { addCommandButton(ability, ui.getOffIconUI(ability.getLevel() - 1), resolveUnknownIcon(offTt, true, ability.getLevel() - 1), ability.getHandleId(), ability.getOffOrderId(), autoCastOn ? ability.getAutoCastOffOrderId() : ability.getAutoCastOnOrderId(), autoCastOn, - false, ability.getUIGoldCost(), ability.getUILumberCost(), ability.getUIFoodCost(), - ability.getUIManaCost(), -1); + ability.isMenuAbility(), ability.getUIGoldCost(), ability.getUILumberCost(), + ability.getUIFoodCost(), ability.getUIManaCost(), -1); } - } - else { + } else { final boolean active = ability.isToggleOn(); War3ID tt = null; if (active) { tt = ability.getOnTooltipOverride(); - } - else { + } else { tt = ability.getOffTooltipOverride(); } if ((tt == null) || (tt == ability.getAlias())) { @@ -138,17 +140,16 @@ public Void accept(final AbilityBuilderActiveAbility ability) { active ? ui.getOffIconUI(ability.getLevel() - 1) : ui.getOnIconUI(ability.getLevel() - 1), ability.getHandleId(), active ? ability.getOffOrderId() : ability.getBaseOrderId(), autoCastOn ? ability.getAutoCastOffOrderId() : ability.getAutoCastOnOrderId(), autoCastOn, - false, ability.getUIGoldCost(), ability.getUILumberCost(), ability.getUIFoodCost(), - ability.getUIManaCost(), active ? -1 : ability.getUsesRemaining()); - } - else { + ability.isMenuAbility(), ability.getUIGoldCost(), ability.getUILumberCost(), + ability.getUIFoodCost(), ability.getUIManaCost(), active ? -1 : ability.getUsesRemaining()); + } else { addCommandButton(ability, active ? ui.getOffIconUI(ability.getLevel() - 1) : ui.getOnIconUI(ability.getLevel() - 1), resolveUnknownIcon(tt, active, ability.getLevel() - 1), ability.getHandleId(), active ? ability.getOffOrderId() : ability.getBaseOrderId(), autoCastOn ? ability.getAutoCastOffOrderId() : ability.getAutoCastOnOrderId(), autoCastOn, - false, ability.getUIGoldCost(), ability.getUILumberCost(), ability.getUIFoodCost(), - ability.getUIManaCost(), active ? -1 : ability.getUsesRemaining()); + ability.isMenuAbility(), ability.getUIGoldCost(), ability.getUILumberCost(), + ability.getUIFoodCost(), ability.getUIManaCost(), active ? -1 : ability.getUsesRemaining()); } } } @@ -175,12 +176,10 @@ private IconUI resolveUnknownIcon(final War3ID id, final boolean active, final i icon = buff.getOnIconUI(); } } - } - else { + } else { if (active) { icon = aui.getOffIconUI(index); - } - else { + } else { icon = aui.getOnIconUI(index); } } @@ -240,8 +239,7 @@ public Void accept(final CAbilityGenericDoNothing ability) { if (abilityUI != null) { addCommandButton(ability, abilityUI.getOnIconUI(ability.getLevel() - 1), ability.getHandleId(), 0, 0, false, false); - } - else { + } else { addCommandButton(ability, this.abilityDataUI.getStopUI(), ability.getHandleId(), 0, 0, false, false); } @@ -329,8 +327,7 @@ public Void accept(final CAbilityColdArrows ability) { int autoCastId; if (autoCastActive) { autoCastId = OrderIds.coldarrows; - } - else { + } else { autoCastId = OrderIds.uncoldarrows; } final IconUI onIconUI = this.abilityDataUI.getUI(ability.getAlias()).getOnIconUI(ability.getLevel() - 1); @@ -406,8 +403,7 @@ private void handleBuildMenu(final AbstractCAbilityBuild ability, final IconUI b simulationUnitType.getFoodUsed(), 0, -1); } } - } - else if (this.menuBaseOrderId == 0) { + } else if (this.menuBaseOrderId == 0) { if (this.multiSelect) { return; } @@ -424,11 +420,17 @@ private void addBuffIcon(final CBuff buff, final IconUI iconUI) { this.commandButtonListener.timedLifeBar(buff.getLevel(), iconUI.getToolTip(), buff.getDurationRemaining(this.game, this.unit), buff.getDurationMax()); } - } - else { + } else { if (buff.isIconShowing()) { - this.commandButtonListener.buff(iconUI.getIcon(), buff.getLevel(), iconUI.getToolTip(), - iconUI.getUberTip()); + String group = buff.getVisibilityGroup(); + if (group != null && this.buffVisibleGroups.contains(group)) { + return; + } + if (iconUI != null) { + this.commandButtonListener.buff(iconUI.getIcon(), buff.getLevel(), iconUI.getToolTip(), + iconUI.getUberTip(), buff.isPositive(), buff.isLeveled()); + } + this.buffVisibleGroups.add(group); } } } @@ -481,8 +483,7 @@ private void addCommandButton(final CAbility ability, final Texture icon, final final CUnit selectedPlayerUnit = neutralBuildingData.getSelectedPlayerUnit(this.localPlayerIndex); if (selectedPlayerUnit != null) { controlShared = true; - } - else { + } else { requiresPatron = true; } } @@ -491,7 +492,7 @@ private void addCommandButton(final CAbility ability, final Texture icon, final return; } } - ability.checkCanUse(this.game, this.unit, orderId, this.previewCallback.reset()); + ability.checkCanUse(this.game, this.unit, orderId, false, this.previewCallback.reset()); if (!this.previewCallback.isOmitIconEntirely()) { if (requiresPatron) { this.previewCallback @@ -500,6 +501,8 @@ private void addCommandButton(final CAbility ability, final Texture icon, final final boolean active = (this.unit.getCurrentBehavior() != null) && (orderId == this.unit.getCurrentBehavior().getHighlightOrderId()); final boolean disabled = ((ability != null) && ability.isDisabled()) || this.previewCallback.isDisabled(); + final boolean clickDisabled = ((ability != null) && ability.isClickDisabled()) + || this.previewCallback.isDisabled(); final float cooldownRemaining = this.previewCallback.getCooldownRemaining(); final float cooldownMax = this.previewCallback.getCooldownMax(); if (disabled) { @@ -512,9 +515,11 @@ private void addCommandButton(final CAbility ability, final Texture icon, final if (this.previewCallback.isShowingRequirements()) { uberTip = this.previewCallback.getRequirementsText() + "|r" + uberTip; } - this.commandButtonListener.commandButton(buttonPosX, buttonPosY, disabled ? iconDisabled : icon, handleId, - disabled ? 0 : orderId, autoCastOrderId, active, autoCastActive, menuButton, toolTip, uberTip, - hotkey, goldCost, lumberCost, foodCost, manaCost, cooldownRemaining, cooldownMax, numberOverlay); + this.commandButtonListener.commandButton(buttonPosX, buttonPosY, + (disabled || clickDisabled) ? iconDisabled : icon, handleId, + (disabled || clickDisabled) ? 0 : orderId, autoCastOrderId, active, autoCastActive, menuButton, + toolTip, uberTip, hotkey, goldCost, lumberCost, foodCost, manaCost, cooldownRemaining, cooldownMax, + numberOverlay); } } @@ -574,8 +579,7 @@ public Void accept(final CAbilityQueue ability) { && (this.game.getPlayer(this.unit.getPlayerIndex()).getHeroTokens() > 0)) { goldCost = 0; lumberCost = 0; - } - else { + } else { goldCost = simulationUnitType.getGoldCost(); lumberCost = simulationUnitType.getLumberCost(); } @@ -638,8 +642,7 @@ public Void accept(final CAbilityUpgrade ability) { if (this.game.getGameplayConstants().isRelativeUpgradeCosts()) { relativeOffsetGold = existingUnitType.getGoldCost(); relativeOffsetLumber = existingUnitType.getLumberCost(); - } - else { + } else { relativeOffsetGold = 0; relativeOffsetLumber = 0; } @@ -674,12 +677,11 @@ public Void accept(final CAbilityHero ability) { unitType.getValue(), 0, false, false, 0, 0, 0, 0, nextLevel); } } - } - else { + } else { if (this.multiSelect) { return null; } - if (this.menuBaseOrderId == 0) { + if (this.menuBaseOrderId == 0 && ability.isIconShowing()) { final int skillPoints = ability.getSkillPoints(); addCommandButton(ability, this.abilityDataUI.getSelectSkillUI(), ability.getHandleId(), OrderIds.skillmenu, 0, false, true, 0, 0, 0, 0, skillPoints != 0 ? skillPoints : -1); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CDestructable.java index bfa32049e..ebe414bdb 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CDestructable.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CDestructable.java @@ -12,6 +12,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.pathing.CBuildingPathingType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; @@ -23,7 +25,7 @@ public class CDestructable extends CWidget { private final CDestructableType destType; private final RemovablePathingMapInstance pathingInstance; private final RemovablePathingMapInstance pathingInstanceDeath; - private UnitAnimationListenerImpl unitAnimationListenerImpl; + private UnitAnimationListenerImpl unitAnimationListener; private boolean invulnerable; private boolean blighted; private Rectangle registeredEnumRectangle; @@ -70,9 +72,9 @@ public Rectangle getOrCreateRegisteredEnumRectangle() { } @Override - public float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage) { + public float damage(final CSimulation simulation, final CUnit source, final CDamageFlags flags, + final CAttackType attackType, final CDamageType damageType, final String weaponSoundType, + final float damage) { if (isInvulnerable()) { return 0; } @@ -86,11 +88,9 @@ public float damage(final CSimulation simulation, final CUnit source, final bool } @Override - public float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage, final float bonusDamage) { - return this.damage(simulation, source, isAttack, isRanged, attackType, damageType, weaponSoundType, - damage + bonusDamage); + public float damage(CSimulation simulation, CDamageCalculation damage) { + return this.damage(simulation, damage.getSource(), damage.getPrimaryDamageFlags(), damage.getAttackType(), + damage.getPrimaryDamageType(), damage.getWeaponSoundType(), damage.computeRawTotalDamage()); } private void kill(final CSimulation simulation) { @@ -187,7 +187,11 @@ public CDestructableType getDestType() { } public void setUnitAnimationListener(final UnitAnimationListenerImpl unitAnimationListenerImpl) { - this.unitAnimationListenerImpl = unitAnimationListenerImpl; + this.unitAnimationListener = unitAnimationListenerImpl; + } + + public CUnitAnimationListener getUnitAnimationListener() { + return this.unitAnimationListener; } @Override @@ -235,6 +239,10 @@ public void remove(final CSimulation simulation, final CDestructableBuff buff) { this.buffs.remove(buff); buff.onRemove(simulation, this); } + + public List getBuffs() { + return this.buffs; + } public void onRemove(CSimulation cSimulation) { if (this.pathingInstance != null) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CGameplayConstants.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CGameplayConstants.java index efb0fba86..4f173f57a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CGameplayConstants.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CGameplayConstants.java @@ -27,22 +27,29 @@ public class CGameplayConstants { private final float structureDecayTime; private final float buildingAngle; private final float rootAngle; - + private final float fogFlashTime; private final float dyingRevealRadius; private final float foggedAttackRevealRadius; private final float defenseArmor; + + private final boolean canDisableDivineShield; - private final float etherealDamageBonusSpells; - private final float etherealDamageBonusMagic; + private final float[] etherealDamageBonus; private final boolean etherealDamageBonusAlly; + private final float frostAttackSpeedDecrease; + private final float frostMoveSpeedDecrease; + + private final boolean allowMultiBounce; + private final boolean abolishMagicSmartDispel; + private final boolean invulnerableSummonsTakeDispelDamage; private final boolean magicImmuneResistsDamage; private final boolean magicImmuneResistsLeech; private final boolean magicImmuneResistsThorns; private final boolean magicImmuneResistsUltimates; - + private final boolean defendDeflection; private final int heroMaxReviveCostGold; @@ -125,7 +132,7 @@ public class CGameplayConstants { private final float maxUnitSpeed; private final float minBldgSpeed; private final float maxBldgSpeed; - + private final float chanceToMiss; private final float missDamageReduction; @@ -152,6 +159,8 @@ public CGameplayConstants(final DataTable parsedDataTable) { this.fogFlashTime = miscData.getFieldFloatValue("FogFlashTime"); this.dyingRevealRadius = miscData.getFieldFloatValue("DyingRevealRadius"); this.foggedAttackRevealRadius = miscData.getFieldFloatValue("FoggedAttackRevealRadius"); + + this.canDisableDivineShield = miscData.getFieldValue("CanDeactivateDivineShield") != 0; final CDefenseType[] defenseTypeOrder = { CDefenseType.SMALL, CDefenseType.MEDIUM, CDefenseType.LARGE, CDefenseType.FORT, CDefenseType.NORMAL, CDefenseType.HERO, CDefenseType.DIVINE, CDefenseType.NONE, }; @@ -171,8 +180,7 @@ public CGameplayConstants(final DataTable parsedDataTable) { try { this.damageBonusTable[i][defenseType.ordinal()] = Float.parseFloat(damageComponents[j]); // System.out.println(attackType + ":" + defenseType + ": " + damageComponents[j]); - } - catch (final NumberFormatException e) { + } catch (final NumberFormatException e) { throw new RuntimeException(fieldName, e); } } @@ -183,38 +191,49 @@ public CGameplayConstants(final DataTable parsedDataTable) { final String damageBonus = miscData.getField("EtherealDamageBonus"); final String[] damageComponents = damageBonus.split(","); - float magBonus = 1; - float spellBonus = 1; + this.etherealDamageBonus = new float[damageComponents.length + 1]; + this.etherealDamageBonus[this.etherealDamageBonus.length - 1] = 1; for (int j = 0; j < damageComponents.length; j++) { - if (j == 3) { - if (damageComponents[j].length() > 0) { - try { - magBonus = Float.parseFloat(damageComponents[j]); - } - catch (final NumberFormatException e) { - throw new RuntimeException("EtherealDamageBonus", e); - } - } - } else if (j == 5) { - if (damageComponents[j].length() > 0) { - try { - spellBonus = Float.parseFloat(damageComponents[j]); - } - catch (final NumberFormatException e) { - throw new RuntimeException("EtherealDamageBonus", e); - } + int iter = 0; + if (j < 5) { + iter = j + 1; + } else if (j > 5) { + iter = j; + } + /* + * The above reordering is to match the War3 attack type order. The ethereal + * table is organized: + * + * Normal,Pierce,Siege,Magic,Chaos,Spells,Hero + * + * + * But the actual internal attack types are ordered: + * + * Spells,Normal,Pierce,Siege,Magic,Chaos,Hero + */ + if (damageComponents[j].length() > 0) { + try { + this.etherealDamageBonus[iter] = Float.parseFloat(damageComponents[j]); + } catch (final NumberFormatException e) { + throw new RuntimeException("EtherealDamageBonus", e); } + } else { + this.etherealDamageBonus[iter] = 0; } } - this.etherealDamageBonusMagic = magBonus; - this.etherealDamageBonusSpells = spellBonus; this.etherealDamageBonusAlly = miscData.getFieldValue("EtherealDamageBonusAlly") != 0; + + this.frostAttackSpeedDecrease = miscData.getFieldFloatValue("FrostAttackSpeedDecrease"); + this.frostMoveSpeedDecrease = miscData.getFieldFloatValue("FrostMoveSpeedDecrease"); + this.allowMultiBounce = miscData.getFieldValue("AllowMultiBounce") != 0; + this.abolishMagicSmartDispel = miscData.getFieldValue("AbolishMagicDispelSmart") != 0; + this.invulnerableSummonsTakeDispelDamage = miscData.getFieldValue("InvulnSummonDispelDamage") != 0; this.magicImmuneResistsDamage = miscData.getFieldValue("MagicImmunesResistDamage") != 0; this.magicImmuneResistsLeech = miscData.getFieldValue("MagicImmunesResistLeech") != 0; this.magicImmuneResistsThorns = miscData.getFieldValue("MagicImmunesResistThorns") != 0; this.magicImmuneResistsUltimates = miscData.getFieldValue("MagicImmunesResistUltimates") != 0; - + this.defendDeflection = miscData.getFieldValue("DefendDeflection") != 0; this.globalExperience = miscData.getFieldValue("GlobalExperience") != 0; @@ -270,8 +289,7 @@ public CGameplayConstants(final DataTable parsedDataTable) { for (int i = 0; i < this.needHeroXpSum.length; i++) { if (i == 0) { this.needHeroXpSum[i] = this.needHeroXp[i]; - } - else { + } else { this.needHeroXpSum[i] = this.needHeroXp[i] + this.needHeroXpSum[i - 1]; } } @@ -392,18 +410,38 @@ public float getDefenseArmor() { return this.defenseArmor; } - public float getEtherealDamageBonusSpells() { - return etherealDamageBonusSpells; + public boolean isCanDisableDivineShield() { + return canDisableDivineShield; } - public float getEtherealDamageBonusMagic() { - return etherealDamageBonusMagic; + public float[] getEtherealDamageBonus() { + return etherealDamageBonus; } public boolean isEtherealDamageBonusAlly() { return etherealDamageBonusAlly; } + public float getFrostAttackSpeedDecrease() { + return frostAttackSpeedDecrease; + } + + public float getFrostMoveSpeedDecrease() { + return frostMoveSpeedDecrease; + } + + public boolean isAllowMultiBounce() { + return allowMultiBounce; + } + + public boolean isAbolishMagicSmartDispel() { + return abolishMagicSmartDispel; + } + + public boolean isInvulnerableSummonsTakeDispelDamage() { + return invulnerableSummonsTakeDispelDamage; + } + public boolean isMagicImmuneResistsDamage() { return magicImmuneResistsDamage; } @@ -419,6 +457,7 @@ public boolean isMagicImmuneResistsThorns() { public boolean isMagicImmuneResistsUltimates() { return magicImmuneResistsUltimates; } + public boolean isDefendDeflection() { return defendDeflection; } @@ -625,8 +664,7 @@ private static int[] parseTable(final String txt, final int formulaA, final int for (int i = 0; i < tableSize; i++) { if (i < splitTxt.length) { result[i] = Integer.parseInt(splitTxt[i]); - } - else { + } else { result[i] = (formulaA * result[i - 1]) + (formulaB * i) + formulaC; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItem.java index 0d7815586..de4604eda 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItem.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItem.java @@ -9,6 +9,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.inventory.CAbilityInventory; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; @@ -16,8 +18,8 @@ public class CItem extends CWidget { private final static int COLLISION_SIZE = 16; - private final War3ID typeId; - private final CItemType itemType; + private War3ID typeId; + private CItemType itemType; private boolean hidden; private boolean invulnerable; private int charges; @@ -41,6 +43,26 @@ public CItem(final int handleId, final float x, final float y, final float life, this.pawnable = itemTypeInstance.isPawnable(); } + public void setTypeId(CSimulation game, War3ID typeId) { + int slot = 0; + if (this.containedInventory != null) { + slot = this.getContainedInventory().getSlot(this); + this.forceDropIfHeld(game); + } + this.typeId = typeId; + this.itemType = game.getItemData().getItemType(typeId); + this.charges = this.itemType.getNumberOfCharges(); + this.dropOnDeath = this.itemType.isDroppedWhenCarrierDies(); + this.droppable = this.itemType.isCanBeDropped(); + this.pawnable = this.itemType.isPawnable(); + + game.updateItemModel(this); + if (this.containedInventory != null) { + this.containedInventory.giveItem(game, this.containedUnit, this, slot, false); + } + + } + @Override public float getFlyHeight() { return 0; @@ -52,10 +74,10 @@ public float getImpactZ() { } @Override - public float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage) { - if (this.invulnerable) { + public float damage(final CSimulation simulation, final CUnit source, final CDamageFlags flags, + final CAttackType attackType, final CDamageType damageType, final String weaponSoundType, + final float damage) { + if (this.invulnerable && !flags.isIgnoreInvulnerable()) { return 0; } final boolean wasDead = isDead(); @@ -70,11 +92,9 @@ public float damage(final CSimulation simulation, final CUnit source, final bool } @Override - public float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage, final float bonusDamage) { - return this.damage(simulation, source, isAttack, isRanged, attackType, damageType, weaponSoundType, - damage + bonusDamage); + public float damage(CSimulation simulation, CDamageCalculation damage) { + return this.damage(simulation, damage.getSource(), damage.getPrimaryDamageFlags(), damage.getAttackType(), + damage.getPrimaryDamageType(), damage.getWeaponSoundType(), damage.computeRawTotalDamage()); } public void forceDropIfHeld(final CSimulation simulation) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItemType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItemType.java index 3201256f2..bd95de460 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItemType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CItemType.java @@ -6,6 +6,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.item.CItemTypeJass; public class CItemType { + private final War3ID typeId; private final List abilityList; private final War3ID cooldownGroup; private final boolean ignoreCooldown; @@ -31,7 +32,7 @@ public class CItemType { private final boolean includeAsRandomChoice; private final CItemTypeJass itemClass; - public CItemType(final List abilityList, final War3ID cooldownGroup, final boolean ignoreCooldown, + public CItemType(final War3ID typeId, final List abilityList, final War3ID cooldownGroup, final boolean ignoreCooldown, final int numberOfCharges, final boolean activelyUsed, final boolean perishable, final boolean useAutomaticallyWhenAcquired, final int goldCost, final int lumberCost, final int stockMax, final int stockReplenishInterval, final int stockStartDelay, final int maxLife, final String armorType, @@ -39,6 +40,7 @@ public CItemType(final List abilityList, final War3ID cooldownGroup, fin final boolean pawnable, final boolean droppedWhenCarrierDies, final boolean canBeDropped, final boolean validTargetForTransformation, final boolean includeAsRandomChoice, final CItemTypeJass itemClass) { + this.typeId = typeId; this.abilityList = abilityList; this.cooldownGroup = cooldownGroup; this.ignoreCooldown = ignoreCooldown; @@ -65,6 +67,10 @@ public CItemType(final List abilityList, final War3ID cooldownGroup, fin this.itemClass = itemClass; } + public War3ID getTypeId() { + return this.typeId; + } + public List getAbilityList() { return this.abilityList; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CSimulation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CSimulation.java index 307ab61de..7d0fe065b 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CSimulation.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CSimulation.java @@ -40,6 +40,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackInstant; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackMissile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityCollisionProjectileListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; @@ -47,7 +48,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CCollisionProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CEffect; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CJassProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CPsuedoProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CPseudoProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.config.CBasePlayer; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.config.CPlayerAPI; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.config.War3MapConfig; @@ -151,6 +152,7 @@ public CSimulation(final War3MapConfig config, final int mapVersion, final DataT this.upgradeData = new CUpgradeData(this.gameplayConstants, parsedUpgradeData, standardUpgradeEffectMeta); this.unitData = new CUnitData(this.gameplayConstants, parsedUnitData, this.abilityData, this.upgradeData, this.simulationRenderController); + this.unitData.getAllUnitTypesLightweight(); // Quick hack to avoid lag on first cast of Mech Critter this.destructableData = new CDestructableData(parsedDestructableData, simulationRenderController); this.itemData = new CItemData(parsedItemData); this.units = new ArrayList<>(); @@ -180,8 +182,7 @@ public CSimulation(final War3MapConfig config, final int mapVersion, final DataT final CRaceManagerEntry raceEntry = WarsmashConstants.RACE_MANAGER .get(seededRandom.nextInt(WarsmashConstants.RACE_MANAGER.getEntryCount())); defaultRace = WarsmashConstants.RACE_MANAGER.getRace(raceEntry.getRaceId()); - } - else { + } else { for (int j = 0; j < WarsmashConstants.RACE_MANAGER.getEntryCount(); j++) { final CRaceManagerEntry entry = WarsmashConstants.RACE_MANAGER.get(j); final CRace race = WarsmashConstants.RACE_MANAGER.getRace(entry.getRaceId()); @@ -232,6 +233,10 @@ public void onFire(final CSimulation simulation) { fogUpdateTimer.setTimeoutTime(1.0f); fogUpdateTimer.start(this); } + + public char getTileset() { + return this.simulationRenderController.getTileset(); + } public CUnitData getUnitData() { return this.unitData; @@ -290,9 +295,10 @@ public void internalUnregisterTimer(final CTimer timer) { } public CUnit internalCreateUnit(final War3ID typeId, final int playerIndex, final float x, final float y, - final float facing, final BufferedImage buildingPathingPixelMap) { + final float facing, final BufferedImage buildingPathingPixelMap, int editorConfigHitPointPercent, + int editorConfigManaAmount) { final CUnit unit = this.unitData.create(this, playerIndex, typeId, x, y, facing, buildingPathingPixelMap, - this.handleIdAllocator); + this.handleIdAllocator, editorConfigHitPointPercent, editorConfigManaAmount); this.newUnits.add(unit); this.handleIdToUnit.put(unit.getHandleId(), unit); return unit; @@ -321,9 +327,19 @@ public CItem createItem(final War3ID alias, final float unitX, final float unitY return this.simulationRenderController.createItem(this, alias, unitX, unitY); } + public void updateItemModel(CItem item) { + this.simulationRenderController.updateItemModel(item); + } + public CUnit createUnit(final War3ID typeId, final int playerIndex, final float x, final float y, final float facing) { + return this.createUnit(typeId, playerIndex, x, y, facing, false); + } + + public CUnit createUnit(final War3ID typeId, final int playerIndex, final float x, final float y, + final float facing, final boolean constructing) { final CUnit createdUnit = this.simulationRenderController.createUnit(this, typeId, playerIndex, x, y, facing); + createdUnit.setConstructing(constructing); if (createdUnit != null) { setupCreatedUnit(createdUnit); if (createdUnit.getCollisionRectangle() == null) { @@ -347,9 +363,9 @@ public CUnit createUnitSimple(final War3ID typeId, final int playerIndex, final final int foodMade = newUnitType.getFoodMade(); newUnit.setFoodUsed(foodUsed); newUnit.setFoodMade(foodMade); - player.setFoodUsed(player.getFoodUsed() + foodUsed); + player.setUnitFoodUsed(newUnit, foodUsed); if (newUnitType.getFoodMade() != 0) { - player.setFoodCap(player.getFoodCap() + newUnitType.getFoodMade()); + player.setUnitFoodMade(newUnit, foodMade); } player.addTechtreeUnlocked(this, typeId); // nudge unit @@ -391,15 +407,15 @@ protected void onAbilityRemovedFromUnit(final CUnit unit, final CAbility ability public CAttackProjectile createProjectile(final CUnit source, final float launchX, final float launchY, final float launchFacing, final CUnitAttackMissile attack, final AbilityTarget target, final float damage, - final int bounceIndex, final CUnitAttackListener attackListener) { + final int bounceIndex, final CUnitAttackListener attackListener, final CUnitAttackSettings settings) { final CAttackProjectile projectile = this.simulationRenderController.createAttackProjectile(this, launchX, - launchY, launchFacing, source, attack, target, damage, bounceIndex, attackListener); + launchY, launchFacing, source, attack, target, damage, bounceIndex, attackListener, settings); this.newProjectiles.add(projectile); return projectile; } public CAbilityProjectile createProjectile(final CUnit source, final War3ID spellAlias, final float launchX, - final float launchY, final float launchFacing, final float speed, final boolean homing, + final float launchY, final float launchFacing, final Float speed, final Boolean homing, final AbilityTarget target, final CAbilityProjectileListener projectileListener) { final CAbilityProjectile projectile = this.simulationRenderController.createProjectile(this, launchX, launchY, launchFacing, speed, homing, source, spellAlias, target, projectileListener); @@ -408,8 +424,18 @@ public CAbilityProjectile createProjectile(final CUnit source, final War3ID spel return projectile; } + public CAbilityProjectile createProjectile(final CUnit source, final CUnitAttackSettings settings, + final float launchX, final float launchY, final float launchFacing, final AbilityTarget target, + final CAbilityProjectileListener projectileListener) { + final CAbilityProjectile projectile = this.simulationRenderController.createProjectile(this, launchX, launchY, + launchFacing, source, settings, target, projectileListener); + this.newProjectiles.add(projectile); + projectileListener.onLaunch(this, projectile, target); + return projectile; + } + public CJassProjectile createProjectile(final CUnit source, final War3ID spellAlias, final float launchX, - final float launchY, final float launchFacing, final float speed, final boolean homing, + final float launchY, final float launchFacing, final Float speed, final Boolean homing, final AbilityTarget target) { final CJassProjectile projectile = this.simulationRenderController.createJassProjectile(this, launchX, launchY, launchFacing, speed, homing, source, spellAlias, target); @@ -418,7 +444,7 @@ public CJassProjectile createProjectile(final CUnit source, final War3ID spellAl } public CCollisionProjectile createCollisionProjectile(final CUnit source, final War3ID spellAlias, - final float launchX, final float launchY, final float launchFacing, final float speed, final boolean homing, + final float launchX, final float launchY, final float launchFacing, final Float speed, final Boolean homing, final AbilityTarget target, final int maxHits, final int hitsPerTarget, final float startingRadius, final float finalRadius, final float collisionInterval, final CAbilityCollisionProjectileListener projectileListener, final boolean provideCounts) { @@ -430,13 +456,13 @@ public CCollisionProjectile createCollisionProjectile(final CUnit source, final return projectile; } - public CPsuedoProjectile createPseudoProjectile(final CUnit source, final War3ID spellAlias, + public CPseudoProjectile createPseudoProjectile(final CUnit source, final War3ID spellAlias, final CEffectType effectType, final int effectArtIndex, final float launchX, final float launchY, final float launchFacing, final float speed, final float projectileStepInterval, final int projectileArtSkip, final boolean homing, final AbilityTarget target, final int maxHits, final int hitsPerTarget, final float startingRadius, final float finalRadius, final CAbilityCollisionProjectileListener projectileListener, final boolean provideCounts) { - final CPsuedoProjectile projectile = this.simulationRenderController.createPseudoProjectile(this, launchX, + final CPseudoProjectile projectile = this.simulationRenderController.createPseudoProjectile(this, launchX, launchY, launchFacing, speed, projectileStepInterval, projectileArtSkip, homing, source, spellAlias, effectType, effectArtIndex, target, maxHits, hitsPerTarget, startingRadius, finalRadius, projectileListener, provideCounts); @@ -471,6 +497,10 @@ public SimulationRenderComponentLightning createAbilityLightning(final CUnit sou duration); } + public SimulationRenderComponent createStaticUberSplat(float x, float y, War3ID id) { + return this.simulationRenderController.createStaticUberSplat(x, y, id); + } + public void createInstantAttackEffect(final CUnit source, final CUnitAttackInstant attack, final CWidget target) { this.simulationRenderController.createInstantAttackEffect(this, source, attack, target); } @@ -550,14 +580,12 @@ public void update() { if (!this.falseTimeOfDay.tick()) { this.falseTimeOfDay = null; } - } - else { + } else { if (this.nextGameTime != null) { this.currentGameDayTimeElapsed = (this.nextGameTime / this.gameplayConstants.getGameDayHours()) * this.gameplayConstants.getGameDayLength(); this.nextGameTime = null; - } - else if (!this.timeOfDaySuspended) { + } else if (!this.timeOfDaySuspended) { this.currentGameDayTimeElapsed = (this.currentGameDayTimeElapsed + WarsmashConstants.SIMULATION_STEP_TIME) % this.gameplayConstants.getGameDayLength(); } @@ -867,6 +895,10 @@ public void unitStopSoundEffectEvent(final CUnit caster, final War3ID alias) { this.simulationRenderController.stopAbilitySoundEffect(caster, alias); } + public SimulationRenderComponent locationSoundEffectEvent(final float x, final float y, final War3ID alias, final boolean looping) { + return this.simulationRenderController.spawnAbilitySoundEffect(x, y, alias, looping); + } + public void unitPreferredSelectionReplacement(final CUnit unit, final CUnit newUnit) { this.simulationRenderController.unitPreferredSelectionReplacement(unit, newUnit); } @@ -1106,8 +1138,8 @@ public void setBlight(final float x, final float y, final float radius, final bo this.simulationRenderController.setBlight(x, y, radius, blighted); } - public void unitUpdatedType(final CUnit unit, final War3ID typeId) { - this.simulationRenderController.unitUpdatedType(unit, typeId); + public void unitUpdatedType(final CUnit unit, final War3ID typeId, final boolean updatePortrait) { + this.simulationRenderController.unitUpdatedType(unit, typeId, updatePortrait); } private void setupCreatedUnit(final CUnit unit) { @@ -1123,6 +1155,10 @@ private void setupCreatedUnit(final CUnit unit) { } } + public void changeUnitScale(final CUnit unit, final float scale, boolean multiplier) { + this.simulationRenderController.changeUnitScale(unit, scale, multiplier); + } + public void changeUnitColor(final CUnit unit, final int playerIndex) { this.simulationRenderController.changeUnitColor(unit, playerIndex); } @@ -1151,6 +1187,30 @@ public GlobalScope getGlobalScope() { return this.globalScope; } + public int[] getTerrainModBufferSize(float x, float y, float width, float height) { + return this.simulationRenderController.getTerrainModBufferSize(x, y, width, height); + } + + public int[] getTerrainModBufferSize(float centerX, float centerY, float radius) { + return this.simulationRenderController.getTerrainModBufferSize(centerX, centerY, radius); + } + + public void adjustTerrain(int[] rect, float[] modBuffer) { + this.simulationRenderController.adjustTerrain(rect, modBuffer); + } + + public void adjustTerrain(float x, float y, float i) { + this.simulationRenderController.adjustTerrain(x, y, i); + } + + public float getTerrainSpaceX(final float x) { + return this.simulationRenderController.getTerrainSpaceX(x); + } + + public float getTerrainSpaceY(final float y) { + return this.simulationRenderController.getTerrainSpaceY(y); + } + public int getTerrainHeight(final float x, final float y) { return this.simulationRenderController.getTerrainHeight(x, y); } @@ -1197,30 +1257,24 @@ public byte getFogStateFromSettings(byte mask) { if (this.fogMaskEnabled) { if (this.fogEnabled) { return CFogState.MASKED.getMask(); - } - else { + } else { return CFogState.MASKED.getMask(); } - } - else if (this.fogEnabled) { + } else if (this.fogEnabled) { return CFogState.FOGGED.getMask(); - } - else { + } else { return CFogState.VISIBLE.getMask(); } case FOGGED: if (this.fogMaskEnabled) { if (this.fogEnabled) { return CFogState.FOGGED.getMask(); - } - else { + } else { return CFogState.VISIBLE.getMask(); } - } - else if (this.fogEnabled) { + } else if (this.fogEnabled) { return CFogState.FOGGED.getMask(); - } - else { + } else { return CFogState.VISIBLE.getMask(); } case VISIBLE: diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java index a8a39ee79..b6bd66a87 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java @@ -5,6 +5,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -53,8 +54,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABGenericTimedBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTickingPausedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABGenericTimedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.CPausedTickingBuff; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorAbilityVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorTargetUnitVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; @@ -72,6 +73,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build.AbilityDisableWhileUpgradingVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.harvest.CBehaviorReturnResources; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CRegenType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; @@ -79,9 +82,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenModificationListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenModificationListenerDamageModResult; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackEvasionListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackFinalDamageTakenModificationListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPostDamageListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerPriority; @@ -92,9 +93,11 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDefaultAccuracyCheckListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDefaultEtherealDamageModListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDefaultLifestealListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDefaultMagicImmuneDamageModListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDefaultSleepListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDefaultThornsListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackModifier; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitPriorityLoopData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.listeners.CUnitAbilityProjReactionListener; @@ -119,6 +122,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CFogState; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitAppliedUpgrade; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitBehaviorChangeListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CWidgetEvent; @@ -127,6 +131,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuffType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.upgrade.CUpgradeEffect; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityActivationReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; @@ -139,6 +144,9 @@ public class CUnit extends CWidget { private static RegionCheckerImpl regionCheckerImpl = new RegionCheckerImpl(); + private static CUnitPriorityLoopData attackModLoop = new CUnitPriorityLoopData(); + private static StateModBuff pauseBuff = new StateModBuff(StateModBuffType.PAUSED, 1); + private War3ID typeId; private float facing; // degrees private float mana; @@ -152,7 +160,10 @@ public class CUnit extends CWidget { private float manaRegenBonus; private int baseMaximumMana; private int maximumMana; - private int speed; + private int maxSpeed; + private int minSpeed; + private int baseSpeed; + private int finalSpeed; private int agilityDefensePermanentBonus; private float agilityDefenseTemporaryBonus; private int permanentDefenseBonus; @@ -182,9 +193,11 @@ public class CUnit extends CWidget { private float turnRate; private float propWindow; private int playerIndex; + private int fakePlayerIndex; private final List abilities = new ArrayList<>(); private final List disabledAbilities = new ArrayList<>(); + private final Set appliedUpgrades = new HashSet<>(); private final List onTickTriggers = new ArrayList<>(); private CBehavior currentBehavior; @@ -234,10 +247,12 @@ public class CUnit extends CWidget { private boolean acceptingOrders = true; private boolean invulnerable = false; private boolean magicImmune = false; + private boolean limitedMagicImmune = false; private boolean morphImmune = false; private boolean resistant = false; private boolean autoAttack = true; private boolean autoCast = true; + private boolean autoTargetable = true; private boolean assistAlly = true; private boolean moveDisabled = false; private boolean noUnitCollision = false; @@ -267,13 +282,13 @@ public class CUnit extends CWidget { private final Map> preDamageListeners = new HashMap<>(); private final List postDamageListeners = new ArrayList<>(); private final List damageTakenModificationListeners = new ArrayList<>(); - private final List finalDamageTakenModificationListeners = new ArrayList<>(); private final List damageTakenListeners = new ArrayList<>(); private final Map> deathReplacementEffects = new HashMap<>(); private final List evasionListeners = new ArrayList<>(); private final List attackProjReactionListeners = new ArrayList<>(); private final List abilityProjReactionListeners = new ArrayList<>(); private final List abilityEffectReactionListeners = new ArrayList<>(); + private final List attackModifiers = new ArrayList<>(); private final List behaviorChangeListeners = new ArrayList<>(); @@ -291,13 +306,27 @@ public class CUnit extends CWidget { private final List detectorLevels = new ArrayList<>(1); private long detections = 0; + private boolean hideMinimapIcon; + + private long unselectablePlayers = 0; + private long untargetablePlayers = 0; + + private boolean unenumerable = false; + private MovementType movementOverride = null; + private boolean repairBlocked; + private boolean trainingBlocked; + private boolean constructionBlocked; + + private List uniqueFlags = null; + public CUnit(final int handleId, final int playerIndex, final float x, final float y, final float life, final War3ID typeId, final float facing, final float mana, final int maximumLife, final float lifeRegen, - final int maximumMana, final int speed, final CUnitType unitType) { + final int maximumMana, final int speed, final int maxSpeed, final int minSpeed, final CUnitType unitType) { super(handleId, x, y, life); this.playerIndex = playerIndex; + this.fakePlayerIndex = playerIndex; this.typeId = typeId; this.facing = facing; this.mana = mana; @@ -307,7 +336,9 @@ public CUnit(final int handleId, final int playerIndex, final float x, final flo this.manaRegen = unitType.getManaRegen(); this.baseMaximumMana = maximumMana; this.maximumMana = maximumMana; - this.speed = speed; + this.maxSpeed = maxSpeed; + this.minSpeed = minSpeed; + this.baseSpeed = speed; this.flyHeight = unitType.getDefaultFlyingHeight(); this.turnRate = unitType.getTurnRate(); this.propWindow = unitType.getPropWindow(); @@ -328,13 +359,17 @@ public CUnit(final int handleId, final int playerIndex, final float x, final flo computeAllDerivedFields(); } - private void beginBehavior(final CSimulation game, final CBehavior behavior) { + public void beginBehavior(final CSimulation game, final CBehavior behavior) { + this.beginBehavior(game, behavior, false); + } + + public void beginBehavior(final CSimulation game, final CBehavior behavior, boolean interrupted) { if (this.currentBehavior != behavior) { final int lastBehaviorHighlightOrderId = this.currentBehavior != null ? this.currentBehavior.getHighlightOrderId() : -1; if (this.currentBehavior != null) { - this.currentBehavior.end(game, false); + this.currentBehavior.end(game, interrupted); } fireBehaviorChangeEvent(game, behavior, false); @@ -364,7 +399,7 @@ public void fireBehaviorChangeEvent(final CSimulation game, final CBehavior beha } public void performDefaultBehavior(final CSimulation game) { - beginBehavior(game, this.defaultBehavior); + beginBehavior(game, this.defaultBehavior, true); } public void regeneratePathingInstance(final CSimulation game, final BufferedImage buildingPathingPixelMap) { @@ -410,7 +445,7 @@ public byte getInvisLevels() { return this.invisLevels; } - public void addNonStackingStatBuff(final NonStackingStatBuff buff) { + public void addNonStackingStatBuff(final CSimulation game, final NonStackingStatBuff buff) { if (buff.getBuffType() == NonStackingStatBuffType.ALLATK) { Map> buffKeyMap = this.nonStackingBuffs .get(NonStackingStatBuffType.MELEEATK); @@ -436,8 +471,7 @@ public void addNonStackingStatBuff(final NonStackingStatBuff buff) { buffKeyMap.put(buff.getStackingKey(), theList); } theList.add(buff); - } - else if (buff.getBuffType() == NonStackingStatBuffType.ALLATKPCT) { + } else if (buff.getBuffType() == NonStackingStatBuffType.ALLATKPCT) { Map> buffKeyMap = this.nonStackingBuffs .get(NonStackingStatBuffType.MELEEATKPCT); if (buffKeyMap == null) { @@ -462,8 +496,7 @@ else if (buff.getBuffType() == NonStackingStatBuffType.ALLATKPCT) { buffKeyMap.put(buff.getStackingKey(), theList); } theList.add(buff); - } - else { + } else { Map> buffKeyMap = this.nonStackingBuffs.get(buff.getBuffType()); if (buffKeyMap == null) { buffKeyMap = new HashMap<>(); @@ -476,17 +509,23 @@ else if (buff.getBuffType() == NonStackingStatBuffType.ALLATKPCT) { } theList.add(buff); } - computeDerivedFields(buff.getBuffType()); + if (buff.getBuffType().isHeroStat()) { + computeDerivedHeroFields(game, buff.getBuffType()); + } else { + computeDerivedFields(buff.getBuffType()); + } } - public void removeNonStackingStatBuff(final NonStackingStatBuff buff) { + public void removeNonStackingStatBuff(final CSimulation game, final NonStackingStatBuff buff) { if (buff.getBuffType() == NonStackingStatBuffType.ALLATK) { Map> buffKeyMap = this.nonStackingBuffs .get(NonStackingStatBuffType.MELEEATK); try { buffKeyMap.get(buff.getStackingKey()).remove(buff); - } - catch (final Exception e) { + if (buffKeyMap.get(buff.getStackingKey()).isEmpty()) { + buffKeyMap.remove(buff.getStackingKey()); + } + } catch (final Exception e) { System.err.println(e.getLocalizedMessage()); System.err.println(e.getStackTrace().toString()); System.err.println("From: " + getTypeId().asStringValue()); @@ -495,20 +534,23 @@ public void removeNonStackingStatBuff(final NonStackingStatBuff buff) { buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.RNGDATK); try { buffKeyMap.get(buff.getStackingKey()).remove(buff); - } - catch (final Exception e) { + if (buffKeyMap.get(buff.getStackingKey()).isEmpty()) { + buffKeyMap.remove(buff.getStackingKey()); + } + } catch (final Exception e) { System.err.println(e.getLocalizedMessage()); System.err.println(e.getStackTrace().toString()); System.err.println("From: " + getTypeId().asStringValue()); } - } - else if (buff.getBuffType() == NonStackingStatBuffType.ALLATKPCT) { + } else if (buff.getBuffType() == NonStackingStatBuffType.ALLATKPCT) { Map> buffKeyMap = this.nonStackingBuffs .get(NonStackingStatBuffType.MELEEATKPCT); try { buffKeyMap.get(buff.getStackingKey()).remove(buff); - } - catch (final Exception e) { + if (buffKeyMap.get(buff.getStackingKey()).isEmpty()) { + buffKeyMap.remove(buff.getStackingKey()); + } + } catch (final Exception e) { System.err.println(e.getLocalizedMessage()); System.err.println(e.getStackTrace().toString()); System.err.println("From: " + getTypeId().asStringValue()); @@ -517,25 +559,32 @@ else if (buff.getBuffType() == NonStackingStatBuffType.ALLATKPCT) { buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.RNGDATKPCT); try { buffKeyMap.get(buff.getStackingKey()).remove(buff); - } - catch (final Exception e) { + if (buffKeyMap.get(buff.getStackingKey()).isEmpty()) { + buffKeyMap.remove(buff.getStackingKey()); + } + } catch (final Exception e) { System.err.println(e.getLocalizedMessage()); System.err.println(e.getStackTrace().toString()); System.err.println("From: " + getTypeId().asStringValue()); } - } - else { + } else { final Map> buffKeyMap = this.nonStackingBuffs.get(buff.getBuffType()); try { buffKeyMap.get(buff.getStackingKey()).remove(buff); - } - catch (final Exception e) { + if (buffKeyMap.get(buff.getStackingKey()).isEmpty()) { + buffKeyMap.remove(buff.getStackingKey()); + } + } catch (final Exception e) { System.err.println(e.getLocalizedMessage()); System.err.println(e.getStackTrace().toString()); System.err.println("From: " + getTypeId().asStringValue()); } } - computeDerivedFields(buff.getBuffType()); + if (buff.getBuffType().isHeroStat()) { + computeDerivedHeroFields(game, buff.getBuffType()); + } else { + computeDerivedFields(buff.getBuffType()); + } } public void addStateModBuff(final StateModBuff listener) { @@ -558,19 +607,42 @@ public void removeAllStateModBuffs(final StateModBuffType type) { public void computeUnitState(final CSimulation game, final StateModBuffType type) { switch (type) { + case ENABLE_ATTACK: + case DISABLE_ALL: + case DISABLE_MOVE: case DISABLE_ATTACK: case DISABLE_MELEE_ATTACK: case DISABLE_RANGED_ATTACK: case DISABLE_SPECIAL_ATTACK: case DISABLE_SPELLS: case ETHEREAL: + case POLYMORPHED: + byte extraEnabledAttacks = 0; + boolean isDisableAll = false; + boolean isDisableMove = false; boolean isDisableAttack = false; boolean isDisableMeleeAttack = false; boolean isDisableRangedAttack = false; boolean isDisableSpecialAttack = false; boolean isDisableSpells = false; boolean isEthereal = false; + boolean isPolymorphed = false; for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.ENABLE_ATTACK) { + if (buff.getValue() != 0) { + extraEnabledAttacks |= buff.getValue(); + } + } + if (buff.getBuffType() == StateModBuffType.DISABLE_ALL) { + if (buff.getValue() != 0) { + isDisableAll = true; + } + } + if (buff.getBuffType() == StateModBuffType.DISABLE_MOVE) { + if (buff.getValue() != 0) { + isDisableMove = true; + } + } if (buff.getBuffType() == StateModBuffType.DISABLE_ATTACK) { if (buff.getValue() != 0) { isDisableAttack = true; @@ -601,6 +673,16 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type isEthereal = true; } } + if (buff.getBuffType() == StateModBuffType.POLYMORPHED) { + if (buff.getValue() != 0) { + isPolymorphed = true; + } + } + } + if (isDisableAll) { + isDisableMove = true; + isDisableAttack = true; + isDisableSpells = true; } // CAbility attack = this.getFirstAbilityOfType(CAbilityAttack.class); // if (attack != null) { @@ -608,21 +690,27 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type // } for (final CAbility ability : this.abilities) { if (((isDisableAttack || isEthereal) && (ability.getAbilityCategory() == CAbilityCategory.ATTACK)) + || (isDisableMove && (ability.getAbilityCategory() == CAbilityCategory.MOVEMENT)) || (isDisableSpells && (ability.getAbilityCategory() == CAbilityCategory.SPELL) - && !ability.isPhysical()) + && ability.isMagic()) || (isEthereal && ability.isPhysical() && ((ability.getAbilityCategory() == CAbilityCategory.SPELL) - || (ability.getAbilityCategory() == CAbilityCategory.CORE)))) { - ability.setDisabled(true, CAbilityDisableType.ATTACKDISABLED); - } - else { - ability.setDisabled(false, CAbilityDisableType.ATTACKDISABLED); + || (ability.getAbilityCategory() == CAbilityCategory.CORE))) + || (isPolymorphed && ((ability.getAbilityCategory() == CAbilityCategory.SPELL) + || (ability.getAbilityCategory() == CAbilityCategory.PASSIVE + || ability.getAbilityCategory() == CAbilityCategory.ATTACK + || (ability.getAbilityCategory() == CAbilityCategory.CORE + && ability.isPhysical()))))) { + ability.setDisabled(true, CAbilityDisableType.DISABLED_EFFECT); + } else { + ability.setDisabled(false, CAbilityDisableType.DISABLED_EFFECT); } } final List newAttackList = new ArrayList(); for (int i = 0; i < this.unitSpecificAttacks.size(); i++) { final CUnitAttack attack = this.unitSpecificAttacks.get(i); - if (((getUnitType().getAttacksEnabled() & (i + 1)) != 0) && !isDisableAttack + if ((((getUnitType().getAttacksEnabled() & (1 << i)) != 0) || ((extraEnabledAttacks & (1 << i)) != 0)) + && !isDisableAttack && (!isDisableMeleeAttack || !attack.getWeaponType().equals(CWeaponType.NORMAL)) && (!isDisableRangedAttack || attack.getWeaponType().equals(CWeaponType.NORMAL)) && (!isDisableSpecialAttack || !((attack.getTargetsAllowed().size() == 1) @@ -633,15 +721,47 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type } setUnitSpecificCurrentAttacks(newAttackList); notifyAttacksChanged(); - checkDisabledAbilities(game, isDisableAttack); + switch (type) { + case ENABLE_ATTACK: + checkDisabledAbilities(game, isDisableAttack); + break; + case DISABLE_ALL: + checkDisabledAbilities(game, isDisableAll); + break; + case DISABLE_MOVE: + checkDisabledAbilities(game, isDisableMove); + break; + case DISABLE_ATTACK: + checkDisabledAbilities(game, isDisableAttack); + break; + case DISABLE_MELEE_ATTACK: + checkDisabledAbilities(game, isDisableMeleeAttack); + break; + case DISABLE_RANGED_ATTACK: + checkDisabledAbilities(game, isDisableRangedAttack); + break; + case DISABLE_SPECIAL_ATTACK: + checkDisabledAbilities(game, isDisableSpecialAttack); + break; + case DISABLE_SPELLS: + checkDisabledAbilities(game, isDisableSpells); + break; + case ETHEREAL: + checkDisabledAbilities(game, isEthereal); + break; + case POLYMORPHED: + checkDisabledAbilities(game, isPolymorphed); + break; + default: + break; + } if (isEthereal) { if (!this.damageTakenModificationListeners.contains(CUnitDefaultEtherealDamageModListener.INSTANCE)) { addDamageTakenModificationListener(CUnitDefaultEtherealDamageModListener.INSTANCE); } game.changeUnitVertexColor(this, RenderUnit.ETHEREAL); - } - else { + } else { if (this.damageTakenModificationListeners.contains(CUnitDefaultEtherealDamageModListener.INSTANCE)) { removeDamageTakenModificationListener(CUnitDefaultEtherealDamageModListener.INSTANCE); game.changeUnitVertexColor(this, RenderUnit.DEFAULT); @@ -691,18 +811,6 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type } } setMagicImmune(isMagicImmune); - if (isMagicImmune) { - if (!this.finalDamageTakenModificationListeners - .contains(CUnitDefaultMagicImmuneDamageModListener.INSTANCE)) { - addFinalDamageTakenModificationListener(CUnitDefaultMagicImmuneDamageModListener.INSTANCE); - } - } - else { - if (this.finalDamageTakenModificationListeners - .contains(CUnitDefaultMagicImmuneDamageModListener.INSTANCE)) { - removeFinalDamageTakenModificationListener(CUnitDefaultMagicImmuneDamageModListener.INSTANCE); - } - } break; case MORPH_IMMUNE: boolean isMorphImmune = false; @@ -730,16 +838,23 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type case STUN: boolean isSleeping = false; boolean isStun = false; + boolean updateAnim = false; for (final StateModBuff buff : this.stateModBuffs) { if (buff.getBuffType() == StateModBuffType.SLEEPING) { if (buff.getValue() != 0) { isSleeping = true; } + if (buff.getValue() == 1) { + updateAnim = true; + } } if (buff.getBuffType() == StateModBuffType.STUN) { if (buff.getValue() != 0) { isStun = true; } + if (buff.getValue() == 1) { + updateAnim = true; + } } } if (isSleeping || isStun) { @@ -749,13 +864,12 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type this.interruptedBehavior = this.currentBehavior; this.interruptedDefaultBehavior = this.defaultBehavior; } - this.currentBehavior = new CBehaviorStun(this); + this.currentBehavior = new CBehaviorStun(this, updateAnim); this.currentBehavior.begin(game); setDefaultBehavior(this.currentBehavior); this.stateNotifier.ordersChanged(); } - } - else { + } else { if ((this.currentBehavior != null) && (this.currentBehavior.getHighlightOrderId() == OrderIds.stunned)) { // this.setAcceptingOrders(true); @@ -771,8 +885,7 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type if (!this.damageTakenListeners.contains(CUnitDefaultSleepListener.INSTANCE)) { addDamageTakenListener(CUnitDefaultSleepListener.INSTANCE); } - } - else { + } else { if (this.damageTakenListeners.contains(CUnitDefaultSleepListener.INSTANCE)) { removeDamageTakenListener(CUnitDefaultSleepListener.INSTANCE); } @@ -790,13 +903,24 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type if (isSnared) { setFlyHeight(0); this.moveDisabled = true; - } - else { + } else { if (this.moveDisabled) { setFlyHeight(this.unitType.getDefaultFlyingHeight()); this.moveDisabled = false; } } + break; + case PAUSED: + boolean isPaused = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.PAUSED) { + if (buff.getValue() != 0) { + isPaused = true; + } + } + } + this.paused = isPaused; + break; case DISABLE_UNIT_COLLISION: boolean isDisableCollision = false; @@ -811,8 +935,7 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type if (!this.noUnitCollision) { this.noUnitCollision = true; } - } - else { + } else { if (this.noUnitCollision) { this.noUnitCollision = false; } @@ -831,8 +954,7 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type if (!this.noBuildingCollision) { this.noBuildingCollision = true; } - } - else { + } else { if (this.noBuildingCollision) { this.noBuildingCollision = false; } @@ -850,6 +972,37 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type setInvulnerable(isInvuln); this.stateNotifier.abilitiesChanged(); break; + case HIDE_MINIMAP_ICON: + boolean hideMini = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.HIDE_MINIMAP_ICON) { + if (buff.getValue() != 0) { + hideMini = true; + } + } + } + this.hideMinimapIcon = hideMini; + break; + case FALSE_OWNERSHIP: + int fakePlayerId = -1; + int prio = -1; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.FALSE_OWNERSHIP) { + if (buff.getValue() != 0) { + int pr = (int) (buff.getValue() & 0b1111); + if (pr > prio) { + prio = pr; + fakePlayerId = (int) (buff.getValue() >> 4); + } + } + } + } + if (fakePlayerId >= 0) { + this.fakePlayerIndex = fakePlayerId; + } else { + this.fakePlayerIndex = this.playerIndex; + } + break; case DETECTOR: this.detectorLevels.clear(); for (final StateModBuff buff : this.stateModBuffs) { @@ -884,6 +1037,83 @@ public void computeUnitState(final CSimulation game, final StateModBuffType type } this.detections = detections; break; + case UNSELECTABLE: + long unselectablePlayers = 0; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.UNSELECTABLE) { + if (buff.getValue() != 0) { + unselectablePlayers = (unselectablePlayers | buff.getValue()); + } + } + } + this.unselectablePlayers = unselectablePlayers; + break; + case UNTARGETABLE: + long untargetablePlayers = 0; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.UNTARGETABLE) { + if (buff.getValue() != 0) { + untargetablePlayers = (untargetablePlayers | buff.getValue()); + } + } + } + this.untargetablePlayers = untargetablePlayers; + break; + case UNENUMERABLE: + boolean isUnenumerable = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.UNENUMERABLE) { + if (buff.getValue() != 0) { + isUnenumerable = true; + } + } + } + this.unenumerable = isUnenumerable; + break; + case UNAUTOATTACKABLE: + boolean isUnAutoAttackable = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.UNAUTOATTACKABLE) { + if (buff.getValue() != 0) { + isUnAutoAttackable = true; + } + } + } + this.autoTargetable = !isUnAutoAttackable; + break; + case BLOCK_REPAIR: + boolean isRepairBlocked = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.BLOCK_REPAIR) { + if (buff.getValue() != 0) { + isRepairBlocked = true; + } + } + } + this.repairBlocked = isRepairBlocked; + break; + case BLOCK_TRAINING: + boolean isTrainingBlocked = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.BLOCK_TRAINING) { + if (buff.getValue() != 0) { + isTrainingBlocked = true; + } + } + } + this.trainingBlocked = isTrainingBlocked; + break; + case BLOCK_CONSTRUCTION: + boolean isConstructionBlocked = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.BLOCK_CONSTRUCTION) { + if (buff.getValue() != 0) { + isConstructionBlocked = true; + } + } + } + this.constructionBlocked = isConstructionBlocked; + break; default: break; } @@ -904,13 +1134,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -925,13 +1154,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -955,13 +1183,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -976,13 +1203,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -997,13 +1223,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1025,13 +1250,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1046,13 +1270,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1068,13 +1291,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1095,13 +1317,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1116,22 +1337,22 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } if (buffForKey == null) { continue; } - totalNSMvSpdBuff += buffForKey * this.speed; + totalNSMvSpdBuff += buffForKey * this.baseSpeed; } this.speedBonus = Math.round(totalNSMvSpdBuff); + this.computeFinalSpeed(); break; case MELEEATK: case MELEEATKPCT: @@ -1181,13 +1402,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1209,13 +1429,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1226,8 +1445,7 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { } if (this.lifestealListener != null) { this.lifestealListener.setAmount(totalNSVampBuff); - } - else { + } else { this.lifestealListener = new CUnitDefaultLifestealListener(totalNSVampBuff); addPostDamageListener(this.lifestealListener); } @@ -1240,13 +1458,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1257,8 +1474,7 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { } if (this.flatThornsListener != null) { this.flatThornsListener.setAmount(totalNSThornsBuff); - } - else { + } else { this.flatThornsListener = new CUnitDefaultThornsListener(false, totalNSThornsBuff); addDamageTakenListener(this.flatThornsListener); } @@ -1271,13 +1487,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1288,8 +1503,7 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { } if (this.percentThornsListener != null) { this.percentThornsListener.setAmount(totalNSThornsPctBuff); - } - else { + } else { this.percentThornsListener = new CUnitDefaultThornsListener(true, totalNSThornsPctBuff); addDamageTakenListener(this.percentThornsListener); } @@ -1303,13 +1517,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1324,13 +1537,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1343,8 +1555,7 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { if (newMaxLife > this.maximumLife) { this.life += newMaxLife - this.maximumLife; this.maximumLife = newMaxLife; - } - else { + } else { this.maximumLife = newMaxLife; this.life = Math.min(this.life, this.maximumLife); } @@ -1358,13 +1569,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1379,13 +1589,12 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); } } } @@ -1398,17 +1607,172 @@ public void computeDerivedFields(final NonStackingStatBuffType type) { if (newMaxMana > this.maximumMana) { this.mana += newMaxMana - this.maximumMana; this.maximumMana = newMaxMana; - } - else { + } else { this.maximumMana = newMaxMana; this.mana = Math.min(this.mana, this.maximumMana); } break; + case STR: + case STRPCT: + case AGI: + case AGIPCT: + case INT: + case INTPCT: + throw new RuntimeException("Cannot run method with hero stat type"); default: break; } } + public void computeDerivedHeroFields(final CSimulation game, final NonStackingStatBuffType type) { + Map> buffKeyMap; + switch (type) { + case STRPCT: + case STR: + if (this.isHero()) { + float totalStrBuff = 0; + buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.STR); + for (final String key : buffKeyMap.keySet()) { + Float buffForKey = null; + for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { + if (buffForKey == null) { + buffForKey = buff.getValue(); + } else { + if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { + buffForKey += buff.getValue(); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); + } + } + } + if (buffForKey == null) { + continue; + } + totalStrBuff += buffForKey; + } + buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.STRPCT); + for (final String key : buffKeyMap.keySet()) { + Float buffForKey = null; + for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { + if (buffForKey == null) { + buffForKey = buff.getValue(); + } else { + if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { + buffForKey += buff.getValue(); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); + } + } + } + if (buffForKey == null) { + continue; + } + totalStrBuff += buffForKey * this.getHeroData().getStrength().getCurrentBase(); + } + this.getHeroData().setStrengthBuffBonus(game, this, Math.round(totalStrBuff)); + } + break; + case AGIPCT: + case AGI: + if (this.isHero()) { + float totalAgiBuff = 0; + buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.AGI); + for (final String key : buffKeyMap.keySet()) { + Float buffForKey = null; + for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { + if (buffForKey == null) { + buffForKey = buff.getValue(); + } else { + if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { + buffForKey += buff.getValue(); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); + } + } + } + if (buffForKey == null) { + continue; + } + totalAgiBuff += buffForKey; + } + buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.AGIPCT); + for (final String key : buffKeyMap.keySet()) { + Float buffForKey = null; + for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { + if (buffForKey == null) { + buffForKey = buff.getValue(); + } else { + if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { + buffForKey += buff.getValue(); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); + } + } + } + if (buffForKey == null) { + continue; + } + totalAgiBuff += buffForKey * this.getHeroData().getAgility().getCurrentBase(); + } + this.getHeroData().setAgilityBuffBonus(game, this, Math.round(totalAgiBuff)); + } + break; + case INTPCT: + case INT: + if (this.isHero()) { + float totalIntBuff = 0; + buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.INT); + for (final String key : buffKeyMap.keySet()) { + Float buffForKey = null; + for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { + if (buffForKey == null) { + buffForKey = buff.getValue(); + } else { + if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { + buffForKey += buff.getValue(); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); + } + } + } + if (buffForKey == null) { + continue; + } + totalIntBuff += buffForKey; + } + buffKeyMap = this.nonStackingBuffs.get(NonStackingStatBuffType.INTPCT); + for (final String key : buffKeyMap.keySet()) { + Float buffForKey = null; + for (final NonStackingStatBuff buff : buffKeyMap.get(key)) { + if (buffForKey == null) { + buffForKey = buff.getValue(); + } else { + if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { + buffForKey += buff.getValue(); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey + : buff.getValue(); + } + } + } + if (buffForKey == null) { + continue; + } + totalIntBuff += buffForKey * this.getHeroData().getIntelligence().getCurrentBase(); + } + this.getHeroData().setIntelligenceBuffBonus(game, this, Math.round(totalIntBuff)); + } + break; + default: + throw new RuntimeException("Cannot run method with non-hero stat type"); + } + } + public NonStackingFx addNonStackingFx(final CSimulation game, final String stackingKey, final War3ID id, final CEffectType target) { List existingArts = this.nonStackingFx.get(stackingKey); @@ -1420,8 +1784,7 @@ public NonStackingFx addNonStackingFx(final CSimulation game, final String stack if (existingArts.isEmpty()) { final SimulationRenderComponent fx = game.createPersistentSpellEffectOnUnit(this, id, target); newFx.setArt(fx); - } - else { + } else { newFx.setArt(existingArts.iterator().next().getArt()); } existingArts.add(newFx); @@ -1446,14 +1809,12 @@ public void addNonStackingDisplayBuff(final CSimulation game, final String stack } if (existingBuffs.isEmpty()) { this.add(game, buff); - } - else { + } else { final CBuff currentBuff = this.getFirstAbilityOfType(buff.getClass()); if (currentBuff == null) { existingBuffs.clear(); this.add(game, buff); - } - else { + } else { if (buff.getLevel() >= currentBuff.getLevel()) { this.remove(game, currentBuff); this.add(game, buff); @@ -1507,6 +1868,12 @@ private void initializeNonStackingBuffs() { this.nonStackingBuffs.put(NonStackingStatBuffType.MAXHPPCT, new HashMap<>(1)); this.nonStackingBuffs.put(NonStackingStatBuffType.MAXMP, new HashMap<>(1)); this.nonStackingBuffs.put(NonStackingStatBuffType.MAXMPPCT, new HashMap<>(1)); + this.nonStackingBuffs.put(NonStackingStatBuffType.STR, new HashMap<>(1)); + this.nonStackingBuffs.put(NonStackingStatBuffType.STRPCT, new HashMap<>(1)); + this.nonStackingBuffs.put(NonStackingStatBuffType.AGI, new HashMap<>(1)); + this.nonStackingBuffs.put(NonStackingStatBuffType.AGIPCT, new HashMap<>(1)); + this.nonStackingBuffs.put(NonStackingStatBuffType.INT, new HashMap<>(1)); + this.nonStackingBuffs.put(NonStackingStatBuffType.INTPCT, new HashMap<>(1)); } private void initializeListenerLists() { @@ -1536,10 +1903,12 @@ private void computeAllDerivedFields() { } private void computeAllUnitStates(final CSimulation game) { + computeUnitState(game, StateModBuffType.FALSE_OWNERSHIP); + computeUnitState(game, StateModBuffType.HIDE_MINIMAP_ICON); computeUnitState(game, StateModBuffType.DETECTOR); computeUnitState(game, StateModBuffType.INVISIBLE); computeUnitState(game, StateModBuffType.INVULNERABLE); - computeUnitState(game, StateModBuffType.ETHEREAL); + computeUnitState(game, StateModBuffType.ENABLE_ATTACK); computeUnitState(game, StateModBuffType.DISABLE_AUTO_ATTACK); computeUnitState(game, StateModBuffType.DISABLE_AUTO_CAST); computeUnitState(game, StateModBuffType.DISABLE_ASSIST_ALLY); @@ -1548,7 +1917,15 @@ private void computeAllUnitStates(final CSimulation game) { computeUnitState(game, StateModBuffType.MAGIC_IMMUNE); computeUnitState(game, StateModBuffType.MORPH_IMMUNE); computeUnitState(game, StateModBuffType.RESISTANT); - computeUnitState(game, StateModBuffType.SNARED); + computeUnitState(game, StateModBuffType.STUN); + computeUnitState(game, StateModBuffType.PAUSED); + computeUnitState(game, StateModBuffType.UNSELECTABLE); + computeUnitState(game, StateModBuffType.UNTARGETABLE); + computeUnitState(game, StateModBuffType.UNENUMERABLE); + computeUnitState(game, StateModBuffType.UNAUTOATTACKABLE); + computeUnitState(game, StateModBuffType.BLOCK_REPAIR); + computeUnitState(game, StateModBuffType.BLOCK_TRAINING); + computeUnitState(game, StateModBuffType.BLOCK_CONSTRUCTION); } public void setManaRegenIntelligenceBonus(final float manaRegenIntelligenceBonus) { @@ -1646,18 +2023,17 @@ public void add(final CSimulation simulation, final CAbility ability) { } if (ability.isDisabled()) { this.disabledAbilities.add(ability); - } - else { + } else { ability.onAdd(simulation, this); } this.stateNotifier.abilitiesChanged(); } public void add(final CSimulation simulation, final CBuff ability) { - if (this.abilities.contains(ability) && (ability instanceof ABGenericTimedBuff)) { - ((ABGenericTimedBuff) ability).updateExpiration(simulation, this); - } - else { + int index = this.abilities.indexOf(ability); + if (index >= 0 && (ability instanceof ABGenericTimedBuff)) { + ((ABGenericTimedBuff) this.abilities.get(index)).updateExpiration(simulation, this); + } else { this.abilities.add(ability); simulation.onAbilityAddedToUnit(this, ability); ability.onAdd(simulation, this); @@ -1672,8 +2048,7 @@ public void remove(final CSimulation simulation, final CAbility ability) { simulation.onAbilityRemovedFromUnit(this, ability); ability.onRemoveDisabled(simulation, this); this.stateNotifier.abilitiesChanged(); - } - else { + } else { this.abilities.remove(ability); simulation.onAbilityRemovedFromUnit(this, ability); ability.onRemove(simulation, this); @@ -1691,7 +2066,7 @@ public void remove(final CSimulation simulation, final CBuff ability) { public void checkDisabledAbilities(final CSimulation simulation, final boolean disable) { if (disable) { - for (final CAbility ability : this.abilities) { + for (final CAbility ability : new ArrayList<>(this.abilities)) { if (!ability.isRequirementsMet(simulation, this)) { ability.setDisabled(true, CAbilityDisableType.REQUIREMENTS); } @@ -1708,8 +2083,7 @@ public void checkDisabledAbilities(final CSimulation simulation, final boolean d } } } - } - else { + } else { for (final CAbility ability : new ArrayList<>(this.disabledAbilities)) { if (ability.isRequirementsMet(simulation, this)) { ability.setDisabled(false, CAbilityDisableType.REQUIREMENTS); @@ -1718,8 +2092,8 @@ public void checkDisabledAbilities(final CSimulation simulation, final boolean d ability.setDisabled(false, CAbilityDisableType.PLAYER); } if (!ability.isDisabled()) { - ability.onAdd(simulation, this); this.disabledAbilities.remove(ability); + ability.onAdd(simulation, this); } } } @@ -1749,31 +2123,44 @@ public int getMaximumLife() { return this.maximumLife; } - public void setTypeId(final CSimulation game, final War3ID typeId) { - setTypeId(game, typeId, true); + public void setTypeId(final CSimulation game, final War3ID typeId, final boolean keepRatios) { + setTypeId(game, typeId, keepRatios, true); } - public void setTypeId(final CSimulation game, final War3ID typeId, final boolean updateArt) { + public void setTypeId(final CSimulation game, final War3ID typeId, final boolean keepRatios, + final boolean updateArt) { game.getWorldCollision().removeUnit(this); final CPlayer player = game.getPlayer(this.playerIndex); player.removeTechtreeUnlocked(game, this.typeId); + game.getUnitData().unapplyPlayerUpgradesToUnit(game, playerIndex, unitType, this); this.typeId = typeId; player.addTechtreeUnlocked(game, this.typeId); final float lifeRatio = this.maximumLife == 0 ? 1 : this.life / this.maximumLife; final float manaRatio = this.maximumMana == 0 ? Float.NaN : this.mana / this.maximumMana; final CUnitType previousUnitType = getUnitType(); this.unitType = game.getUnitData().getUnitType(typeId); - this.maximumMana = this.unitType.getManaMaximum(); - this.maximumLife = this.unitType.getMaxLife(); - this.life = lifeRatio * this.maximumLife; + this.baseMaximumMana += this.unitType.getManaMaximum() - previousUnitType.getManaMaximum(); + this.baseMaximumLife += this.unitType.getMaxLife() - previousUnitType.getMaxLife(); + this.maximumMana += this.unitType.getManaMaximum() - previousUnitType.getManaMaximum(); + this.maximumLife += this.unitType.getMaxLife() - previousUnitType.getMaxLife(); this.lifeRegen = this.unitType.getLifeRegen(); this.manaRegen = this.unitType.getManaRegen(); + computeAllDerivedFields(); + if (updateArt) { this.flyHeight = this.unitType.getDefaultFlyingHeight(); } this.turnRate = this.unitType.getTurnRate(); this.propWindow = this.unitType.getPropWindow(); - this.speed = this.unitType.getSpeed(); + this.maxSpeed = this.unitType.getMaxSpeed(); + if (maxSpeed == 0) { + this.maxSpeed = (int) game.getGameplayConstants().getMaxUnitSpeed(); + } + this.minSpeed = this.unitType.getMinSpeed(); + if (minSpeed == 0) { + this.minSpeed = (int) game.getGameplayConstants().getMinUnitSpeed(); + } + this.baseSpeed = this.unitType.getSpeed(); this.classifications.removeAll(previousUnitType.getClassifications()); this.classifications.addAll(this.unitType.getClassifications()); this.targetedAs.removeAll(previousUnitType.getTargetedAs()); @@ -1784,30 +2171,30 @@ public void setTypeId(final CSimulation game, final War3ID typeId, final boolean this.raisable = this.unitType.isRaise(); this.decays = this.unitType.isDecay(); final List sharedAbilities = new ArrayList(previousUnitType.getAbilityList()); - sharedAbilities.addAll(previousUnitType.getHeroAbilityList()); + // sharedAbilities.addAll(previousUnitType.getHeroAbilityList()); final List newIds = new ArrayList(this.unitType.getAbilityList()); - newIds.addAll(this.unitType.getHeroAbilityList()); + // newIds.addAll(this.unitType.getHeroAbilityList()); sharedAbilities.retainAll(newIds); // TODO Seems wasteful, but need to avoid messing up heros on transform final List persistedAbilities = new ArrayList<>(); final List removedAbilities = new ArrayList<>(); final List startingAbilities = new ArrayList<>(this.abilities); for (final CAbility ability : startingAbilities) { if (!ability.isPermanent() && !sharedAbilities.contains(ability.getAlias()) + && (!ability.isHero() || !this.unitType.isHero()) && !(ability.getAbilityCategory() == CAbilityCategory.BUFF)) { ability.onRemove(game, this); game.onAbilityRemovedFromUnit(this, ability); removedAbilities.add(ability); - } - else { + } else { persistedAbilities.add(ability); } } for (final CAbility removed : removedAbilities) { this.abilities.remove(removed); // TODO remove inefficient O(N) search } - game.unitUpdatedType(this, typeId); + game.unitUpdatedType(this, typeId, true); game.getUnitData().addMissingDefaultAbilitiesToUnit(game, game.getHandleIdAllocator(), this.unitType, false, -1, - this.speed, this); + this.baseSpeed, this); { // Remove and add the persisted abilities, so that some stuff like move and // attack are "first" in the end resulting list. This is "dumb" and a better @@ -1822,19 +2209,29 @@ public void setTypeId(final CSimulation game, final War3ID typeId, final boolean this.abilities.add(persisted); } } - if (Float.isNaN(manaRatio)) { - this.mana = this.unitType.getManaInitial(); - } - else { - this.mana = manaRatio * this.maximumMana; - } game.getWorldCollision().addUnit(this); for (final CAbility ability : persistedAbilities) { ability.onSetUnitType(game, this); game.onAbilityAddedToUnit(this, ability); } + game.getUnitData().applyPlayerUpgradesToUnit(game, playerIndex, unitType, this); computeAllDerivedFields(); computeAllUnitStates(game); + if (keepRatios) { + this.life = lifeRatio * this.maximumLife; + if (Float.isNaN(manaRatio)) { + this.mana = this.unitType.getManaInitial(); + } else { + this.mana = manaRatio * this.maximumMana; + } + } else { + this.life += this.unitType.getMaxLife() - previousUnitType.getMaxLife(); + if (Float.isNaN(manaRatio)) { + this.mana = this.unitType.getManaInitial(); + } else { + this.mana += this.unitType.getManaMaximum() - previousUnitType.getManaMaximum(); + } + } } public void setFacing(final float facing) { @@ -1870,12 +2267,16 @@ public void setMaximumMana(final int maximumMana) { } public void setSpeed(final int speed) { - this.speed = speed; + this.baseSpeed = speed; computeDerivedFields(NonStackingStatBuffType.MVSPD); } + private void computeFinalSpeed() { + this.finalSpeed = Math.max(Math.min(this.baseSpeed + this.speedBonus, this.maxSpeed), this.minSpeed); + } + public int getSpeed() { - return this.speed + this.speedBonus; + return this.moveDisabled ? 0 : this.finalSpeed; } /** @@ -1917,14 +2318,12 @@ public boolean update(final CSimulation game) { // we just delete the unit return true; } - } - else { + } else { game.heroDeathEvent(this); } this.deathTurnTick = gameTurnTick; } - } - else if (!this.boneCorpse) { + } else if (!this.boneCorpse) { if (game.getGameTurnTick() > (this.deathTurnTick + (int) (game.getGameplayConstants().getDecayTime() / WarsmashConstants.SIMULATION_STEP_TIME))) { this.boneCorpse = true; @@ -1934,8 +2333,7 @@ else if (!this.boneCorpse) { game.getWorldCollision().addUnit(this); } } - } - else if (game.getGameTurnTick() > (this.deathTurnTick + } else if (game.getGameTurnTick() > (this.deathTurnTick + (int) (getEndingDecayTime(game) / WarsmashConstants.SIMULATION_STEP_TIME))) { if (this.unitType.isHero()) { if (!getHeroData().isAwaitingRevive()) { @@ -1948,28 +2346,26 @@ else if (game.getGameTurnTick() > (this.deathTurnTick return true; } } - } - else { + } else { if (!this.paused) { if ((this.rallyPoint != this) && (this.rallyPoint instanceof CUnit) && ((CUnit) this.rallyPoint).isDead()) { setRallyPoint(this); } if (this.constructing) { - if (!this.constructingPaused) { + if (!(this.constructingPaused || this.constructionBlocked)) { this.constructionProgress += WarsmashConstants.SIMULATION_STEP_TIME; } final int buildTime; final boolean upgrading = isUpgrading(); if (!upgrading) { buildTime = this.unitType.getBuildTime(); - if (!this.constructingPaused) { + if (!(this.constructingPaused || this.constructionBlocked)) { final float healthGain = (WarsmashConstants.SIMULATION_STEP_TIME / buildTime) * (this.maximumLife * (1.0f - WarsmashConstants.BUILDING_CONSTRUCT_START_LIFE)); setLife(game, Math.min(this.life + healthGain, this.maximumLife)); } - } - else { + } else { buildTime = game.getUnitData().getUnitType(this.upgradeIdType).getBuildTime(); } if (this.constructionProgress >= buildTime) { @@ -1981,8 +2377,7 @@ else if (game.getGameTurnTick() > (this.deathTurnTick game.removeUnit(this.worker); this.worker = null; } - } - else { + } else { popoutWorker(game); } final Iterator abilityIterator = this.abilities.iterator(); @@ -1990,8 +2385,7 @@ else if (game.getGameTurnTick() > (this.deathTurnTick final CAbility ability = abilityIterator.next(); if (ability instanceof CAbilityBuildInProgress) { abilityIterator.remove(); - } - else { + } else { ability.setDisabled(false, CAbilityDisableType.CONSTRUCTION); ability.setIconShowing(true); } @@ -2002,7 +2396,7 @@ else if (game.getGameTurnTick() > (this.deathTurnTick if (this.unitType.getFoodMade() != 0) { player.setFoodCap(player.getFoodCap() - this.unitType.getFoodMade()); } - setTypeId(game, this.upgradeIdType); + setTypeId(game, this.upgradeIdType, true); this.upgradeIdType = null; } if (this.unitType.getFoodMade() != 0) { @@ -2013,9 +2407,11 @@ else if (game.getGameTurnTick() > (this.deathTurnTick if (!upgrading) { game.unitConstructFinishEvent(this); fireConstructFinishEvents(game); - } - else { + } else { game.unitUpgradeFinishEvent(this); + fireSimpleEvents(game, JassGameEventsWar3.EVENT_UNIT_UPGRADE_FINISH); + game.getPlayer(this.playerIndex).fireSimpleUnitEvents(this, + JassGameEventsWar3.EVENT_PLAYER_UNIT_UPGRADE_FINISH, game); } if (upgrading || true) { // TODO shouldnt need to play stand here, probably @@ -2024,15 +2420,23 @@ else if (game.getGameTurnTick() > (this.deathTurnTick } this.stateNotifier.ordersChanged(); } - } - else { + for (int i = this.abilities.size() - 1; i >= 0; i--) { + // okay if it removes self from this during onTick() because of reverse + // iteration order + CAbility abil = this.abilities.get(i); + if (abil.getAbilityCategory() == CAbilityCategory.BUFF) { + abil.onTick(game, this); + } + } + } else { final War3ID queuedRawcode = this.buildQueue[0]; if (queuedRawcode != null) { // queue step forward if (this.queuedUnitFoodPaid) { - this.constructionProgress += WarsmashConstants.SIMULATION_STEP_TIME; - } - else { + if (!this.trainingBlocked) { + this.constructionProgress += WarsmashConstants.SIMULATION_STEP_TIME; + } + } else { if (this.buildQueueTypes[0] == QueueItemType.UNIT) { final CPlayer player = game.getPlayer(this.playerIndex); final CUnitType trainedUnitType = game.getUnitData().getUnitType(queuedRawcode); @@ -2042,15 +2446,12 @@ else if (game.getGameTurnTick() > (this.deathTurnTick player.setFoodUsed(newFoodUsed); this.queuedUnitFoodPaid = true; } - } - else { + } else { this.queuedUnitFoodPaid = true; } - } - else if (this.buildQueueTypes[0] == QueueItemType.SACRIFICE) { + } else if (this.buildQueueTypes[0] == QueueItemType.SACRIFICE) { this.queuedUnitFoodPaid = true; - } - else if (this.buildQueueTypes[0] == QueueItemType.HERO_REVIVE) { + } else if (this.buildQueueTypes[0] == QueueItemType.HERO_REVIVE) { final CPlayer player = game.getPlayer(this.playerIndex); final CUnitType trainedUnitType = game.getUnit(queuedRawcode.getValue()).getUnitType(); final int newFoodUsed = player.getFoodUsed() + trainedUnitType.getFoodUsed(); @@ -2058,8 +2459,7 @@ else if (this.buildQueueTypes[0] == QueueItemType.HERO_REVIVE) { player.setFoodUsed(newFoodUsed); this.queuedUnitFoodPaid = true; } - } - else { + } else { this.queuedUnitFoodPaid = true; System.err.println( "Unpaid food for non unit queue item ???? Attempting to correct this by setting paid=true"); @@ -2092,8 +2492,7 @@ else if (this.buildQueueTypes[0] == QueueItemType.HERO_REVIVE) { setBuildQueueItem(game, this.buildQueue.length - 1, null, null); this.stateNotifier.queueChanged(); } - } - else if (this.buildQueueTypes[0] == QueueItemType.SACRIFICE) { + } else if (this.buildQueueTypes[0] == QueueItemType.SACRIFICE) { final CUnitType trainedUnitType = game.getUnitData().getUnitType(queuedRawcode); if (this.constructionProgress >= trainedUnitType.getBuildTime()) { this.constructionProgress = 0; @@ -2123,8 +2522,7 @@ else if (this.buildQueueTypes[0] == QueueItemType.SACRIFICE) { setBuildQueueItem(game, this.buildQueue.length - 1, null, null); this.stateNotifier.queueChanged(); } - } - else if (this.buildQueueTypes[0] == QueueItemType.HERO_REVIVE) { + } else if (this.buildQueueTypes[0] == QueueItemType.HERO_REVIVE) { final CUnit revivingHero = game.getUnit(queuedRawcode.getValue()); final CUnitType trainedUnitType = revivingHero.getUnitType(); final CGameplayConstants gameplayConstants = game.getGameplayConstants(); @@ -2169,8 +2567,7 @@ else if (this.buildQueueTypes[0] == QueueItemType.HERO_REVIVE) { setBuildQueueItem(game, this.buildQueue.length - 1, null, null); this.stateNotifier.queueChanged(); } - } - else if (this.buildQueueTypes[0] == QueueItemType.RESEARCH) { + } else if (this.buildQueueTypes[0] == QueueItemType.RESEARCH) { final CUpgradeType trainedUnitType = game.getUpgradeData().getType(queuedRawcode); // TODO the "getBuildTime" math below probably would be better served to have // been cached, for performance, since we are in the update method. But maybe it @@ -2217,17 +2614,14 @@ else if (this.buildQueueTypes[0] == QueueItemType.RESEARCH) { if (lifePlusRegen > this.maximumLife) { lifePlusRegen = this.maximumLife; } - this.life = lifePlusRegen; - this.stateNotifier.lifeChanged(); - } - else { + setLife(game, lifePlusRegen); + } else { float lifePlusRegen = (this.life + this.currentLifeRegenPerTick) - this.baseLifeRegenPerTick; if (lifePlusRegen > this.maximumLife) { lifePlusRegen = this.maximumLife; } - this.life = lifePlusRegen; - this.stateNotifier.lifeChanged(); + setLife(game, lifePlusRegen); } } if ((this.mana < this.maximumMana) || (this.currentManaRegenPerTick < 0)) { @@ -2248,8 +2642,7 @@ else if (this.buildQueueTypes[0] == QueueItemType.RESEARCH) { this.attackFogMod.setPlayerIndex(target.getPlayerIndex()); game.getPlayer(target.getPlayerIndex()).addFogModifer(game, this.attackFogMod, false); } - } - else { + } else { if (this.attackFogMod.getPlayerIndex() != this.playerIndex) { game.getPlayer(this.attackFogMod.getPlayerIndex()).removeFogModifer(game, this.attackFogMod); @@ -2258,8 +2651,7 @@ else if (this.buildQueueTypes[0] == QueueItemType.RESEARCH) { } beginBehavior(game, this.currentBehavior.update(game)); - } - else { + } else { // check to auto acquire targets autoAcquireTargets(game, this.moveDisabled); } @@ -2281,8 +2673,7 @@ else if (this.buildQueueTypes[0] == QueueItemType.RESEARCH) { } } } - } - else if (!this.constructing) { + } else if (!this.constructing) { // Paused units only allow passives to function. Buffs don't tick (except a few) // Base and bonus life/mana regen function, but regen from Str/Int doesn't if ((this.life < this.maximumLife) @@ -2312,8 +2703,7 @@ else if (!this.constructing) { if (lifePlusRegen > this.maximumLife) { lifePlusRegen = this.maximumLife; } - this.life = lifePlusRegen; - this.stateNotifier.lifeChanged(); + setLife(game, lifePlusRegen); } } if ((this.mana < this.maximumMana) @@ -2335,7 +2725,7 @@ else if (!this.constructing) { // okay if it removes self from this during onTick() because of reverse // iteration order if ((this.abilities.get(i) instanceof AbilityGenericSingleIconPassiveAbility) - || (this.abilities.get(i) instanceof ABTimedTickingPausedBuff)) { + || (this.abilities.get(i) instanceof CPausedTickingBuff)) { this.abilities.get(i).onTick(game, this); } } @@ -2370,21 +2760,20 @@ public boolean autoAcquireTargets(final CSimulation game, final boolean disableM } public boolean autoAcquireAutocastTargets(final CSimulation game, final boolean disableMove) { - if ((this.autocastAbility != null) && !this.autocastAbility.isDisabled()) { + if ((this.autocastAbility != null) && !this.autocastAbility.isDisabled() + && this.autocastAbility.getAutocastType() != AutocastType.NOAUTOCASTBEHAVIOR) { if (this.autocastAbility.getAutocastType() == AutocastType.NOTARGET) { final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); this.autocastAbility.checkCanAutoTargetNoTarget(game, this, this.autocastAbility.getBaseOrderId(), booleanTargetReceiver); if (booleanTargetReceiver.isTargetable()) { - return this.order(game, this.autocastAbility.getBaseOrderId(), null); + return this.order(game, this.autocastAbility.getBaseOrderId(), null, true); } - } - else if (this.autocastAbility.getAutocastType() != AutocastType.NONE) { + } else if (this.autocastAbility.getAutocastType() != AutocastType.NONE) { if (this.collisionRectangle != null) { tempRect.set(this.collisionRectangle); - } - else { + } else { tempRect.set(getX(), getY(), 0, 0); } final float halfSize = this.acquisitionRange; @@ -2395,7 +2784,8 @@ else if (this.autocastAbility.getAutocastType() != AutocastType.NONE) { game.getWorldCollision().enumUnitsInRect(tempRect, autocastTargetFinderEnum.reset(game, this, this.autocastAbility, disableMove)); if (autocastTargetFinderEnum.currentUnitTarget != null) { - this.order(game, this.autocastAbility.getBaseOrderId(), autocastTargetFinderEnum.currentUnitTarget); + this.order(game, this.autocastAbility.getBaseOrderId(), autocastTargetFinderEnum.currentUnitTarget, + true); return true; } } @@ -2407,8 +2797,7 @@ public boolean autoAcquireAttackTargets(final CSimulation game, final boolean di if (!getCurrentAttacks().isEmpty() && !this.classifications.contains(CUnitClassification.PEON)) { if (this.collisionRectangle != null) { tempRect.set(this.collisionRectangle); - } - else { + } else { tempRect.set(getX(), getY(), 0, 0); } final float halfSize = this.acquisitionRange; @@ -2433,7 +2822,11 @@ public float getEndingDecayTime(final CSimulation game) { return game.getGameplayConstants().getBoneDecayTime(); } - public void order(final CSimulation game, final COrder order, final boolean queue) { + public void order(final CSimulation game, final COrder order, final boolean queue) { + this.order(game, order, queue, false); + } + + public void order(final CSimulation game, final COrder order, final boolean queue, final boolean autoOrder) { if (isDead()) { return; } @@ -2448,7 +2841,7 @@ public void order(final CSimulation game, final COrder order, final boolean queu } // Allow the ability to response to the order without actually placing itself in // the queue, nor modifying (interrupting) the queue. - if (!ability.checkBeforeQueue(game, this, order.getOrderId(), order.getTarget(game))) { + if (!ability.checkBeforeQueue(game, this, order.getOrderId(), autoOrder, order.getTarget(game))) { // TODO is this a possible bug vector that the network request doesn't // checkCanUse like the UI before checkBeforeQueue is called?? order.fireEvents(game, this); @@ -2470,32 +2863,30 @@ public void order(final CSimulation game, final COrder order, final boolean queu if (queuedOrder != null) { final int abilityHandleId = queuedOrder.getAbilityHandleId(); final CAbility ability = game.getAbility(abilityHandleId); - ability.onCancelFromQueue(game, this, queuedOrder.getOrderId()); + if (ability != null) { + ability.onCancelFromQueue(game, this, queuedOrder.getOrderId()); + } } } this.orderQueue.clear(); this.orderQueue.add(order); this.stateNotifier.ordersChanged(); this.stateNotifier.waypointsChanged(); - } - else if (queue && (this.currentBehavior != this.stopBehavior) + } else if (queue && (this.currentBehavior != this.stopBehavior) && (this.currentBehavior != this.holdPositionBehavior)) { if (order.getOrderId() == OrderIds.patrol) { if (this.defaultBehavior == this.patrolBehavior) { this.patrolBehavior.addPatrolPoint(order.getTarget(game)); - } - else { + } else { this.orderQueue.add(order); } - } - else { + } else { this.orderQueue.add(order); } this.stateNotifier.waypointsChanged(); - } - else { + } else { setDefaultBehavior(this.stopBehavior); - beginBehavior(game, beginOrder(game, order)); + beginBehavior(game, beginOrder(game, order), true); for (final COrder queuedOrder : this.orderQueue) { if (queuedOrder != null) { final int abilityHandleId = queuedOrder.getAbilityHandleId(); @@ -2510,34 +2901,41 @@ else if (queue && (this.currentBehavior != this.stopBehavior) } public boolean order(final CSimulation simulation, final int orderId, final AbilityTarget target) { + return this.order(simulation, orderId, target, false); + } + + public boolean order(final CSimulation simulation, final int orderId, final AbilityTarget target, + final boolean autoOrder) { if (orderId == OrderIds.stop) { - order(simulation, new COrderNoTarget(0, orderId, false), false); + order(simulation, new COrderNoTarget(0, orderId, false), false, autoOrder); return true; } for (final CAbility ability : this.abilities) { final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; - ability.checkCanUse(simulation, this, orderId, activationReceiver); + ability.checkCanUse(simulation, this, orderId, false, activationReceiver); if (activationReceiver.isOk()) { if (target == null) { final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); - ability.checkCanTargetNoTarget(simulation, this, orderId, booleanTargetReceiver); + ability.checkCanTargetNoTarget(simulation, this, orderId, false, booleanTargetReceiver); if (booleanTargetReceiver.isTargetable()) { - order(simulation, new COrderNoTarget(ability.getHandleId(), orderId, false), false); + order(simulation, new COrderNoTarget(ability.getHandleId(), orderId, false, autoOrder), false, + autoOrder); return true; } - } - else { + } else { final boolean targetable = target.visit(new AbilityTargetVisitor() { @Override public Boolean accept(final AbilityPointTarget target) { final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); - ability.checkCanTarget(simulation, CUnit.this, orderId, target, booleanTargetReceiver); + ability.checkCanTarget(simulation, CUnit.this, orderId, false, target, + booleanTargetReceiver); final boolean pointTargetable = booleanTargetReceiver.isTargetable(); if (pointTargetable) { - order(simulation, new COrderTargetPoint(ability.getHandleId(), orderId, target, false), - false); + order(simulation, + new COrderTargetPoint(ability.getHandleId(), orderId, target, false, autoOrder), + false, autoOrder); } return pointTargetable; } @@ -2545,11 +2943,12 @@ public Boolean accept(final AbilityPointTarget target) { public Boolean acceptWidget(final CWidget target) { final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); - ability.checkCanTarget(simulation, CUnit.this, orderId, target, booleanTargetReceiver); + ability.checkCanTarget(simulation, CUnit.this, orderId, autoOrder, target, + booleanTargetReceiver); final boolean widgetTargetable = booleanTargetReceiver.isTargetable(); if (widgetTargetable) { order(simulation, new COrderTargetWidget(ability.getHandleId(), orderId, - target.getHandleId(), false), false); + target.getHandleId(), false, autoOrder), false, autoOrder); } return widgetTargetable; } @@ -2583,8 +2982,7 @@ private CBehavior beginOrder(final CSimulation game, final COrder order) { CBehavior nextBehavior; if (order != null) { nextBehavior = order.begin(game, this); - } - else { + } else { nextBehavior = this.defaultBehavior; } return nextBehavior; @@ -2659,6 +3057,11 @@ public void setPlayerIndex(final CSimulation simulation, final int playerIndex, if (changeColor) { simulation.changeUnitColor(this, playerIndex); } + this.computeUnitState(simulation, StateModBuffType.FALSE_OWNERSHIP); + } + + public int getFakePlayerIndex() { + return this.fakePlayerIndex; } public CUnitType getUnitType() { @@ -2699,12 +3102,10 @@ public void setPointAndCheckUnstuck(final float newX, final float newY, final CS tempRect.setSize(this.unitType.getBuildingPathingPixelMap().getWidth() * 32, this.unitType.getBuildingPathingPixelMap().getHeight() * 32); collisionSize = tempRect.getWidth() / 2; - } - else if (this.collisionRectangle != null) { + } else if (this.collisionRectangle != null) { tempRect.set(this.collisionRectangle); collisionSize = this.unitType.getCollisionSize(); - } - else { + } else { tempRect.setSize(16, 16); collisionSize = this.unitType.getCollisionSize(); } @@ -2786,8 +3187,7 @@ public double distance(final AbilityTarget target) { if (target instanceof CUnit) { final CUnitType targetUnitType = ((CUnit) target).getUnitType(); targetCollisionSize = targetUnitType.getCollisionSize(); - } - else { + } else { targetCollisionSize = 0; // TODO destructable collision size here } if (dx < 0) { @@ -2827,13 +3227,11 @@ public double distance(final double x, final double y) { return groundDistance; } - public boolean checkForMiss(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, final float damage, - final float bonusDamage) { + public boolean checkForMiss(final CSimulation simulation, final CDamageCalculation damage) { boolean miss = false; - if (isAttack) { + if (damage.getPrimaryDamageFlags().isAttack()) { for (final CUnitAttackEvasionListener listener : new ArrayList<>(this.evasionListeners)) { - miss = miss || listener.onAttack(simulation, source, this, isAttack, isRanged, damageType); + miss = miss || listener.onAttack(simulation, this, damage); } } return miss; @@ -2872,74 +3270,235 @@ public boolean checkForAbilityEffectReaction(final CSimulation simulation, final return allow; } + public CUnitAttackSettings checkForAttackPreLaunchModification(final CSimulation simulation, + final AbilityTarget target, final CUnitAttack attack, final CUnitAttackSettings settings) { + if (!this.attackModifiers.isEmpty()) { + int maxPriority = 0; + int i = 0; + attackModLoop.reset(); + while (i <= maxPriority) { + attackModLoop.startLoop(i); + for (final CUnitAttackModifier modification : new ArrayList<>(this.attackModifiers)) { + int prio = modification.getPriority(simulation, this, target, attack); + if (prio > maxPriority) { + maxPriority = prio; + } + if (prio == i && !attackModLoop.skipCurrentLevel()) { + if (modification.checkPreLaunchApplication(simulation, this, target, attack)) { + modification.applyPreLaunchModification(simulation, this, target, attack, settings, + attackModLoop); + } + } + } + if (attackModLoop.end()) { + break; + } + i++; + } + } + return settings; + } + + public CUnitAttackSettings checkForAttackModification(final CSimulation simulation, final AbilityTarget target, + final CUnitAttack attack, final CUnitAttackSettings settings) { + if (!this.attackModifiers.isEmpty()) { + int maxPriority = 0; + int i = 0; + attackModLoop.reset(); + while (i <= maxPriority) { + attackModLoop.startLoop(i); + for (final CUnitAttackModifier modification : new ArrayList<>(this.attackModifiers)) { + int prio = modification.getPriority(simulation, this, target, attack); + if (prio > maxPriority) { + maxPriority = prio; + } + if (prio == i && !attackModLoop.skipCurrentLevel()) { + if (modification.checkApplication(simulation, this, target, attack)) { + modification.applyModification(simulation, this, target, attack, settings, attackModLoop); + } + } + } + if (attackModLoop.end()) { + break; + } + i++; + } + } + return settings; + } + + public boolean isImmuneToDamage(final CSimulation simulation, final CDamageFlags flags, + final CAttackType attackType, final CDamageType damageType) { + if (flags != null && flags.isOnlyDamageSummons() && !this.isUnitType(CUnitTypeJass.SUMMONED)) { + return true; + } + if (simulation.getGameplayConstants().isMagicImmuneResistsDamage()) { + if (attackType.isMagic() || damageType.isMagic()) { + if (this.isMagicImmune() || (this.isLimitedMagicImmune() && !flags.isPassLimitedMagicImmune())) { + return true; + } + } else if (attackType.isPhysical() || damageType.isPhysical()) { + if (this.isUnitType(CUnitTypeJass.ETHEREAL)) { + return true; + } + } + } else { + if (damageType.isOldMagic() + && (this.isMagicImmune() || (this.isLimitedMagicImmune() && !flags.isPassLimitedMagicImmune()))) { + return true; + } + } + return false; + } + @Override - public float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage) { - return this.damage(simulation, source, isAttack, isRanged, attackType, damageType, weaponSoundType, damage, 0); + public float damage(final CSimulation simulation, final CUnit source, final CDamageFlags flags, + final CAttackType attackType, final CDamageType damageType, final String weaponSoundType, + final float damage) { + if (!(this.damageTakenModificationListeners.isEmpty() && this.damageTakenListeners.isEmpty())) { + return this.damage(simulation, + new CDamageCalculation(source, damage, attackType, damageType, flags, weaponSoundType)); + } + final boolean wasDead = isDead(); + if (wasDead) { + return 0; + } + if (this.isImmuneToDamage(simulation, flags, attackType, damageType)) { + return 0; + } + float trueDamage = 0; + if (!this.invulnerable || (flags != null && (flags.isIgnoreInvulnerable() || (flags.isOnlyDamageSummons() + && simulation.getGameplayConstants().isInvulnerableSummonsTakeDispelDamage() + && this.isUnitType(CUnitTypeJass.SUMMONED))))) { + + trueDamage = CDamageCalculation.calculateDamageByArmor(simulation, this, attackType, damageType, damage, + flags); + + this.callPreDamageEvents(source, trueDamage); + + this.damageModifyHp(trueDamage, flags.isNonlethal()); + } + this.callPostDamageEvents(simulation, wasDead, source, flags.isExplode(), weaponSoundType); + return trueDamage; } @Override - public float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage, final float bonusDamage) { + public float damage(final CSimulation simulation, final CDamageCalculation damage) { final boolean wasDead = isDead(); if (wasDead) { return 0; } + if (damage.isImmuneToDamage(simulation, this)) { + return 0; + } float trueDamage = 0; - if (!this.invulnerable) { - final CUnitAttackDamageTakenModificationListenerDamageModResult result = new CUnitAttackDamageTakenModificationListenerDamageModResult( - damage, bonusDamage); - for (final CUnitAttackDamageTakenModificationListener listener : this.damageTakenModificationListeners) { - listener.onDamage(simulation, source, this, isAttack, isRanged, attackType, damageType, result); + damage.resetLoop(); + int maxPriority = 0; + int priorityMask = 0; + int i = 0; + boolean firstLoop = true; + while (i <= maxPriority) { + if (i == 0 || (priorityMask & (1 << (i < 31 ? i : 31))) != 0) { + damage.startLoop(i); + for (int j = this.damageTakenModificationListeners.size() - 1; j >= 0; j--) { + CUnitAttackDamageTakenModificationListener listener = this.damageTakenModificationListeners.get(j); + int prio = listener.getPriority(simulation, this, damage); + if (firstLoop) { + if (prio > maxPriority) { + maxPriority = prio; + } + priorityMask |= 1 << (prio < 31 ? prio : 31); + } + if (prio == i && !damage.isSkipCurrentLevel()) { + damage.applyMultiplier(); + listener.onDamage(simulation, this, damage); + } + } + if (damage.isEndLoop()) { + break; + } } + i++; + firstLoop = false; + } - final float damageRatioFromArmorClass = simulation.getGameplayConstants().getDamageRatioAgainst(attackType, - getDefenseType()); - final float damageRatioFromDefense; - final float defense = this.currentDefense; - if (damageType != CDamageType.NORMAL) { - damageRatioFromDefense = 1.0f; - } - else if (defense >= 0) { - damageRatioFromDefense = 1f - ((defense * simulation.getGameplayConstants().getDefenseArmor()) - / (1 + (simulation.getGameplayConstants().getDefenseArmor() * defense))); - } - else { - damageRatioFromDefense = 2f - - (float) StrictMath.pow(1f - simulation.getGameplayConstants().getDefenseArmor(), -defense); - } - trueDamage = damageRatioFromArmorClass * damageRatioFromDefense * result.computeFinalDamage(); + trueDamage = damage.computeFinalDamage(simulation, this); + + this.callPreDamageEvents(damage.getSource(), trueDamage); + + this.damageModifyHp(trueDamage, false); - for (final CUnitAttackFinalDamageTakenModificationListener listener : new ArrayList<>( - this.finalDamageTakenModificationListeners)) { - trueDamage = listener.onDamage(simulation, source, this, isAttack, isRanged, attackType, damageType, - trueDamage); + damage.resetLoop(); + maxPriority = 0; + priorityMask = 0; + i = 0; + firstLoop = true; + while (i <= maxPriority) { + if (i == 0 || (priorityMask & (1 << (i < 31 ? i : 31))) != 0) { + damage.startLoop(i); + for (int j = this.damageTakenListeners.size() - 1; j >= 0; j--) { + CUnitAttackDamageTakenListener listener = this.damageTakenListeners.get(j); + int prio = listener.getPriority(simulation, this, damage); + if (firstLoop) { + if (prio > maxPriority) { + maxPriority = prio; + } + priorityMask |= 1 << (prio < 31 ? prio : 31); + } + if (prio == i && !damage.isSkipCurrentLevel()) { + listener.onDamage(simulation, this, damage); + } + } + if (damage.isEndLoop()) { + break; + } } + i++; + firstLoop = false; + } + + this.callPostDamageEvents(simulation, wasDead, damage.getSource(), damage.isExplode(), + damage.getWeaponSoundType()); + return trueDamage; + } - final boolean wasAboveMax = this.life > this.maximumLife; - this.life -= trueDamage; - if ((result.computeFinalDamage() < 0) && !wasAboveMax && (this.life > this.maximumLife)) { - // NOTE wasAboveMax is for that weird life drain power to drain above max... to - // be honest that's a crazy mechanic anyway so I didn't test whether it works - // yet - this.life = this.maximumLife; + private void callPreDamageEvents(CUnit source, float damage) { + final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_DAMAGED); + if (eventList != null) { + for (final CWidgetEvent event : eventList) { + event.fire(this, CommonTriggerExecutionScope.unitDamageTakenScope(JassGameEventsWar3.EVENT_UNIT_DAMAGED, + event.getTrigger(), this, source, damage)); } - this.stateNotifier.lifeChanged(); } - for (final CUnitAttackDamageTakenListener listener : new ArrayList<>(this.damageTakenListeners)) { - listener.onDamage(simulation, source, this, isAttack, isRanged, damageType, damage, bonusDamage, - trueDamage); + } + + private void damageModifyHp(float trueDamage, boolean isNonLethal) { + final boolean wasAboveMax = this.life > this.maximumLife; + this.life -= trueDamage; + if ((trueDamage < 0) && !wasAboveMax && (this.life > this.maximumLife)) { + // NOTE wasAboveMax is for that weird life drain power to drain above max... to + // be honest that's a crazy mechanic anyway so I didn't test whether it works + // yet + this.life = this.maximumLife; } + if (isNonLethal && this.life < 1) { + this.life = 1; + } + this.stateNotifier.lifeChanged(); + } + + private void callPostDamageEvents(CSimulation simulation, boolean wasDead, CUnit source, final boolean isExplode, + String weaponSoundType) { simulation.unitDamageEvent(this, weaponSoundType, this.unitType.getArmorType()); - if (!this.invulnerable && isDead()) { + if (isDead()) { if (!wasDead) { + if (isExplode) { + this.setExplodesOnDeath(true); + } kill(simulation, source); } - } - else { + } else { if ((this.currentBehavior == null) || ((this.currentBehavior == this.defaultBehavior) && this.currentBehavior.interruptable())) { boolean foundMatchingReturnFireAttack = false; @@ -2950,7 +3509,7 @@ else if (defense >= 0) { final CBehaviorAttack attackBehaviorForAtk = getAttackBehavior(); if (attackBehaviorForAtk != null) { beginBehavior(simulation, attackBehaviorForAtk.reset(simulation, OrderIds.attack, - attack, source, false, CBehaviorAttackListener.DO_NOTHING)); + attack, source, false, CBehaviorAttackListener.DO_NOTHING), true); foundMatchingReturnFireAttack = true; break; } @@ -2961,26 +3520,26 @@ else if (defense >= 0) { && (this.moveBehavior != null) && (this.playerIndex != source.getPlayerIndex())) { final double angleTo = source.angleTo(this); final int distanceToFlee = getSpeed(); - beginBehavior(simulation, + this.beginBehavior(simulation, this.moveBehavior.reset(OrderIds.move, new AbilityPointTarget( (float) (getX() + (distanceToFlee * StrictMath.cos(angleTo))), - (float) (getY() + (distanceToFlee * StrictMath.sin(angleTo)))))); + (float) (getY() + (distanceToFlee * StrictMath.sin(angleTo))))), + true); } } } - return trueDamage; } private void kill(final CSimulation simulation, final CUnit source) { - beginBehavior(simulation, null); + beginBehavior(simulation, null, true); final CUnitDeathReplacementResult result = new CUnitDeathReplacementResult(); CUnitDeathReplacementStacking allowContinue = new CUnitDeathReplacementStacking(); for (final CUnitDeathReplacementEffectPriority priority : CUnitDeathReplacementEffectPriority.values()) { if (allowContinue.isAllowStacking()) { for (final CUnitDeathReplacementEffect effect : new ArrayList<>( - this.deathReplacementEffects.get(priority))) { + deathReplacementEffects.get(priority))) { if (allowContinue.isAllowSamePriorityStacking()) { allowContinue = effect.onDeath(simulation, this, source, result); } @@ -3015,8 +3574,7 @@ private void kill(final CSimulation simulation, final CUnit source) { if (this.constructing) { simulation.createDeathExplodeEffect(this, this.explodesOnDeathBuffId); - } - else { + } else { this.deathTurnTick = simulation.getGameTurnTick(); } @@ -3030,8 +3588,7 @@ private void kill(final CSimulation simulation, final CUnit source) { if (getHeroData() == null) { if (this.constructing) { player.removeTechtreeInProgress(this.unitType.getTypeId()); - } - else { + } else { player.removeTechtreeUnlocked(simulation, this.unitType.getTypeId()); } } @@ -3076,8 +3633,7 @@ private void kill(final CSimulation simulation, final CUnit source) { int availableAwardXp; if (killedUnitIsAHero) { availableAwardXp = gameplayConstants.getGrantHeroXP(killedUnitHeroData.getHeroLevel()); - } - else { + } else { availableAwardXp = gameplayConstants.getGrantNormalXP(this.unitType.getLevel()); } final List xpReceivingHeroes = new ArrayList<>(); @@ -3155,8 +3711,7 @@ public boolean canReach(final AbilityTarget target, final float range) { return true; } } - } - else if (target instanceof CDestructable) { + } else if (target instanceof CDestructable) { final CDestructable targetDest = (CDestructable) target; final CDestructableType targetDestType = targetDest.getDestType(); final BufferedImage pathingPixelMap = targetDest.isDead() ? targetDestType.getPathingDeathPixelMap() @@ -3289,132 +3844,142 @@ public boolean canBeTargetedBy(final CSimulation simulation, final CUnit source, receiver.targetCheckFailed(CommandStringErrorKeys.THAT_UNIT_IS_IMMUNE_TO_MAGIC); return false; } - if (targeted && !isVisible(simulation, source.getPlayerIndex())) { + if (isLimitedMagicImmune() && targetsAllowed.contains(CTargetType.NON_MAGIC_IMMUNE) + && !targetsAllowed.contains(CTargetType.LIMITED_MAGIC_IMMUNE)) { + receiver.targetCheckFailed(CommandStringErrorKeys.THAT_UNIT_IS_IMMUNE_TO_MAGIC); + return false; + } + if (targeted && (!isVisible(simulation, source.getPlayerIndex()) + || (this.untargetablePlayers & (1 << source.getPlayerIndex())) != 0)) { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_UNIT_WITH_THIS_ACTION); return false; } + if (this.repairBlocked && targetsAllowed.contains(CTargetType.REPAIRABLE)) { + if (this.hasUniqueFlag("b_Frozen")) { + receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_BUILDING_HAS_BEEN_FROZEN); + } else if (this.hasUniqueFlag("b_LFire")) { + receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_BUILDING_HAS_LIQUID_FIRE); + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); + } + return false; + } if (targetsAllowed.containsAll(this.targetedAs) || (!targetsAllowed.contains(CTargetType.GROUND) && !targetsAllowed.contains(CTargetType.STRUCTURE) && !targetsAllowed.contains(CTargetType.AIR))) { final int sourcePlayerIndex = source.getPlayerIndex(); final CPlayer sourcePlayer = simulation.getPlayer(sourcePlayerIndex); if (!targetsAllowed.contains(CTargetType.ENEMIES) - || !sourcePlayer.hasAlliance(this.playerIndex, CAllianceType.PASSIVE) - || targetsAllowed.contains(CTargetType.FRIEND)) { + || !sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.PASSIVE) + || (targetsAllowed.contains(CTargetType.FRIEND) + && sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.SHARED_SPELLS)) + || (targetsAllowed.contains(CTargetType.NEUTRAL) + && !sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.SHARED_SPELLS))) { if (!targetsAllowed.contains(CTargetType.FRIEND) - || sourcePlayer.hasAlliance(this.playerIndex, CAllianceType.PASSIVE) - || targetsAllowed.contains(CTargetType.ENEMIES)) { - if (!targetsAllowed.contains(CTargetType.MECHANICAL) - || this.classifications.contains(CUnitClassification.MECHANICAL)) { - if (!targetsAllowed.contains(CTargetType.ORGANIC) - || !this.classifications.contains(CUnitClassification.MECHANICAL)) { - if (!targetsAllowed.contains(CTargetType.ANCIENT) - || this.classifications.contains(CUnitClassification.ANCIENT)) { - if (!targetsAllowed.contains(CTargetType.NONANCIENT) - || !this.classifications.contains(CUnitClassification.ANCIENT)) { - final boolean invulnerable = isInvulnerable(); - if ((!invulnerable && (targetsAllowed.contains(CTargetType.VULNERABLE) - || !targetsAllowed.contains(CTargetType.INVULNERABLE))) - || (invulnerable && targetsAllowed.contains(CTargetType.INVULNERABLE))) { - if (!targetsAllowed.contains(CTargetType.HERO) || (getHeroData() != null)) { - if (!targetsAllowed.contains(CTargetType.NONHERO) - || (getHeroData() == null)) { - if (isDead()) { - if (isRaisable() && isDecays() && isBoneCorpse()) { - if (targetsAllowed.contains(CTargetType.DEAD)) { - return true; + || sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.SHARED_SPELLS) + || (targetsAllowed.contains(CTargetType.ENEMIES) + && !sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.PASSIVE)) + || (targetsAllowed.contains(CTargetType.NEUTRAL) + && sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.PASSIVE))) { + if (!targetsAllowed.contains(CTargetType.NEUTRAL) + || (sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.PASSIVE) + && !sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.SHARED_SPELLS)) + || (targetsAllowed.contains(CTargetType.ENEMIES) + && !sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.PASSIVE)) + || (targetsAllowed.contains(CTargetType.FRIEND) + && sourcePlayer.hasAlliance(this.fakePlayerIndex, CAllianceType.SHARED_SPELLS))) { + if (!targetsAllowed.contains(CTargetType.MECHANICAL) + || this.classifications.contains(CUnitClassification.MECHANICAL)) { + if (!targetsAllowed.contains(CTargetType.ORGANIC) + || !this.classifications.contains(CUnitClassification.MECHANICAL)) { + if (!targetsAllowed.contains(CTargetType.ANCIENT) + || this.classifications.contains(CUnitClassification.ANCIENT)) { + if (!targetsAllowed.contains(CTargetType.NONANCIENT) + || !this.classifications.contains(CUnitClassification.ANCIENT)) { + final boolean invulnerable = isInvulnerable(); + if ((!invulnerable && (targetsAllowed.contains(CTargetType.VULNERABLE) + || !targetsAllowed.contains(CTargetType.INVULNERABLE))) + || (invulnerable + && targetsAllowed.contains(CTargetType.INVULNERABLE))) { + if (!targetsAllowed.contains(CTargetType.HERO) || (getHeroData() != null)) { + if (!targetsAllowed.contains(CTargetType.NONHERO) + || (getHeroData() == null)) { + if (isDead()) { + if (isRaisable() && isDecays() && isBoneCorpse()) { + if (targetsAllowed.contains(CTargetType.DEAD)) { + return true; + } else { + receiver.targetCheckFailed( + CommandStringErrorKeys.TARGET_MUST_BE_LIVING); + } + } else { + receiver.targetCheckFailed( + CommandStringErrorKeys.MUST_TARGET_A_UNIT_WITH_THIS_ACTION); } - else { + } else { + if (!targetsAllowed.contains(CTargetType.DEAD) + || targetsAllowed.contains(CTargetType.ALIVE)) { + return true; + } else { receiver.targetCheckFailed( - CommandStringErrorKeys.TARGET_MUST_BE_LIVING); + CommandStringErrorKeys.MUST_TARGET_A_CORPSE); } } - else { - receiver.targetCheckFailed( - CommandStringErrorKeys.MUST_TARGET_A_UNIT_WITH_THIS_ACTION); - } - } - else { - if (!targetsAllowed.contains(CTargetType.DEAD) - || targetsAllowed.contains(CTargetType.ALIVE)) { - return true; - } - else { - receiver.targetCheckFailed( - CommandStringErrorKeys.MUST_TARGET_A_CORPSE); - } + } else { + receiver.targetCheckFailed( + CommandStringErrorKeys.UNABLE_TO_TARGET_HEROES); } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_HERO); } - else { + } else { + if (invulnerable) { receiver.targetCheckFailed( - CommandStringErrorKeys.UNABLE_TO_TARGET_HEROES); + CommandStringErrorKeys.THAT_TARGET_IS_INVULNERABLE); + } else { + receiver.targetCheckFailed( + CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); } } - else { - receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_HERO); - } - } - else { - if (invulnerable) { - receiver.targetCheckFailed( - CommandStringErrorKeys.THAT_TARGET_IS_INVULNERABLE); - } - else { - receiver.targetCheckFailed( - CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); - } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_ANCIENTS); } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_AN_ANCIENT); } - else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_ANCIENTS); - } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_ORGANIC_UNITS); } - else { - receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_AN_ANCIENT); - } - } - else { - receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_ORGANIC_UNITS); + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_ORGANIC_UNITS); } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_NEUTRAL_UNIT); } - else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_ORGANIC_UNITS); - } - } - else { + } else { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_FRIENDLY_UNIT); } - } - else { + } else { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_AN_ENEMY_UNIT); } - } - else { + } else { if (this.targetedAs.contains(CTargetType.GROUND) && !targetsAllowed.contains(CTargetType.GROUND)) { receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_GROUND_UNITS); - } - else if (this.targetedAs.contains(CTargetType.STRUCTURE) + } else if (this.targetedAs.contains(CTargetType.STRUCTURE) && !targetsAllowed.contains(CTargetType.STRUCTURE)) { receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_BUILDINGS); - } - else if (this.targetedAs.contains(CTargetType.AIR) && !targetsAllowed.contains(CTargetType.AIR)) { + } else if (this.targetedAs.contains(CTargetType.AIR) && !targetsAllowed.contains(CTargetType.AIR)) { receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_AIR_UNITS); - } - else if (this.targetedAs.contains(CTargetType.WARD) && !targetsAllowed.contains(CTargetType.WARD)) { + } else if (this.targetedAs.contains(CTargetType.WARD) && !targetsAllowed.contains(CTargetType.WARD)) { receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_WARDS); - } - else if (targetsAllowed.contains(CTargetType.GROUND)) { + } else if (targetsAllowed.contains(CTargetType.GROUND)) { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_GROUND_UNIT); - } - else if (targetsAllowed.contains(CTargetType.STRUCTURE)) { + } else if (targetsAllowed.contains(CTargetType.STRUCTURE)) { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_BUILDING); - } - else if (targetsAllowed.contains(CTargetType.AIR)) { + } else if (targetsAllowed.contains(CTargetType.AIR)) { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_AN_AIR_UNIT); - } - else if (targetsAllowed.contains(CTargetType.WARD)) { + } else if (targetsAllowed.contains(CTargetType.WARD)) { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_WARD); - } - else { + } else { receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); } } @@ -3436,20 +4001,15 @@ public MovementType getMovementType() { if (isMovementDisabled()) { return MovementType.DISABLED; } - return this.movementOverride != null ? this.movementOverride : getUnitType().getMovementType(); // later maybe - // it has unit - // instance - // override for - // windwalk, so - // this - // wrapper exists to later mod + return this.movementOverride != null ? this.movementOverride : getUnitType().getMovementType(); + // later maybe it has unit instance override for windwalk, so this wrapper + // exists to later mod } public void setNoCollisionMovementType(final boolean active) { if (active) { this.movementOverride = MovementType.FOOT_NO_COLLISION; - } - else { + } else { this.movementOverride = null; } } @@ -3483,7 +4043,7 @@ public void resurrect(final CSimulation simulation) { this.explodesOnDeathBuffId = null; setLife(simulation, getMaximumLife()); simulation.getWorldCollision().addUnit(this); - simulation.unitUpdatedType(this, this.typeId); // clear out some state + simulation.unitUpdatedType(this, this.typeId, true); // clear out some state this.unitAnimationListener.playAnimation(true, PrimaryTag.STAND, SequenceUtils.EMPTY, 0.0f, true); } @@ -3514,7 +4074,7 @@ private AutocastTargetFinderEnum reset(final CSimulation game, final CUnit sourc @Override public boolean call(final CUnit unit) { - if (this.type != AutocastType.NONE) { + if (unit.isAutoTargetable() && this.type != AutocastType.NONE) { switch (this.type) { case ATTACKINGALLY: case ATTACKINGENEMY: @@ -3537,8 +4097,7 @@ public boolean call(final CUnit unit) { if (this.currentUnitTarget == null) { this.currentUnitTarget = unit; this.comparisonValue = this.source.distance(unit); - } - else { + } else { final double dist = this.source.distance(unit); if (dist < this.comparisonValue) { this.currentUnitTarget = unit; @@ -3567,8 +4126,7 @@ public boolean call(final CUnit unit) { if (this.currentUnitTarget == null) { this.currentUnitTarget = unit; this.comparisonValue = this.source.distance(unit); - } - else { + } else { final double dist = this.source.distance(unit); if (dist < this.comparisonValue) { this.currentUnitTarget = unit; @@ -3589,8 +4147,7 @@ public boolean call(final CUnit unit) { if (this.currentUnitTarget == null) { this.currentUnitTarget = unit; this.comparisonValue = unit.getLife() / unit.getMaximumLife(); - } - else { + } else { final double ratio = unit.getLife() / unit.getMaximumLife(); if (ratio > this.comparisonValue) { this.currentUnitTarget = unit; @@ -3608,8 +4165,7 @@ public boolean call(final CUnit unit) { if (this.currentUnitTarget == null) { this.currentUnitTarget = unit; this.comparisonValue = unit.getLife() / unit.getMaximumLife(); - } - else { + } else { final double ratio = unit.getLife() / unit.getMaximumLife(); if (ratio < this.comparisonValue) { this.currentUnitTarget = unit; @@ -3619,7 +4175,7 @@ public boolean call(final CUnit unit) { } } break; - case NEARESTVALID: + case FARTHESTVALID: targetCheckReceiver.reset(); this.ability.checkCanAutoTarget(this.game, this.source, this.ability.getBaseOrderId(), unit, targetCheckReceiver); @@ -3627,8 +4183,24 @@ public boolean call(final CUnit unit) { if (this.currentUnitTarget == null) { this.currentUnitTarget = unit; this.comparisonValue = this.source.distance(unit); + } else { + final double dist = this.source.distance(unit); + if (dist > this.comparisonValue) { + this.currentUnitTarget = unit; + this.comparisonValue = dist; + } } - else { + } + break; + case NEARESTVALID: + targetCheckReceiver.reset(); + this.ability.checkCanAutoTarget(this.game, this.source, this.ability.getBaseOrderId(), unit, + targetCheckReceiver); + if (targetCheckReceiver.isTargetable()) { + if (this.currentUnitTarget == null) { + this.currentUnitTarget = unit; + this.comparisonValue = this.source.distance(unit); + } else { final double dist = this.source.distance(unit); if (dist < this.comparisonValue) { this.currentUnitTarget = unit; @@ -3646,8 +4218,7 @@ public boolean call(final CUnit unit) { if (this.currentUnitTarget == null) { this.currentUnitTarget = unit; this.comparisonValue = this.source.distance(unit); - } - else { + } else { final double dist = this.source.distance(unit); if (dist < this.comparisonValue) { this.currentUnitTarget = unit; @@ -3685,7 +4256,7 @@ private AutoAttackTargetFinderEnum reset(final CSimulation game, final CUnit sou @Override public boolean call(final CUnit unit) { - if ((this.source.getAttackBehavior() != null) + if (unit.isAutoTargetable() && (this.source.getAttackBehavior() != null) && !this.source.getFirstAbilityOfType(CAbilityAttack.class).isDisabled()) { // TODO this "attack behavior null" check was added for some weird Root edge // case with NE, maybe @@ -3703,9 +4274,10 @@ public boolean call(final CUnit unit) { && !(this.game.getGameplayConstants().isMagicImmuneResistsDamage() && unit.isUnitType(CUnitTypeJass.MAGIC_IMMUNE) && (attack.getAttackType() == CAttackType.MAGIC))) { - this.source.beginBehavior(this.game, - this.source.getAttackBehavior().reset(this.game, OrderIds.attack, attack, unit, - this.disableMove, CBehaviorAttackListener.DO_NOTHING)); + this.source.beginBehavior( + this.game, this.source.getAttackBehavior().reset(this.game, OrderIds.attack, + attack, unit, this.disableMove, CBehaviorAttackListener.DO_NOTHING), + true); this.foundAnyTarget = true; return true; } @@ -3841,7 +4413,12 @@ public void setHidden(final boolean hidden) { } public void setPaused(final boolean paused) { - this.paused = paused; + if (paused) { + this.addStateModBuff(pauseBuff); + } else { + this.removeStateModBuff(pauseBuff); + } + this.computeUnitState(null, StateModBuffType.PAUSED); } public boolean isPaused() { @@ -3865,6 +4442,10 @@ public boolean isInvulnerable() { return this.invulnerable; } + public boolean isAutoTargetable() { + return this.autoTargetable; + } + public void setWorker(final CUnit unit, final boolean inside) { this.worker = unit; this.workerInside = inside; @@ -4040,23 +4621,20 @@ public void setBuildQueueItem(final CSimulation game, final int index, final War final int newFoodUsed = player.getFoodUsed() + unitType.getFoodUsed(); if (newFoodUsed <= player.getFoodCap()) { player.setFoodUsed(newFoodUsed); - } - else { + } else { this.queuedUnitFoodPaid = false; game.getCommandErrorListener().showInterfaceError(this.playerIndex, CommandStringErrorKeys.NOT_ENOUGH_FOOD); player.removeTechtreeInProgress(rawcode); } } - } - else if (queueItemType == QueueItemType.HERO_REVIVE) { + } else if (queueItemType == QueueItemType.HERO_REVIVE) { final CUnitType unitType = game.getUnit(this.buildQueue[index].getValue()).getUnitType(); if (unitType.getFoodUsed() != 0) { final int newFoodUsed = player.getFoodUsed() + unitType.getFoodUsed(); if (newFoodUsed <= player.getFoodCap()) { player.setFoodUsed(newFoodUsed); - } - else { + } else { this.queuedUnitFoodPaid = false; game.getCommandErrorListener().showInterfaceError(this.playerIndex, CommandStringErrorKeys.NOT_ENOUGH_FOOD); @@ -4074,8 +4652,7 @@ public void queueTrainingUnit(final CSimulation game, final War3ID rawcode) { final boolean isHeroType = unitType.isHero(); if (isHeroType && (player.getHeroTokens() > 0)) { player.setHeroTokens(player.getHeroTokens() - 1); - } - else { + } else { player.chargeFor(unitType); } } @@ -4091,8 +4668,7 @@ public void queueSacrificingUnit(final CSimulation game, final War3ID rawcode, f final boolean isHeroType = unitType.isHero(); if (isHeroType && (player.getHeroTokens() > 0)) { player.setHeroTokens(player.getHeroTokens() - 1); - } - else { + } else { player.chargeFor(unitType); } } @@ -4169,12 +4745,13 @@ private UseAbilityOnTargetByIdVisitor reset(final CSimulation game, final CUnit public Void accept(final AbilityPointTarget target) { CAbility abilityToUse = null; for (final CAbility ability : this.trainedUnit.getAbilities()) { - ability.checkCanUse(this.game, this.trainedUnit, this.rallyOrderId, + ability.checkCanUse(this.game, this.trainedUnit, this.rallyOrderId, false, BooleanAbilityActivationReceiver.INSTANCE); if (BooleanAbilityActivationReceiver.INSTANCE.isOk()) { final BooleanAbilityTargetCheckReceiver targetCheckReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); - ability.checkCanTarget(this.game, this.trainedUnit, this.rallyOrderId, target, targetCheckReceiver); + ability.checkCanTarget(this.game, this.trainedUnit, this.rallyOrderId, false, target, + targetCheckReceiver); if (targetCheckReceiver.isTargetable()) { abilityToUse = ability; } @@ -4196,11 +4773,11 @@ private Void acceptWidget(final CSimulation game, final CUnit trainedUnit, final final CWidget target) { CAbility abilityToUse = null; for (final CAbility ability : trainedUnit.getAbilities()) { - ability.checkCanUse(game, trainedUnit, rallyOrderId, BooleanAbilityActivationReceiver.INSTANCE); + ability.checkCanUse(game, trainedUnit, rallyOrderId, false, BooleanAbilityActivationReceiver.INSTANCE); if (BooleanAbilityActivationReceiver.INSTANCE.isOk()) { final BooleanAbilityTargetCheckReceiver targetCheckReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); - ability.checkCanTarget(game, trainedUnit, rallyOrderId, target, targetCheckReceiver); + ability.checkCanTarget(game, trainedUnit, rallyOrderId, false, target, targetCheckReceiver); if (targetCheckReceiver.isTargetable()) { abilityToUse = ability; } @@ -4436,13 +5013,11 @@ public void onRemove(final CSimulation simulation) { // in melee games. // (See "Remove creeps and critters from used start locations" implementation) setLife(simulation, 0); - } - else { + } else { if (!isDead()) { if (this.constructing) { player.removeTechtreeInProgress(this.unitType.getTypeId()); - } - else { + } else { player.removeTechtreeUnlocked(simulation, this.unitType.getTypeId()); } } // else techtree was removed upon death @@ -4475,6 +5050,13 @@ public StateListenerUpdateType getUpdateType() { } } + public void cancelConstruction(final CSimulation game) { + this.setLife(game, 0); + this.fireSimpleEvents(game, JassGameEventsWar3.EVENT_UNIT_CONSTRUCT_CANCEL); + game.getPlayer(this.playerIndex).fireSimpleUnitEvents(this, + JassGameEventsWar3.EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL, game); + } + public void cancelUpgrade(final CSimulation game) { final CPlayer player = game.getPlayer(this.playerIndex); player.setUnitFoodUsed(this, this.unitType.getFoodUsed()); @@ -4483,8 +5065,7 @@ public void cancelUpgrade(final CSimulation game) { if (game.getGameplayConstants().isRelativeUpgradeCosts()) { goldCost = newUpgradeUnitType.getGoldCost() - this.unitType.getGoldCost(); lumberCost = newUpgradeUnitType.getLumberCost() - this.unitType.getLumberCost(); - } - else { + } else { goldCost = newUpgradeUnitType.getGoldCost(); lumberCost = newUpgradeUnitType.getLumberCost(); } @@ -4495,8 +5076,7 @@ public void cancelUpgrade(final CSimulation game) { final CAbility ability = abilityIterator.next(); if (ability instanceof CAbilityBuildInProgress) { abilityIterator.remove(); - } - else { + } else { ability.setDisabled(false, CAbilityDisableType.CONSTRUCTION); ability.setIconShowing(true); } @@ -4508,6 +5088,9 @@ public void cancelUpgrade(final CSimulation game) { this.constructing = false; this.constructionProgress = 0; this.unitAnimationListener.playAnimation(true, PrimaryTag.STAND, SequenceUtils.EMPTY, 0.0f, true); + this.fireSimpleEvents(game, JassGameEventsWar3.EVENT_UNIT_UPGRADE_CANCEL); + game.getPlayer(this.playerIndex).fireSimpleUnitEvents(this, JassGameEventsWar3.EVENT_PLAYER_UNIT_UPGRADE_CANCEL, + game); } public void beginUpgrade(final CSimulation game, final War3ID rawcode) { @@ -4522,8 +5105,7 @@ public void beginUpgrade(final CSimulation game, final War3ID rawcode) { if (game.getGameplayConstants().isRelativeUpgradeCosts()) { goldCost = newUpgradeUnitType.getGoldCost() - this.unitType.getGoldCost(); lumberCost = newUpgradeUnitType.getLumberCost() - this.unitType.getLumberCost(); - } - else { + } else { goldCost = newUpgradeUnitType.getGoldCost(); lumberCost = newUpgradeUnitType.getLumberCost(); } @@ -4537,6 +5119,9 @@ public void beginUpgrade(final CSimulation game, final War3ID rawcode) { game.unitUpgradingEvent(this, rawcode); this.unitAnimationListener.playAnimation(true, PrimaryTag.BIRTH, SequenceUtils.EMPTY, 0.0f, true); + this.fireSimpleEvents(game, JassGameEventsWar3.EVENT_UNIT_UPGRADE_START); + game.getPlayer(this.playerIndex).fireSimpleUnitEvents(this, JassGameEventsWar3.EVENT_PLAYER_UNIT_UPGRADE_START, + game); } public void setUnitState(final CSimulation game, final CUnitState whichUnitState, final float value) { @@ -4580,9 +5165,12 @@ public boolean isUnitType(final CUnitTypeJass whichUnitType) { return isBuilding(); case FLYING: - return this.targetedAs.contains(CTargetType.AIR); + return this.unitType.getMovementType() == PathingGrid.MovementType.FLY; case GROUND: - return this.targetedAs.contains(CTargetType.GROUND); + return this.unitType.getMovementType() == PathingGrid.MovementType.FOOT + || this.unitType.getMovementType() == PathingGrid.MovementType.FOOT_NO_COLLISION + || this.unitType.getMovementType() == PathingGrid.MovementType.HORSE + || this.unitType.getMovementType() == PathingGrid.MovementType.HOVER; case ATTACKS_FLYING: for (final CUnitAttack attack : getCurrentAttacks()) { @@ -4655,8 +5243,15 @@ public boolean isUnitType(final CUnitTypeJass whichUnitType) { throw new UnsupportedOperationException( "cannot ask engine if unit is poisoned: poison is not yet implemented"); case POLYMORPHED: - throw new UnsupportedOperationException( - "cannot ask engine if unit is POLYMORPHED: POLYMORPHED is not yet implemented"); + boolean isPolymorphed = false; + for (final StateModBuff buff : this.stateModBuffs) { + if (buff.getBuffType() == StateModBuffType.POLYMORPHED) { + if (buff.getValue() != 0) { + isPolymorphed = true; + } + } + } + return isPolymorphed; case SLEEPING: boolean isSleeping = false; for (final StateModBuff buff : this.stateModBuffs) { @@ -4680,7 +5275,7 @@ public boolean isUnitType(final CUnitTypeJass whichUnitType) { } return isEthereal; case MAGIC_IMMUNE: - return isMagicImmune(); + return isMagicImmune() || isLimitedMagicImmune(); } return false; } @@ -4872,6 +5467,57 @@ public boolean removeUnitType(final CSimulation game, final CUnitTypeJass whichU return false; } + public Set getAppliedUpgrades() { + return this.appliedUpgrades; + } + + public int getLevelOfAppliedUpgrade(War3ID id) { + CUnitAppliedUpgrade upgrade = getAppliedUpgrade(id); + if (upgrade != null) { + return upgrade.getLevel(); + } + return 0; + } + + private CUnitAppliedUpgrade getAppliedUpgrade(War3ID id) { + for (CUnitAppliedUpgrade upgrade : this.appliedUpgrades) { + if (upgrade.getType().getTypeId().equals(id)) { + return upgrade; + } + } + return null; + } + + public void applyUpgrade(CSimulation simulation, CUpgradeType upgradeType, int level) { + CUnitAppliedUpgrade upgrade = getAppliedUpgrade(upgradeType.getTypeId()); + if (upgrade != null) { + if (upgrade.getLevel() == level) { + System.err.println("Unit already has upgrade? " + upgrade.getLevel() + " (target" + level + ")"); + return; + } + unapplyUpgrade(simulation, upgradeType, upgrade); + } + for (CUpgradeEffect upgradeEffect : upgradeType.getUpgradeEffects()) { + upgradeEffect.apply(simulation, this, level); + } + this.appliedUpgrades.add(new CUnitAppliedUpgrade(upgradeType, level)); + this.notifyUpgradesChanged(); + } + + public void unapplyUpgrade(CSimulation simulation, CUpgradeType upgradeType) { + CUnitAppliedUpgrade upgrade = getAppliedUpgrade(upgradeType.getTypeId()); + unapplyUpgrade(simulation, upgradeType, upgrade); + } + + public void unapplyUpgrade(CSimulation simulation, CUpgradeType upgradeType, CUnitAppliedUpgrade upgrade) { + if (upgrade != null) { + for (CUpgradeEffect upgradeEffect : upgradeType.getUpgradeEffects()) { + upgradeEffect.unapply(simulation, this, upgrade.getLevel()); + } + } + this.appliedUpgrades.remove(upgrade); + } + public int getTriggerEditorCustomValue() { return this.triggerEditorCustomValue; } @@ -4895,8 +5541,7 @@ public int getAbilityLevel(final War3ID abilityId) { final CLevelingAbility ability = getAbility(GetAbilityByRawcodeVisitor.getInstance().reset(abilityId)); if (ability == null) { return 0; - } - else { + } else { return ability.getLevel(); } } @@ -4913,8 +5558,7 @@ public void fireSpellEvents(final CSimulation game, final JassGameEventsWar3 eve final AbilityTarget target) { if (target == null) { fireSpellEventsNoTarget(game, eventId, ability); - } - else { + } else { target.visit(new AbilityTargetVisitor() { @Override @@ -5031,10 +5675,23 @@ private JassGameEventsWar3 unitSpellEventToPlayerEvent(final JassGameEventsWar3 } } + public void fireSimpleEvents(final CSimulation game, JassGameEventsWar3 type) { + final List eventList = getEventList(type); + if (eventList != null) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); + event.fire(this, CommonTriggerExecutionScope.simpleUnitScope(type, event.getTrigger(), this, + game.getPlayer(this.playerIndex))); + } + } + game.getPlayer(this.playerIndex).fireSimpleUnitEvents(this, type, game); + } + public void firePickUpItemEvents(final CSimulation game, final CItem item) { final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_PICKUP_ITEM); if (eventList != null) { - for (final CWidgetEvent event : eventList) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); event.fire(this, CommonTriggerExecutionScope.unitPickupItemScope( JassGameEventsWar3.EVENT_UNIT_PICKUP_ITEM, event.getTrigger(), this, item)); } @@ -5045,7 +5702,8 @@ public void firePickUpItemEvents(final CSimulation game, final CItem item) { public void fireOrderEvents(final CSimulation game, final COrderNoTarget order) { final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_ISSUED_ORDER); if (eventList != null) { - for (final CWidgetEvent event : eventList) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); event.fire(this, CommonTriggerExecutionScope.unitOrderScope(JassGameEventsWar3.EVENT_UNIT_ISSUED_ORDER, event.getTrigger(), this, order.getOrderId())); } @@ -5057,7 +5715,8 @@ public void fireOrderEvents(final CSimulation game, final COrderTargetPoint orde final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_ISSUED_POINT_ORDER); if (eventList != null) { final AbilityPointTarget target = order.getTarget(game); - for (final CWidgetEvent event : eventList) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); event.fire(this, CommonTriggerExecutionScope.unitOrderPointScope( JassGameEventsWar3.EVENT_UNIT_ISSUED_POINT_ORDER, event.getTrigger(), this, @@ -5071,7 +5730,8 @@ public void fireOrderEvents(final CSimulation game, final COrderTargetWidget ord final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_ISSUED_TARGET_ORDER); if (eventList != null) { final CWidget target = order.getTarget(game); - for (final CWidgetEvent event : eventList) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); event.fire(this, CommonTriggerExecutionScope.unitOrderTargetScope( JassGameEventsWar3.EVENT_UNIT_ISSUED_TARGET_ORDER, event.getTrigger(), this, @@ -5085,7 +5745,8 @@ public void fireConstructFinishEvents(final CSimulation game) { final CUnit constructingUnit = this.worker; final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_CONSTRUCT_FINISH); if (eventList != null) { - for (final CWidgetEvent event : eventList) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); event.fire(this, CommonTriggerExecutionScope.unitConstructFinishScope( JassGameEventsWar3.EVENT_UNIT_CONSTRUCT_FINISH, event.getTrigger(), this, constructingUnit)); } @@ -5096,7 +5757,8 @@ public void fireConstructFinishEvents(final CSimulation game) { public void fireTrainFinishEvents(final CSimulation game, final CUnit trainedUnit) { final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_TRAIN_FINISH); if (eventList != null) { - for (final CWidgetEvent event : eventList) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); event.fire(this, CommonTriggerExecutionScope.unitTrainFinishScope( JassGameEventsWar3.EVENT_UNIT_TRAIN_FINISH, event.getTrigger(), this, trainedUnit)); } @@ -5107,7 +5769,8 @@ public void fireTrainFinishEvents(final CSimulation game, final CUnit trainedUni public void fireResearchFinishEvents(final CSimulation game, final War3ID researched) { final List eventList = getEventList(JassGameEventsWar3.EVENT_UNIT_RESEARCH_FINISH); if (eventList != null) { - for (final CWidgetEvent event : eventList) { + for (int i = eventList.size() - 1; i >= 0; i--) { + CWidgetEvent event = eventList.get(i); event.fire(this, CommonTriggerExecutionScope.unitResearchFinishScope( JassGameEventsWar3.EVENT_UNIT_RESEARCH_FINISH, event.getTrigger(), this, researched, game.getPlayer(this.playerIndex))); } @@ -5116,7 +5779,8 @@ public void fireResearchFinishEvents(final CSimulation game, final War3ID resear } public boolean isHero() { - return getHeroData() != null; // in future maybe do this with better performance + CAbility hdata = getHeroData(); + return hdata != null && !hdata.isDisabled(); // in future maybe do this with better performance } public boolean isUnitAlly(final CPlayer whichPlayer) { @@ -5137,8 +5801,7 @@ public ResourceType backToWork(final CSimulation game, final ResourceType defaul abilityHarvest.getBehaviorReturnResources().reset(game); this.order(game, OrderIds.returnresources, abilityHarvest.getBehaviorReturnResources().findNearestDropoffPoint(game)); - } - else { + } else { this.order(game, OrderIds.harvest, CBehaviorReturnResources.findNearestMine(this, game)); } return ResourceType.GOLD; @@ -5147,8 +5810,7 @@ public ResourceType backToWork(final CSimulation game, final ResourceType defaul abilityHarvest.getBehaviorReturnResources().reset(game); this.order(game, OrderIds.returnresources, abilityHarvest.getBehaviorReturnResources().findNearestDropoffPoint(game)); - } - else { + } else { this.order(game, OrderIds.harvest, CBehaviorReturnResources.findNearestTree(this, abilityHarvest, game, abilityHarvest.getLastHarvestTarget())); } @@ -5157,25 +5819,21 @@ public ResourceType backToWork(final CSimulation game, final ResourceType defaul throw new IllegalStateException( "Worker was carrying a resource of unsupported type: " + carriedResourceType); } - } - else if (carriedResourceType != null) { + } else if (carriedResourceType != null) { if (carriedResourceType == ResourceType.GOLD) { this.order(game, OrderIds.harvest, CBehaviorReturnResources.findNearestMine(this, game)); return ResourceType.GOLD; - } - else if (carriedResourceType == ResourceType.LUMBER) { + } else if (carriedResourceType == ResourceType.LUMBER) { this.order(game, OrderIds.harvest, CBehaviorReturnResources.findNearestTree(this, abilityHarvest, game, abilityHarvest.getLastHarvestTarget())); return ResourceType.LUMBER; } - } - else if (defaultResourceType != null) { + } else if (defaultResourceType != null) { if (((defaultResourceType == ResourceType.GOLD) || (abilityHarvest.getLumberCapacity() == 0)) && (abilityHarvest.getGoldCapacity() > 0)) { this.order(game, OrderIds.harvest, CBehaviorReturnResources.findNearestMine(this, game)); return ResourceType.GOLD; - } - else if (abilityHarvest.getLumberCapacity() > 0) { + } else if (abilityHarvest.getLumberCapacity() > 0) { this.order(game, OrderIds.harvest, CBehaviorReturnResources.findNearestTree(this, abilityHarvest, game, abilityHarvest.getLastHarvestTarget())); return ResourceType.LUMBER; @@ -5195,6 +5853,14 @@ public void notifyOrdersChanged() { this.stateNotifier.ordersChanged(); } + public void notifyAbilitiesChanged() { + this.stateNotifier.abilitiesChanged(); + } + + public void notifyUpgradesChanged() { + this.stateNotifier.upgradesChanged(); + } + public void setConstructionConsumesWorker(final boolean constructionConsumesWorker) { this.constructionConsumesWorker = constructionConsumesWorker; } @@ -5351,16 +6017,6 @@ public void removeDamageTakenModificationListener(final CUnitAttackDamageTakenMo this.damageTakenModificationListeners.remove(listener); } - public void addFinalDamageTakenModificationListener( - final CUnitAttackFinalDamageTakenModificationListener listener) { - this.finalDamageTakenModificationListeners.add(0, listener); - } - - public void removeFinalDamageTakenModificationListener( - final CUnitAttackFinalDamageTakenModificationListener listener) { - this.finalDamageTakenModificationListeners.remove(listener); - } - public void addDamageTakenListener(final CUnitAttackDamageTakenListener listener) { this.damageTakenListeners.add(0, listener); } @@ -5435,6 +6091,14 @@ public void removePostDamageListener(final CUnitAttackPostDamageListener listene this.postDamageListeners.remove(listener); } + public void addAttackModifier(final CUnitAttackModifier modifier) { + this.attackModifiers.add(0, modifier); + } + + public void removeAttackModifier(final CUnitAttackModifier modifier) { + this.attackModifiers.remove(modifier); + } + public void beginCooldown(final CSimulation game, final War3ID abilityId, final float cooldownDuration) { final int gameTurnTick = game.getGameTurnTick(); this.rawcodeToCooldownExpireTime.put(abilityId.getValue(), @@ -5493,6 +6157,18 @@ public boolean isMagicImmune() { return this.magicImmune; } + public void setLimitedMagicImmune(final boolean limitedMagicImmune) { + this.limitedMagicImmune = limitedMagicImmune; + } + + public boolean isLimitedMagicImmune() { + return this.limitedMagicImmune; + } + + public boolean isMorphImmune() { + return this.morphImmune; + } + public boolean isFalseDeath() { return this.falseDeath; } @@ -5501,18 +6177,19 @@ public void setFalseDeath(final boolean falseDeath) { this.falseDeath = falseDeath; } - public void setAutocastAbility(final CAutocastAbility autocastAbility) { - if (this.autocastAbility != null) { - this.autocastAbility.setAutoCastOff(); + public void setAutocastAbility(final CSimulation simulation, final CAutocastAbility autocastAbility) { + if (this.autocastAbility != null && !this.autocastAbility.equals(autocastAbility)) { + this.autocastAbility.setAutoCastOn(simulation, this, false, false); } this.autocastAbility = autocastAbility; } public boolean isVisible(final CSimulation simulation, final int toPlayerIndex) { final CPlayer toPlayer = simulation.getPlayer(toPlayerIndex); - if (((toPlayerIndex == this.playerIndex) || toPlayer.hasAlliance(this.playerIndex, CAllianceType.SHARED_VISION)) + if (this.isDead() || (((toPlayerIndex == this.playerIndex) + || toPlayer.hasAlliance(this.playerIndex, CAllianceType.SHARED_VISION)) && ((simulation.isDay() ? this.unitType.getSightRadiusDay() - : this.unitType.getSightRadiusNight()) > 0)) { + : this.unitType.getSightRadiusNight()) > 0))) { return true; } if ((this.invisLevels > 0) && ((this.detections & (1 << toPlayerIndex)) == 0)) { @@ -5522,6 +6199,38 @@ public boolean isVisible(final CSimulation simulation, final int toPlayerIndex) return toPlayer.getFogOfWar().isVisible(simulation, simulation.getPathingGrid(), getX(), getY()); } + public boolean hasUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + return this.uniqueFlags.contains(flag); + } + return false; + } + + public void addUniqueFlag(String flag) { + if (this.uniqueFlags == null) { + this.uniqueFlags = new ArrayList<>(); + } + this.uniqueFlags.add(flag); + } + + public void removeUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + this.uniqueFlags.remove(flag); + } + } + + public boolean isSelectable(final CSimulation simulation, final int toPlayerIndex) { + return ((this.unselectablePlayers & (1 << toPlayerIndex)) == 0); + } + + public boolean isUnenumerable() { + return this.unenumerable; + } + + public boolean isHideMinimapIcon() { + return hideMinimapIcon; + } + private final class CTimerUnitFade extends CTimer { private final StateModBuff stateModBuff; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitAnimationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitAnimationListener.java index b4ca3af39..4a3e168dd 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitAnimationListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitAnimationListener.java @@ -21,6 +21,8 @@ void playAnimationWithDuration(final boolean force, final PrimaryTag animationNa void queueAnimation(final PrimaryTag animationName, final EnumSet secondaryAnimationTags, boolean allowRarityVariations); + boolean isAnimationQueued(PrimaryTag animationName); + boolean addSecondaryTag(SecondaryTag secondaryTag); boolean removeSecondaryTag(SecondaryTag secondaryTag); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitStateListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitStateListener.java index ce2de3735..7beb7a50e 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitStateListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitStateListener.java @@ -25,6 +25,8 @@ public interface CUnitStateListener { void hideStateChanged(); + void upgradesChanged(); + public static final class CUnitStateNotifier extends SubscriberSetNotifier implements CUnitStateListener { @Override @@ -103,5 +105,12 @@ public void hideStateChanged() { listener.hideStateChanged(); } } + + @Override + public void upgradesChanged() { + for (final CUnitStateListener listener : set) { + listener.upgradesChanged(); + } + } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitType.java index 5fd870cd3..6f6d9302d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnitType.java @@ -33,6 +33,8 @@ public class CUnitType { private final int manaInitial; private final int manaMaximum; private final int speed; + private final int maxSpeed; + private final int minSpeed; private final int defense; private final War3ID defaultAutocastAbility; private final List abilityList; @@ -110,10 +112,12 @@ public class CUnitType { private final int lumberBountyAwardedDice; private final int lumberBountyAwardedSides; private final boolean neutralBuildingShowMinimapIcon; + private final String tilesets; + private boolean special; public CUnitType(final String name, final String legacyName, final War3ID typeId, final int maxLife, final float lifeRegen, final float manaRegen, final CRegenType lifeRegenType, final int manaInitial, - final int manaMaximum, final int speed, final int defense, final War3ID defaultAutocastAbility, + final int manaMaximum, final int speed, final int maxSpeed, final int minSpeed, final int defense, final War3ID defaultAutocastAbility, final List abilityList, final boolean isBldg, final MovementType movementType, final float defaultFlyingHeight, final float collisionSize, final EnumSet classifications, final List attacks, @@ -137,7 +141,7 @@ public CUnitType(final String name, final String legacyName, final War3ID typeId final int sightRadiusDay, final int sightRadiusNight, final boolean extendedLineOfSight, final int goldBountyAwardedBase, final int goldBountyAwardedDice, final int goldBountyAwardedSides, final int lumberBountyAwardedBase, final int lumberBountyAwardedDice, final int lumberBountyAwardedSides, - boolean neutralBuildingShowMinimapIcon) { + boolean neutralBuildingShowMinimapIcon, final String tilesets, final boolean special) { this.name = name; this.legacyName = legacyName; this.typeId = typeId; @@ -148,6 +152,8 @@ public CUnitType(final String name, final String legacyName, final War3ID typeId this.manaInitial = manaInitial; this.manaMaximum = manaMaximum; this.speed = speed; + this.maxSpeed = maxSpeed; + this.minSpeed = minSpeed; this.defense = defense; this.defaultAutocastAbility = defaultAutocastAbility; this.abilityList = abilityList; @@ -222,6 +228,8 @@ public CUnitType(final String name, final String legacyName, final War3ID typeId this.lumberBountyAwardedDice = lumberBountyAwardedDice; this.lumberBountyAwardedSides = lumberBountyAwardedSides; this.neutralBuildingShowMinimapIcon = neutralBuildingShowMinimapIcon; + this.tilesets = tilesets; + this.special = special; } public String getName() { @@ -264,6 +272,14 @@ public int getSpeed() { return this.speed; } + public int getMaxSpeed() { + return this.maxSpeed; + } + + public int getMinSpeed() { + return this.minSpeed; + } + public int getDefense() { return this.defense; } @@ -572,4 +588,12 @@ public int getCargoCapacity() { public boolean isNeutralBuildingShowMinimapIcon() { return this.neutralBuildingShowMinimapIcon; } + + public String getTilesets() { + return this.tilesets; + } + + public boolean isSpecial() { + return this.special; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUpgradeType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUpgradeType.java index b60393a42..061ea0332 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUpgradeType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUpgradeType.java @@ -135,9 +135,7 @@ public List getRequirements() { } public void apply(CSimulation simulation, CUnit unit, int i) { - for (CUpgradeEffect upgradeEffect : getUpgradeEffects()) { - upgradeEffect.apply(simulation, unit, i); - } + unit.applyUpgrade(simulation, this, i); } public void apply(CSimulation simulation, int playerIndex, int i) { @@ -147,9 +145,7 @@ public void apply(CSimulation simulation, int playerIndex, int i) { } public void unapply(CSimulation simulation, CUnit unit, int i) { - for (CUpgradeEffect upgradeEffect : getUpgradeEffects()) { - upgradeEffect.unapply(simulation, unit, i); - } + unit.unapplyUpgrade(simulation, this); } public void unapply(CSimulation simulation, int playerIndex, int i) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWidget.java index 179207daa..a415fccd4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWidget.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWidget.java @@ -14,6 +14,8 @@ import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; @@ -70,13 +72,11 @@ public void setLife(final CSimulation simulation, final float life) { this.life = life; } - public abstract float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage); + public abstract float damage(final CSimulation simulation, final CUnit source, final CDamageFlags flags, + final CAttackType attackType, final CDamageType damageType, final String weaponSoundType, + final float damage); - public abstract float damage(final CSimulation simulation, final CUnit source, final boolean isAttack, - final boolean isRanged, final CAttackType attackType, final CDamageType damageType, - final String weaponSoundType, final float damage, final float bonusDamage); + public abstract float damage(CSimulation simulation, CDamageCalculation damage); public abstract float getFlyHeight(); @@ -162,4 +162,5 @@ public RemovableTriggerEvent addDeathEvent(final GlobalScope globalScope, final } public abstract double distance(float x, float y); + } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWorldCollision.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWorldCollision.java index 932640706..9f849029e 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWorldCollision.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CWorldCollision.java @@ -161,7 +161,7 @@ public void enumUnitsInRect(final Rectangle rect, final CUnitEnumFunction callba // and so a recycled allocation did not work final Set intersectedUnits = new HashSet<>(); this.anyUnitEnumerableCollision.intersect(rect, (unit) -> { - if (unit.isHidden() || !intersectedUnits.add(unit)) { + if (unit.isHidden() || unit.isUnenumerable() || !intersectedUnits.add(unit)) { return false; } return callback.call(unit); @@ -172,7 +172,7 @@ public void enumCorpsesInRect(final Rectangle rect, final CUnitEnumFunction call // NOTE: allocation here seems quite wasteful, see note on enumUnitsInRect final Set intersectedUnits = new HashSet<>(); this.deadUnitCollision.intersect(rect, (unit) -> { - if (unit.isHidden() || !intersectedUnits.add(unit)) { + if (unit.isHidden() || unit.isUnenumerable() || !intersectedUnits.add(unit)) { return false; } return callback.call(unit); @@ -183,7 +183,7 @@ public void enumUnitsOrCorpsesInRect(final Rectangle rect, final CUnitEnumFuncti // NOTE: allocation here seems quite wasteful, see note on enumUnitsInRect final Set intersectedUnits = new HashSet<>(); final QuadtreeIntersector intersectorFxn = (unit) -> { - if (unit.isHidden() || !intersectedUnits.add(unit)) { + if (unit.isHidden() || unit.isUnenumerable() || !intersectedUnits.add(unit)) { return false; } return callback.call(unit); @@ -363,7 +363,7 @@ public AnyUnitExceptTwoIntersector reset(final CUnit firstUnit, final CUnit seco @Override public boolean onIntersect(final CUnit intersectingObject) { - if (intersectingObject.isHidden() + if (intersectingObject.isHidden() || intersectingObject.isUnenumerable() || MovementType.FOOT_NO_COLLISION.equals(intersectingObject.getMovementType()) || (this.forConstruction && intersectingObject.isNoBuildingCollision()) || (!this.forConstruction && intersectingObject.isNoUnitCollision())) { @@ -387,7 +387,7 @@ public EachUnitOnlyOnceIntersector reset(final CUnitEnumFunction consumerDelegat @Override public boolean onIntersect(final CUnit intersectingObject) { - if (intersectingObject.isHidden()) { + if (intersectingObject.isHidden() || intersectingObject.isUnenumerable()) { return false; } if (this.done) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/AbstractCAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/AbstractCAbility.java index 6e53e07cd..cab8fe5da 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/AbstractCAbility.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/AbstractCAbility.java @@ -10,6 +10,7 @@ public abstract class AbstractCAbility extends CExtensibleHandleAbstract implements CAbility { private final int handleId; private byte disabled = 0; + private boolean hero = false; private boolean iconShowing = true; private boolean permanent = false; @@ -35,24 +36,43 @@ public War3ID getAlias() { return getCode(); } + @Override + public boolean isHero() { + return hero; + } + + public void setHero(boolean hero) { + this.hero = hero; + } + @Override public final boolean isDisabled() { return this.disabled != 0; } - protected void onSetDisabled(final boolean disabled, final CAbilityDisableType type) { + protected void onSetDisabled(final boolean disabled, final boolean wasDisabled, final CAbilityDisableType type) { } @Override public final void setDisabled(final boolean disabled, final CAbilityDisableType type) { + boolean wasDisabled = this.isDisabled(); if (disabled) { this.disabled |= type.getMask(); } else { this.disabled &= ~type.getMask(); } - onSetDisabled(disabled, type); + onSetDisabled(disabled, wasDisabled, type); + } + + @Override + public boolean isClickDisabled() { + return this.disabled != 0; + } + + @Override + public void setClickDisabled(final boolean disabled, final CAbilityDisableType type) { } @Override @@ -95,19 +115,47 @@ public CItem getItem() { // do nothing return null; } + + @Override + public boolean hasUniqueFlag(String flag) { + return false; + } + + public void addUniqueFlag(String flag) { + } + + public void removeUniqueFlag(String flag) { + } + + @Override + public T getUniqueValue(String key, Class cls) { + return null; + } + + public void addUniqueValue(Object item, String key) { + } + + public void removeUniqueValue(String key) { + } @Override public final void checkCanUse(final CSimulation game, final CUnit unit, final int orderId, - final AbilityActivationReceiver receiver) { + boolean autoOrder, final AbilityActivationReceiver receiver) { if (isDisabled()) { receiver.disabled(); checkRequirementsMet(game, unit, receiver); + innerCheckCooldownDisabled(game,unit,orderId,receiver); } else { innerCheckCanUse(game, unit, orderId, receiver); } } + protected void innerCheckCooldownDisabled(final CSimulation game, final CUnit unit, final int orderId, + final AbilityActivationReceiver receiver) { + //do nothing + } + protected abstract void innerCheckCanUse(final CSimulation game, final CUnit unit, final int orderId, final AbilityActivationReceiver receiver); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbility.java index 5801e4920..04b8c3d3c 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbility.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbility.java @@ -34,15 +34,18 @@ public interface CAbility extends CAbilityView, CExtensibleHandle { void onCancelFromQueue(CSimulation game, CUnit unit, int orderId); /* return false to not do anything, such as for toggling autocast */ - boolean checkBeforeQueue(CSimulation game, CUnit caster, int orderId, AbilityTarget target); + boolean checkBeforeQueue(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget target); - CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target); + CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target); - CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point); + CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point); - CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId); + CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder); + + void setHero(boolean isHero); void setDisabled(boolean disabled, CAbilityDisableType type); + void setClickDisabled(boolean disabled, CAbilityDisableType type); void setIconShowing(boolean iconShowing); @@ -52,4 +55,12 @@ public interface CAbility extends CAbilityView, CExtensibleHandle { CItem getItem(); + boolean hasUniqueFlag(String flag); + void addUniqueFlag(String flag); + void removeUniqueFlag(String flag); + + T getUniqueValue(String key, Class cls); + void addUniqueValue(Object item, String key); + void removeUniqueValue(String key); + } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityAttack.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityAttack.java index 6761d6215..0e2754ed6 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityAttack.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityAttack.java @@ -39,8 +39,8 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { if (target == unit) { receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_SELF); return; // no attacking self ever @@ -102,13 +102,13 @@ else if (target instanceof CDestructable) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.attack: receiver.targetOk(target); @@ -136,7 +136,7 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_A_UNIT_WITH_THIS_ACTION); } @@ -157,7 +157,7 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { CBehavior behavior = null; for (final CUnitAttack attack : caster.getCurrentAttacks()) { if (target.canBeTargetedBy(game, caster, attack.getTargetsAllowed())) { @@ -174,7 +174,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { switch (orderId) { case OrderIds.attack: if (caster.getAttackMoveBehavior() == null) { @@ -201,7 +201,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -223,6 +223,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityDisableType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityDisableType.java index dca5d3837..03573f8b2 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityDisableType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityDisableType.java @@ -7,8 +7,9 @@ public enum CAbilityDisableType implements CHandle { CONSTRUCTION((byte) 2), TRANSFORMATION((byte) 4), TRIGGER((byte) 8), - ATTACKDISABLED((byte) 16), - PLAYER((byte) 32); + DISABLED_EFFECT((byte) 16), + PLAYER((byte) 32), + ABILITYINTERNAL((byte) 64); private byte mask; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityGenericDoNothing.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityGenericDoNothing.java index b04ac511e..e0c83a7d2 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityGenericDoNothing.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityGenericDoNothing.java @@ -27,20 +27,20 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @@ -63,23 +63,23 @@ public void onTick(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return false; } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -93,7 +93,12 @@ public void onDeath(final CSimulation game, final CUnit cUnit) { @Override public boolean isPhysical() { - return true; + return false; + } + + @Override + public boolean isMagic() { + return false; } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityMove.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityMove.java index 44d04f8d6..49bc1b984 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityMove.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityMove.java @@ -32,8 +32,8 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.smart: case OrderIds.patrol: @@ -53,7 +53,7 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.smart: case OrderIds.move: @@ -68,7 +68,7 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.holdposition: receiver.targetOk(null); @@ -99,12 +99,12 @@ public void onTick(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { final boolean smart = orderId == OrderIds.smart; final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); if (targetUnit != null) { @@ -129,7 +129,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { if (orderId == OrderIds.patrol) { final CBehavior patrolBehavior = caster.getPatrolBehavior().reset(point); caster.setDefaultBehavior(patrolBehavior); @@ -141,7 +141,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { if (orderId == OrderIds.holdposition) { caster.setDefaultBehavior(caster.getHoldPositionBehavior()); } @@ -166,6 +166,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityView.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityView.java index 21707f1fc..a60e5a1f8 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityView.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityView.java @@ -10,15 +10,15 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; public interface CAbilityView extends CHandle { - void checkCanUse(CSimulation game, CUnit unit, int orderId, AbilityActivationReceiver receiver); + void checkCanUse(CSimulation game, CUnit unit, int orderId, boolean autoOrder, AbilityActivationReceiver receiver); - void checkCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver); + void checkCanTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, + CWidget target, AbilityTargetCheckReceiver receiver); - void checkCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver); + void checkCanTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, + AbilityPointTarget target, AbilityTargetCheckReceiver receiver); - void checkCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, AbilityTargetCheckReceiver receiver); + void checkCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, AbilityTargetCheckReceiver receiver); void checkRequirementsMet(CSimulation game, CUnit unit, AbilityActivationReceiver receiver); @@ -31,13 +31,18 @@ void checkCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarge War3ID getCode(); + boolean isHero(); + boolean isDisabled(); + boolean isClickDisabled(); boolean isIconShowing(); boolean isPermanent(); boolean isPhysical(); + + boolean isMagic(); boolean isUniversal(); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityVisitor.java index 531fdefd3..928565052 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/CAbilityVisitor.java @@ -22,7 +22,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; /** * A visitor for the lowest level inherent types of an ability. It's a bit of a @@ -83,5 +83,5 @@ public interface CAbilityVisitor { T accept(CAbilityNeutralBuilding ability); - T accept(AbilityBuilderActiveAbility ability); + T accept(ABAbilityBuilderActiveAbility ability); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/GetAbilityByRawcodeVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/GetAbilityByRawcodeVisitor.java index bdda0b550..5acf67e73 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/GetAbilityByRawcodeVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/GetAbilityByRawcodeVisitor.java @@ -20,7 +20,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; public class GetAbilityByRawcodeVisitor implements CAbilityVisitor { private static final GetAbilityByRawcodeVisitor INSTANCE = new GetAbilityByRawcodeVisitor(); @@ -119,7 +119,7 @@ public CLevelingAbility accept(final CAbilityReviveHero ability) { } @Override - public CLevelingAbility accept(final AbilityBuilderActiveAbility ability) { + public CLevelingAbility accept(final ABAbilityBuilderActiveAbility ability) { if (this.rawcode.equals(ability.getAlias())) { return ability; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/AutocastType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/AutocastType.java index de01f124e..a6d498742 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/AutocastType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/AutocastType.java @@ -9,11 +9,12 @@ public enum AutocastType implements CHandle { ATTACKTARGETING, ATTACKINGALLY, ATTACKINGENEMY, + FARTHESTVALID, NEARESTVALID, NEARESTENEMY, NOTARGET, - ATTACKREPLACEMENT; + NOAUTOCASTBEHAVIOR; @Override public int getHandleId() { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/CAutocastAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/CAutocastAbility.java index 841361e9d..24282f384 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/CAutocastAbility.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/autocast/CAutocastAbility.java @@ -16,9 +16,7 @@ public interface CAutocastAbility { boolean isAutoCastOn(); - void setAutoCastOn(final CUnit caster, final boolean autoCastOn); - - void setAutoCastOff(); + void setAutoCastOn(final CSimulation simulation, final CUnit caster, final boolean autoCastOn, final boolean notify); void checkCanAutoTarget(CSimulation game, CUnit unit, int orderId, CWidget target, AbilityTargetCheckReceiver receiver); @@ -30,6 +28,6 @@ void checkCanAutoTargetNoTarget(CSimulation game, CUnit unit, int orderId, AbilityTargetCheckReceiver receiver); void checkCanUse(final CSimulation game, final CUnit unit, final int orderId, - final AbilityActivationReceiver receiver); + boolean autoOrder, final AbilityActivationReceiver receiver); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/blight/CAbilityBlight.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/blight/CAbilityBlight.java index bd503be9e..d7433b2ce 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/blight/CAbilityBlight.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/blight/CAbilityBlight.java @@ -66,36 +66,36 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/AbstractCAbilityBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/AbstractCAbilityBuild.java index 497993efb..bc42fbc6b 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/AbstractCAbilityBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/AbstractCAbilityBuild.java @@ -92,14 +92,14 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { War3ID orderIdAsWar3ID = new War3ID(orderId); if (this.structuresBuilt.contains(orderIdAsWar3ID)) { final CUnitType unitTypeToCreate = game.getUnitData().getUnitType(orderIdAsWar3ID); @@ -122,13 +122,13 @@ public final void checkCanTarget(final CSimulation game, final CUnit unit, final @Override public final void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityBuildInProgress.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityBuildInProgress.java index 2c3a11324..09b6c67fe 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityBuildInProgress.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityBuildInProgress.java @@ -38,14 +38,14 @@ public void onTick(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { final CPlayer player = game.getPlayer(caster.getPlayerIndex()); if (caster.isUpgrading()) { player.removeTechtreeInProgress(caster.getUpgradeIdType()); caster.cancelUpgrade(game); } else { - caster.setLife(game, 0); + caster.cancelConstruction(game); } return false; } @@ -65,18 +65,18 @@ public void onDeath(final CSimulation game, final CUnit caster) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -87,20 +87,20 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { if (orderId == OrderIds.cancel) { receiver.targetOk(null); } @@ -125,6 +125,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanBuild.java index 868c5139e..257a9c717 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanBuild.java @@ -38,13 +38,13 @@ public void onRemove(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { final War3ID orderIdAsRawtype = new War3ID(orderId); final CUnitType unitType = game.getUnitData().getUnitType(orderIdAsRawtype); roundTargetPoint(point, unitType); @@ -57,7 +57,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -71,6 +71,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanRepair.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanRepair.java index 3afe6ea0d..3656b044a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanRepair.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityHumanRepair.java @@ -37,6 +37,7 @@ public CAbilityHumanRepair(final int handleId, final War3ID code, final War3ID a final float castRange) { super(handleId, code, alias); this.targetsAllowed = targetsAllowed; + this.targetsAllowed.add(CTargetType.REPAIRABLE); this.navalRangeBonus = navalRangeBonus; this.powerBuildCostRatio = powerBuildCostRatio; this.powerBuildTimeRatio = powerBuildTimeRatio; @@ -124,18 +125,18 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorRepair.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -203,14 +204,11 @@ public AutocastType getAutocastType() { } @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { + public void setAutoCastOn(final CSimulation simulation, final CUnit caster, final boolean autoCastOn, final boolean notify) { this.autocasting = autoCastOn; - caster.setAutocastAbility(autoCastOn ? this : null); - } - - @Override - public void setAutoCastOff() { - this.autocasting = false; + if (notify) { + caster.setAutocastAbility(simulation, autoCastOn ? this : null); + } } @Override @@ -231,7 +229,7 @@ public int getAutoCastOffOrderId() { @Override public void checkCanAutoTarget(CSimulation game, CUnit unit, int orderId, CWidget target, AbilityTargetCheckReceiver receiver) { - this.checkCanTarget(game, unit, orderId, target, receiver); + this.checkCanTarget(game, unit, orderId, false, target, receiver); } @Override @@ -251,6 +249,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNagaBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNagaBuild.java index 28231721c..806fc8ba4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNagaBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNagaBuild.java @@ -38,13 +38,13 @@ public void onRemove(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { final War3ID orderIdAsRawtype = new War3ID(orderId); final CUnitType unitType = game.getUnitData().getUnitType(orderIdAsRawtype); roundTargetPoint(point, unitType); @@ -57,7 +57,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -71,6 +71,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNeutralBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNeutralBuild.java index 8c871158c..62ae92fce 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNeutralBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNeutralBuild.java @@ -32,19 +32,19 @@ public void onRemove(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { // TODO Auto-generated method stub return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -64,6 +64,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNightElfBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNightElfBuild.java index b9b92eaa2..00eaca5f6 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNightElfBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityNightElfBuild.java @@ -37,13 +37,13 @@ public void onRemove(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { final War3ID orderIdAsRawtype = new War3ID(orderId); final CUnitType unitType = game.getUnitData().getUnitType(orderIdAsRawtype); roundTargetPoint(point, unitType); @@ -56,7 +56,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -70,6 +70,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityOrcBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityOrcBuild.java index 388a1a45b..fddcfb6a4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityOrcBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityOrcBuild.java @@ -37,13 +37,13 @@ public void onRemove(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { final War3ID orderIdAsRawtype = new War3ID(orderId); final CUnitType unitType = game.getUnitData().getUnitType(orderIdAsRawtype); roundTargetPoint(point, unitType); @@ -56,7 +56,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -70,6 +70,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityRepair.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityRepair.java index 886b8ffe3..48e25d591 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityRepair.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityRepair.java @@ -34,6 +34,7 @@ public CAbilityRepair(final int handleId, final War3ID code, final War3ID alias, final float castRange) { super(handleId, code, alias); this.targetsAllowed = targetsAllowed; + this.targetsAllowed.add(CTargetType.REPAIRABLE); this.navalRangeBonus = navalRangeBonus; this.repairCostRatio = repairCostRatio; this.repairTimeRatio = repairTimeRatio; @@ -119,18 +120,18 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorRepair.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -190,9 +191,11 @@ public AutocastType getAutocastType() { } @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { + public void setAutoCastOn(final CSimulation simulation, final CUnit caster, final boolean autoCastOn, final boolean notify) { this.autocasting = autoCastOn; - caster.setAutocastAbility(autoCastOn ? this : null); + if (notify) { + caster.setAutocastAbility(simulation, autoCastOn ? this : null); + } } @Override @@ -200,11 +203,6 @@ public boolean isAutoCastOn() { return autocasting ; } - @Override - public void setAutoCastOff() { - this.autocasting = false; - } - @Override public int getAutoCastOnOrderId() { return OrderIds.repairon; @@ -218,7 +216,7 @@ public int getAutoCastOffOrderId() { @Override public void checkCanAutoTarget(CSimulation game, CUnit unit, int orderId, CWidget target, AbilityTargetCheckReceiver receiver) { - this.checkCanTarget(game, unit, orderId, target, receiver); + this.checkCanTarget(game, unit, orderId, false, target, receiver); } @Override @@ -238,6 +236,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityUndeadBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityUndeadBuild.java index b1994f2da..8b420a5fb 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityUndeadBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/build/CAbilityUndeadBuild.java @@ -37,13 +37,13 @@ public void onRemove(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { final War3ID orderIdAsRawtype = new War3ID(orderId); final CUnitType unitType = game.getUnitData().getUnitType(orderIdAsRawtype); roundTargetPoint(point, unitType); @@ -56,7 +56,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -70,6 +70,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityCargoHold.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityCargoHold.java index 19fadcbbe..f140723d6 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityCargoHold.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityCargoHold.java @@ -52,7 +52,7 @@ public void onTick(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { if (orderId == OrderIds.unload) { final int targetIndex = cargoUnits.indexOf(target); if (targetIndex != -1) { @@ -64,7 +64,7 @@ public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, fina } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @@ -78,18 +78,18 @@ public void dropUnitByIndex(final CSimulation game, final CUnit caster, final in @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { if (orderId == OrderIds.unload) { if (cargoUnits.contains(target)) { receiver.targetOk(target); @@ -105,13 +105,13 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDrop.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDrop.java index b22605bd0..c681733a8 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDrop.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDrop.java @@ -43,18 +43,18 @@ public int getBaseOrderId() { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return this.behaviorDrop.reset(game, point); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -113,6 +113,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDropInstant.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDropInstant.java index ea857a2d9..62fdb6ec5 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDropInstant.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityDropInstant.java @@ -35,18 +35,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { final CAbilityCargoHold cargoData = caster.getCargoData(); cargoData.unloadAllInstant(game, caster); return caster.pollNextOrderBehavior(game); @@ -104,6 +104,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityLoad.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityLoad.java index 5fe1be10e..870fda50a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityLoad.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityLoad.java @@ -52,18 +52,18 @@ public int getBaseOrderId() { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorLoad.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -169,14 +169,14 @@ public static CAbilityLoad getTransportLoad(final CSimulation game, final CUnit if (potentialLoadAbility instanceof CAbilityLoad) { final CAbilityLoad abilityLoad = (CAbilityLoad) potentialLoadAbility; final BooleanAbilityActivationReceiver transportUnitReceiver = BooleanAbilityActivationReceiver.INSTANCE; - abilityLoad.checkCanUse(game, transport, OrderIds.smart, transportUnitReceiver); + abilityLoad.checkCanUse(game, transport, OrderIds.smart, false, transportUnitReceiver); // NOTE: disabled load ability should enable later in case of under construction // entangled gold mine if (transportUnitReceiver.isOk() || (ignoreDisabled && abilityLoad.isDisabled())) { final ExternStringMsgTargetCheckReceiver transportUnitTargetCheckReceiver = ExternStringMsgTargetCheckReceiver .getInstance(); - abilityLoad.checkCanTarget(game, transport, OrderIds.smart, caster, - transportUnitTargetCheckReceiver.reset()); + abilityLoad.checkCanTarget(game, transport, OrderIds.smart, false, + caster, transportUnitTargetCheckReceiver.reset()); if ((transportUnitTargetCheckReceiver.getTarget() != null) || (ignoreRange && (transportUnitTargetCheckReceiver .getExternStringKey() == CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE))) { @@ -193,6 +193,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityStandDown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityStandDown.java index 3726a6d34..f567eb7e0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityStandDown.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/cargohold/CAbilityStandDown.java @@ -39,18 +39,18 @@ public int getBaseOrderId() { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -74,7 +74,7 @@ public boolean isToggleOn() { } @Override - public boolean checkBeforeQueue(CSimulation game, CUnit caster, int orderId, AbilityTarget target) { + public boolean checkBeforeQueue(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget target) { CAbilityCargoHold cargoData = caster.getCargoData(); game.unitSoundEffectEvent(caster, cargoData.getAlias()); int goldWorkers = 0; @@ -114,6 +114,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityColdArrows.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityColdArrows.java index 85985a03c..82ed647eb 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityColdArrows.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityColdArrows.java @@ -34,8 +34,8 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.coldarrowstarg: receiver.targetOk(target); @@ -48,13 +48,13 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.coldarrows: case OrderIds.uncoldarrows: @@ -89,7 +89,7 @@ public void onTick(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { switch (orderId) { case OrderIds.coldarrows: case OrderIds.uncoldarrows: @@ -101,7 +101,7 @@ public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, fina } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { CBehavior behavior = null; for (final CUnitAttack attack : caster.getCurrentAttacks()) { if (target.canBeTargetedBy(game, caster, attack.getTargetsAllowed())) { @@ -118,12 +118,12 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -140,6 +140,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return true; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityInvulnerable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityInvulnerable.java index ba5737768..c5f736ce4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityInvulnerable.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/combat/CAbilityInvulnerable.java @@ -31,36 +31,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbilityGenericSingleIconPassiveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbilityGenericSingleIconPassiveAbility.java index 8ccf5a08d..caa94c0d0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbilityGenericSingleIconPassiveAbility.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbilityGenericSingleIconPassiveAbility.java @@ -28,20 +28,20 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @@ -64,23 +64,23 @@ public void onTick(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return false; } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -94,7 +94,12 @@ public void onDeath(final CSimulation game, final CUnit cUnit) { @Override public boolean isPhysical() { - return true; + return false; + } + + @Override + public boolean isMagic() { + return false; } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractCBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractCBuff.java index 0bac68c51..22a961550 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractCBuff.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractCBuff.java @@ -1,6 +1,8 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic; import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityCategory; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; @@ -15,6 +17,11 @@ public T visit(final CAbilityVisitor visitor) { return visitor.accept(this); } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isPhysical() { return false; @@ -29,5 +36,47 @@ public boolean isUniversal() { public CAbilityCategory getAbilityCategory() { return CAbilityCategory.BUFF; } + + @Override + public boolean isPositive() { + return true; + } + + @Override + public boolean isLeveled() { + return false; + } + + @Override + public boolean isDispellable() { + return false; + } + + @Override + public boolean isAura() { + return false; + } + + @Override + public boolean isHero() { + return false; + } + + @Override + public String getVisibilityGroup() { + return null; + } + + @Override + public CAbility getSourceAbility() { + // TODO Auto-generated method stub + return null; + } + + @Override + public CUnit getSourceUnit() { + // TODO Auto-generated method stub + return null; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericAliasedAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericAliasedAbility.java index 1072c4f6b..43a56a38f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericAliasedAbility.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericAliasedAbility.java @@ -17,7 +17,7 @@ public AbstractGenericAliasedAbility(final int handleId, final War3ID code, fina @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericNoIconAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericNoIconAbility.java index d87ea93ad..fa87cb522 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericNoIconAbility.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericNoIconAbility.java @@ -18,7 +18,12 @@ public T visit(final CAbilityVisitor visitor) { @Override public boolean isPhysical() { - return true; + return false; + } + + @Override + public boolean isMagic() { + return false; } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericSingleIconActiveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericSingleIconActiveAbility.java index 17372526b..d62c11c8a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericSingleIconActiveAbility.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/AbstractGenericSingleIconActiveAbility.java @@ -18,30 +18,30 @@ public AbstractGenericSingleIconActiveAbility(final int handleId, final War3ID c @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { final int autoCastOnOrderId = getAutoCastOnOrderId(); final int autoCastOffOrderId = getAutoCastOffOrderId(); if (orderId != 0) { if (orderId == autoCastOnOrderId) { - setAutoCastOn(caster, true); + setAutoCastOn(game, caster, true, true); return false; } else if (orderId == autoCastOffOrderId) { - setAutoCastOn(caster, false); + setAutoCastOn(game, caster, false, true); return false; } else { - return super.checkBeforeQueue(game, caster, orderId, target); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); } } else { - return super.checkBeforeQueue(game, caster, orderId, target); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); } } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { if (orderId == getBaseOrderId()) { innerCheckCanTarget(game, unit, orderId, target, receiver); } @@ -61,7 +61,7 @@ protected abstract void innerCheckCanSmartTarget(CSimulation game, CUnit unit, i @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { if (orderId == getBaseOrderId()) { innerCheckCanTarget(game, unit, orderId, target, receiver); } @@ -81,7 +81,7 @@ protected abstract void innerCheckCanSmartTarget(CSimulation game, CUnit unit, i @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { if ((orderId != 0) && ((orderId == getAutoCastOffOrderId()) || (orderId == getAutoCastOnOrderId()))) { receiver.targetOk(null); } @@ -146,7 +146,7 @@ public int getAutoCastOffOrderId() { return 0; } - public void setAutoCastOn(final CUnit unit, final boolean autoCastOn) { + public void setAutoCastOn(final CSimulation simulation, final CUnit unit, final boolean autoCastOn, final boolean notify) { } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CBuff.java index 5266e15c2..427ebf9bb 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CBuff.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CBuff.java @@ -2,6 +2,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; public interface CBuff extends CAliasedLevelingAbility { float getDurationRemaining(CSimulation game, CUnit unit); @@ -9,4 +10,25 @@ public interface CBuff extends CAliasedLevelingAbility { float getDurationMax(); boolean isTimedLifeBar(); + + boolean isLeveled(); + + boolean isPositive(); + + boolean isDispellable(); + + boolean isHero(); + + boolean isPhysical(); + + boolean isMagic(); + + boolean isAura(); + + String getVisibilityGroup(); + + CAbility getSourceAbility(); + + CUnit getSourceUnit(); + } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CDestructableBuff.java index 0ad330608..78d09615d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CDestructableBuff.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/generic/CDestructableBuff.java @@ -17,4 +17,18 @@ public interface CDestructableBuff extends CHandle, Aliased { int getLevel(); void setLevel(int level); + + boolean isDispellable(); + + boolean isTimedLife(); + + boolean isPositive(); + + boolean isHero(); + + boolean isMagic(); + + boolean isPhysical(); + + boolean isAura(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityAcolyteHarvest.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityAcolyteHarvest.java index 484713d41..58e1a9988 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityAcolyteHarvest.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityAcolyteHarvest.java @@ -42,18 +42,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorAcolyteHarvest.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -150,6 +150,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityHarvest.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityHarvest.java index 62cb766d4..9415dcc44 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityHarvest.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityHarvest.java @@ -86,18 +86,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorHarvest.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { if (isToggleOn() && (orderId == OrderIds.returnresources)) { return this.behaviorReturnResources.reset(game); } @@ -266,6 +266,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityReturnResources.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityReturnResources.java index 4e9840639..6e24b512a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityReturnResources.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityReturnResources.java @@ -47,36 +47,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @@ -110,6 +110,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityWispHarvest.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityWispHarvest.java index b98ee73d9..ccc11e412 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityWispHarvest.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/harvest/CAbilityWispHarvest.java @@ -53,18 +53,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorWispHarvest.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -172,6 +172,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/hero/CAbilityHero.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/hero/CAbilityHero.java index f6c52be7b..0c723aa96 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/hero/CAbilityHero.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/hero/CAbilityHero.java @@ -1,5 +1,6 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.hero; +import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -23,19 +24,22 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.data.CAbilityData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityActivationReceiver; public class CAbilityHero extends AbstractCAbility { private Set skillsAvailable; + private List learnedAbilities; private int xp; - private int heroLevel; + private int heroLevel = 0; private int skillPoints = 1; private HeroStatValue strength; private HeroStatValue agility; private HeroStatValue intelligence; + private int nameIndex; private String properName; private boolean awaitingRevive; private boolean reviving; @@ -43,33 +47,37 @@ public class CAbilityHero extends AbstractCAbility { public CAbilityHero(final int handleId, final List skillsAvailable) { super(handleId, War3ID.fromString("AHer")); this.skillsAvailable = new LinkedHashSet<>(skillsAvailable); + this.learnedAbilities = new ArrayList<>(); setPermanent(true); } @Override public void onAdd(final CSimulation game, final CUnit unit) { - this.heroLevel = 1; - this.xp = 0; - final CUnitType unitType = unit.getUnitType(); - this.strength = new HeroStatValue(unitType.getStartingStrength(), unitType.getStrengthPerLevel()); - this.agility = new HeroStatValue(unitType.getStartingAgility(), unitType.getAgilityPerLevel()); - this.intelligence = new HeroStatValue(unitType.getStartingIntelligence(), unitType.getIntelligencePerLevel()); - calculateDerivatedFields(game, unit); - - final int properNamesCount = unitType.getProperNamesCount(); - final int nameIndex = properNamesCount > 0 ? game.getSeededRandom().nextInt(properNamesCount) : 0; + if (this.heroLevel == 0) { + this.heroLevel = 1; + this.xp = 0; + final CUnitType unitType = unit.getUnitType(); + this.strength = new HeroStatValue(unitType.getStartingStrength(), unitType.getStrengthPerLevel()); + this.agility = new HeroStatValue(unitType.getStartingAgility(), unitType.getAgilityPerLevel()); + this.intelligence = new HeroStatValue(unitType.getStartingIntelligence(), + unitType.getIntelligencePerLevel()); + calculateDerivatedFields(game, unit); + + final int properNamesCount = unitType.getProperNamesCount(); + nameIndex = properNamesCount > 0 ? game.getSeededRandom().nextInt(properNamesCount) : 0; + + setHeroName(unitType); + } + } + public void setHeroName(CUnitType unitType) { String properName; final List heroProperNames = unitType.getHeroProperNames(); - if (heroProperNames.size() > 0) { - if (nameIndex < heroProperNames.size()) { - properName = heroProperNames.get(nameIndex); - } - else { - properName = heroProperNames.get(heroProperNames.size() - 1); - } - } - else { + int cnt = unitType.getProperNamesCount() > 0 ? Math.min(heroProperNames.size(), unitType.getProperNamesCount()) + : heroProperNames.size(); + if (heroProperNames.size() > 0 && cnt > 0) { + properName = heroProperNames.get(nameIndex % cnt); + } else { properName = WarsmashConstants.DEFAULT_STRING; } this.properName = properName; @@ -91,7 +99,7 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, + public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final AbilityTarget target) { final War3ID orderIdAsRawtype = new War3ID(orderId); learnSkill(game, caster, orderIdAsRawtype); @@ -106,62 +114,66 @@ private void learnSkill(final CSimulation game, final CUnit caster, final War3ID .getAbility(GetAbilityByRawcodeVisitor.getInstance().reset(skillId)); if (existingAbility == null) { final CAbility newAbility = abilityType.createAbility(game.getHandleIdAllocator().createId()); + newAbility.setHero(true); + this.learnedAbilities.add(newAbility); caster.add(game, newAbility); - } - else { + } else { abilityType.setLevel(game, caster, existingAbility, existingAbility.getLevel() + 1); } - } - else { + } else { game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: Ability is not yet programmed, unable to learn!"); } } + public List getLearnedHeroAbilities() { + return this.learnedAbilities; + } + public void selectHeroSkill(final CSimulation game, final CUnit caster, final War3ID skillId) { final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; - checkCanUse(game, caster, skillId.getValue(), activationReceiver); + checkCanUse(game, caster, skillId.getValue(), false, activationReceiver); if (activationReceiver.isOk()) { learnSkill(game, caster, skillId); } } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, + final CWidget target) { return null; } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override - public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, + public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, final AbilityTargetCheckReceiver receiver) { final War3ID orderIdAsRawtype = new War3ID(orderId); if (this.skillsAvailable.contains(orderIdAsRawtype)) { receiver.targetOk(null); - } - else { + } else { receiver.orderIdNotAccepted(); } } @@ -185,20 +197,16 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final if ((abilityType == null) || (priorLevel < abilityType.getLevelCount())) { if (this.heroLevel >= heroRequiredLevel) { receiver.useOk(); - } - else { + } else { receiver.missingHeroLevelRequirement(heroRequiredLevel); } - } - else { + } else { receiver.techtreeMaximumReached(); } - } - else { + } else { receiver.noHeroSkillPointsAvailable(); } - } - else { + } else { receiver.useOk(); } } @@ -291,8 +299,7 @@ public void setHeroLevel(final CSimulation simulation, final CUnit unit, final i (int) Math.ceil( (neededTotalXp - this.xp) / simulation.getPlayer(unit.getPlayerIndex()).getHandicapXP()), showEffect); - } - else { + } else { // remove xp TODO } } @@ -312,6 +319,21 @@ public void setIntelligenceBase(final CSimulation game, final CUnit unit, final calculateDerivatedFields(game, unit); } + public void setStrengthBuffBonus(final CSimulation game, final CUnit unit, final int strengthBuffBonus) { + this.strength.setBuffBonus(strengthBuffBonus); + calculateDerivatedFields(game, unit); + } + + public void setAgilityBuffBonus(final CSimulation game, final CUnit unit, final int agilityBuffBonus) { + this.agility.setBuffBonus(agilityBuffBonus); + calculateDerivatedFields(game, unit); + } + + public void setIntelligenceBuffBonus(final CSimulation game, final CUnit unit, final int intelligenceBuffBonus) { + this.intelligence.setBuffBonus(intelligenceBuffBonus); + calculateDerivatedFields(game, unit); + } + public void addStrengthBonus(final CSimulation game, final CUnit unit, final int strengthBonus) { this.strength.setBonus(this.strength.getBonus() + strengthBonus); calculateDerivatedFields(game, unit); @@ -354,7 +376,7 @@ private HeroStatValue getStat(final CPrimaryAttribute attribute) { } } - private void calculateDerivatedFields(final CSimulation game, final CUnit unit) { + public void calculateDerivatedFields(final CSimulation game, final CUnit unit) { final CGameplayConstants gameplayConstants = game.getGameplayConstants(); final int prevStrength = this.strength.getCurrent(); final int prevAgility = this.agility.getCurrent(); @@ -368,11 +390,11 @@ private void calculateDerivatedFields(final CSimulation game, final CUnit unit) final int deltaIntelligence = currentIntelligence - prevIntelligence; final int currentAgility = this.agility.getCurrent(); final int currentAgilityBase = this.agility.getCurrentBase(); - final int currentAgilityBonus = this.agility.getBonus(); + final int currentAgilityBonus = this.agility.getBonus() + this.agility.getBuffBonus(); final HeroStatValue primaryAttributeStat = getStat(unit.getUnitType().getPrimaryAttribute()); final int primaryAttributeBase = primaryAttributeStat.getCurrentBase(); - final int primaryAttributeBonus = primaryAttributeStat.getBonus(); + final int primaryAttributeBonus = primaryAttributeStat.getBonus() + primaryAttributeStat.getBuffBonus(); final float agiAttackSpeedBonus = gameplayConstants.getAgiAttackSpeedBonus() * currentAgility; for (final CUnitAttack attack : unit.getUnitSpecificAttacks()) { attack.setPrimaryAttributePermanentDamageBonus( @@ -415,11 +437,11 @@ public void recalculateAllStats(final CSimulation game, final CUnit unit) { final int currentIntelligence = this.intelligence.getCurrent(); final int currentAgility = this.agility.getCurrent(); final int currentAgilityBase = this.agility.getCurrentBase(); - final int currentAgilityBonus = this.agility.getBonus(); + final int currentAgilityBonus = this.agility.getBonus() + this.agility.getBuffBonus(); final HeroStatValue primaryAttributeStat = getStat(unit.getUnitType().getPrimaryAttribute()); final int primaryAttributeBase = primaryAttributeStat.getCurrentBase(); - final int primaryAttributeBonus = primaryAttributeStat.getBonus(); + final int primaryAttributeBonus = primaryAttributeStat.getBonus() + primaryAttributeStat.getBuffBonus(); final float agiAttackSpeedBonus = gameplayConstants.getAgiAttackSpeedBonus() * currentAgility; for (final CUnitAttack attack : unit.getUnitSpecificAttacks()) { attack.setPrimaryAttributePermanentDamageBonus( @@ -457,6 +479,7 @@ public static final class HeroStatValue { private final float perLevelFactor; private int base; private int bonus; + private int buffbonus = 0; private int currentBase; private int current; @@ -467,7 +490,7 @@ private HeroStatValue(final int base, final float perLevelFactor) { public void calculate(final int level) { this.currentBase = this.base + (int) ((level - 1) * this.perLevelFactor); - this.current = this.currentBase + this.bonus; + this.current = this.currentBase + (this.bonus + this.buffbonus); } public void setBase(final int base) { @@ -478,6 +501,10 @@ public void setBonus(final int bonus) { this.bonus = bonus; } + public void setBuffBonus(final int buffbonus) { + this.buffbonus = buffbonus; + } + public int getBase() { return this.base; } @@ -490,18 +517,21 @@ public int getBonus() { return this.bonus; } + public int getBuffBonus() { + return this.buffbonus; + } + public int getCurrent() { return this.current; } public String getDisplayText() { String text = Integer.toString(this.currentBase); - if (this.bonus != 0) { - if (this.bonus > 0) { - text += "|cFF00FF00 +" + this.bonus + ""; - } - else { - text += "|cFFFF0000 " + this.bonus + ""; + if ((this.bonus + this.buffbonus) != 0) { + if ((this.bonus + this.buffbonus) > 0) { + text += "|cFF00FF00 +" + (this.bonus + this.buffbonus) + ""; + } else { + text += "|cFFFF0000 " + (this.bonus + this.buffbonus) + ""; } } return text; @@ -525,6 +555,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/inventory/CAbilityInventory.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/inventory/CAbilityInventory.java index 2b4784134..18c13522d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/inventory/CAbilityInventory.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/inventory/CAbilityInventory.java @@ -28,8 +28,10 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityActivationReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.ExternStringMsgAbilityActivationReceiver; public class CAbilityInventory extends AbstractGenericNoIconAbility { private final boolean canDropItems; @@ -79,7 +81,7 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, + public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final AbilityTarget target) { if ((orderId >= OrderIds.itemdrag00) && (orderId <= OrderIds.itemdrag05)) { for (int i = 0; i < this.itemsHeld.length; i++) { @@ -94,8 +96,7 @@ public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, fina return false; } } - } - else if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { + } else if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { final int slot = orderId - OrderIds.itemuse00; final List itemsHeldAbilitiesForSlot = this.itemsHeldAbilities[slot]; if (!itemsHeldAbilitiesForSlot.isEmpty()) { @@ -104,7 +105,7 @@ else if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { if (cAbility instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) cAbility).getBaseOrderId(); } - final boolean checkResult = cAbility.checkBeforeQueue(game, caster, forwardedOrderId, target); + final boolean checkResult = cAbility.checkBeforeQueue(game, caster, forwardedOrderId, false, target); if (!checkResult) { // we will never call begin, so we need to consume a charge of perishables here // assuming this is a no-queue instant use perishable... later if we have some @@ -119,7 +120,7 @@ else if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { return checkResult; } } - return super.checkBeforeQueue(game, caster, orderId, target); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); } private void consumePerishableCharge(final CSimulation game, final CUnit caster, final int slot, @@ -157,7 +158,8 @@ public boolean isDropItemsOnDeath() { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, + final CWidget target) { if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { final int slot = orderId - OrderIds.itemuse00; final List itemsHeldAbilitiesForSlot = this.itemsHeldAbilities[slot]; @@ -167,7 +169,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord if (ability instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) ability).getBaseOrderId(); } - final CBehavior behavior = ability.begin(game, caster, forwardedOrderId, target); + final CBehavior behavior = ability.begin(game, caster, forwardedOrderId, false, target); final CItem cItem = this.itemsHeld[slot]; consumePerishableCharge(game, caster, slot, cItem); return behavior; @@ -191,7 +193,7 @@ public CBehavior beginDropItem(final CSimulation game, final CUnit caster, final } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final AbilityPointTarget point) { if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { final int slot = orderId - OrderIds.itemuse00; @@ -202,7 +204,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord if (ability instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) ability).getBaseOrderId(); } - final CBehavior behavior = ability.begin(game, caster, forwardedOrderId, point); + final CBehavior behavior = ability.begin(game, caster, forwardedOrderId, false, point); final CItem cItem = this.itemsHeld[slot]; consumePerishableCharge(game, caster, slot, cItem); return behavior; @@ -212,7 +214,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { final int slot = orderId - OrderIds.itemuse00; final List itemsHeldAbilitiesForSlot = this.itemsHeldAbilities[slot]; @@ -222,7 +224,7 @@ public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final if (ability instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) ability).getBaseOrderId(); } - final CBehavior behavior = ability.beginNoTarget(game, caster, forwardedOrderId); + final CBehavior behavior = ability.beginNoTarget(game, caster, forwardedOrderId, false); final CItem cItem = this.itemsHeld[slot]; consumePerishableCharge(game, caster, slot, cItem); return behavior; @@ -232,65 +234,54 @@ public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { if (((orderId == OrderIds.getitem) || (orderId == OrderIds.smart)) && !target.isDead()) { if (target instanceof CItem) { if (this.canGetItems) { final CItem targetItem = (CItem) target; if (!targetItem.isHidden()) { receiver.targetOk(target); - } - else { + } else { receiver.orderIdNotAccepted(); } } else { receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_PICK_UP_THIS_ITEM); } - } - else { + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { if ((orderId >= OrderIds.itemdrag00) && (orderId <= OrderIds.itemdrag05)) { if (target instanceof CItem) { final int slot = getSlot((CItem) target); if (slot != -1) { receiver.targetOk(target); - } - else { + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { receiver.orderIdNotAccepted(); } - } - else if (orderId == OrderIds.dropitem) { + } else if (orderId == OrderIds.dropitem) { if (target instanceof CUnit) { final CUnit hero = (CUnit) target; if (game.getPlayer(hero.getPlayerIndex()).hasAlliance(unit.getPlayerIndex(), CAllianceType.PASSIVE) && (hero != unit)) { if (hero.getInventoryData() != null) { receiver.targetOk(target); - } - else if (hero.getFirstAbilityOfType(CAbilityShopPurhaseItem.class) != null) { + } else if (hero.getFirstAbilityOfType(CAbilityShopPurhaseItem.class) != null) { receiver.targetOk(target); - } - else { + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { final int slot = orderId - OrderIds.itemuse00; final List itemsHeldAbilitiesForSlot = this.itemsHeldAbilities[slot]; @@ -300,13 +291,11 @@ else if (hero.getFirstAbilityOfType(CAbilityShopPurhaseItem.class) != null) { if (ability instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) ability).getBaseOrderId(); } - ability.checkCanTarget(game, unit, forwardedOrderId, target, receiver); - } - else { + ability.checkCanTarget(game, unit, forwardedOrderId, false, target, receiver); + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { receiver.orderIdNotAccepted(); } } @@ -324,7 +313,7 @@ public int getSlot(final CItem target) { } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { if (orderId != OrderIds.dropitem) { if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { @@ -336,23 +325,20 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o if (ability instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) ability).getBaseOrderId(); } - ability.checkCanTarget(game, unit, forwardedOrderId, target, receiver); - } - else { + ability.checkCanTarget(game, unit, forwardedOrderId, false, target, receiver); + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { receiver.targetOk(target); } } @Override - public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, + public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, final AbilityTargetCheckReceiver receiver) { if ((orderId >= OrderIds.itemuse00) && (orderId <= OrderIds.itemuse05)) { final int slot = orderId - OrderIds.itemuse00; @@ -363,13 +349,11 @@ public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, fin if (ability instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) ability).getBaseOrderId(); } - ability.checkCanTargetNoTarget(game, unit, forwardedOrderId, receiver); - } - else { + ability.checkCanTargetNoTarget(game, unit, forwardedOrderId, false, receiver); + } else { receiver.orderIdNotAccepted(); } - } - else { + } else { receiver.orderIdNotAccepted(); } } @@ -382,8 +366,7 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final final int slot = orderId - OrderIds.itemuse00; if (this.itemsHeldAbilities[slot].size() < 1) { receiver.notAnActiveAbility(); - } - else { + } else { final List itemsHeldAbilitiesForSlot = this.itemsHeldAbilities[slot]; if (!itemsHeldAbilitiesForSlot.isEmpty()) { final CAbility ability = itemsHeldAbilitiesForSlot.get(0); @@ -391,18 +374,15 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final if (ability instanceof SingleOrderAbility) { forwardedOrderId = ((SingleOrderAbility) ability).getBaseOrderId(); } - ability.checkCanUse(game, unit, forwardedOrderId, receiver); - } - else { + ability.checkCanUse(game, unit, forwardedOrderId, false, receiver); + } else { receiver.notAnActiveAbility(); } } - } - else { + } else { receiver.activationCheckFailed(CommandStringErrorKeys.UNABLE_TO_USE_THIS_ITEM); } - } - else if(orderId == OrderIds.dropitem && !this.canDropItems) { + } else if (orderId == OrderIds.dropitem && !this.canDropItems) { receiver.activationCheckFailed(CommandStringErrorKeys.UNABLE_TO_DROP_THIS_ITEM); } else { receiver.useOk(); @@ -427,7 +407,7 @@ public int giveItem(final CSimulation simulation, final CUnit hero, final CItem final CItemType itemType = item.getItemType(); if (this.canUseItems && itemType.isUseAutomaticallyWhenAcquired()) { if (itemType.isActivelyUsed()) { - item.setLife(simulation, 0); + // TODO when we give unit ability here, then use ability final List addedAbilities = new ArrayList<>(); for (final War3ID abilityId : item.getItemType().getAbilityList()) { @@ -441,24 +421,39 @@ public int giveItem(final CSimulation simulation, final CUnit hero, final CItem if (abilityFromItem instanceof SingleOrderAbility) { final int baseOrderId = ((SingleOrderAbility) abilityFromItem).getBaseOrderId(); - final BooleanAbilityTargetCheckReceiver booleanUnitTargetReceiver = BooleanAbilityTargetCheckReceiver - .getInstance().reset(); - abilityFromItem.checkCanTarget(simulation, hero, baseOrderId, hero, booleanUnitTargetReceiver); - if (booleanUnitTargetReceiver.isTargetable()) { - hero.order(simulation, - new COrderTargetWidget(abilityFromItem.getHandleId(), baseOrderId, hero.getHandleId(), false), false); - - } else { - final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver - .getInstance().reset(); - AbilityPointTarget tar = new AbilityPointTarget(hero.getX(), hero.getY()); - abilityFromItem.checkCanTarget(simulation, hero, baseOrderId, tar, booleanTargetReceiver); - - if (booleanTargetReceiver.isTargetable()) {hero.order(simulation, - new COrderTargetPoint(abilityFromItem.getHandleId(), baseOrderId, tar, false), false); + ExternStringMsgAbilityActivationReceiver act = ExternStringMsgAbilityActivationReceiver.INSTANCE; + act.reset(); + abilityFromItem.checkCanUse(simulation, hero, baseOrderId, false, act); + if (act.isUseOk()) { + item.setLife(simulation, 0); + final BooleanAbilityTargetCheckReceiver booleanUnitTargetReceiver = BooleanAbilityTargetCheckReceiver + .getInstance().reset(); + abilityFromItem.checkCanTarget(simulation, hero, baseOrderId, false, hero, + booleanUnitTargetReceiver); + if (booleanUnitTargetReceiver.isTargetable()) { + hero.order(simulation, new COrderTargetWidget(abilityFromItem.getHandleId(), + baseOrderId, hero.getHandleId(), false), false); + } else { - hero.order(simulation, - new COrderNoTarget(abilityFromItem.getHandleId(), baseOrderId, false), false); + final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver + .getInstance().reset(); + AbilityPointTarget tar = new AbilityPointTarget(hero.getX(), hero.getY()); + abilityFromItem.checkCanTarget(simulation, hero, baseOrderId, false, tar, + booleanTargetReceiver); + + if (booleanTargetReceiver.isTargetable()) { + hero.order(simulation, new COrderTargetPoint(abilityFromItem.getHandleId(), + baseOrderId, tar, false), false); + } else { + hero.order(simulation, new COrderNoTarget(abilityFromItem.getHandleId(), + baseOrderId, false), false); + } + } + } + else { + final String externStringKey = act.getExternStringKey(); + if ((externStringKey != null) && !externStringKey.isEmpty()) { + simulation.getCommandErrorListener().showInterfaceError(hero.getPlayerIndex(), externStringKey); } } } @@ -470,8 +465,7 @@ public int giveItem(final CSimulation simulation, final CUnit hero, final CItem hero.remove(simulation, ability); } } - } - else { + } else { for (int i = 0; i < this.itemsHeld.length; i++) { final int itemIndex = (i + slotPreference) % this.itemsHeld.length; if (this.itemsHeld[itemIndex] == null) { @@ -497,7 +491,8 @@ public int giveItem(final CSimulation simulation, final CUnit hero, final CItem } } if (playUserUISounds) { - simulation.getCommandErrorListener().showInterfaceError(hero.getPlayerIndex(), CommandStringErrorKeys.INVENTORY_IS_FULL); + simulation.getCommandErrorListener().showInterfaceError(hero.getPlayerIndex(), + CommandStringErrorKeys.INVENTORY_IS_FULL); } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemAttackBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemAttackBonus.java index 0d87af79d..2b2fa9c12 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemAttackBonus.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemAttackBonus.java @@ -38,36 +38,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemChestOfGold.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemChestOfGold.java index 05902a178..bdddc0fbd 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemChestOfGold.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemChestOfGold.java @@ -34,7 +34,7 @@ public void onAdd(final CSimulation game, final CUnit unit) { } @Override - public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, final AbilityTarget target) { + public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, final boolean autoCast, final AbilityTarget target) { if (orderId == OrderIds.itemgivegold) { final CPlayer player = game.getPlayer(caster.getPlayerIndex()); game.createTemporarySpellEffectOnUnit(caster, getAlias(), CEffectType.CASTER); @@ -62,18 +62,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final boolean autoCast, final CWidget target) { return null; } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final boolean autoCast, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, final boolean autoCast) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemDefenseBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemDefenseBonus.java index 4460df539..da4164b45 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemDefenseBonus.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemDefenseBonus.java @@ -33,36 +33,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemExperienceGain.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemExperienceGain.java index e355e9726..616ae80b7 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemExperienceGain.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemExperienceGain.java @@ -34,7 +34,7 @@ public void onAdd(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { if (orderId == OrderIds.itemxpgain) { final CAbilityHero heroData = caster.getHeroData(); heroData.addXp(game, caster, this.xpToGain, true); @@ -60,18 +60,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemHeal.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemHeal.java index 2f824baa0..bbc57ff4f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemHeal.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemHeal.java @@ -100,29 +100,29 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { if ((target == null) && (orderId == getBaseOrderId())) { caster.heal(game, this.lifeToRegain); game.createTemporarySpellEffectOnUnit(caster, getAlias(), CEffectType.TARGET); caster.beginCooldown(game, CODE, cooldown); return false; } - return super.checkBeforeQueue(game, caster, orderId, target); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -131,6 +131,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLevelGain.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLevelGain.java index c5a2bd41e..802186090 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLevelGain.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLevelGain.java @@ -34,7 +34,7 @@ public void onAdd(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { if (orderId == getBaseOrderId()) { final CAbilityHero heroData = caster.getHeroData(); heroData.setHeroLevel(game, caster, heroData.getHeroLevel() + levelsToGain, true); @@ -60,18 +60,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLifeBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLifeBonus.java index 953f13d31..49735a0e1 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLifeBonus.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemLifeBonus.java @@ -38,36 +38,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaBonus.java index 16e9b7e63..f730a647d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaBonus.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaBonus.java @@ -46,18 +46,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaRegain.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaRegain.java index 8a8cc734a..ad52d8a0a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaRegain.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemManaRegain.java @@ -101,29 +101,29 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { if ((target == null) && (orderId == getBaseOrderId())) { caster.restoreMana(game, this.manaToRegain); game.createTemporarySpellEffectOnUnit(caster, getAlias(), CEffectType.CASTER); caster.beginCooldown(game, CODE, cooldown); return false; } - return super.checkBeforeQueue(game, caster, orderId, target); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -132,6 +132,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentLifeGain.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentLifeGain.java index d8fb908a0..1514361f8 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentLifeGain.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentLifeGain.java @@ -33,7 +33,7 @@ public void onAdd(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { if (orderId == getBaseOrderId()) { final float life = caster.getLife(); final int maximumLife = caster.getMaximumLife(); @@ -61,18 +61,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentStatGain.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentStatGain.java index 195c3204a..7e3a5fee9 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentStatGain.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemPermanentStatGain.java @@ -33,7 +33,7 @@ public void onAdd(final CSimulation game, final CUnit unit) { } @Override - public boolean checkBeforeQueue(CSimulation game, CUnit caster, int orderId, AbilityTarget target) { + public boolean checkBeforeQueue(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget target) { if (orderId == OrderIds.itemstatgain) { final CAbilityHero heroData = caster.getHeroData(); heroData.addStrengthBase(game, caster, this.strength); @@ -56,36 +56,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { if (orderId == OrderIds.itemstatgain) { receiver.targetOk(null); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemStatBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemStatBonus.java index ba16fec47..eed8412d0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemStatBonus.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/CAbilityItemStatBonus.java @@ -45,36 +45,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityNeutralBuilding.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityNeutralBuilding.java index 4116ade2e..041bf9fa6 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityNeutralBuilding.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityNeutralBuilding.java @@ -153,7 +153,7 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); if (showSelectUnitButton && (orderId == OrderIds.neutralinteract) && canSelectUnit(game, caster, targetUnit)) { final int playerIndex = targetUnit.getPlayerIndex(); @@ -165,20 +165,20 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { // TODO Auto-generated method stub return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { // TODO Auto-generated method stub return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { if (showSelectUnitButton && (orderId == OrderIds.neutralinteract) && canSelectUnit(game, unit, target.visit(AbilityTargetVisitor.UNIT))) { receiver.targetOk(target); @@ -190,13 +190,13 @@ && canSelectUnit(game, unit, target.visit(AbilityTargetVisitor.UNIT))) { @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @@ -260,6 +260,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilitySellItems.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilitySellItems.java index 30edd5d3c..ce49bdd7f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilitySellItems.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilitySellItems.java @@ -66,20 +66,20 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { final int playerIndex = orderId & 0xFF; // TODO this is stupid, and should be passed as some "acting player" arg final int itemIndex = ((orderId & 0xFF00) >> 8) - 1; if ((itemIndex >= 0) && (itemIndex < this.itemsSold.size())) { @@ -92,7 +92,7 @@ public final void checkCanTargetNoTarget(final CSimulation game, final CUnit uni @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } @@ -111,18 +111,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { final int playerIndex = orderId & 0xFF; // TODO this is stupid, and should be passed as some "acting player" arg final int itemIndex = ((orderId & 0xFF00) >> 8) - 1; final CAbilityNeutralBuilding neutralBuildingData = caster.getNeutralBuildingData(); @@ -174,6 +174,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityShopPurhaseItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityShopPurhaseItem.java index 4558596ef..380193f0e 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityShopPurhaseItem.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/item/shop/CAbilityShopPurhaseItem.java @@ -29,36 +29,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CAbilityJass.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CAbilityJass.java index df570fb68..f6303e045 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CAbilityJass.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CAbilityJass.java @@ -122,7 +122,7 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { for (final CAbilityOrderButtonJass orderButton : this.orderButtons) { if ((orderButton.getType() == JassOrderButtonType.UNIT_TARGET) || (orderButton.getType() == JassOrderButtonType.UNIT_OR_POINT_TARGET)) { @@ -137,7 +137,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { for (final CAbilityOrderButtonJass orderButton : this.orderButtons) { if ((orderButton.getType() == JassOrderButtonType.POINT_TARGET) || (orderButton.getType() == JassOrderButtonType.UNIT_OR_POINT_TARGET)) { @@ -151,7 +151,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { for (final CAbilityOrderButtonJass orderButton : this.orderButtons) { if ((orderButton.getType() == JassOrderButtonType.INSTANT_NO_TARGET) || (orderButton.getType() == JassOrderButtonType.INSTANT_NO_TARGET_NO_INTERRUPT)) { @@ -165,8 +165,8 @@ public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { final RecordingAbilityTargetCheckReceiver delegateReceiver = RecordingAbilityTargetCheckReceiver .getInstance(); String errorMessage = null; @@ -195,7 +195,7 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { final RecordingAbilityTargetCheckReceiver delegateReceiver = RecordingAbilityTargetCheckReceiver .getInstance(); String errorMessage = null; @@ -225,7 +225,7 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { final RecordingAbilityTargetCheckReceiver delegateReceiver = RecordingAbilityTargetCheckReceiver .getInstance(); String errorMessage = null; @@ -286,7 +286,7 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { for (final CAbilityOrderButtonJass orderButton : this.orderButtons) { if (orderButton.getType() == JassOrderButtonType.INSTANT_NO_TARGET_NO_INTERRUPT) { if (orderButton.getOrderId() == orderId) { @@ -325,6 +325,11 @@ public boolean isPhysical() { return this.physical; } + @Override + public boolean isMagic() { + return true; + } + @Override public boolean isUniversal() { return this.universal; @@ -420,7 +425,7 @@ public void onSetUnitType(final CSimulation game, final CUnit unit) { } @Override - protected void onSetDisabled(final boolean disabled, final CAbilityDisableType type) { + protected void onSetDisabled(final boolean disabled, final boolean wasDisabled, final CAbilityDisableType type) { final List arguments = new ArrayList<>(); final StructJassValue structValue = getStructValue(); arguments.add(structValue); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CBuffJass.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CBuffJass.java index ffb095d03..40954c28d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CBuffJass.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/jass/CBuffJass.java @@ -19,6 +19,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractCBuff; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; @@ -140,36 +141,36 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @@ -179,4 +180,16 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final receiver.notAnActiveAbility(); } + @Override + public CAbility getSourceAbility() { + // TODO Auto-generated method stub + return null; + } + + @Override + public CUnit getSourceUnit() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityBlightedGoldMine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityBlightedGoldMine.java index f644a5075..45de6222d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityBlightedGoldMine.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityBlightedGoldMine.java @@ -121,36 +121,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityEntangledMine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityEntangledMine.java index 96c698270..4f083fb9f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityEntangledMine.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityEntangledMine.java @@ -70,36 +70,36 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityGoldMine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityGoldMine.java index eb62c2559..2f847f3dd 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityGoldMine.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityGoldMine.java @@ -80,36 +80,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityOverlayedMinableMine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityOverlayedMinableMine.java index dbdb181e8..19b58450b 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityOverlayedMinableMine.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/mine/CAbilityOverlayedMinableMine.java @@ -78,36 +78,36 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/neutral/CAbilityWayGate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/neutral/CAbilityWayGate.java index 68d4b51de..44a026e7c 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/neutral/CAbilityWayGate.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/neutral/CAbilityWayGate.java @@ -72,7 +72,7 @@ public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) { } @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { final CUnit unitTarget = target.visit(AbilityTargetVisitor.UNIT); if (unitTarget != null) { if (!unitTarget.isMovementDisabled()) { @@ -93,18 +93,18 @@ public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget targ } @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(CSimulation game, CUnit caster, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder, + CWidget target, AbilityTargetCheckReceiver receiver) { if (orderId == ORDER_ID) { final CUnit unitTarget = target.visit(AbilityTargetVisitor.UNIT); if (unitTarget != null) { @@ -137,14 +137,14 @@ public void checkCanTarget(CSimulation game, CUnit caster, int orderId, CWidget } @Override - public void checkCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, + AbilityPointTarget target, AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { + boolean autoOrder, AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @@ -153,6 +153,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return true; @@ -205,14 +210,14 @@ public static CAbilityWayGate getWayGateAbility(final CSimulation game, final CU if (potentialLoadAbility instanceof CAbilityWayGate) { final CAbilityWayGate abilityLoad = (CAbilityWayGate) potentialLoadAbility; final BooleanAbilityActivationReceiver transportUnitReceiver = BooleanAbilityActivationReceiver.INSTANCE; - abilityLoad.checkCanUse(game, transport, ORDER_ID, transportUnitReceiver); + abilityLoad.checkCanUse(game, transport, ORDER_ID, false, transportUnitReceiver); // NOTE: disabled load ability should enable later in case of under construction // entangled gold mine if (transportUnitReceiver.isOk() || (ignoreDisabled && abilityLoad.isDisabled())) { final ExternStringMsgTargetCheckReceiver transportUnitTargetCheckReceiver = ExternStringMsgTargetCheckReceiver .getInstance(); - abilityLoad.checkCanTarget(game, transport, ORDER_ID, caster, - transportUnitTargetCheckReceiver.reset()); + abilityLoad.checkCanTarget(game, transport, ORDER_ID, false, + caster, transportUnitTargetCheckReceiver.reset()); if ((transportUnitTargetCheckReceiver.getTarget() != null) || (ignoreRange && (transportUnitTargetCheckReceiver .getExternStringKey() == CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE))) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/eattree/CAbilityEatTree.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/eattree/CAbilityEatTree.java index d8b050c9e..5fa9f1405 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/eattree/CAbilityEatTree.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/eattree/CAbilityEatTree.java @@ -59,13 +59,13 @@ public void onAdd(final CSimulation game, final CUnit unit) { } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { if (orderId == OrderIds.smart) { - super.checkCanTarget(game, unit, getBaseOrderId(), target, receiver); + super.checkCanTarget(game, unit, getBaseOrderId(), autoOrder, target, receiver); } else { - super.checkCanTarget(game, unit, orderId, target, receiver); + super.checkCanTarget(game, unit, orderId, autoOrder, target, receiver); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/moonwell/CAbilityMoonWell.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/moonwell/CAbilityMoonWell.java index 62efabdb1..83f44ecc2 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/moonwell/CAbilityMoonWell.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/moonwell/CAbilityMoonWell.java @@ -136,7 +136,7 @@ public boolean call(final CUnit enumUnit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { final CUnit unitTarget = target.visit(AbilityTargetVisitor.UNIT); if (unitTarget != null) { final float life = unitTarget.getLife(); @@ -169,12 +169,12 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -230,9 +230,11 @@ public boolean isAutoCastOn() { } @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { + public void setAutoCastOn(final CSimulation simulation, final CUnit caster, final boolean autoCastOn, final boolean notify) { this.autoCastActive = autoCastOn; - caster.setAutocastAbility(autoCastOn ? this : null); + if (notify) { + caster.setAutocastAbility(simulation, autoCastOn ? this : null); + } } @Override @@ -250,15 +252,10 @@ public int getAutoCastOffOrderId() { return OrderIds.replenishoff; } - @Override - public void setAutoCastOff() { - this.autoCastActive = false; - } - @Override public void checkCanAutoTarget(CSimulation game, CUnit unit, int orderId, CWidget target, AbilityTargetCheckReceiver receiver) { - this.checkCanTarget(game, unit, orderId, target, receiver); + this.checkCanTarget(game, unit, orderId, false, target, receiver); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityEntangleGoldMine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityEntangleGoldMine.java index bf70e5148..557fa509b 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityEntangleGoldMine.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityEntangleGoldMine.java @@ -75,12 +75,12 @@ public void populateData(final GameObject worldEditorAbility, final int level) { } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { if (orderId == OrderIds.entangleinstant) { orderId = getBaseOrderId(); } - super.checkCanTarget(game, unit, orderId, target, receiver); + super.checkCanTarget(game, unit, orderId, autoOrder, target, receiver); } @Override @@ -112,9 +112,9 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { instant = orderId == OrderIds.entangleinstant; - return super.begin(game, caster, orderId, target); + return super.begin(game, caster, orderId, autoOrder, target); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityRoot.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityRoot.java index 0bea536de..22680391c 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityRoot.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/nightelf/root/CAbilityRoot.java @@ -164,13 +164,13 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { if (!this.rooted && (orderId == OrderIds.root)) { return this.behaviorRoot.reset(game, point); } @@ -178,7 +178,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { if (this.rooted && (orderId == OrderIds.unroot)) { return this.behaviorUproot.reset(); } @@ -332,6 +332,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityQueue.java index 9ecbe67a0..f89163e50 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityQueue.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityQueue.java @@ -173,20 +173,20 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { if (this.unitsTrained.contains(new War3ID(orderId)) || this.researchesAvailable.contains(new War3ID(orderId))) { receiver.targetOk(null); } @@ -200,7 +200,7 @@ else if (orderId == OrderIds.cancel) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } @@ -219,18 +219,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { if (orderId == OrderIds.cancel) { caster.cancelBuildQueueItem(game, 0); } @@ -278,6 +278,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityRally.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityRally.java index ecf703f34..29c414361 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityRally.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityRally.java @@ -42,8 +42,8 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.smart: case OrderIds.setrally: @@ -57,7 +57,7 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { switch (orderId) { case OrderIds.smart: case OrderIds.setrally: @@ -71,31 +71,31 @@ public void checkCanTarget(final CSimulation game, final CUnit unit, final int o @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { caster.setRallyPoint(target); return caster.pollNextOrderBehavior(game); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { caster.setRallyPoint(point); return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -130,6 +130,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return true; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityReviveHero.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityReviveHero.java index b981d2273..a260be327 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityReviveHero.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/queue/CAbilityReviveHero.java @@ -63,20 +63,20 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { final CUnit deadHero = game.getUnit(orderId); if ((deadHero != null) && (deadHero.getPlayerIndex() == unit.getPlayerIndex())) { receiver.targetOk(null); @@ -91,7 +91,7 @@ else if (orderId == OrderIds.cancel) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } @@ -110,18 +110,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { if (orderId == OrderIds.cancel) { caster.cancelBuildQueueItem(game, 0); } @@ -153,6 +153,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityNoTargetSpellBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityNoTargetSpellBase.java index 2e3d2f81a..4325165da 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityNoTargetSpellBase.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityNoTargetSpellBase.java @@ -22,18 +22,18 @@ public void onAdd(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return this.behavior.reset(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityPointTargetSpellBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityPointTargetSpellBase.java index 5100bc498..73aed3a1f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityPointTargetSpellBase.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityPointTargetSpellBase.java @@ -23,18 +23,18 @@ public void onAdd(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return this.behavior.reset(game, point); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilitySpellBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilitySpellBase.java index f9ba0e26c..b0773f3ed 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilitySpellBase.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilitySpellBase.java @@ -18,11 +18,13 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; public abstract class CAbilitySpellBase extends AbstractGenericSingleIconNoSmartActiveAbility implements CAbilitySpell { + protected static CSpellDamageFlags DAMAGE_FLAGS = new CSpellDamageFlags(); private int manaCost; private float castRange; private float cooldown; @@ -230,6 +232,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return true; + } + @Override public CAbilityCategory getAbilityCategory() { return CAbilityCategory.SPELL; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityTargetSpellBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityTargetSpellBase.java index 8a8811cf1..87b69a655 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityTargetSpellBase.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityTargetSpellBase.java @@ -23,18 +23,18 @@ public void onAdd(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behavior.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityUnitOrPointTargetSpellBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityUnitOrPointTargetSpellBase.java index f58ca84fa..c7e3067cf 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityUnitOrPointTargetSpellBase.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/CAbilityUnitOrPointTargetSpellBase.java @@ -24,18 +24,18 @@ public void onAdd(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behavior.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return this.behavior.reset(game, point); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/archmage/CAbilityBlizzard.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/archmage/CAbilityBlizzard.java index bb0c47ed6..f9220aad1 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/archmage/CAbilityBlizzard.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/archmage/CAbilityBlizzard.java @@ -16,6 +16,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; @@ -106,7 +107,7 @@ public boolean call(final CUnit possibleTarget) { else { thisTargetDamage = damagePerTarget; } - damageTarget.damage(simulation, caster, false, true, CAttackType.SPELLS, CDamageType.COLD, + damageTarget.damage(simulation, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.COLD, CWeaponSoundTypeJass.WHOKNOWS.name(), thisTargetDamage); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/bloodmage/phoenix/CAbilityPhoenixFire.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/bloodmage/phoenix/CAbilityPhoenixFire.java index 358782532..a053a540f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/bloodmage/phoenix/CAbilityPhoenixFire.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/bloodmage/phoenix/CAbilityPhoenixFire.java @@ -78,36 +78,36 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderBolt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderBolt.java index 10ed80cf9..7a7b276f7 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderBolt.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderBolt.java @@ -58,7 +58,7 @@ public void onLaunch(final CSimulation game, CProjectile projectile, final Abili public void onHit(final CSimulation game, CProjectile projectile, final AbilityTarget target) { final CUnit unitTarget = target.visit(AbilityTargetUnitVisitor.INSTANCE); if (unitTarget != null) { - unitTarget.damage(game, caster, false, true, CAttackType.SPELLS, CDamageType.LIGHTNING, + unitTarget.damage(game, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.LIGHTNING, CWeaponSoundTypeJass.WHOKNOWS.name(), damage); if (!unitTarget.isDead()) { unitTarget.add(game, new CBuffStun(game.getHandleIdAllocator().createId(), diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderClap.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderClap.java index f8bce7a54..fe55a7098 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderClap.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/mountainking/CAbilityThunderClap.java @@ -50,7 +50,7 @@ public boolean doEffect(final CSimulation simulation, final CUnit caster, final new CBuffSlow(simulation.getHandleIdAllocator().createId(), CAbilityThunderClap.this.buffId, getDurationForTarget(enumUnit), attackSpeedReductionPercent, movementSpeedReductionPercent)); - enumUnit.damage(simulation, caster, false, true, CAttackType.SPELLS, CDamageType.UNIVERSAL, + enumUnit.damage(simulation, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.UNIVERSAL, CWeaponSoundTypeJass.WHOKNOWS.name(), CAbilityThunderClap.this.damage); } return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/paladin/CAbilityHolyLight.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/paladin/CAbilityHolyLight.java index ddde3e4e9..d264c4fc1 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/paladin/CAbilityHolyLight.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/human/paladin/CAbilityHolyLight.java @@ -11,6 +11,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; @@ -65,7 +66,7 @@ public boolean doEffect(final CSimulation simulation, final CUnit caster, final final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); if (targetUnit != null) { if (targetUnit.getClassifications().contains(CUnitClassification.UNDEAD)) { - targetUnit.damage(simulation, caster, false, true, CAttackType.SPELLS, CDamageType.DIVINE, null, healAmount * 0.5f); + targetUnit.damage(simulation, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.DIVINE, null, healAmount * 0.5f); } else { targetUnit.heal(simulation, healAmount); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/sappers/CAbilityKaboom.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/sappers/CAbilityKaboom.java index 7680079ac..ba55a1a8e 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/sappers/CAbilityKaboom.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/sappers/CAbilityKaboom.java @@ -12,6 +12,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; @@ -101,7 +102,7 @@ private void explode(final CSimulation simulation, final CUnit caster) { if (enumUnit.isBuilding()) { damageAmount *= buildingDamageFactor; } - enumUnit.damage(simulation, caster, false, true, CAttackType.SPELLS, CDamageType.DEMOLITION, + enumUnit.damage(simulation, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.DEMOLITION, CWeaponSoundTypeJass.WHOKNOWS.name(), damageAmount); } return false; @@ -109,9 +110,11 @@ private void explode(final CSimulation simulation, final CUnit caster) { } @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { + public void setAutoCastOn(final CSimulation simulation, final CUnit caster, final boolean autoCastOn, final boolean notify) { this.autoCastOn = autoCastOn; - caster.setAutocastAbility(autoCastOn ? this : null); + if (notify) { + caster.setAutocastAbility(simulation, autoCastOn ? this : null); + } } @Override @@ -119,11 +122,6 @@ public boolean isAutoCastOn() { return autoCastOn; } - @Override - public void setAutoCastOff() { - this.autoCastOn = false; - } - @Override public AutocastType getAutocastType() { return AutocastType.NEARESTENEMY; @@ -133,7 +131,7 @@ public AutocastType getAutocastType() { @Override public void checkCanAutoTarget(CSimulation game, CUnit unit, int orderId, CWidget target, AbilityTargetCheckReceiver receiver) { - this.checkCanTarget(game, unit, orderId, target, receiver); + this.checkCanTarget(game, unit, orderId, false, target, receiver); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/tinker/CAbilityClusterRockets.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/tinker/CAbilityClusterRockets.java index 8ac29fa67..936a87ab2 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/tinker/CAbilityClusterRockets.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/neutral/tinker/CAbilityClusterRockets.java @@ -18,6 +18,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; @@ -156,7 +157,7 @@ public boolean call(final CUnit possibleTarget) { else { thisTargetDamage = damagePerTarget; } - damageTarget.damage(simulation, unit, false, true, CAttackType.SPELLS, CDamageType.FIRE, + damageTarget.damage(simulation, unit, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.FIRE, CWeaponSoundTypeJass.WHOKNOWS.name(), thisTargetDamage); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityImmolation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityImmolation.java index da8c00285..f65d39df3 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityImmolation.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityImmolation.java @@ -92,7 +92,7 @@ public void onTick(final CSimulation game, final CUnit unit) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { if (this.active && (orderId == OrderIds.unimmolation)) { deactivate(game, caster); return false; @@ -103,7 +103,7 @@ else if (!this.active && (orderId == OrderIds.immolation)) { } return false; } - return super.checkBeforeQueue(game, caster, orderId, target); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); } public void activate(final CSimulation game, final CUnit caster) { @@ -121,18 +121,18 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @@ -250,6 +250,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return true; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityManaBurn.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityManaBurn.java index 899a176c1..97ac4a5d1 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityManaBurn.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CAbilityManaBurn.java @@ -12,6 +12,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CEffect; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; @@ -106,7 +107,7 @@ public boolean update(final CSimulation game) { final float targetMana = targetUnit.getMana(); final float manaDamage = StrictMath.min(targetMana, this.maxManaDrained); targetUnit.setMana(targetMana - manaDamage); - targetUnit.damage(game, caster, false, true, CAttackType.SPELLS, CDamageType.FIRE, + targetUnit.damage(game, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.FIRE, CWeaponSoundTypeJass.WHOKNOWS.name(), manaDamage); game.spawnTextTag(targetUnit, caster.getPlayerIndex(), TextTagConfigType.MANA_BURN, (int) manaDamage); this.boltDelayEndTick = Integer.MAX_VALUE; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CBuffImmolationCaster.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CBuffImmolationCaster.java index b9248fbe7..b8926f4a0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CBuffImmolationCaster.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/nightelf/demonhunter/CBuffImmolationCaster.java @@ -11,6 +11,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; @@ -19,6 +21,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; public class CBuffImmolationCaster extends AbstractCBuff { + private final static CDamageFlags DAMAGE_FLAGS = new CSpellDamageFlags(); private final CAbilityImmolation abilityImmolation; private SimulationRenderComponent fx; private int nextDamageTick; @@ -54,7 +57,7 @@ public void onTick(final CSimulation game, final CUnit caster) { public boolean call(final CUnit enumUnit) { if (caster.canReach(enumUnit, areaOfEffect) && enumUnit.canBeTargetedBy(game, caster, CBuffImmolationCaster.this.abilityImmolation.getTargetsAllowed())) { - enumUnit.damage(game, caster, false, true, CAttackType.SPELLS, CDamageType.FIRE, CWeaponSoundTypeJass.WHOKNOWS.name(), + enumUnit.damage(game, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.FIRE, CWeaponSoundTypeJass.WHOKNOWS.name(), CBuffImmolationCaster.this.abilityImmolation.getDamagePerInterval()); game.createPersistentSpellEffectOnUnit(enumUnit, CBuffImmolationCaster.this.abilityImmolation.getBuffId(), CEffectType.SPECIAL, 0).remove(); @@ -75,36 +78,36 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/blademaster/CBuffWhirlWindCaster.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/blademaster/CBuffWhirlWindCaster.java index bd88409d1..30a78612f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/blademaster/CBuffWhirlWindCaster.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/blademaster/CBuffWhirlWindCaster.java @@ -12,6 +12,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; @@ -21,6 +23,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; public class CBuffWhirlWindCaster extends CBuffTimed { + private final static CDamageFlags DAMAGE_FLAGS = new CSpellDamageFlags(); private final CAbilityWhirlWind abilityImmolation; private int nextDamageTick; private final Rectangle recycleRect = new Rectangle(); @@ -65,7 +68,7 @@ public void onTick(final CSimulation game, final CUnit caster) { public boolean call(final CUnit enumUnit) { if (caster.canReach(enumUnit, areaOfEffect) && enumUnit.canBeTargetedBy(game, caster, CBuffWhirlWindCaster.this.abilityImmolation.getTargetsAllowed())) { - enumUnit.damage(game, caster, false, true, CAttackType.SPELLS, CDamageType.NORMAL, + enumUnit.damage(game, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.NORMAL, CWeaponSoundTypeJass.WHOKNOWS.name(), CBuffWhirlWindCaster.this.abilityImmolation.getDamagePerSecond()); } @@ -85,36 +88,36 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/farseer/CAbilityChainLightning.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/farseer/CAbilityChainLightning.java index 6dc32736a..118b54fc0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/farseer/CAbilityChainLightning.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/farseer/CAbilityChainLightning.java @@ -17,6 +17,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CEffect; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; @@ -65,7 +66,7 @@ public boolean doEffect(final CSimulation simulation, final CUnit caster, final + (int) StrictMath.ceil(SECONDS_BETWEEN_JUMPS / WarsmashConstants.SIMULATION_STEP_TIME); final int boltLifetimeEndTick = simulation.getGameTurnTick() + (int) StrictMath.ceil(BOLT_LIFETIME_SECONDS / WarsmashConstants.SIMULATION_STEP_TIME); - targetUnit.damage(simulation, caster, false, true, CAttackType.SPELLS, CDamageType.LIGHTNING, + targetUnit.damage(simulation, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.LIGHTNING, CWeaponSoundTypeJass.WHOKNOWS.name(), damagePerTarget); final float remainingDamageJumpMultiplier = 1.0f - damageReductionPerTarget; final Set previousTargets = new HashSet<>(); @@ -139,7 +140,7 @@ public boolean update(final CSimulation game) { + (int) StrictMath.ceil(SECONDS_BETWEEN_JUMPS / WarsmashConstants.SIMULATION_STEP_TIME); final int boltLifetimeEndTick = gameTurnTick + (int) StrictMath.ceil(BOLT_LIFETIME_SECONDS / WarsmashConstants.SIMULATION_STEP_TIME); - nextJumpTarget.damage(game, caster, false, true, CAttackType.SPELLS, CDamageType.LIGHTNING, + nextJumpTarget.damage(game, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.LIGHTNING, CWeaponSoundTypeJass.WHOKNOWS.name(), remainingDamage); previousTargets.add(nextJumpTarget); game.registerEffect(new CEffectChainLightningBolt(boltLifetimeEndTick, jumpDelayEndTick, diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/taurenchieftain/CAbilityWarStomp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/taurenchieftain/CAbilityWarStomp.java index a8a3042f7..d969a9248 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/taurenchieftain/CAbilityWarStomp.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/orc/taurenchieftain/CAbilityWarStomp.java @@ -44,7 +44,7 @@ public boolean doEffect(final CSimulation simulation, final CUnit caster, final && enumUnit.canBeTargetedBy(simulation, caster, getTargetsAllowed())) { enumUnit.add(simulation, new CBuffStun(simulation.getHandleIdAllocator().createId(), CAbilityWarStomp.this.buffId, getDurationForTarget(enumUnit))); - enumUnit.damage(simulation, caster, false, true, CAttackType.SPELLS, CDamageType.UNIVERSAL, + enumUnit.damage(simulation, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.UNIVERSAL, CWeaponSoundTypeJass.WHOKNOWS.name(), CAbilityWarStomp.this.damage); } return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/undead/deathknight/CAbilityDeathCoil.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/undead/deathknight/CAbilityDeathCoil.java index 51ca40581..258b82965 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/undead/deathknight/CAbilityDeathCoil.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/undead/deathknight/CAbilityDeathCoil.java @@ -10,6 +10,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; @@ -82,7 +83,7 @@ public void onHit(final CSimulation game, CProjectile projectile, final AbilityT final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); if (targetUnit != null) { if (!targetUnit.isUnitType(CUnitTypeJass.UNDEAD)) { - targetUnit.damage(simulation, caster, false, true, CAttackType.SPELLS, CDamageType.DEATH, null, + targetUnit.damage(simulation, caster, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.DEATH, null, healAmount * .5f); } else { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffAuraBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffAuraBase.java index 3e88eefbf..fd28c16d4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffAuraBase.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffAuraBase.java @@ -71,35 +71,35 @@ public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) { } @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { return null; } @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, + CWidget target, AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } @Override - public void checkCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, + AbilityPointTarget target, AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } @Override public void checkCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { + boolean autoOrder, AbilityTargetCheckReceiver receiver) { receiver.notAnActiveAbility(); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffSlow.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffSlow.java index 09eeb7b2e..fdb209152 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffSlow.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffSlow.java @@ -48,5 +48,10 @@ protected void onBuffRemove(final CSimulation game, final CUnit unit) { public boolean isTimedLifeBar() { return false; } + + @Override + public boolean isPositive() { + return false; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffStun.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffStun.java index a4b0958b5..afc5ec9c0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffStun.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffStun.java @@ -35,5 +35,10 @@ protected void onBuffRemove(final CSimulation game, final CUnit unit) { public boolean isTimedLifeBar() { return false; } + + @Override + public boolean isPositive() { + return false; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimed.java index c20e7213a..5ef232c04 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimed.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimed.java @@ -59,36 +59,36 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return null; } @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimedLife.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimedLife.java index cf741f3a4..001852fae 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimedLife.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/skills/util/CBuffTimedLife.java @@ -3,6 +3,7 @@ import com.etheller.warsmash.util.War3ID; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; public class CBuffTimedLife extends CBuffTimed { @@ -19,6 +20,10 @@ protected void onBuffAdd(final CSimulation game, final CUnit unit) { unit.setExplodesOnDeath(true); unit.setExplodesOnDeathBuffId(getAlias()); } + + final CPlayer player = game.getPlayer(unit.getPlayerIndex()); + player.setUnitFoodMade(unit, 0); + player.setUnitFoodUsed(unit, 0); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTarget.java index c172d19f5..96741d09c 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTarget.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTarget.java @@ -6,4 +6,16 @@ public interface AbilityTarget { float getY(); T visit(AbilityTargetVisitor visitor); + + public static double angleBetween(final AbilityTarget source, final AbilityTarget target) { + final double dx = target.getX() - source.getX(); + final double dy = target.getY() - source.getY(); + return StrictMath.atan2(dy, dx); + } + + public static double distanceBetweenPoints(final AbilityTarget source, final AbilityTarget target) { + final double dx = target.getX() - source.getX(); + final double dy = target.getY() - source.getY(); + return StrictMath.sqrt((dx * dx) + (dy * dy)); + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTargetStillAliveAndTargetableVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTargetStillAliveAndTargetableVisitor.java index 87bc79d46..e51819d46 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTargetStillAliveAndTargetableVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/targeting/AbilityTargetStillAliveAndTargetableVisitor.java @@ -4,7 +4,6 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.*; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; public final class AbilityTargetStillAliveAndTargetableVisitor implements AbilityTargetVisitor { private CSimulation simulation; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCarrionSwarmDummy.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCarrionSwarmDummy.java index 01d4cf048..95929a90c 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCarrionSwarmDummy.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCarrionSwarmDummy.java @@ -61,18 +61,18 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorCarrionSwarmDummy.reset(game, target); } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return this.behaviorCarrionSwarmDummy.reset(game, point); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return caster.pollNextOrderBehavior(game); } @@ -134,6 +134,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return true; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityChannelTest.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityChannelTest.java index b1215fab6..73c5d5871 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityChannelTest.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityChannelTest.java @@ -46,18 +46,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return this.behaviorChannelTest; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return this.behaviorChannelTest; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { return this.behaviorChannelTest; } @@ -102,6 +102,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCoupleInstant.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCoupleInstant.java index 1ede760a0..c092f1428 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCoupleInstant.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/test/CAbilityCoupleInstant.java @@ -79,7 +79,7 @@ public void onCancelFromQueue(final CSimulation game, final CUnit unit, final in } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { // only from engine, not ever allowed by the checks if (target instanceof CUnit) { return this.behaviorCoupleInstant.reset(game, (CUnit) target); @@ -89,12 +89,12 @@ public CBehavior begin(final CSimulation game, final CUnit caster, final int ord @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return caster.pollNextOrderBehavior(game); } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { final PossiblePairFinderEnum possiblePairFinder = new PossiblePairFinderEnum(caster); game.getWorldCollision().enumUnitsInRect( new Rectangle(caster.getX() - this.area, caster.getY() - this.area, this.area * 2, this.area * 2), @@ -249,6 +249,11 @@ public boolean isPhysical() { return true; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return false; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/upgrade/CAbilityUpgrade.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/upgrade/CAbilityUpgrade.java index 26e389d0a..ffbbfab65 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/upgrade/CAbilityUpgrade.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilities/upgrade/CAbilityUpgrade.java @@ -106,20 +106,20 @@ protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final } @Override - public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { + public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { receiver.orderIdNotAccepted(); } @Override public final void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { + boolean autoOrder, final AbilityTargetCheckReceiver receiver) { if (this.upgradesTo.contains(new War3ID(orderId))) { receiver.targetOk(null); } @@ -133,7 +133,7 @@ else if (orderId == OrderIds.cancel) { @Override public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { + boolean autoOrder, final AbilityTarget target) { return true; } @@ -152,18 +152,18 @@ public void onTick(final CSimulation game, final CUnit unit) { } @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, final CWidget target) { return null; } @Override public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { + boolean autoOrder, final AbilityPointTarget point) { return null; } @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { if (orderId == OrderIds.cancel) { caster.cancelUpgrade(game); } @@ -202,6 +202,11 @@ public boolean isPhysical() { return false; } + @Override + public boolean isMagic() { + return false; + } + @Override public boolean isUniversal() { return true; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderAbility.java deleted file mode 100644 index cd709d05d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderAbility.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.Aliased; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public interface AbilityBuilderAbility extends CLevelingAbility, Aliased { - public List getLevelData(); - - public AbilityBuilderConfiguration getConfig(); - - public Map getLocalStore(); - - public float getArea(); - - public float getCooldown(); - - public float getCastRange(); - - public void startCooldown(CSimulation game, CUnit unit); - - public void resetCooldown(CSimulation game, CUnit unit); - - public float getCooldownRemainingTicks(CSimulation game, CUnit unit); - - War3ID getOnTooltipOverride(); - - public int getAbilityIntField(String field); - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderActiveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderActiveAbility.java deleted file mode 100644 index a09fe053f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderActiveAbility.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.CAutocastAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.GenericSingleIconActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -public interface AbilityBuilderActiveAbility extends AbilityBuilderAbility, CAutocastAbility, GenericSingleIconActiveAbility { - public List getLevelData(); - - public AbilityBuilderConfiguration getConfig(); - - public Map getLocalStore(); - - public int getChargedManaCost(); - public void setCastRange(float castRange); - - public int getOffOrderId(); - - public PrimaryTag getCastingPrimaryTag(); - - public EnumSet getCastingSecondaryTags(); - - public void activate(final CSimulation game, final CUnit caster); - - public void deactivate(final CSimulation game, final CUnit caster); - - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver); - - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver); - - public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver); - - public void runOnOrderIssuedActions(CSimulation game, CUnit caster, int orderId); - - public void runBeginCastingActions(CSimulation game, CUnit caster, int orderId); - - public void runEndCastingActions(CSimulation game, CUnit caster, int orderId); - - public void runChannelTickActions(CSimulation game, CUnit caster, int orderId); - - public void runEndChannelActions(CSimulation game, CUnit caster, int orderId); - - public void runCancelPreCastActions(CSimulation game, CUnit caster, int orderId); - - public boolean isSeparateOnAndOff(); - - War3ID getOnTooltipOverride(); - - War3ID getOffTooltipOverride(); - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderPassiveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderPassiveAbility.java deleted file mode 100644 index 47a2001ba..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/AbilityBuilderPassiveAbility.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -public interface AbilityBuilderPassiveAbility extends AbilityBuilderAbility { - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveAutoTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveAutoTarget.java deleted file mode 100644 index 5ffc11caf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveAutoTarget.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.ABBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -public class CAbilityAbilityBuilderActiveAutoTarget extends CAbilityAbilityBuilderGenericActive { - private ABBehavior behavior; - - public CAbilityAbilityBuilderActiveAutoTarget(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, code, alias, levelData, config, localStore); - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - this.behavior = this.createRangedBehavior(unit); - super.onAdd(game, unit); - } - - @Override - protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - return true; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - return true; - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - castId++; - CWidget target = autoTarget(game, caster); - if (target != null) { - this.runOnOrderIssuedActions(game, caster, orderId); - this.behavior.setCastId(castId); - return this.behavior.reset(game, target); - } else { - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId); - return null; - } - } - - public CWidget autoTarget(CSimulation game, CUnit caster) { - CWidget target = null; - - if (this.config.getSpecialFields() != null && this.config.getSpecialFields().getAutoAquireTarget() != null) { - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId); - - for (ABAction action : this.config.getSpecialFields().getAutoAquireTarget()) { - action.runAction(game, caster, this.localStore, castId); - } - - target = (CWidget) this.localStore.get(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - if (target == null) { - target = (CWidget) this.localStore.get(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId); - if (target == null) { - target = (CWidget) this.localStore.get(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId); - } - } - } - return target; - } - - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - CWidget prevTarget = null; - prevTarget = (CWidget) this.localStore.get(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - if (prevTarget == null) { - prevTarget = (CWidget) this.localStore.get(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId); - if (prevTarget == null) { - prevTarget = (CWidget) this.localStore.get(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId); - } - } - if (target == prevTarget) { - return true; - } else { - receiver.orderIdNotAccepted(); - return false; - } - } - - - - // Unused - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - return null; - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - return null; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveFlexTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveFlexTarget.java deleted file mode 100644 index 4c6149652..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveFlexTarget.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.ABBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderNoTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -public class CAbilityAbilityBuilderActiveFlexTarget extends CAbilityAbilityBuilderGenericActive { - private ABBehavior behavior; - - private boolean targetedSpell = false; - private boolean pointTarget = false; - private boolean castless; - - public CAbilityAbilityBuilderActiveFlexTarget(int handleId, War3ID alias, War3ID code, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, alias, code, levelData, config, localStore); - } - - private void setTargeted(CSimulation game, CUnit unit) { - if (config.getSpecialFields() != null && config.getSpecialFields().getTargetedSpell() != null) { - boolean result = true; - for (ABCondition condition : config.getSpecialFields().getTargetedSpell()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - this.targetedSpell = result; - } - } - private void setPointTarget(CSimulation game, CUnit unit) { - if (config.getSpecialFields() != null && config.getSpecialFields().getPointTargeted() != null) { - boolean result = true; - for (ABCondition condition : config.getSpecialFields().getPointTargeted()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - this.pointTarget = result; - } - } - protected void determineCastless(CUnit unit) { - if (this.item != null || this.config.getDisplayFields() != null && this.config.getDisplayFields().getCastlessNoTarget() != null - && this.config.getDisplayFields().getCastlessNoTarget().callback(null, unit, localStore, castId)) { - this.castless = true; - this.behavior = null; - } else { - this.castless = false; - if (this.behavior == null || !(this.behavior instanceof CBehaviorAbilityBuilderNoTarget)) { - this.behavior = this.createNoTargetBehavior(unit); - } - } - } - private void setBehavior(final CUnit unit) { - if (this.targetedSpell) { - if (this.behavior == null || !(this.behavior instanceof CBehaviorAbilityBuilderBase)) { - this.behavior = this.createRangedBehavior(unit); - } - } else { - this.determineCastless(unit); - } - } - - public boolean isTargetedSpell() { - return this.targetedSpell; - } - - public boolean isPointTarget() { - return this.pointTarget; - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - this.setTargeted(game, unit); - this.setPointTarget(game, unit); - this.setBehavior(unit); - - } - - @Override - public void onAddDisabled(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.FLEXABILITY, this); - super.onAddDisabled(game, unit); - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - this.behavior = new CBehaviorAbilityBuilderBase(unit, localStore, this); - this.setTargeted(game, unit); - this.setPointTarget(game, unit); - this.setBehavior(unit); - super.onAdd(game, unit); - } - - @Override - public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { - if (!this.isTargetedSpell() && castless && orderId == this.getBaseOrderId()) { - this.runBeginCastingActions(game, caster, orderId); - this.runEndCastingActions(game, caster, orderId); - return false; - } - return super.checkBeforeQueue(game, caster, orderId, target); - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - if (this.isTargetedSpell() && !this.isPointTarget()) { - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, target.visit(AbilityTargetVisitor.UNIT)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId, target.visit(AbilityTargetVisitor.ITEM)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId, target.visit(AbilityTargetVisitor.DESTRUCTABLE)); - this.runOnOrderIssuedActions(game, caster, orderId); - return this.behavior.reset(game, target); - } else { - return null; - } - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - if (this.isTargetedSpell() && this.isPointTarget()) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION+this.castId, point); - this.runOnOrderIssuedActions(game, caster, orderId); - return this.behavior.reset(game, point); - } else { - return null; - } - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - if (!this.isTargetedSpell()) { - if (castless) { - return null; - } else { - this.runOnOrderIssuedActions(game, caster, orderId); - return this.behavior.reset(); - } - } else { - return null; - } - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - if (this.isTargetedSpell() && !this.isPointTarget()) { - return true; - } else { - receiver.orderIdNotAccepted(); - return false; - } - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - if (this.isTargetedSpell() && this.isPointTarget()) { - return true; - } else { - receiver.orderIdNotAccepted(); - return false; - } - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - if (!this.isTargetedSpell()) { - return true; - } else { - receiver.orderIdNotAccepted(); - return false; - } - } - - @Override - protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - return true; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveFlexTargetSimple.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveFlexTargetSimple.java deleted file mode 100644 index aaa484643..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveFlexTargetSimple.java +++ /dev/null @@ -1,365 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.CAbilitySpellBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.skills.CBehaviorNoTargetSpellBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.skills.CBehaviorTargetSpellBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; - -@Deprecated -public class CAbilityAbilityBuilderActiveFlexTargetSimple extends CAbilitySpellBase { - private CBehavior behavior; - - List levelData; - private AbilityBuilderConfiguration config; - private Map localStore; - private int orderId; - private int autoCastOnId = 0; - private int autoCastOffId = 0; - private boolean autocasting = false; - private boolean initialized; - - private int castId = 0; - - private boolean targetedSpell = false; - private boolean pointTarget = false; - - public CAbilityAbilityBuilderActiveFlexTargetSimple(int handleId, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, alias); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - orderId = OrderIdUtils.getOrderId(config.getCastId()); - if (config.getAutoCastOnId() != null) { - autoCastOnId = OrderIdUtils.getOrderId(config.getAutoCastOnId()); - } - if (config.getAutoCastOffId() != null) { - autoCastOffId = OrderIdUtils.getOrderId(config.getAutoCastOffId()); - } - } - - private void setTargeted(CSimulation game, CUnit unit) { - if (config.getSpecialFields() != null && config.getSpecialFields().getTargetedSpell() != null) { - boolean result = true; - for (ABCondition condition : config.getSpecialFields().getTargetedSpell()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - this.targetedSpell = result; - } - } - private void setPointTarget(CSimulation game, CUnit unit) { - if (config.getSpecialFields() != null && config.getSpecialFields().getPointTargeted() != null) { - boolean result = true; - for (ABCondition condition : config.getSpecialFields().getPointTargeted()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - this.pointTarget = result; - } - } - private void setBehavior(final CUnit unit) { - if (this.targetedSpell) { - if (this.behavior == null || !(this.behavior instanceof CBehaviorTargetSpellBase)) { - this.behavior = new CBehaviorTargetSpellBase(unit, this); - } - } else { - if (this.behavior == null || !(this.behavior instanceof CBehaviorNoTargetSpellBase)) { - this.behavior = new CBehaviorNoTargetSpellBase(unit, this); - } - } - } - - public boolean isTargetedSpell() { - return this.targetedSpell; - } - - public boolean isPointTarget() { - return this.pointTarget; - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - } - - @Override - public void populateData(GameObject worldEditorAbility, int level) { - if (this.initialized) { - CSimulation game = (CSimulation) this.localStore.get(ABLocalStoreKeys.GAME); - CUnit unit = (CUnit) this.localStore.get(ABLocalStoreKeys.THISUNIT); - this.setTargeted(game, unit); - this.setPointTarget(game, unit); - this.setBehavior(unit); - if (config.getOnLevelChange() != null) { - for (ABAction action : config.getOnLevelChange()) { - action.runAction(game, unit, this.localStore, castId); - } - } - } - this.initialized = true; - } - - @Override - public int getBaseOrderId() { - return this.orderId; - } - - public List getLevelData() { - return this.levelData; - } - - public AbilityBuilderConfiguration getConfig() { - return this.config; - } - - public Map getLocalStore() { - return this.localStore; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.FLEXABILITY, this); - this.setTargeted(game, unit); - this.setPointTarget(game, unit); - this.setBehavior(unit); - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public boolean doEffect(CSimulation simulation, CUnit unit, AbilityTarget target) { - this.castId++; - if (this.config.getOnBeginCasting() != null) { - if (this.isTargetedSpell()) { - if (this.isPointTarget() && target instanceof AbilityPointTarget) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + this.castId, target); - } else if (!this.isPointTarget()) { - final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, targetUnit); - final CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId, targetDest); - final CItem targetItem = target.visit(AbilityTargetVisitor.ITEM); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId, targetItem); - } - } - - for (ABAction action : this.config.getOnBeginCasting()) { - action.runAction(simulation, unit, this.localStore, castId); - } - - if (this.isTargetedSpell()) { - if (this.isPointTarget()) { - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + castId); - } else if (!this.isPointTarget()) { - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId); - } - } - } - return false; - } - - @Override - protected void innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - if (config.getExtraCastConditions() != null) { - boolean result = true; - for (ABCondition condition : config.getExtraCastConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.useOk(); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.activationCheckFailed(failReason); - } else { - receiver.unknownReasonUseNotOk(); - } - } - } else { - receiver.useOk(); - } - } - - protected void innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - if (this.config.getExtraTargetConditions() != null) { - final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, targetUnit); - final CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId, targetDest); - final CItem targetItem = target.visit(AbilityTargetVisitor.ITEM); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId, targetItem); - boolean result = true; - for (ABCondition condition : config.getExtraTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.targetOk(targetUnit); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.targetCheckFailed(failReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); - } - } - } else { - receiver.targetOk(target); - } - } - - protected void innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - if (this.config.getExtraTargetConditions() != null) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + this.castId, target); - boolean result = true; - for (ABCondition condition : config.getExtraTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.targetOk(target); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.targetCheckFailed(failReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THERE); - } - } - localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + this.castId); - } else { - receiver.targetOk(target); - } - } - - @Override - public int getAutoCastOnOrderId() { - return this.autoCastOnId; - } - - @Override - public int getAutoCastOffOrderId() { - return this.autoCastOffId; - } - - @Override - public boolean isAutoCastOn() { - return this.autocasting; - } - - @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { - this.autocasting = autoCastOn; - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - if (this.isTargetedSpell() && !this.isPointTarget()) { - if (this.behavior instanceof CBehaviorTargetSpellBase) { - return ((CBehaviorTargetSpellBase) this.behavior).reset(game, target); - } else { - return null; - } - } else { - return null; - } - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - if (this.isTargetedSpell() && this.isPointTarget()) { - if (this.behavior instanceof CBehaviorTargetSpellBase) { - return ((CBehaviorTargetSpellBase) this.behavior).reset(game, point); - } else { - return null; - } - } else { - return null; - } - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - if (!this.isTargetedSpell()) { - if (this.behavior instanceof CBehaviorNoTargetSpellBase) { - return ((CBehaviorNoTargetSpellBase) this.behavior).reset(); - } else { - return null; - } - } else { - return null; - } - } - - @Override - protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - if (this.isTargetedSpell() && !this.isPointTarget()) { - if (target.canBeTargetedBy(game, unit, getTargetsAllowed(), receiver)) { - if (!unit.isMovementDisabled() || unit.canReach(target, getCastRange())) { - this.innerCheckCanTargetSpell(game, unit, orderId, target, receiver); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); - } - } - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - if (this.isTargetedSpell() && this.isPointTarget()) { - if (!unit.isMovementDisabled() || unit.canReach(target, getCastRange())) { - this.innerCheckCanTargetSpell(game, unit, orderId, target, receiver); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); - } - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - protected void innerCheckCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - if (!this.isTargetedSpell()) { - receiver.targetOk(null); - } else { - receiver.orderIdNotAccepted(); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveNoTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveNoTarget.java deleted file mode 100644 index 49c25941d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveNoTarget.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.ABBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; - -public class CAbilityAbilityBuilderActiveNoTarget extends CAbilityAbilityBuilderGenericActive { - - private ABBehavior behavior; - private boolean castless; - - public CAbilityAbilityBuilderActiveNoTarget(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, code, alias, levelData, config, localStore); - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - super.onAdd(game, unit); - determineCastless(unit); - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - determineCastless(unit); - } - - protected void determineCastless(CUnit unit) { - if (this.item != null || this.config.getDisplayFields() != null && this.config.getDisplayFields().getCastlessNoTarget() != null - && this.config.getDisplayFields().getCastlessNoTarget().callback(null, unit, localStore, castId)) { - this.castless = true; - this.behavior = null; - } else { - this.castless = false; - this.behavior = this.createNoTargetBehavior(unit); - } - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - return null; - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - return null; - } - - @Override - public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { - -// System.err.println("Checking queue notarg level: " + active + " orderID : " + orderId + " offID: " + this.getOffOrderId()); - if (castless && orderId == this.getBaseOrderId()) { -// System.err.println("Castless"); - if (!caster.chargeMana(this.getChargedManaCost())) { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), - CommandStringErrorKeys.NOT_ENOUGH_MANA); -// System.err.println("NoMana"); - return false; - } -// System.err.println("Had mana?"); - this.startCooldown(game, caster); - this.runBeginCastingActions(game, caster, orderId); - this.runEndCastingActions(game, caster, orderId); - return false; - } - return super.checkBeforeQueue(game, caster, orderId, target); - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - this.castId++; - if (castless) { - return null; - } else { - this.runOnOrderIssuedActions(game, caster, orderId); - this.behavior.setCastId(castId); - return this.behavior.reset(); - } - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - return true; - } - - @Override - protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - return true; - } - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveNoTargetSimple.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveNoTargetSimple.java deleted file mode 100644 index d5e8c6cc8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveNoTargetSimple.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.CAbilityNoTargetSpellBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; - -@Deprecated -public class CAbilityAbilityBuilderActiveNoTargetSimple extends CAbilityNoTargetSpellBase { - - List levelData; - private AbilityBuilderConfiguration config; - private Map localStore; - private int orderId; - private int autoCastOnId = 0; - private int autoCastOffId = 0; - private boolean autocasting = false; - private boolean initialized; - - private int castId = 0; - - public CAbilityAbilityBuilderActiveNoTargetSimple(int handleId, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, alias); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - orderId = OrderIdUtils.getOrderId(config.getCastId()); - if (config.getAutoCastOnId() != null) { - autoCastOnId = OrderIdUtils.getOrderId(config.getAutoCastOnId()); - } - if (config.getAutoCastOffId() != null) { - autoCastOffId = OrderIdUtils.getOrderId(config.getAutoCastOffId()); - } - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - } - - @Override - public void populateData(GameObject worldEditorAbility, int level) { - if (this.initialized) { - if (config.getOnLevelChange() != null) { - CSimulation game = (CSimulation) this.localStore.get(ABLocalStoreKeys.GAME); - CUnit unit = (CUnit) this.localStore.get(ABLocalStoreKeys.THISUNIT); - for (ABAction action : config.getOnLevelChange()) { - action.runAction(game, unit, this.localStore, castId); - } - } - } - this.initialized = true; - } - - @Override - public int getBaseOrderId() { - return orderId; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - super.onAdd(game, unit); - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public boolean doEffect(CSimulation simulation, CUnit unit, AbilityTarget target) { - this.castId++; - if (config.getOnBeginCasting() != null) { - for (ABAction action : config.getOnBeginCasting()) { - action.runAction(simulation, unit, localStore, castId); - } - } - return false; - } - - @Override - protected void innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, AbilityActivationReceiver receiver) { - if (config.getExtraCastConditions() != null) { - boolean result = true; - for (ABCondition condition : config.getExtraCastConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.useOk(); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.activationCheckFailed(failReason); - } else { - receiver.unknownReasonUseNotOk(); - } - } - } else { - receiver.useOk(); - } - } - - @Override - public int getAutoCastOnOrderId() { - return this.autoCastOnId; - } - - @Override - public int getAutoCastOffOrderId() { - return this.autoCastOffId; - } - - @Override - public boolean isAutoCastOn() { - return this.autocasting; - } - - @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { - this.autocasting = autoCastOn; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePairing.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePairing.java deleted file mode 100644 index 6055745d3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePairing.java +++ /dev/null @@ -1,477 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CPairingAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.ABBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorSendOrder; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.iterstructs.UnitAndRange; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeysEnum; - -public class CAbilityAbilityBuilderActivePairing extends CAbilityAbilityBuilderGenericActive - implements CPairingAbility { - private ABBehavior behavior; - - private War3ID pairUnitId = null; - private War3ID pairAbilityId = null; - - private boolean autoTargetPartner = false; - private float pairSearchRadius = 0; - - private int internalOrderId = -1; - private int maxPartners = 1; - - private boolean orderPairedUnit = false; - private int orderPairedUnitOrderId = -1; - - private int internalOffOrderId = -1; - private int orderPairedUnitOffOrderId = -1; - - public CAbilityAbilityBuilderActivePairing(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, code, alias, levelData, config, localStore); - - if (this.castingPrimaryTag == null) { - this.castingPrimaryTag = PrimaryTag.STAND; - } - - this.allowCastlessDeactivate = false; - } - - private void setPairingValues(CSimulation game, CUnit unit) { - - if (this.config.getSpecialFields() != null) { - if (this.config.getSpecialFields().getPairAbilityId() != null) { - this.pairAbilityId = this.config.getSpecialFields().getPairAbilityId().callback(game, unit, localStore, - castId); - } - if (this.config.getSpecialFields().getPairUnitId() != null) { - this.pairUnitId = this.config.getSpecialFields().getPairUnitId().callback(game, unit, localStore, - castId); - } - - if (this.config.getSpecialFields().getAutoTargetPartner() != null) { - this.autoTargetPartner = this.config.getSpecialFields().getAutoTargetPartner().callback(game, unit, - localStore, castId); - } - if (this.config.getSpecialFields().getPairSearchRadius() != null) { - this.pairSearchRadius = this.config.getSpecialFields().getPairSearchRadius().callback(game, unit, - localStore, castId); - } - - if (this.config.getSpecialFields().getPairingOrderId() != null) { - this.internalOrderId = this.config.getSpecialFields().getPairingOrderId().callback(game, unit, - localStore, castId); - } - - if (this.config.getSpecialFields().getPairingOffOrderId() != null) { - this.internalOffOrderId = this.config.getSpecialFields().getPairingOffOrderId().callback(game, unit, - localStore, castId); - } - if (this.config.getSpecialFields().getMaxPartners() != null) { - this.maxPartners = this.config.getSpecialFields().getMaxPartners().callback(game, unit, localStore, - castId); - } - if (this.config.getSpecialFields().getOrderPairedUnit() != null) { - this.orderPairedUnit = this.config.getSpecialFields().getOrderPairedUnit().callback(game, unit, - localStore, castId); - } - if (this.config.getSpecialFields().getOrderPairedUnitOrderId() != null) { - this.orderPairedUnitOrderId = this.config.getSpecialFields().getOrderPairedUnitOrderId().callback(game, - unit, localStore, castId); - } - if (this.config.getSpecialFields().getOrderPairedUnitOffOrderId() != null) { - this.orderPairedUnitOffOrderId = this.config.getSpecialFields().getOrderPairedUnitOffOrderId().callback(game, - unit, localStore, castId); - } - } - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.PAIRABILITY, this); - this.behavior = this.createRangedBehavior(unit); - this.behavior.setInstant(true); - super.onAdd(game, unit); - this.setPairingValues(game, unit); - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - this.setPairingValues(game, unit); - } - - protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { -// System.err.println(unit.getUnitType().getName() + " Checking can use order: " + orderId + " (Base: " -// + this.getBaseOrderId() + ", Internal: " + this.getPairOrderId(game, unit) + ")"); - if (checkNoTargetOrderId(game, unit, orderId)) { - Set partners = this.findPairUnits(game, unit); - if (partners == null || partners.isEmpty()) { - boolean isOffId = orderId == this.getOffOrderId() || orderId == this.getPairOffOrderId(game, unit); - if (!isOffId && this.config.getSpecialFields().getCantPairError() != null) { -// System.out.println("Use check failed: no parter, special message"); - receiver.activationCheckFailed(this.config.getSpecialFields().getCantPairError().getKey()); - return false; - } else if (isOffId && this.config.getSpecialFields().getCantPairOffError() != null) { -// System.out.println("Use check failed: no parter, special message"); - receiver.activationCheckFailed(this.config.getSpecialFields().getCantPairOffError().getKey()); - return false; - } else { -// System.out.println("Use check failed: no parter"); - receiver.activationCheckFailed(CommandStringErrorKeysEnum.UNABLE_TO_FIND_COUPLE_TARGET.getKey()); - return false; - } - } -// System.err.println("Check use: Partner found"); - } - return true; - } - - @Override - protected boolean innerCheckCastOrderId(final CSimulation game, final CUnit unit, final int orderId) { - return orderId == getBaseOrderId() || orderId == this.getPairOrderId(game, unit) || offOrderId(orderId) - || orderId == this.getPairOffOrderId(game, unit); - } - - private boolean checkNoTargetOrderId(final CSimulation game, final CUnit unit, final int orderId) { - return this.autoTargetParter(game, unit) && (onOrderId(orderId) || offOrderId(orderId)); - } - - private boolean checkTargetPrimeOrderId(final CSimulation game, final CUnit unit, final int orderId) { - return !this.autoTargetParter(game, unit) && (onOrderId(orderId) || offOrderId(orderId)); - } - - private boolean checkTargetInternalOrderId(final CSimulation game, final CUnit unit, final int orderId) { - return (((!this.active || this.separateOnAndOff) - && orderId == this.getPairOrderId(game, unit)) - || ((this.toggleable && this.active) || this.separateOnAndOff) - && orderId == this.getPairOffOrderId(game, unit)); - } - - private boolean onOrderId(final int orderId) { - return (!this.active || this.separateOnAndOff) && orderId == this.getBaseOrderId(); - } - - private boolean offOrderId(final int orderId) { - return ((this.toggleable && this.active) || this.separateOnAndOff) && orderId == this.getOffOrderId(); - } - - // ---- - // Non-Targeted - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - if (checkNoTargetOrderId(game, caster, orderId)) { - -// System.err.println(caster.getUnitType().getName() + " Beginning NoTarget: " + orderId); - boolean isOffId = orderId == this.getOffOrderId(); - Set partners = this.findPairUnits(game, caster); - CUnit finalPartner = null; - if (partners != null) { -// System.err.println(caster.getUnitType().getName() + " Found Partners"); - int sendOrderId = isOffId ? this.orderPairedUnitOffOrderId(game, caster) - : this.orderPairedUnitOrderId(game, caster); -// System.err.println(caster.getUnitType().getName() + " isOffId = " + isOffId + " so picking between " + this.orderPairedUnitOrderId(game, caster) + " and " + this.orderPairedUnitOffOrderId(game, caster)); - boolean ordered = sendOrderId < 0; - for (CUnit partner : partners) { - if (sendOrderId >= 0) { - ordered |= partner.order(game, sendOrderId, caster); -// System.err.println(caster.getUnitType().getName() + " Sending order to " + partner.getUnitType().getName() + " (" + sendOrderId + ")"); - } - if ((isOffId ? this.getPairOffOrderId(game, caster) : this.getPairOrderId(game, caster)) >= 0) { -// System.err.println(caster.getUnitType().getName() + " Saved last partner for self-order: " -// + partner.getUnitType().getName()); - finalPartner = partner; - } - } - if (!ordered) { - // Failed to order any partners despite wanting to -// System.err.println( -// caster.getUnitType().getName() + " Attempted to order parter(s) but failed to order any: " -// + (isOffId ? this.orderPairedUnitOffOrderId(game, caster) -// : this.orderPairedUnitOrderId(game, caster))); - if (!isOffId && this.config.getSpecialFields().getCantPairError() != null) { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), - this.config.getSpecialFields().getCantPairError().getKey()); - } else if (isOffId && this.config.getSpecialFields().getCantPairOffError() != null) { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), - this.config.getSpecialFields().getCantPairOffError().getKey()); - } else { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), - CommandStringErrorKeysEnum.UNABLE_TO_FIND_COUPLE_TARGET.getKey()); - } - return null; - } - } - if (finalPartner != null - && (isOffId ? this.getPairOffOrderId(game, caster) : this.getPairOrderId(game, caster)) >= 0) { -// System.err.println(caster.getUnitType().getName() + " Have final partner, issuing self order behavior"); - if (isOffId) { - return new CBehaviorSendOrder(caster, this, this.getPairOffOrderId(game, caster), - this.getBaseOrderId(), finalPartner); - } - return new CBehaviorSendOrder(caster, this, this.getPairOrderId(game, caster), this.getBaseOrderId(), - finalPartner); - } else { - return null; - } - } - return null; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - if (checkNoTargetOrderId(game, unit, orderId)) { - return true; - } else { - receiver.orderIdNotAccepted(); - return false; - } - } - - // ---- - // Targeted - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - this.castId++; -// System.err.println(caster.getUnitType().getName() + " Received pair target order: " + orderId + " (Base: " -// + this.getBaseOrderId() + ", Internal: " + this.getPairOrderId(game, caster) + ")"); - if (checkTargetPrimeOrderId(game, caster, orderId)) { - final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - if (this.orderPairedUnit(game, caster) && this.orderPairedUnitOrderId(game, caster) != null) { -// System.err.println(caster.getUnitType().getName() + " Sending internal order to paired unit"); - boolean ordered = targetUnit.order(game, this.orderPairedUnitOrderId(game, caster), caster); - if (!ordered) { - if (this.config.getSpecialFields() != null - && this.config.getSpecialFields().getCantPairError() != null) { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), - this.config.getSpecialFields().getCantPairError().getKey()); - } else { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), - CommandStringErrorKeysEnum.UNABLE_TO_MERGE_WITH_THAT_UNIT.getKey()); - } - return caster.pollNextOrderBehavior(game); - } - } - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, targetUnit); - this.localStore.put(ABLocalStoreKeys.ABILITYPAIREDUNIT + castId, targetUnit); -// System.out.println("Starting targeted behavior"); - - this.runOnOrderIssuedActions(game, caster, orderId); - this.behavior.setCastId(castId); - return this.behavior.reset(game, target); - } else if (checkTargetInternalOrderId(game, caster, orderId)) { -// System.err.println(caster.getUnitType().getName() + " Got internal order"); - final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, targetUnit); - this.localStore.put(ABLocalStoreKeys.ABILITYPAIREDUNIT + castId, targetUnit); -// System.out.println("Starting internal targeted behavior with target: " + targetUnit); - - this.runOnOrderIssuedActions(game, caster, orderId); - this.behavior.setCastId(castId); - return this.behavior.reset(game, target, orderId); - } else { - return null; - } - } - - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { -// System.err.println(unit.getUnitType().getName() + " Checking can pair target order: " + orderId + " (Base: " -// + this.getBaseOrderId() + ", Internal: " + this.getPairOrderId(game, unit) + ")"); - if (checkTargetPrimeOrderId(game, unit, orderId) - || checkTargetInternalOrderId(game, unit, orderId)) { - final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - - if (targetUnit != null && unit.getPlayerIndex() != targetUnit.getPlayerIndex()) { - receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_ONE_OF_YOUR_OWN_UNITS); - return false; - } - - if (this.config.getSpecialFields() != null - && this.config.getSpecialFields().getPairUnitTypeError() != null) { - if (getPairUnitID(game, unit) != null && !targetUnit.getTypeId().equals(getPairUnitID(game, unit))) { - receiver.targetCheckFailed(this.config.getSpecialFields().getPairUnitTypeError().getKey()); - return false; - } - } - if (!this.canPairWith(game, unit, targetUnit)) { - if (this.config.getSpecialFields() != null - && this.config.getSpecialFields().getCantTargetError() != null) { - receiver.targetCheckFailed(this.config.getSpecialFields().getCantTargetError().getKey()); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_MERGE_WITH_THAT_UNIT); - } - return false; - } - return true; - } else { - receiver.orderIdNotAccepted(); - return false; - } - } - - // Method to search out partner unit - private boolean canPairWith(CSimulation game, CUnit caster, CUnit target) { - if (caster.isPaused() || target.isPaused() || caster.getPlayerIndex() != target.getPlayerIndex()) { -// System.err.println( -// caster.getUnitType().getName() + " Couldn't pair: unit is owned by different player, or is paused"); - return false; - } - if (getPairUnitID(game, caster) != null && !target.getTypeId().equals(getPairUnitID(game, caster))) { -// System.err.println(caster.getUnitType().getName() + " Couldn't pair: wrong unit id (Want:" -// + getPairUnitID(game, caster) + ", Got:" + target.getTypeId() + ")"); - return false; - } - if (getPairAbilityCode(game, caster) != null) { - for (CAbility ability : target.getAbilities()) { - if (ability.getCode().equals(this.getPairAbilityCode(game, caster))) { - localStore.put(ABLocalStoreKeys.LASTPARTNERABILITY, ability); - return true; - } - } -// System.err.println(caster.getUnitType().getName() + " Couldn't pair: No matching ability (Want:" -// + getPairAbilityCode(game, caster) + ")"); - } - return false; - } - - @Override - public Set findPairUnits(CSimulation game, CUnit caster) { - if (this.getPairAbilityCode(game, caster) != null || this.getPairUnitID(game, caster) != null) { - final Set retSet = new HashSet<>(); - if (this.maxPartners(game, caster) != 1) { - game.getWorldCollision().enumUnitsInRange(caster.getX(), caster.getY(), - this.getPairSearchRadius(game, caster), (enumUnit) -> { - if ((enumUnit != caster) && canPairWith(game, caster, enumUnit)) { - retSet.add(enumUnit); - } - return maxPartners(game, caster) != 0 && retSet.size() >= maxPartners(game, caster); - }); - } else { - final UnitAndRange ur = new UnitAndRange(); - Rectangle rect = new Rectangle(); - float rangeVal = this.getPairSearchRadius(game, caster); - - rect.set(caster.getX() - rangeVal, caster.getY() - rangeVal, rangeVal * 2, rangeVal * 2); - game.getWorldCollision().enumUnitsInRect(rect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (caster.canReach(enumUnit, rangeVal)) { - double dist = caster.distance(enumUnit); - if (ur.getUnit() == null || ur.getRange() > dist) { - if ((enumUnit != caster) && canPairWith(game, caster, enumUnit)) { - ur.setRange(dist); - ur.setUnit(enumUnit); - } - } - } - return false; - } - }); - if (ur.getUnit() != null) { - retSet.add(ur.getUnit()); - } - } - if (retSet.size() > 0) { - return retSet; - } - } - return null; - } - - // Methods to identify partner unit(s) - @Override - public War3ID getPairAbilityCode(CSimulation game, CUnit caster) { - return this.pairAbilityId; - } - - @Override - public War3ID getPairUnitID(CSimulation game, CUnit caster) { - return this.pairUnitId; - } - - @Override - public float getPairSearchRadius(CSimulation game, CUnit caster) { - if (this.pairSearchRadius == 0) { - return Float.MAX_VALUE; - } - return this.pairSearchRadius; - } - - // Methods to determine how targeting works - @Override - public boolean autoTargetParter(CSimulation game, CUnit caster) { - return this.autoTargetPartner; - } - - @Override - public int maxPartners(CSimulation game, CUnit caster) { - return this.maxPartners; - } // should only be one if autoTargetParter is false - - // Internal order to give to casting unit (generally used if auto targeting a - // partner. Not always needed) - @Override - public Integer getPairOrderId(CSimulation game, CUnit caster) { - return this.internalOrderId; - } - - @Override - public Integer getPairOffOrderId(CSimulation game, CUnit caster) { - return this.internalOffOrderId; - } - - // Optional order to send to paired unit - @Override - public boolean orderPairedUnit(CSimulation game, CUnit caster) { - return this.orderPairedUnit; - } - - @Override - public Integer orderPairedUnitOrderId(CSimulation game, CUnit caster) { - return this.orderPairedUnitOrderId; - } - - @Override - public Integer orderPairedUnitOffOrderId(CSimulation game, CUnit caster) { - return this.orderPairedUnitOffOrderId; - } - - // Not Used - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - return null; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePointTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePointTarget.java deleted file mode 100644 index 4543ef20a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePointTarget.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.ABBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -public class CAbilityAbilityBuilderActivePointTarget extends CAbilityAbilityBuilderGenericActive { - - private ABBehavior behavior; - - public CAbilityAbilityBuilderActivePointTarget(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, code, alias, levelData, config, localStore); - } - - @Override - public boolean isToggleOn() { - return false; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - this.behavior = this.createRangedBehavior(unit); - super.onAdd(game, unit); - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - return null; - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - this.castId++; - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION+this.castId, point); - this.runOnOrderIssuedActions(game, caster, orderId); - this.behavior.setCastId(castId); - return this.behavior.reset(game, point); - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - return null; - } - - @Override - protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - return true; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - return true; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePointTargetSimple.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePointTargetSimple.java deleted file mode 100644 index bc66414d5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActivePointTargetSimple.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.CAbilityPointTargetSpellBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; - -@Deprecated -public class CAbilityAbilityBuilderActivePointTargetSimple extends CAbilityPointTargetSpellBase { - - List levelData; - private AbilityBuilderConfiguration config; - private Map localStore; - private int orderId; - - private int castId = 0; - private boolean initialized = false; - - public CAbilityAbilityBuilderActivePointTargetSimple(int handleId, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, alias); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - orderId = OrderIdUtils.getOrderId(config.getCastId()); - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - } - - @Override - public int getBaseOrderId() { - return orderId; - } - - @Override - public void populateData(GameObject worldEditorAbility, int level) { - if (this.initialized ) { - if (config.getOnLevelChange() != null) { - CSimulation game = (CSimulation) this.localStore.get(ABLocalStoreKeys.GAME); - CUnit unit = (CUnit) this.localStore.get(ABLocalStoreKeys.THISUNIT); - for (ABAction action : config.getOnLevelChange()) { - action.runAction(game, unit, this.localStore, castId); - } - } - } - this.initialized = true; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - super.onAdd(game, unit); - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public boolean doEffect(CSimulation simulation, CUnit unit, AbilityTarget target) { - this.castId++; - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION+this.castId, target); - if (config.getOnBeginCasting() != null) { - for (ABAction action : config.getOnBeginCasting()) { - action.runAction(simulation, unit, localStore, castId); - } - } - localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDLOCATION+this.castId); - return false; - } - - @Override - protected void innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - if (config.getExtraCastConditions() != null) { - boolean result = true; - for (ABCondition condition : config.getExtraCastConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.useOk(); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.activationCheckFailed(failReason); - } else { - receiver.unknownReasonUseNotOk(); - } - } - } else { - receiver.useOk(); - } - } - - @Override - protected void innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - if (this.config.getExtraTargetConditions() != null) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION+this.castId, target); - boolean result = true; - for (ABCondition condition : config.getExtraTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.targetOk(target); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.targetCheckFailed(failReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THERE); - } - } - localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDLOCATION+this.castId); - } else { - receiver.targetOk(target); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveSmart.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveSmart.java deleted file mode 100644 index 0ca42eb83..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveSmart.java +++ /dev/null @@ -1,357 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityCategory; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractGenericSingleIconActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -//TODO: Figure out if we need smart? Not implemented -@Deprecated -public class CAbilityAbilityBuilderActiveSmart extends AbstractGenericSingleIconActiveAbility implements AbilityBuilderActiveAbility { - - List levelData; - private AbilityBuilderConfiguration config; - private Map localStore; - private CBehaviorAbilityBuilderBase behavior; - - private int castId = 0; - - public CAbilityAbilityBuilderActiveSmart(int handleId, War3ID code, War3ID alias, List levelData, AbilityBuilderConfiguration config, Map localStore) { - super(handleId, code, alias); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - this.behavior = new CBehaviorAbilityBuilderBase(unit, localStore, this); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - if (config.getOnRemoveAbility() != null) { - for (ABAction action : config.getOnRemoveAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - if (config.getOnDeathPreCast() != null) { - for (ABAction action : config.getOnDeathPreCast()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) { - // TODO Auto-generated method stub - - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - this.castId++; - return this.behavior.reset(); - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - // TODO Auto-generated method stub - return null; - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - // TODO Auto-generated method stub - return null; - } - - @Override - protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - protected void innerCheckCanSmartTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - protected void innerCheckCanSmartTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - protected void innerCheckCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - protected void innerCheckCanUse(CSimulation game, CUnit unit, int orderId, AbilityActivationReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - public boolean isToggleOn() { - // TODO Auto-generated method stub - return false; - } - - @Override - public int getBaseOrderId() { - // TODO Auto-generated method stub - return 0; - } - - public PrimaryTag getCastingPrimaryTag() { - return null; - } - - public EnumSet getCastingSecondaryTags() { - return null; - } - - @Override - public List getLevelData() { - return levelData; - } - - @Override - public AbilityBuilderConfiguration getConfig() { - return config; - } - - @Override - public Map getLocalStore() { - return localStore; - } - - public void startCooldown(CSimulation game, CUnit unit) { - // TODO Auto-generated method stub - } - - @Override - public int getChargedManaCost() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void activate(CSimulation game, CUnit caster) { - // TODO Auto-generated method stub - - } - - @Override - public void deactivate(CSimulation game, CUnit caster) { - // TODO Auto-generated method stub - - } - - @Override - public int getOffOrderId() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public boolean isSeparateOnAndOff() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void runBeginCastingActions(CSimulation game, CUnit caster, int orderId) { - // TODO Auto-generated method stub - - } - - @Override - public void runEndCastingActions(CSimulation game, CUnit caster, int orderId) { - // TODO Auto-generated method stub - - } - - @Override - public void runChannelTickActions(CSimulation game, CUnit caster, int orderId) { - // TODO Auto-generated method stub - - } - - @Override - public void runEndChannelActions(CSimulation game, CUnit caster, int orderId) { - // TODO Auto-generated method stub - - } - - @Override - public void runCancelPreCastActions(CSimulation game, CUnit caster, int orderId) { - // TODO Auto-generated method stub - - } - - @Override - public float getArea() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public float getCastRange() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public War3ID getOnTooltipOverride() { - // TODO Auto-generated method stub - return null; - } - - @Override - public War3ID getOffTooltipOverride() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void resetCooldown(CSimulation game, CUnit unit) { - // TODO Auto-generated method stub - - } - - @Override - public void setCastRange(float castRange) { - // TODO Auto-generated method stub - - } - - @Override - public void runOnOrderIssuedActions(CSimulation game, CUnit caster, int orderId) { - // TODO Auto-generated method stub - - } - - @Override - public AutocastType getAutocastType() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void checkCanAutoTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - public void checkCanAutoTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - public void checkCanAutoTargetNoTarget(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - // TODO Auto-generated method stub - - } - - @Override - public float getCooldown() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public void setAutoCastOff() { - // TODO Auto-generated method stub - - } - - @Override - public boolean isPhysical() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isUniversal() { - // TODO Auto-generated method stub - return false; - } - - @Override - public CAbilityCategory getAbilityCategory() { - // TODO Auto-generated method stub - return null; - } - - @Override - public float getCooldownRemainingTicks(CSimulation game, CUnit unit) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public int getAbilityIntField(String field) { - // TODO Auto-generated method stub - return 0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveToggle.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveToggle.java deleted file mode 100644 index 3b7d575e4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveToggle.java +++ /dev/null @@ -1,233 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.ManaDepletedCheckTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.MeleeUIAbilityActivationReceiver; - -@Deprecated -public class CAbilityAbilityBuilderActiveToggle extends CAbilityAbilityBuilderGenericActive { - - protected int unorderId; - - protected boolean active; - - protected int bufferMana = 0; - protected int manaDrainedPerSecond = 0; - protected float duration = 0; - - private ManaDepletedCheckTimer timer; - private NonStackingStatBuff manaDrain; - - public CAbilityAbilityBuilderActiveToggle(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, code, alias, levelData, config, localStore); - unorderId = OrderIdUtils.getOrderId(config.getUncastId()); - active = false; - - CAbilityTypeAbilityBuilderLevelData levelDataLevel = levelData.get(this.getLevel() - 1); - this.duration = levelDataLevel.getDurationNormal(); - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - CAbilityTypeAbilityBuilderLevelData levelDataLevel = this.levelData.get(this.getLevel() - 1); - this.duration = levelDataLevel.getDurationNormal(); - if (config.getSpecialFields() != null) { - if (config.getSpecialFields().getBufferManaRequired() != null) { - this.bufferMana = config.getSpecialFields().getBufferManaRequired().callback(game, unit, localStore, castId); - } - if (config.getSpecialFields().getManaDrainedPerSecond() != null) { - this.manaDrainedPerSecond = config.getSpecialFields().getManaDrainedPerSecond().callback(game, unit, localStore, castId); - } - } - manaDrain.setValue((-1 * this.manaDrainedPerSecond / this.duration)); - } - - @Override - public int getBaseOrderId() { - return this.active ? this.unorderId : this.orderId; - } - - @Override - public int getUIManaCost() { - return this.active ? 0 :this.manaCost + this.bufferMana; - } - - @Override - public boolean isToggleOn() { - return this.active; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - timer = new ManaDepletedCheckTimer(unit, this); - localStore.put(ABLocalStoreKeys.TOGGLEDABILITY, this); - if (config.getSpecialFields() != null) { - if (config.getSpecialFields().getBufferManaRequired() != null) { - this.bufferMana = config.getSpecialFields().getBufferManaRequired().callback(game, unit, localStore, castId); - } - if (config.getSpecialFields().getManaDrainedPerSecond() != null) { - this.manaDrainedPerSecond = config.getSpecialFields().getManaDrainedPerSecond().callback(game, unit, localStore, castId); - } - } - manaDrain = new NonStackingStatBuff(NonStackingStatBuffType.MPGEN, NonStackingStatBuff.ALLOW_STACKING_KEY, (-1 * this.manaDrainedPerSecond / this.duration)); - super.onAdd(game, unit); - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - if (this.active) { - deactivate(game, unit); - } - super.onRemove(game, unit); - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - if (this.active) { - deactivate(game, unit); - } - super.onDeath(game, unit); - } - - @Override - public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { - if (this.active && (orderId == this.unorderId)) { - this.runOnOrderIssuedActions(game, caster, orderId); - deactivate(game, caster); - return false; - } else if (!this.active && (orderId == this.orderId)) { - if (caster.chargeMana(this.manaCost)) { - this.runOnOrderIssuedActions(game, caster, orderId); - activate(game, caster); - } - return false; - } - return super.checkBeforeQueue(game, caster, orderId, target); - } - - @Override - public void activate(final CSimulation game, final CUnit caster) { - this.castId++; - this.active = true; - this.startCooldown(game, caster); - if (this.manaDrainedPerSecond > 0) { - this.timer.start(game); - caster.addNonStackingStatBuff(manaDrain); - } - if (config.getOnBeginCasting() != null) { - for (ABAction action : config.getOnBeginCasting()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void deactivate(final CSimulation game, final CUnit caster) { - this.active = false; - if (this.manaDrainedPerSecond > 0) { - timer.pause(game); - caster.removeNonStackingStatBuff(manaDrain); - } - if (config.getOnEndCasting() != null) { - for (ABAction action : config.getOnEndCasting()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - return null; - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - return null; - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - return null; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - if (this.active && (orderId == this.unorderId)) { - return true; - } else if (!this.active && (orderId == this.orderId)) { - return true; - } else { - receiver.orderIdNotAccepted(); - return false; - } - } - - @Override - protected void innerCheckCanUse(CSimulation game, CUnit unit, int orderId, AbilityActivationReceiver receiver) { - int cooldownRemaining = unit.getCooldownRemainingTicks(game, getAlias()); - if (!this.active) { - if (cooldownRemaining > 0) { - float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getAlias()) - * WarsmashConstants.SIMULATION_STEP_TIME; - receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, cooldownLengthDisplay); - } else if (unit.getMana() < (this.manaCost + this.bufferMana)) { - receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_MANA); - } else { - innerCheckExtraCastConditions(game, unit, cooldownRemaining, receiver); - } - } else { - if (cooldownRemaining > 0 && !(receiver instanceof MeleeUIAbilityActivationReceiver)) { - float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getAlias()) - * WarsmashConstants.SIMULATION_STEP_TIME; - receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, cooldownLengthDisplay); - } - receiver.useOk(); - } - } - - @Override - protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - return true; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveUnitTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveUnitTarget.java deleted file mode 100644 index 3daaa6b60..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveUnitTarget.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.ABBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -public class CAbilityAbilityBuilderActiveUnitTarget extends CAbilityAbilityBuilderGenericActive { - - private ABBehavior behavior; - - public CAbilityAbilityBuilderActiveUnitTarget(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, code, alias, levelData, config, localStore); - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - this.behavior = this.createRangedBehavior(unit); - super.onAdd(game, unit); - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - this.castId++; - this.behavior.setCastId(castId); - - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, target.visit(AbilityTargetVisitor.UNIT)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId, target.visit(AbilityTargetVisitor.ITEM)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId, target.visit(AbilityTargetVisitor.DESTRUCTABLE)); - this.runOnOrderIssuedActions(game, caster, orderId); - return this.behavior.reset(game, target); - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - return null; - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - return null; - } - - @Override - protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - return true; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - return true; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - - @Override - protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - return false; - } - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveUnitTargetSimple.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveUnitTargetSimple.java deleted file mode 100644 index fec1f5f66..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderActiveUnitTargetSimple.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.CAbilityTargetSpellBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; - -@Deprecated -public class CAbilityAbilityBuilderActiveUnitTargetSimple extends CAbilityTargetSpellBase { - - List levelData; - private AbilityBuilderConfiguration config; - private Map localStore; - private int orderId; - private int autoCastOnId = 0; - private int autoCastOffId = 0; - private boolean autocasting = false; - private boolean initialized; - - private int castId = 0; - - public CAbilityAbilityBuilderActiveUnitTargetSimple(int handleId, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, alias); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - orderId = OrderIdUtils.getOrderId(config.getCastId()); - if (config.getAutoCastOnId() != null) { - autoCastOnId = OrderIdUtils.getOrderId(config.getAutoCastOnId()); - } - if (config.getAutoCastOffId() != null) { - autoCastOffId = OrderIdUtils.getOrderId(config.getAutoCastOffId()); - } - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - } - - @Override - public void populateData(GameObject worldEditorAbility, int level) { - if (this.initialized) { - if (config.getOnLevelChange() != null) { - CSimulation game = (CSimulation) this.localStore.get(ABLocalStoreKeys.GAME); - CUnit unit = (CUnit) this.localStore.get(ABLocalStoreKeys.THISUNIT); - for (ABAction action : config.getOnLevelChange()) { - action.runAction(game, unit, this.localStore, castId); - } - } - } - this.initialized = true; - } - - @Override - public int getBaseOrderId() { - return this.orderId; - } - - public List getLevelData() { - return this.levelData; - } - - public AbilityBuilderConfiguration getConfig() { - return this.config; - } - - public Map getLocalStore() { - return this.localStore; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - super.onAdd(game, unit); - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public boolean doEffect(CSimulation simulation, CUnit unit, AbilityTarget target) { - this.castId++; - CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - if (targetUnit != null) { - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, targetUnit); - if (this.config.getOnBeginCasting() != null) { - for (ABAction action : this.config.getOnBeginCasting()) { - action.runAction(simulation, unit, this.localStore, castId); - } - } - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - } - return false; - } - - @Override - protected void innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - if (config.getExtraCastConditions() != null) { - boolean result = true; - for (ABCondition condition : config.getExtraCastConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.useOk(); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.activationCheckFailed(failReason); - } else { - receiver.unknownReasonUseNotOk(); - } - } - } else { - receiver.useOk(); - } - } - - @Override - protected void innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - if (target instanceof CUnit) { - final CUnit targetUnit = (CUnit) target; - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, targetUnit); - - if (this.config.getExtraTargetConditions() != null) { - boolean result = true; - for (ABCondition condition : config.getExtraTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, castId); - } - if (result) { - receiver.targetOk(targetUnit); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.targetCheckFailed(failReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); - } - } - } else { - receiver.targetOk(targetUnit); - } - } - } - - @Override - public int getAutoCastOnOrderId() { - return this.autoCastOnId; - } - - @Override - public int getAutoCastOffOrderId() { - return this.autoCastOffId; - } - - @Override - public boolean isAutoCastOn() { - return this.autocasting; - } - - @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { - this.autocasting = autoCastOn; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderGenericActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderGenericActive.java deleted file mode 100644 index d0a196217..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderGenericActive.java +++ /dev/null @@ -1,1069 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.mdx.Sequence; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens; -import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityCategory; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractGenericSingleIconNoSmartActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.ABBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderNoTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.ManaDepletedCheckTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.MeleeUIAbilityActivationReceiver; - -public abstract class CAbilityAbilityBuilderGenericActive extends AbstractGenericSingleIconNoSmartActiveAbility - implements AbilityBuilderActiveAbility { - protected List levelData; - protected AbilityBuilderConfiguration config; - protected Map localStore; - protected int orderId; - protected int unorderId = 0; - protected int autoCastOnId = 0; - protected int autoCastOffId = 0; - protected boolean autocasting = false; - protected AutocastType autocastType = AutocastType.NONE; - protected boolean toggleable = false; - protected boolean separateOnAndOff = false; - protected boolean active = false; - protected boolean allowCastlessDeactivate = true; - protected PrimaryTag castingPrimaryTag; - protected EnumSet castingSecondaryTags; - - protected CItem item = null; - - protected float cooldown = 0; - protected int manaCost = 0; - protected float area = 0; - protected float range = 0; - - protected boolean hideAreaCursor = false; - - protected int bufferMana = 0; - private ManaDepletedCheckTimer timer; - private NonStackingStatBuff manaDrain; - - protected int castId = 0; - private War3ID onTooltipOverride = null; - private War3ID offTooltipOverride = null; - private EnumSet targetsAllowed; - private boolean physical = false; - private boolean universal = false; - - public CAbilityAbilityBuilderGenericActive(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(handleId, code, alias); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - localStore.put(ABLocalStoreKeys.ABILITY, this); - - orderId = OrderIdUtils.getOrderId(config.getCastId()); - if (config.getUncastId() != null) { - unorderId = OrderIdUtils.getOrderId(config.getUncastId()); - } - if (config.getAutoCastOnId() != null) { - autoCastOnId = OrderIdUtils.getOrderId(config.getAutoCastOnId()); - } - if (config.getAutoCastOffId() != null) { - autoCastOffId = OrderIdUtils.getOrderId(config.getAutoCastOffId()); - } - if (config.getAutoCastType() != null) { - autocastType = config.getAutoCastType(); - } - - GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final String animNames = editorData.getField(AbilityFields.ANIM_NAMES); - final EnumSet primaryTags = EnumSet.noneOf(AnimationTokens.PrimaryTag.class); - this.castingSecondaryTags = EnumSet.noneOf(AnimationTokens.SecondaryTag.class); - Sequence.populateTags(primaryTags, this.castingSecondaryTags, animNames); - if (primaryTags.isEmpty()) { - this.castingPrimaryTag = null; - } else { - this.castingPrimaryTag = primaryTags.iterator().next(); - } - if (this.castingSecondaryTags.isEmpty()) { - this.castingSecondaryTags = SequenceUtils.SPELL; - } - } - - @Override - public int getAbilityIntField(String field) { - GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - return editorData.getFieldValue(field); - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - setSpellFields(game, unit); - determineToggleableFields(game, unit); - if (config.getOnLevelChange() != null) { - for (ABAction action : config.getOnLevelChange()) { - action.runAction(game, unit, this.localStore, castId); - } - } - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - setSpellFields(game, unit); - determineToggleableFields(game, unit); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public void onAddDisabled(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - setSpellFields(game, unit); - determineToggleableFields(game, unit); - if (config.getOnAddDisabledAbility() != null) { - for (ABAction action : config.getOnAddDisabledAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - - if (this.autocastType == AutocastType.ATTACKREPLACEMENT) { - //game.createProjectile(unit, offTooltipOverride, bufferMana, autoCastOnId, autoCastOffId, area, active, unit, null) - } - } - - @Override - public void onRemoveDisabled(CSimulation game, CUnit unit) { - if (config.getOnRemoveDisabledAbility() != null) { - for (ABAction action : config.getOnRemoveDisabledAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - private void determineToggleableFields(CSimulation game, CUnit unit) { - if (config.getDisplayFields() != null && config.getDisplayFields().getSeparateOnAndOff() != null) { - this.separateOnAndOff = config.getDisplayFields().getSeparateOnAndOff().callback(game, unit, localStore, - castId); - } - if (config.getDisplayFields() != null && config.getDisplayFields().getToggleable() != null) { - this.toggleable = config.getDisplayFields().getToggleable().callback(game, unit, localStore, castId); - } - if (config.getDisplayFields() != null && config.getDisplayFields().getCastToggleOff() != null) { - this.allowCastlessDeactivate = !config.getDisplayFields().getCastToggleOff().callback(game, unit, - localStore, castId); - } - if (toggleable && config.getDisplayFields() != null && config.getDisplayFields().getAlternateUnitId() != null) { - if (unit.getTypeId() - .equals(config.getDisplayFields().getAlternateUnitId().callback(game, unit, localStore, castId))) { - this.active = true; - } - } - if (config.getSpecialFields() != null && config.getSpecialFields().getBufferManaRequired() != null) { - this.bufferMana = config.getSpecialFields().getBufferManaRequired().callback(game, unit, localStore, - castId); - } - if (this.toggleable) { - localStore.put(ABLocalStoreKeys.TOGGLEDABILITY, this); - int manaPerSec = 0; - if (config.getSpecialFields() != null && config.getSpecialFields().getManaDrainedPerSecond() != null) { - manaPerSec = config.getSpecialFields().getManaDrainedPerSecond().callback(game, unit, localStore, - castId); - } - if (manaPerSec != 0) { - if (manaDrain == null) { - manaDrain = new NonStackingStatBuff(NonStackingStatBuffType.MPGEN, - NonStackingStatBuff.ALLOW_STACKING_KEY, (-1 * manaPerSec)); - } else { - manaDrain.setValue((-1 * manaPerSec)); - } - if (this.timer == null) { - timer = new ManaDepletedCheckTimer(unit, this); - } - } else { - this.manaDrain = null; - this.timer = null; - } - - if (config.getDisplayFields() != null && config.getDisplayFields().getAlternateUnitId() != null) { - if (unit.getTypeId().equals( - config.getDisplayFields().getAlternateUnitId().callback(game, unit, localStore, manaPerSec))) { - this.active = true; - } - } - } - } - - protected void setSpellFields(CSimulation game, CUnit unit) { - CAbilityTypeAbilityBuilderLevelData levelDataLevel = this.levelData.get(this.getLevel() - 1); - this.manaCost = levelDataLevel.getManaCost(); - this.cooldown = levelDataLevel.getCooldown(); - this.range = levelDataLevel.getCastRange(); - this.area = levelDataLevel.getArea(); - if (this.config.getOverrideFields() != null) { - if (this.config.getOverrideFields().getAreaOverride() != null) { - this.area = this.config.getOverrideFields().getAreaOverride().callback(game, unit, localStore, castId); - } - if (this.config.getOverrideFields().getRangeOverride() != null) { - this.range = this.config.getOverrideFields().getRangeOverride().callback(game, unit, localStore, - castId); - } - if (this.config.getOverrideFields().getCooldownOverride() != null) { - this.cooldown = this.config.getOverrideFields().getCooldownOverride().callback(game, unit, localStore, - castId); - } - if (this.config.getOverrideFields().getManaCostOverride() != null) { - this.manaCost = this.config.getOverrideFields().getManaCostOverride().callback(game, unit, localStore, - castId); - } - if (this.config.getOverrideFields().getAutocastTypeOverride() != null) { - this.autocastType = this.config.getOverrideFields().getAutocastTypeOverride().callback(game, unit, localStore, - castId); - } - - if (this.config.getOverrideFields().getOnTooltipOverride() != null) { - this.onTooltipOverride = this.config.getOverrideFields().getOnTooltipOverride().callback(game, unit, - localStore, castId); - } - if (this.config.getOverrideFields().getOffTooltipOverride() != null) { - this.offTooltipOverride = this.config.getOverrideFields().getOffTooltipOverride().callback(game, - unit, localStore, castId); - } - if (this.config.getOverrideFields().getPhysicalSpell() != null) { - this.physical = this.config.getOverrideFields().getPhysicalSpell().callback(game, - unit, localStore, castId); - } - if (this.config.getOverrideFields().getUniversalSpell() != null) { - this.universal = this.config.getOverrideFields().getUniversalSpell().callback(game, - unit, localStore, castId); - } - } - - GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final int requiredLevel = editorData.getFieldAsInteger(AbilityFields.REQUIRED_LEVEL, 0); - this.targetsAllowed = levelDataLevel.getTargetsAllowed(); - if ((requiredLevel < 6 || game.getGameplayConstants().isMagicImmuneResistsUltimates()) && !isPhysical() && !isUniversal()) { - this.targetsAllowed.add(CTargetType.NON_MAGIC_IMMUNE); - } - if (isPhysical() && !isUniversal()) { - this.targetsAllowed.add(CTargetType.NON_ETHEREAL); - } - - if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getHideAreaCursor() != null) { - this.hideAreaCursor = this.config.getDisplayFields().getHideAreaCursor().callback(game, unit, localStore, - this.getLevel()); - } - } - - @Override - public void startCooldown(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - unit.beginCooldown(game, cdID, this.cooldown); - } - } - - @Override - public float getCooldownRemainingTicks(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - return unit.getCooldownRemainingTicks(game, cdID); - } - return unit.getCooldownRemainingTicks(game, this.getCode()); - } - - @Override - public void resetCooldown(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - unit.beginCooldown(game, cdID, 0); - } - } - - private War3ID getCooldownId() { - if (this.item != null) { - if (item.getItemType().isIgnoreCooldown()) { - return War3ID.NONE; - } else { - if (item.getItemType().getCooldownGroup() != null) { - return item.getItemType().getCooldownGroup(); - } - } - } - return getCode(); - } - - @Override - public void setItemAbility(final CItem item, int slot) { - this.item = item; - this.localStore.put(ABLocalStoreKeys.ITEM, item); - this.localStore.put(ABLocalStoreKeys.ITEMSLOT, slot); - } - - @Override - public CItem getItem() { - return this.item; - } - - @Override - public int getBaseOrderId() { - return this.orderId; - } - - @Override - public int getOffOrderId() { - return this.unorderId; - } - - public PrimaryTag getCastingPrimaryTag() { - return this.castingPrimaryTag; - } - - public EnumSet getCastingSecondaryTags() { - return this.castingSecondaryTags; - } - - public List getLevelData() { - return this.levelData; - } - - public AbilityBuilderConfiguration getConfig() { - return this.config; - } - - public Map getLocalStore() { - return this.localStore; - } - - @Override - public War3ID getOnTooltipOverride() { - return onTooltipOverride; - } - - @Override - public War3ID getOffTooltipOverride() { - return offTooltipOverride; - } - - @Override - public int getUIManaCost() { - return (this.toggleable && this.active && this.allowCastlessDeactivate) ? 0 : this.manaCost + this.bufferMana; - } - - @Override - public int getChargedManaCost() { - return this.manaCost; - } - - @Override - public float getUIAreaOfEffect() { - return (this.area == 0 || this.hideAreaCursor) ? Float.NaN : this.area; - } - - public float getCooldown() { - return cooldown; - } - - public float getArea() { - return area; - } - - public float getCastRange() { - return range; - } - - public void setCastRange(float range) { - this.range = range; - } - - @Override - public boolean isSeparateOnAndOff() { - return separateOnAndOff; - } - - @Override - public boolean isToggleOn() { - return this.toggleable && this.active; - } - - @Override - public int getAutoCastOnOrderId() { - return this.autoCastOnId; - } - - @Override - public int getAutoCastOffOrderId() { - return this.autoCastOffId; - } - - @Override - public boolean isAutoCastOn() { - return this.autocasting; - } - - @Override - public void setAutoCastOn(final CUnit caster, final boolean autoCastOn) { - this.autocasting = autoCastOn; - if (this.autocastType == AutocastType.ATTACKREPLACEMENT) { - //caster.addAttackReplacement(null, CUnitAttackReplacementPriority.AUTOCAST); - } - caster.setAutocastAbility(autoCastOn ? this : null); - } - - @Override - public void setAutoCastOff() { - this.autocasting = false; - } - - @Override - public AutocastType getAutocastType() { - return autocastType; - } - - protected ABBehavior createNoTargetBehavior(CUnit unit) { - ABBehavior beh = new CBehaviorAbilityBuilderNoTarget(unit, localStore, this); - if (this.item != null - || (this.config.getDisplayFields() != null && this.config.getDisplayFields().getInstantCast() != null - && this.config.getDisplayFields().getInstantCast().callback(null, unit, localStore, castId))) { - beh.setInstant(true); - } - if (this.config.getSpecialFields() != null && this.config.getSpecialFields().getBehaviorCategory() != null) { - beh.setBehaviorCategory(this.config.getSpecialFields().getBehaviorCategory()); - } - return beh; - } - - protected ABBehavior createRangedBehavior(CUnit unit) { - ABBehavior beh = new CBehaviorAbilityBuilderBase(unit, localStore, this); - if (this.item != null - || (this.config.getDisplayFields() != null && this.config.getDisplayFields().getInstantCast() != null - && this.config.getDisplayFields().getInstantCast().callback(null, unit, localStore, castId))) { - beh.setInstant(true); - } - if (this.config.getSpecialFields() != null && this.config.getSpecialFields().getBehaviorCategory() != null) { - beh.setBehaviorCategory(this.config.getSpecialFields().getBehaviorCategory()); - } - return beh; - } - - @Override - protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final int orderId, - final AbilityActivationReceiver receiver) { - if ((orderId != 0) && ((orderId == getAutoCastOffOrderId()) || (orderId == getAutoCastOnOrderId()))) { - receiver.useOk(); - return; - } - final int cooldownRemaining = unit.getCooldownRemainingTicks(game, getCooldownId()); - - if (this.toggleable && this.active && this.allowCastlessDeactivate) { - if (cooldownRemaining > 0 && !(receiver instanceof MeleeUIAbilityActivationReceiver)) { - float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) - * WarsmashConstants.SIMULATION_STEP_TIME; - receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, - cooldownLengthDisplay); - } - receiver.useOk(); - } else { - if (cooldownRemaining > 0) { - float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) - * WarsmashConstants.SIMULATION_STEP_TIME; - receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, - cooldownLengthDisplay); - } else if (unit.getMana() < (this.manaCost + this.bufferMana)) { - receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_MANA); - } else { - CPlayer p = game.getPlayer(unit.getPlayerIndex()); - if (this.getUIGoldCost() > p.getGold()) { - receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_GOLD); - } else if (this.getUILumberCost() > p.getLumber()) { - receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_LUMBER); - } else if (this.getUIFoodCost() > 0 && this.getUIFoodCost() > p.getFoodCap() - p.getFoodUsed()) { - receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_FOOD); - } else { - innerCheckExtraCastConditions(game, unit, orderId, receiver); - } - } - } - } - - protected void innerCheckExtraCastConditions(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver) { - if (innerCheckCanUseSpell(game, unit, orderId, receiver)) { - if (config.getExtraCastConditions() != null) { - boolean result = true; - for (ABCondition condition : config.getExtraCastConditions()) { - result = result && condition.evaluate(game, unit, localStore, -1); - } - if (result) { - receiver.useOk(); - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - receiver.activationCheckFailed(failReason); - } else { - receiver.unknownReasonUseNotOk(); - } - } - } else { - receiver.useOk(); - } - } - } - - protected abstract boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, - AbilityActivationReceiver receiver); - - @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { - if (innerCheckCastOrderId(game, unit, orderId)) { - innerCheckCanTarget(game, unit, orderId, target, receiver); - } else if (orderId == OrderIds.smart) { - innerCheckCanSmartTarget(game, unit, orderId, target, receiver); - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - public void checkCanAutoTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { - if (orderId == getBaseOrderId()) { - if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { - if (innerCheckTargetTargetable(game, unit, target, receiver)) { - if (innerCheckTargetInRange(unit, target)) { - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + -1, - target.visit(AbilityTargetVisitor.UNIT)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDITEM + -1, - target.visit(AbilityTargetVisitor.ITEM)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + -1, - target.visit(AbilityTargetVisitor.DESTRUCTABLE)); - String extraFailReason = innerCheckExtraAutoTargetConditions(game, unit, orderId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDUNIT + -1); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDITEM + -1); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + -1); - if (extraFailReason != null) { - if (!extraFailReason.equals("unknown")) { - receiver.targetCheckFailed(extraFailReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); - } - } else { - receiver.targetOk(target); - } - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); - } - } - } - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { - if (innerCheckCastOrderId(game, unit, orderId)) { - innerCheckCanTarget(game, unit, orderId, target, receiver); - } else if (orderId == OrderIds.smart) { - innerCheckCanSmartTarget(game, unit, orderId, target, receiver); - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - public void checkCanAutoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { - if (orderId == getBaseOrderId()) { - if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { - if (innerCheckTargetInRange(unit, target)) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + -1, target); - String extraFailReason = innerCheckExtraAutoTargetConditions(game, unit, orderId); - localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + -1); - if (extraFailReason != null) { - if (!extraFailReason.equals("unknown")) { - receiver.targetCheckFailed(extraFailReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THERE); - } - } else { - receiver.targetOk(target); - } - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); - } - } - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { - if ((orderId != 0) && ((orderId == getAutoCastOffOrderId()) || (orderId == getAutoCastOnOrderId()))) { - receiver.targetOk(null); - } else if (innerCheckCastOrderId(game, unit, orderId)) { - innerCheckCanTargetNoTarget(game, unit, orderId, receiver); - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - public void checkCanAutoTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { - if (orderId == getBaseOrderId()) { - if (innerCheckCanTargetSpell(game, unit, orderId, receiver)) { - String extraFailReason = innerCheckExtraAutoNoTargetConditions(game, unit, orderId, receiver); - if (extraFailReason != null) { - if (!extraFailReason.equals("unknown")) { - receiver.targetCheckFailed(extraFailReason); - } else { - receiver.orderIdNotAccepted(); - } - } else { - receiver.targetOk(null); - } - } - } else { - receiver.orderIdNotAccepted(); - } - } - - @Override - protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { - if (innerCheckTargetInRange(unit, target)) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + -1, target); - String extraFailReason = innerCheckExtraTargetConditions(game, unit, orderId); - localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + -1); - if (extraFailReason != null) { - if (!extraFailReason.equals("unknown")) { - receiver.targetCheckFailed(extraFailReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THERE); - } - } else { - receiver.targetOk(target); - } - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); - } - } - } - - @Override - protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { - if (innerCheckTargetTargetable(game, unit, target, receiver)) { - if (innerCheckTargetInRange(unit, target)) { - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + -1, - target.visit(AbilityTargetVisitor.UNIT)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDITEM + -1, - target.visit(AbilityTargetVisitor.ITEM)); - this.localStore.put(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + -1, - target.visit(AbilityTargetVisitor.DESTRUCTABLE)); - String extraFailReason = innerCheckExtraTargetConditions(game, unit, orderId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDUNIT + -1); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDITEM + -1); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + -1); - if (extraFailReason != null) { - if (!extraFailReason.equals("unknown")) { - receiver.targetCheckFailed(extraFailReason); - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); - } - } else { - receiver.targetOk(target); - } - } else { - receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); - } - } - } - } - - @Override - protected void innerCheckCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - if (innerCheckCanTargetSpell(game, unit, orderId, receiver)) { - receiver.targetOk(null); - } - } - - protected boolean innerCheckCastOrderId(final CSimulation game, final CUnit unit, final int orderId) { - return (!this.active && orderId == getBaseOrderId()) - || ((this.active || this.separateOnAndOff) && orderId == getOffOrderId()); - } - - protected boolean innerCheckTargetTargetable(CSimulation game, CUnit unit, CWidget target, final AbilityTargetCheckReceiver receiver) { - return target.canBeTargetedBy(game, unit, targetsAllowed, receiver); - } - - protected boolean innerCheckTargetInRange(CUnit unit, AbilityTarget target) { - return !unit.isMovementDisabled() || unit.canReach(target, this.getCastRange()); - } - - protected String innerCheckExtraTargetConditions(CSimulation game, CUnit unit, int orderId) { - if (config.getExtraTargetConditions() != null) { - boolean result = true; - for (ABCondition condition : config.getExtraTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, -1); - } - if (result) { - return null; - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - return failReason; - } else { - return "unknown"; - } - } - } else { - return null; - } - } - - protected String innerCheckExtraAutoTargetConditions(CSimulation game, CUnit unit, int orderId) { - if (config.getExtraTargetConditions() != null || config.getExtraAutoTargetConditions() != null) { - boolean result = true; - if (config.getExtraTargetConditions() != null) { - for (ABCondition condition : config.getExtraTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, -1); - } - } - if (config.getExtraAutoTargetConditions() != null) { - for (ABCondition condition : config.getExtraAutoTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, -1); - } - } - if (result) { - return null; - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - return failReason; - } else { - return "unknown"; - } - } - } else { - return null; - } - } - - protected String innerCheckExtraAutoNoTargetConditions(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - if (config.getExtraAutoNoTargetConditions() != null) { - boolean result = true; - if (config.getExtraAutoNoTargetConditions() != null) { - for (ABCondition condition : config.getExtraAutoNoTargetConditions()) { - result = result && condition.evaluate(game, unit, localStore, -1); - } - } - if (result) { - return null; - } else { - String failReason = (String) localStore.get(ABLocalStoreKeys.CANTUSEREASON); - if (failReason != null) { - return failReason; - } else { - return "unknown"; - } - } - } else { - return null; - } - } - - protected abstract boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver); - - protected abstract boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityPointTarget target, AbilityTargetCheckReceiver receiver); - - protected abstract boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver); - - @Override - public int getUIFoodCost() { - if (this.toggleable && this.active && this.allowCastlessDeactivate) { - return 0; - } - if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getFoodCost() != null) { - CSimulation game = (CSimulation) this.localStore.get(ABLocalStoreKeys.GAME); - CUnit unit = (CUnit) this.localStore.get(ABLocalStoreKeys.THISUNIT); - return this.config.getDisplayFields().getFoodCost().callback(game, unit, localStore, castId); - } - return 0; - } - - @Override - public int getUIGoldCost() { - if (this.toggleable && this.active && this.allowCastlessDeactivate) { - return 0; - } - if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getGoldCost() != null) { - CSimulation game = (CSimulation) this.localStore.get(ABLocalStoreKeys.GAME); - CUnit unit = (CUnit) this.localStore.get(ABLocalStoreKeys.THISUNIT); - return this.config.getDisplayFields().getGoldCost().callback(game, unit, localStore, castId); - } - return 0; - } - - @Override - public int getUILumberCost() { - if (this.toggleable && this.active && this.allowCastlessDeactivate) { - return 0; - } - if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getLumberCost() != null) { - CSimulation game = (CSimulation) this.localStore.get(ABLocalStoreKeys.GAME); - CUnit unit = (CUnit) this.localStore.get(ABLocalStoreKeys.THISUNIT); - return this.config.getDisplayFields().getLumberCost().callback(game, unit, localStore, castId); - } - return 0; - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - if (this.toggleable && this.active) { - deactivate(game, unit); - } - if (config.getOnRemoveAbility() != null) { - for (ABAction action : config.getOnRemoveAbility()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - if (this.toggleable && this.active) { - deactivate(game, unit); - } - if (config.getOnDeathPreCast() != null) { - for (ABAction action : config.getOnDeathPreCast()) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - public void runOnOrderIssuedActions(final CSimulation game, final CUnit caster, int orderId) { - if (config.getOnOrderIssued() != null) { - for (ABAction action : config.getOnOrderIssued()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void runBeginCastingActions(final CSimulation game, final CUnit caster, int orderId) { - if (config.getOnBeginCasting() != null) { - for (ABAction action : config.getOnBeginCasting()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void runEndCastingActions(final CSimulation game, final CUnit caster, int orderId) { - if (config.getOnEndCasting() != null) { - for (ABAction action : config.getOnEndCasting()) { - action.runAction(game, caster, localStore, castId); - } - } - if (this.toggleable) { - if (orderId == this.getBaseOrderId()) { - this.activate(game, caster); - } - if (orderId == this.getOffOrderId()) { - this.deactivate(game, caster); - } - } - } - - @Override - public void runChannelTickActions(final CSimulation game, final CUnit caster, int orderId) { - if (config.getOnChannelTick() != null) { - for (ABAction action : config.getOnChannelTick()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void runEndChannelActions(final CSimulation game, final CUnit caster, int orderId) { - if (config.getOnEndChannel() != null) { - for (ABAction action : config.getOnEndChannel()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void runCancelPreCastActions(final CSimulation game, final CUnit caster, int orderId) { - if (config.getOnCancelPreCast() != null) { - for (ABAction action : config.getOnCancelPreCast()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void activate(final CSimulation game, final CUnit caster) { - Boolean failed = (Boolean) this.localStore.get(ABLocalStoreKeys.FAILEDTOCAST + castId); - if (failed != null && failed) { - System.err.println("Failed to cast!"); - return; - } -// System.err.println("Activating!"); - this.active = true; - if (this.manaDrain != null) { - this.timer.start(game); - caster.addNonStackingStatBuff(manaDrain); - } - if (config.getOnActivate() != null) { - for (ABAction action : config.getOnActivate()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void deactivate(final CSimulation game, final CUnit caster) { - Boolean failed = (Boolean) this.localStore.get(ABLocalStoreKeys.FAILEDTOCAST + castId); - if (failed != null && failed) { - System.err.println("Failed to cast!"); - return; - } -// System.err.println("Deactivating!"); - this.active = false; - if (this.manaDrain != null) { - timer.pause(game); - caster.removeNonStackingStatBuff(manaDrain); - } - if (config.getOnDeactivate() != null) { - for (ABAction action : config.getOnDeactivate()) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, - final AbilityTarget target) { -// System.err.println("Checking queue top level: " + active + " orderID : " + orderId + " offID: " + this.getOffOrderId()); - if (this.allowCastlessDeactivate && this.toggleable && this.active && orderId == this.getOffOrderId()) { - this.deactivate(game, caster); - return false; - } - return super.checkBeforeQueue(game, caster, orderId, target); - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - - } - - @Override - public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) { - - } - - @Override - public T visit(final CAbilityVisitor visitor) { - return visitor.accept(this); - } - - @Override - public void checkRequirementsMet(CSimulation game, CUnit unit, AbilityActivationReceiver receiver) { - List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); - CPlayer player = game.getPlayer(unit.getPlayerIndex()); - if (reqs != null) { - for (final CUnitTypeRequirement requirement : reqs) { -// System.err.println("Checking reqs for " + this.getAlias() + ": looking for " -// + requirement.getRequirement() + " at amount " + requirement.getRequiredLevel() + " and found " -// + player.getTechtreeUnlocked(requirement.getRequirement())); - if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { - receiver.missingRequirement(requirement.getRequirement(), requirement.getRequiredLevel()); - } - } - } - } - - @Override - public boolean isRequirementsMet(CSimulation game, CUnit unit) { - List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); - CPlayer player = game.getPlayer(unit.getPlayerIndex()); - boolean requirementsMet = player.isTechtreeAllowedByMax(this.getAlias()); - if (reqs != null) { - for (final CUnitTypeRequirement requirement : reqs) { -// System.err.println("Checking reqs for " + this.getAlias() + ": looking for " -// + requirement.getRequirement() + " at amount " + requirement.getRequiredLevel() + " and found " -// + player.getTechtreeUnlocked(requirement.getRequirement())); - if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { - requirementsMet = false; - } - } - } -// System.err.println("Returning "+requirementsMet+" for " + this.getAlias()); - return requirementsMet; - } - - @Override - public boolean isPhysical() { - return physical; - } - - @Override - public boolean isUniversal() { - return universal; - } - - @Override - public CAbilityCategory getAbilityCategory() { - return CAbilityCategory.SPELL; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderNoIcon.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderNoIcon.java deleted file mode 100644 index 0662efec0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderNoIcon.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractGenericNoIconAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -public class CAbilityAbilityBuilderNoIcon extends AbstractGenericNoIconAbility implements AbilityBuilderPassiveAbility { - - protected List levelData; - protected AbilityBuilderConfiguration config; - protected Map localStore; - - protected CItem item = null; - - protected float cooldown = 0; - protected float area = 0; - protected float range = 0; - - public CAbilityAbilityBuilderNoIcon(int handleId, War3ID code, War3ID alias, List levelData, - AbilityBuilderConfiguration config, Map localStore) { - super(handleId, code, alias); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - localStore.put(ABLocalStoreKeys.ABILITY, this); - } - - protected void setSpellFields(CSimulation game, CUnit unit) { - CAbilityTypeAbilityBuilderLevelData levelDataLevel = this.levelData.get(this.getLevel() - 1); - this.cooldown = levelDataLevel.getCooldown(); - this.area = levelDataLevel.getArea(); - this.range = levelDataLevel.getCastRange(); - if (this.config.getOverrideFields() != null) { - if (this.config.getOverrideFields().getAreaOverride() != null) { - this.area = this.config.getOverrideFields().getAreaOverride().callback(game, unit, localStore, 0); - } - if (this.config.getOverrideFields().getRangeOverride() != null) { - this.range = this.config.getOverrideFields().getRangeOverride().callback(game, unit, localStore, - 0); - } - if (this.config.getOverrideFields().getCooldownOverride() != null) { - this.cooldown = this.config.getOverrideFields().getCooldownOverride().callback(game, unit, localStore, - 0); - } - } - } - - @Override - public int getAbilityIntField(String field) { - GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - return editorData.getFieldValue(field); - } - - @Override - public List getLevelData() { - return this.levelData; - } - - @Override - public AbilityBuilderConfiguration getConfig() { - return this.config; - } - - @Override - public Map getLocalStore() { - return this.localStore; - } - - @Override - public float getArea() { - return area; - } - - @Override - public float getCastRange() { - return range; - } - - @Override - public float getCooldown() { - return cooldown; - } - - @Override - public void startCooldown(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - unit.beginCooldown(game, cdID, this.cooldown); - } - } - - @Override - public float getCooldownRemainingTicks(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - return unit.getCooldownRemainingTicks(game, cdID); - } - return unit.getCooldownRemainingTicks(game, this.getCode()); - } - - @Override - public void resetCooldown(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - unit.beginCooldown(game, cdID, 0); - } - } - - private War3ID getCooldownId() { - if (this.item != null) { - if (item.getItemType().isIgnoreCooldown()) { - return War3ID.NONE; - } else { - if (item.getItemType().getCooldownGroup() != null) { - return item.getItemType().getCooldownGroup(); - } - } - } - return getCode(); - } - - @Override - public void setItemAbility(final CItem item, int slot) { - this.item = item; - this.localStore.put(ABLocalStoreKeys.ITEM, item); - this.localStore.put(ABLocalStoreKeys.ITEMSLOT, slot); - } - - @Override - public CItem getItem() { - return this.item; - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - setSpellFields(game, unit); - if (config.getOnLevelChange() != null) { - for (ABAction action : config.getOnLevelChange()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onAddDisabled(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - setSpellFields(game, unit); - if (config.getOnAddDisabledAbility() != null) { - for (ABAction action : config.getOnAddDisabledAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - if (config.getOnRemoveAbility() != null) { - for (ABAction action : config.getOnRemoveAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onRemoveDisabled(CSimulation game, CUnit unit) { - if (config.getOnRemoveDisabledAbility() != null) { - for (ABAction action : config.getOnRemoveDisabledAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - if (config.getOnDeathPreCast() != null) { - for (ABAction action : config.getOnDeathPreCast()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public T visit(final CAbilityVisitor visitor) { - return visitor.accept(this); - } - - @Override - public void checkRequirementsMet(CSimulation game, CUnit unit, AbilityActivationReceiver receiver) { - List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); - CPlayer player = game.getPlayer(unit.getPlayerIndex()); - if (reqs != null) { - for (final CUnitTypeRequirement requirement : reqs) { - if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { - receiver.missingRequirement(requirement.getRequirement(), requirement.getRequiredLevel()); - } - } - } - } - - @Override - public boolean isRequirementsMet(CSimulation game, CUnit unit) { - List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); - CPlayer player = game.getPlayer(unit.getPlayerIndex()); - boolean requirementsMet = player.isTechtreeAllowedByMax(this.getAlias()); - if (reqs != null) { - for (final CUnitTypeRequirement requirement : reqs) { - if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { - requirementsMet = false; - } - } - } - return requirementsMet; - } - - - - - - - // Unneeded Methods - @Override - public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) { - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, CWidget target) { - return null; - } - - @Override - public CBehavior begin(CSimulation game, CUnit caster, int orderId, AbilityPointTarget point) { - return null; - } - - @Override - public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId) { - return null; - } - - @Override - protected void innerCheckCanUse(CSimulation game, CUnit unit, int orderId, AbilityActivationReceiver receiver) { - receiver.notAnActiveAbility(); - } - - @Override - public void checkCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - } - - @Override - public void checkCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - } - - @Override - public void checkCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, - AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - } - - @Override - public War3ID getOnTooltipOverride() { - return null; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderPassive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderPassive.java deleted file mode 100644 index e0c52f219..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/CAbilityAbilityBuilderPassive.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; - -public class CAbilityAbilityBuilderPassive extends AbilityGenericSingleIconPassiveAbility implements AbilityBuilderPassiveAbility { - - protected List levelData; - protected AbilityBuilderConfiguration config; - protected Map localStore; - - protected CItem item = null; - - protected float cooldown = 0; - protected float area = 0; - protected float range = 0; - - private War3ID onTooltipOverride = null; - - public CAbilityAbilityBuilderPassive(int handleId, War3ID code, War3ID alias, - List levelData, AbilityBuilderConfiguration config, - Map localStore) { - super(code, alias, handleId); - this.levelData = levelData; - this.config = config; - this.localStore = localStore; - localStore.put(ABLocalStoreKeys.ABILITY, this); - } - - protected void setSpellFields(CSimulation game, CUnit unit) { - if (this.levelData.size() > 0) { - CAbilityTypeAbilityBuilderLevelData levelDataLevel = this.levelData.get(this.getLevel() - 1); - this.cooldown = levelDataLevel.getCooldown(); - this.area = levelDataLevel.getArea(); - this.range = levelDataLevel.getCastRange(); - } - if (this.config.getOverrideFields() != null) { - if (this.config.getOverrideFields().getAreaOverride() != null) { - this.area = this.config.getOverrideFields().getAreaOverride().callback(game, unit, localStore, 0); - } - if (this.config.getOverrideFields().getRangeOverride() != null) { - this.range = this.config.getOverrideFields().getRangeOverride().callback(game, unit, localStore, - 0); - } - if (this.config.getOverrideFields().getCooldownOverride() != null) { - this.cooldown = this.config.getOverrideFields().getCooldownOverride().callback(game, unit, localStore, - 0); - } - if (this.config.getOverrideFields().getOnTooltipOverride() != null) { - this.onTooltipOverride = this.config.getOverrideFields().getOnTooltipOverride().callback(game, unit, - localStore, 0); - } - } - } - - @Override - public int getAbilityIntField(String field) { - GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - return editorData.getFieldValue(field); - } - - @Override - public List getLevelData() { - return this.levelData; - } - - @Override - public AbilityBuilderConfiguration getConfig() { - return this.config; - } - - @Override - public Map getLocalStore() { - return this.localStore; - } - - @Override - public float getArea() { - return area; - } - - @Override - public float getCastRange() { - return range; - } - - @Override - public float getCooldown() { - return cooldown; - } - - @Override - public void startCooldown(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - unit.beginCooldown(game, cdID, this.cooldown); - } - } - - @Override - public float getCooldownRemainingTicks(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - return unit.getCooldownRemainingTicks(game, cdID); - } - return unit.getCooldownRemainingTicks(game, this.getCode()); - } - - @Override - public void resetCooldown(CSimulation game, CUnit unit) { - War3ID cdID = getCooldownId(); - if (cdID != War3ID.NONE) { - unit.beginCooldown(game, cdID, 0); - } - } - - private War3ID getCooldownId() { - if (this.item != null) { - if (item.getItemType().isIgnoreCooldown()) { - return War3ID.NONE; - } else { - if (item.getItemType().getCooldownGroup() != null) { - return item.getItemType().getCooldownGroup(); - } - } - } - return getCode(); - } - - @Override - public void setItemAbility(final CItem item, int slot) { - this.item = item; - this.localStore.put(ABLocalStoreKeys.ITEM, item); - this.localStore.put(ABLocalStoreKeys.ITEMSLOT, slot); - } - - @Override - public CItem getItem() { - return this.item; - } - - @Override - public War3ID getOnTooltipOverride() { - return onTooltipOverride; - } - - - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - setSpellFields(game, unit); - if (config.getOnLevelChange() != null) { - for (ABAction action : config.getOnLevelChange()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - if (config.getOnAddAbility() != null) { - for (ABAction action : config.getOnAddAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onAddDisabled(CSimulation game, CUnit unit) { - localStore.put(ABLocalStoreKeys.GAME, game); - localStore.put(ABLocalStoreKeys.THISUNIT, unit); - setSpellFields(game, unit); - if (config.getOnAddDisabledAbility() != null) { - for (ABAction action : config.getOnAddDisabledAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - if (config.getOnRemoveAbility() != null) { - for (ABAction action : config.getOnRemoveAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onRemoveDisabled(CSimulation game, CUnit unit) { - if (config.getOnRemoveDisabledAbility() != null) { - for (ABAction action : config.getOnRemoveDisabledAbility()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - if (config.getOnDeathPreCast() != null) { - for (ABAction action : config.getOnDeathPreCast()) { - action.runAction(game, unit, localStore, 0); - } - } - } - - @Override - public T visit(final CAbilityVisitor visitor) { - return visitor.accept(this); - } - - @Override - public void checkRequirementsMet(CSimulation game, CUnit unit, AbilityActivationReceiver receiver) { - if (this.levelData.size() > 0) { - List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); - CPlayer player = game.getPlayer(unit.getPlayerIndex()); - if (reqs != null) { - for (final CUnitTypeRequirement requirement : reqs) { - if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { - receiver.missingRequirement(requirement.getRequirement(), requirement.getRequiredLevel()); - } - } - } - } - } - - @Override - public boolean isRequirementsMet(CSimulation game, CUnit unit) { - if (this.levelData.size() > 0) { - List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); - CPlayer player = game.getPlayer(unit.getPlayerIndex()); - boolean requirementsMet = player.isTechtreeAllowedByMax(this.getAlias()); - if (reqs != null) { - for (final CUnitTypeRequirement requirement : reqs) { - if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { - requirementsMet = false; - } - } - } - return requirementsMet; - } - return true; - } - - @Override - protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final int orderId, - final AbilityActivationReceiver receiver) { - final int cooldownRemaining = unit.getCooldownRemainingTicks(game, getCooldownId()); - - if (cooldownRemaining > 0) { - float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) - * WarsmashConstants.SIMULATION_STEP_TIME; - receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, - cooldownLengthDisplay); - } - - super.innerCheckCanUse(game, unit, orderId, receiver); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/GetABAbilityByRawcodeVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/GetABAbilityByRawcodeVisitor.java deleted file mode 100644 index 57383a7a7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/GetABAbilityByRawcodeVisitor.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityAttack; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityGenericDoNothing; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityMove; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityBuildInProgress; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityHumanBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNagaBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNeutralBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNightElfBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityOrcBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityUndeadBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.combat.CAbilityColdArrows; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityReturnResources; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.hero.CAbilityHero; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilityNeutralBuilding; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilitySellItems; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.jass.CAbilityJass; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.nightelf.root.CAbilityRoot; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityQueue; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; - -public class GetABAbilityByRawcodeVisitor implements CAbilityVisitor { - private static final GetABAbilityByRawcodeVisitor INSTANCE = new GetABAbilityByRawcodeVisitor(); - - public static GetABAbilityByRawcodeVisitor getInstance() { - return INSTANCE; - } - - private War3ID rawcode; - - public GetABAbilityByRawcodeVisitor reset(final War3ID rawcode) { - this.rawcode = rawcode; - return this; - } - - @Override - public AbilityBuilderAbility accept(final AbilityBuilderActiveAbility ability) { - if (this.rawcode.equals(ability.getAlias())) { - return (AbilityBuilderAbility) ability; - } - return null; - } - - @Override - public AbilityBuilderAbility accept(final GenericSingleIconActiveAbility ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(GenericSingleIconPassiveAbility ability) { - if (ability instanceof AbilityBuilderAbility && this.rawcode.equals(ability.getAlias())) { - return (AbilityBuilderAbility) ability; - } - return null; - } - - @Override - public AbilityBuilderAbility accept(final GenericNoIconAbility ability) { - if (ability instanceof AbilityBuilderAbility && this.rawcode.equals(ability.getAlias())) { - return (AbilityBuilderAbility) ability; - } - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityAttack ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityMove ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityOrcBuild ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityHumanBuild ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityUndeadBuild ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityNightElfBuild ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityGenericDoNothing ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityColdArrows ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityNagaBuild ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityNeutralBuild ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityBuildInProgress ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityQueue ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilitySellItems ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityUpgrade ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityReviveHero ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityRoot ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityRally ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CBuff ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityReturnResources ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityHero ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityJass ability) { - return null; - } - - @Override - public AbilityBuilderAbility accept(final CAbilityNeutralBuilding ability) { - return null; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/GetInstantTransformationBuffVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/GetInstantTransformationBuffVisitor.java deleted file mode 100644 index 42f35ae2c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/GetInstantTransformationBuffVisitor.java +++ /dev/null @@ -1,209 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityAttack; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityGenericDoNothing; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityMove; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityBuildInProgress; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityHumanBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNagaBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNeutralBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNightElfBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityOrcBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityUndeadBuild; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.combat.CAbilityColdArrows; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityReturnResources; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.hero.CAbilityHero; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilityNeutralBuilding; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilitySellItems; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.jass.CAbilityJass; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.nightelf.root.CAbilityRoot; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityQueue; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedInstantTransformationBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTransformationBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; - -public class GetInstantTransformationBuffVisitor implements CAbilityVisitor { - private static final GetInstantTransformationBuffVisitor INSTANCE = new GetInstantTransformationBuffVisitor(); - - public static GetInstantTransformationBuffVisitor getInstance() { - return INSTANCE; - } - - private CSimulation game; - private Map localStore; - private CUnitType newType; - private OnTransformationActions actions; - private War3ID buffId; - private boolean addAlternateTagAfter; - private float transformationTime; - private float duration; - private boolean permanent; - - public GetInstantTransformationBuffVisitor reset(CSimulation game, Map localStore, - CUnitType newType, OnTransformationActions actions, War3ID buffId, boolean addAlternateTagAfter, - float transformationTime, float duration, boolean permanent) { - this.game = game; - this.localStore = localStore; - this.newType = newType; - this.actions = actions; - this.buffId = buffId; - this.addAlternateTagAfter = addAlternateTagAfter; - this.transformationTime = transformationTime; - this.duration = duration; - this.permanent = permanent; - return this; - } - - @Override - public ABBuff accept(final AbilityBuilderActiveAbility ability) { - return new ABTimedTransformationBuff(game.getHandleIdAllocator().createId(), localStore, actions, - buffId == null ? ability.getAlias() : buffId, duration, ability, newType, !addAlternateTagAfter, - permanent, transformationTime); - } - - @Override - public ABBuff accept(final GenericSingleIconActiveAbility ability) { - return null; - } - - @Override - public ABBuff accept(GenericSingleIconPassiveAbility ability) { - if (ability instanceof AbilityBuilderPassiveAbility) { - return new ABTimedInstantTransformationBuff(game.getHandleIdAllocator().createId(), localStore, actions, - buffId == null ? ability.getAlias() : buffId, duration, (AbilityBuilderPassiveAbility)ability, newType, !addAlternateTagAfter, - permanent, transformationTime); - } - return null; - } - - @Override - public ABBuff accept(final GenericNoIconAbility ability) { - if (ability instanceof AbilityBuilderPassiveAbility) { - return new ABTimedInstantTransformationBuff(game.getHandleIdAllocator().createId(), localStore, actions, - buffId == null ? ability.getAlias() : buffId, duration, (AbilityBuilderPassiveAbility)ability, newType, !addAlternateTagAfter, - permanent, transformationTime); - } - return null; - } - - @Override - public ABBuff accept(final CAbilityAttack ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityMove ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityOrcBuild ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityHumanBuild ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityUndeadBuild ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityNightElfBuild ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityGenericDoNothing ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityColdArrows ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityNagaBuild ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityNeutralBuild ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityBuildInProgress ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityQueue ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilitySellItems ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityUpgrade ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityReviveHero ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityRoot ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityRally ability) { - return null; - } - - @Override - public ABBuff accept(final CBuff ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityReturnResources ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityHero ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityJass ability) { - return null; - } - - @Override - public ABBuff accept(final CAbilityNeutralBuilding ability) { - return null; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderAuraTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderAuraTemplate.java deleted file mode 100644 index 5cf47f08f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderAuraTemplate.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; - -public class CAbilityAbilityBuilderAuraTemplate extends AbilityGenericSingleIconPassiveAbility { - - private List levelData; - private Map localStore; - - private Set auraGroup; - private int lastSeenLevel = 0; - private int loopTick = 0; - - private static final Rectangle recycleRect = new Rectangle(); - private EnumSet targetsAllowed = null; - private float range = 0; - - private CBuff buff; - - private List addToAuraActions; - private List updateAuraLevelActions; - private List removeFromAuraActions; - - private final int LEAVE_GROUP_TICKS = (int) (3 / WarsmashConstants.SIMULATION_STEP_TIME); - private final int ENTER_GROUP_TICKS = (int) (0.4 / WarsmashConstants.SIMULATION_STEP_TIME); - private final int RESET_GROUP_TICKS = LEAVE_GROUP_TICKS * 2; - - public CAbilityAbilityBuilderAuraTemplate(int handleId, War3ID code, War3ID alias, - List levelData, Map localStore, - List addToAuraActions, List updateAuraLevelActions, - List removeFromAuraActions) { - super(code, alias, handleId); - this.levelData = levelData; - this.localStore = localStore; - this.addToAuraActions = addToAuraActions; - this.updateAuraLevelActions = updateAuraLevelActions; - this.removeFromAuraActions = removeFromAuraActions; - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - targetsAllowed = levelData.get(getLevel()).getTargetsAllowed(); - range = levelData.get(getLevel()).getCastRange(); - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - auraGroup = new HashSet<>(); - localStore.put(ABLocalStoreKeys.AURAGROUP, auraGroup); - lastSeenLevel = getLevel(); - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - emptyAura(game, unit); - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - if (loopTick % LEAVE_GROUP_TICKS == 0) { - List unitList; - if (lastSeenLevel != getLevel()) { - unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { - updateLevelOfAura(game, iter, lastSeenLevel, getLevel()); - } - } - lastSeenLevel = getLevel(); - } - unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { - removeUnitFromAura(game, iter); - } - } - } - if (loopTick % ENTER_GROUP_TICKS == 0) { - recycleRect.set(unit.getX() - range, unit.getY() - range, range * 2, range * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (unit.canReach(enumUnit, range) && enumUnit.canBeTargetedBy(game, unit, targetsAllowed) - && !auraGroup.contains(enumUnit)) { - addUnitToAura(game, enumUnit); - } - return false; - } - }); - } - loopTick++; - loopTick = loopTick % (RESET_GROUP_TICKS); - - } - - public void emptyAura(CSimulation game, CUnit unit) { - List unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - removeUnitFromAura(game, iter); - } - } - - public void addUnitToAura(CSimulation game, CUnit unit) { - auraGroup.add(unit); - if (addToAuraActions != null) { - for (ABAction action : addToAuraActions) { - action.runAction(game, unit, localStore, 0); - } - } - unit.add(game, buff); - } - - public void updateLevelOfAura(CSimulation game, CUnit unit, int prevLevel, int curLevel) { - if (updateAuraLevelActions != null) { - for (ABAction action : updateAuraLevelActions) { - action.runAction(game, unit, localStore, 0); - } - } - } - - public void removeUnitFromAura(CSimulation game, CUnit unit) { - unit.remove(game, buff); - if (removeFromAuraActions != null) { - for (ABAction action : removeFromAuraActions) { - action.runAction(game, unit, localStore, 0); - } - } - auraGroup.remove(unit); - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - emptyAura(game, unit); - } - - @Override - public boolean isUniversal() { - return true; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderSimpleAuraTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderSimpleAuraTemplate.java deleted file mode 100644 index 4cf2594b9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderSimpleAuraTemplate.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; - -public class CAbilityAbilityBuilderSimpleAuraTemplate extends AbilityGenericSingleIconPassiveAbility { - - private List levelData; - private Map localStore; - - private Set auraGroup; - private int lastSeenLevel = 0; - private int loopTick = 0; - - private static final Rectangle recycleRect = new Rectangle(); - private EnumSet targetsAllowed = null; - private float range = 0; - - private CBuff buff; - - private Map> abilityIdsToAddPerLevel; - private List levellingAbilityIdsToAdd; - - private Map> abilitiesToAddPerLevel; - private List levellingAbilitiesToAdd; - - private final int LEAVE_GROUP_TICKS = (int) (3 / WarsmashConstants.SIMULATION_STEP_TIME); - private final int ENTER_GROUP_TICKS = (int) (0.4 / WarsmashConstants.SIMULATION_STEP_TIME); - private final int RESET_GROUP_TICKS = LEAVE_GROUP_TICKS * 2; - - public CAbilityAbilityBuilderSimpleAuraTemplate(int handleId, War3ID code, War3ID alias, - List levelData, Map localStore, - Map> abilityIdsToAddPerLevel, List levellingAbilityIdsToAdd) { - super(code, alias, handleId); - this.levelData = levelData; - this.localStore = localStore; - this.abilityIdsToAddPerLevel = abilityIdsToAddPerLevel; - this.levellingAbilityIdsToAdd = levellingAbilityIdsToAdd; - - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - targetsAllowed = levelData.get(getLevel()).getTargetsAllowed(); - range = levelData.get(getLevel()).getCastRange(); - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - game.getAbilityData().createAbility(getAlias(), game.getHandleIdAllocator().createId()); - auraGroup = new HashSet<>(); - localStore.put(ABLocalStoreKeys.AURAGROUP, auraGroup); - lastSeenLevel = getLevel(); - this.abilitiesToAddPerLevel = new HashMap<>(); - this.levellingAbilitiesToAdd = new ArrayList<>(); - if (abilityIdsToAddPerLevel != null) { - for (Integer i : abilityIdsToAddPerLevel.keySet()) { - List list = new ArrayList<>(); - abilitiesToAddPerLevel.put(i, list); - for (War3ID abilityId : abilityIdsToAddPerLevel.get(i)) { - list.add(game.getAbilityData().getAbilityType(abilityId) - .createAbility(game.getHandleIdAllocator().createId())); - } - } - } - if (levellingAbilityIdsToAdd != null) { - for (War3ID abilityId : levellingAbilityIdsToAdd) { - CAbility abil = game.getAbilityData().getAbilityType(abilityId) - .createAbility(game.getHandleIdAllocator().createId()); - if (abil instanceof CLevelingAbility) { - levellingAbilitiesToAdd.add((CLevelingAbility) abil); - } - } - } - - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - emptyAura(game, unit); - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - if (loopTick % LEAVE_GROUP_TICKS == 0) { - List unitList; - if (lastSeenLevel != getLevel()) { - unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { - updateLevelOfAura(game, iter, lastSeenLevel, getLevel()); - } - } - lastSeenLevel = getLevel(); - } - unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { - removeUnitFromAura(game, iter); - } - } - } - if (loopTick % ENTER_GROUP_TICKS == 0) { - recycleRect.set(unit.getX() - range, unit.getY() - range, range * 2, range * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (unit.canReach(enumUnit, range) && enumUnit.canBeTargetedBy(game, unit, targetsAllowed) - && !auraGroup.contains(enumUnit)) { - addUnitToAura(game, enumUnit); - } - return false; - } - }); - } - loopTick++; - loopTick = loopTick % (RESET_GROUP_TICKS); - - } - - public void emptyAura(CSimulation game, CUnit unit) { - List unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - removeUnitFromAura(game, iter); - } - } - - public void addUnitToAura(CSimulation game, CUnit unit) { - auraGroup.add(unit); - if (abilitiesToAddPerLevel != null) { - for (CAbility ability : abilitiesToAddPerLevel.get(getLevel())) { - unit.add(game, ability); - } - } - if (levellingAbilitiesToAdd != null) { - for (CAbility ability : levellingAbilitiesToAdd) { - unit.add(game, ability); - } - } - unit.add(game, buff); - } - - public void updateLevelOfAura(CSimulation game, CUnit unit, int prevLevel, int curLevel) { - if (abilitiesToAddPerLevel != null) { - for (CAbility ability : abilitiesToAddPerLevel.get(prevLevel)) { - unit.remove(game, ability); - } - } - if (abilitiesToAddPerLevel != null) { - for (CAbility ability : abilitiesToAddPerLevel.get(curLevel)) { - unit.add(game, ability); - } - } - if (levellingAbilitiesToAdd != null) { - for (CLevelingAbility ability : levellingAbilitiesToAdd) { - ability.setLevel(game, unit, curLevel); - } - } - } - - public void removeUnitFromAura(CSimulation game, CUnit unit) { - unit.remove(game, buff); - if (abilitiesToAddPerLevel != null) { - for (CAbility ability : abilitiesToAddPerLevel.get(getLevel())) { - unit.remove(game, ability); - } - } - if (levellingAbilitiesToAdd != null) { - for (CAbility ability : levellingAbilitiesToAdd) { - unit.remove(game, ability); - } - } - auraGroup.remove(unit); - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - emptyAura(game, unit); - } - - @Override - public boolean isUniversal() { - return true; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderStatAuraTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderStatAuraTemplate.java deleted file mode 100644 index c79e3a5f4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderStatAuraTemplate.java +++ /dev/null @@ -1,329 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABGenericAuraBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.MeleeRangeTargetOverride; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.StatBuffFromDataField; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class CAbilityAbilityBuilderStatAuraTemplate extends AbilityGenericSingleIconPassiveAbility { - - private List levelData; - private Map localStore; - - private Set auraGroup; - private int loopTick = 0; - - private static final Rectangle recycleRect = new Rectangle(); - private EnumSet targetsAllowed = null; - private float range = 0; - - private War3ID buffId; - private CBuff buff; - - private SimulationRenderComponent fx; - - private boolean targetMelee = false; - private boolean targetRange = false; - private MeleeRangeTargetOverride rangeOverride; - - private String auraStackingKey; - - private List statBuffDataFields; - - private final int LEAVE_GROUP_TICKS = (int) (3 / WarsmashConstants.SIMULATION_STEP_TIME); - private final int ENTER_GROUP_TICKS = (int) (0.4 / WarsmashConstants.SIMULATION_STEP_TIME); - private final int RESET_GROUP_TICKS = LEAVE_GROUP_TICKS * 2; - - public CAbilityAbilityBuilderStatAuraTemplate(int handleId, War3ID code, War3ID alias, - List levelData, Map localStore, - List statBuffDataFields, MeleeRangeTargetOverride meleeRangeTargetOverride) { - super(code, alias, handleId); - this.levelData = levelData; - this.localStore = localStore; - this.rangeOverride = meleeRangeTargetOverride; - this.targetsAllowed = levelData.get(getLevel() - 1).getTargetsAllowed(); - this.range = levelData.get(getLevel() - 1).getArea(); - this.auraStackingKey = ""; - - this.statBuffDataFields = new ArrayList<>(); - for (StatBuffFromDataField statBuff : statBuffDataFields) { - this.statBuffDataFields.add(new StatBuffFromDataField(statBuff)); - } - - if (!this.levelData.get(getLevel() - 1).getBuffs().isEmpty()) { - buffId = this.levelData.get(getLevel() - 1).getBuffs().get(0); - this.auraStackingKey = buffId.asStringValue(); - } - - for (StatBuffFromDataField statBuff : this.statBuffDataFields) { - createNewBuffs(statBuff); - } - - if (this.rangeOverride != null) { - this.targetMelee = this.rangeOverride.isTargetMelee(); - this.targetRange = this.rangeOverride.isTargetRange(); - } - } - - private void removeExistingBuffs(StatBuffFromDataField statBuff) { - for (CUnit unit : auraGroup) { - unit.removeNonStackingStatBuff(statBuff.getBuff()); - if (statBuff.getSecondAtkBuff() != null) { - unit.removeNonStackingStatBuff(statBuff.getSecondAtkBuff()); - } - } - } - - private void addNewBuffs(StatBuffFromDataField statBuff) { - for (CUnit unit : auraGroup) { - unit.addNonStackingStatBuff(statBuff.getBuff()); - if (statBuff.getSecondAtkBuff() != null) { - unit.addNonStackingStatBuff(statBuff.getSecondAtkBuff()); - } - } - } - - private void createNewBuffs(StatBuffFromDataField parsedBuff) { - NonStackingStatBuffType type = parsedBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); - NonStackingStatBuff newBuff = null; - switch (type) { - case RNGDATK: - case RNGDATKPCT: - newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - targetRange = true; - break; - case MELEEATK: - case MELEEATKPCT: - newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - targetMelee = true; - break; - case ALLATK: - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATK, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATK, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setSecondAtkBuff(newBuff); - targetMelee = true; - targetRange = true; - break; - case ALLATKPCT: - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATKPCT, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATKPCT, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setSecondAtkBuff(newBuff); - targetMelee = true; - targetRange = true; - break; - default: - newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - targetMelee = true; - targetRange = true; - } - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - targetsAllowed = levelData.get(getLevel() - 1).getTargetsAllowed(); - range = levelData.get(getLevel() - 1).getArea(); - this.targetMelee = false; - this.targetRange = false; - for (StatBuffFromDataField statBuff : this.statBuffDataFields) { - NonStackingStatBuffType type = statBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); - if (type == null) { - continue; - } - switch (type) { - case ALLATK: - if (statBuff.getSecondAtkBuff() == null) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - addNewBuffs(statBuff); - } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATK) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - addNewBuffs(statBuff); - } else { - statBuff.getBuff().setValue(Float.parseFloat( - levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); - targetMelee = true; - targetRange = true; - } - break; - case ALLATKPCT: - if (statBuff.getSecondAtkBuff() == null) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - addNewBuffs(statBuff); - } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATKPCT) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - addNewBuffs(statBuff); - } else { - statBuff.getBuff().setValue(Float.parseFloat( - levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); - targetMelee = true; - targetRange = true; - } - break; - default: - if (statBuff.getSecondAtkBuff() != null) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - addNewBuffs(statBuff); - } else if (type != statBuff.getBuff().getBuffType()) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - addNewBuffs(statBuff); - } else { - float parsedFloat; - try { - parsedFloat = Float.parseFloat( - levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex())); - } catch (NumberFormatException exc) { - parsedFloat = 0; - } - statBuff.getBuff().setValue(parsedFloat); - if (type == NonStackingStatBuffType.MELEEATK || type == NonStackingStatBuffType.MELEEATKPCT) { - targetMelee = true; - } else if (type == NonStackingStatBuffType.RNGDATK || type == NonStackingStatBuffType.RNGDATKPCT) { - targetRange = true; - } else { - targetMelee = true; - targetRange = true; - } - } - } - for (CUnit unitA : auraGroup) { - unitA.computeDerivedFields(statBuff.getBuff().getBuffType()); - } - } - if (this.rangeOverride != null) { - this.targetMelee = this.rangeOverride.isTargetMelee(); - this.targetRange = this.rangeOverride.isTargetRange(); - } - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - if (this.buffId != null) { - this.buff = new ABGenericAuraBuff(game.getHandleIdAllocator().createId(), this.buffId, unit); - } - game.getAbilityData().createAbility(getAlias(), game.getHandleIdAllocator().createId()); - auraGroup = new HashSet<>(); - localStore.put(ABLocalStoreKeys.AURAGROUP, auraGroup); - this.fx = game.createPersistentSpellEffectOnUnit(unit, this.getAlias(), CEffectType.TARGET); - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - emptyAura(game, unit); - this.fx.remove(); - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - if (loopTick % LEAVE_GROUP_TICKS == 0) { - List unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { - removeUnitFromAura(game, iter); - } - } - } - if (loopTick % ENTER_GROUP_TICKS == 0) { - recycleRect.set(unit.getX() - range, unit.getY() - range, range * 2, range * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (unit.canReach(enumUnit, range) && enumUnit.canBeTargetedBy(game, unit, targetsAllowed) - && !auraGroup.contains(enumUnit) - && ((targetMelee && enumUnit.isUnitType(CUnitTypeJass.MELEE_ATTACKER) - || (targetRange && enumUnit.isUnitType(CUnitTypeJass.RANGED_ATTACKER))))) { - addUnitToAura(game, enumUnit); - } - return false; - } - }); - } - loopTick++; - loopTick = loopTick % (RESET_GROUP_TICKS); - - } - - public void emptyAura(CSimulation game, CUnit unit) { - List unitList = new ArrayList<>(auraGroup); - for (CUnit iter : unitList) { - removeUnitFromAura(game, iter); - } - } - - public void addUnitToAura(CSimulation game, CUnit unit) { - for (StatBuffFromDataField statBuff : this.statBuffDataFields) { - unit.addNonStackingStatBuff(statBuff.getBuff()); - if (statBuff.getSecondAtkBuff() != null) { - unit.addNonStackingStatBuff(statBuff.getSecondAtkBuff()); - } - } - if (buff != null) { - unit.addNonStackingDisplayBuff(game, auraStackingKey, buff); - } - auraGroup.add(unit); - } - - public void removeUnitFromAura(CSimulation game, CUnit unit) { - if (buff != null) { - unit.removeNonStackingDisplayBuff(game, auraStackingKey, buff); - } - for (StatBuffFromDataField statBuff : this.statBuffDataFields) { - unit.removeNonStackingStatBuff(statBuff.getBuff()); - if (statBuff.getSecondAtkBuff() != null) { - unit.removeNonStackingStatBuff(statBuff.getSecondAtkBuff()); - } - } - auraGroup.remove(unit); - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - emptyAura(game, unit); - } - - @Override - public boolean isUniversal() { - return true; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderStatPassiveTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderStatPassiveTemplate.java deleted file mode 100644 index c952747b5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/ability/template/CAbilityAbilityBuilderStatPassiveTemplate.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template; - -import java.util.List; -import java.util.Map; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABPermanentPassiveBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.StatBuffFromDataField; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; - -public class CAbilityAbilityBuilderStatPassiveTemplate extends AbilityGenericSingleIconPassiveAbility { - - private List levelData; - private Map localStore; - - private War3ID buffId; - private CBuff buff; - - private CUnit caster; - - private String auraStackingKey; - - private List statBuffDataFields; - - public CAbilityAbilityBuilderStatPassiveTemplate(int handleId, War3ID code, War3ID alias, - List levelData, Map localStore, - List statBuffDataFields) { - super(code, alias, handleId); - this.levelData = levelData; - this.localStore = localStore; - this.statBuffDataFields = statBuffDataFields; - this.auraStackingKey = ""; - - if (!this.levelData.get(getLevel() - 1).getBuffs().isEmpty()) { - buffId = this.levelData.get(getLevel() - 1).getBuffs().get(0); - this.auraStackingKey = buffId.asStringValue(); - } - - for (StatBuffFromDataField statBuff : statBuffDataFields) { - createNewBuffs(statBuff); - } - } - - private void removeExistingBuffs(StatBuffFromDataField statBuff) { - this.caster.removeNonStackingStatBuff(statBuff.getBuff()); - if (statBuff.getSecondAtkBuff() != null) { - this.caster.removeNonStackingStatBuff(statBuff.getSecondAtkBuff()); - } - } - - private void createNewBuffs(StatBuffFromDataField parsedBuff) { - NonStackingStatBuffType type = parsedBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); - NonStackingStatBuff newBuff = null; - switch (type) { - case RNGDATK: - case RNGDATKPCT: - newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - break; - case MELEEATK: - case MELEEATKPCT: - newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - break; - case ALLATK: - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATK, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATK, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setSecondAtkBuff(newBuff); - break; - case ALLATKPCT: - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATKPCT, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATKPCT, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setSecondAtkBuff(newBuff); - break; - default: - newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float - .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); - parsedBuff.setBuff(newBuff); - } - } - - @Override - public void setLevel(CSimulation game, CUnit unit, int level) { - super.setLevel(game, unit, level); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, level); - for (StatBuffFromDataField statBuff : this.statBuffDataFields) { - NonStackingStatBuffType type = statBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); - if (type == null) { - continue; - } - switch (type) { - case ALLATK: - if (statBuff.getSecondAtkBuff() == null) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATK) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - } else { - statBuff.getBuff().setValue(Float.parseFloat( - levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); - } - break; - case ALLATKPCT: - if (statBuff.getSecondAtkBuff() == null) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATKPCT) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - } else { - statBuff.getBuff().setValue(Float.parseFloat( - levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); - } - break; - default: - if (statBuff.getSecondAtkBuff() != null) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - } else if (type != statBuff.getBuff().getBuffType()) { - removeExistingBuffs(statBuff); - createNewBuffs(statBuff); - } else { - statBuff.getBuff().setValue(Float.parseFloat( - levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); - } - } - caster.computeDerivedFields(statBuff.getBuff().getBuffType()); - } - if (this.buff != null) { - this.buff.setLevel(game, unit, level); - } - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - if (this.buffId != null) { - this.buff = new ABPermanentPassiveBuff(game.getHandleIdAllocator().createId(), this.buffId, localStore, null, null, 0); - unit.addNonStackingDisplayBuff(game, auraStackingKey, buff); - } - this.caster = unit; - game.getAbilityData().createAbility(getAlias(), game.getHandleIdAllocator().createId()); - - for (StatBuffFromDataField statBuff : this.statBuffDataFields) { - unit.addNonStackingStatBuff(statBuff.getBuff()); - } - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - removeBuffFromUnit(game, unit); - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - } - - public void removeBuffFromUnit(CSimulation game, CUnit unit) { - if (this.buff != null) { - unit.removeNonStackingDisplayBuff(game, auraStackingKey, buff); - } - for (StatBuffFromDataField statBuff : this.statBuffDataFields) { - unit.removeNonStackingStatBuff(statBuff.getBuff()); - } - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - removeBuffFromUnit(game, unit); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/ABAbilityTargetStillTargetableVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/ABAbilityTargetStillTargetableVisitor.java deleted file mode 100644 index c40332638..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/ABAbilityTargetStillTargetableVisitor.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; - -public final class ABAbilityTargetStillTargetableVisitor implements AbilityTargetVisitor { - private CSimulation simulation; - private CUnit unit; - private AbilityBuilderActiveAbility ability; - private boolean channeling; - private int orderId; - - public ABAbilityTargetStillTargetableVisitor reset(final CSimulation simulation, final CUnit unit, - final AbilityBuilderActiveAbility ability, boolean channeling) { - this.simulation = simulation; - this.unit = unit; - this.ability = ability; - this.channeling = channeling; - this.orderId = this.ability.getBaseOrderId(); - return this; - } - - public ABAbilityTargetStillTargetableVisitor reset(final CSimulation simulation, final CUnit unit, - final AbilityBuilderActiveAbility ability, boolean channeling, int orderId) { - this.simulation = simulation; - this.unit = unit; - this.ability = ability; - this.channeling = channeling; - this.orderId = orderId; - return this; - } - - @Override - public Boolean accept(final AbilityPointTarget target) { - return Boolean.TRUE; - } - - @Override - public Boolean accept(final CUnit target) { - if (channeling) { - return !target.isHidden(); - } - BooleanAbilityTargetCheckReceiver receiver = new BooleanAbilityTargetCheckReceiver<>(); - ability.checkCanTarget(simulation, unit, this.orderId, target, receiver); - return !target.isHidden() - && receiver.isTargetable(); - } - - @Override - public Boolean accept(final CDestructable target) { - if (channeling) { - return !target.isDead(); - } - BooleanAbilityTargetCheckReceiver receiver = new BooleanAbilityTargetCheckReceiver<>(); - ability.checkCanTarget(simulation, unit, this.orderId, target, receiver); - return !target.isDead() && receiver.isTargetable(); - } - - @Override - public Boolean accept(final CItem target) { - if (channeling) { - return !target.isDead() && !target.isHidden(); - } - BooleanAbilityTargetCheckReceiver receiver = new BooleanAbilityTargetCheckReceiver<>(); - ability.checkCanTarget(simulation, unit, this.orderId, target, receiver); - return !target.isDead() && !target.isHidden() - && receiver.isTargetable(); - } - -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/ABBehavior.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/ABBehavior.java deleted file mode 100644 index 4e94fa42e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/ABBehavior.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; - -public interface ABBehavior extends CBehavior { - public CBehavior reset(final CSimulation game, final CWidget target); - public CBehavior reset(final CSimulation game, final CWidget target, int orderId); - - public CBehavior reset(final CSimulation game, final AbilityPointTarget target); - public CBehavior reset(final CSimulation game, final AbilityPointTarget target, int orderId); - - public CBehavior reset(); - public CBehavior reset(int orderId); - - public void setCastId(int castId); - public void setInstant(boolean instant); - public void setBehaviorCategory(CBehaviorCategory behaviorCategory); - - public CAbility getAbility(); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorAbilityBuilderBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorAbilityBuilderBase.java deleted file mode 100644 index d3d5b1637..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorAbilityBuilderBase.java +++ /dev/null @@ -1,311 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior; - -import java.util.Map; - -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CAbstractRangedBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; - -public class CBehaviorAbilityBuilderBase extends CAbstractRangedBehavior implements ABBehavior { - private Map localStore; - private AbilityBuilderActiveAbility ability; - private ABAbilityTargetStillTargetableVisitor preCastTargetableVisitor; - - private int castStartTick = 0; - private int castBehaviorNotifyTick = 0; - private boolean doneEffect = false; - private boolean channeling = false; - private boolean preventReInterrupt = false; - - private int castId = 0; - private int orderId; - - private boolean instant = false; - private CBehaviorCategory behaviorCategory = null; - - public CBehaviorAbilityBuilderBase(final CUnit unit, - final Map localStore, AbilityBuilderActiveAbility ability) { - super(unit); - this.localStore = localStore; - this.ability = ability; - this.preCastTargetableVisitor = new ABAbilityTargetStillTargetableVisitor(); - - } - - public void setInstant(boolean instant) { - this.instant = instant; - } - - public void setBehaviorCategory(CBehaviorCategory behaviorCategory) { - this.behaviorCategory = behaviorCategory; - } - - public CBehavior reset(final CSimulation game, final CWidget target) { - this.doneEffect = false; - this.castStartTick = 0; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - this.orderId = this.ability.getBaseOrderId(); - this.preventReInterrupt = false; - return innerReset(game, target, false); - } - - public CBehavior reset(final CSimulation game, final CWidget target, int orderId) { - this.doneEffect = false; - this.castStartTick = 0; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - this.orderId = orderId; - this.preventReInterrupt = false; - return innerReset(game, target, false); - } - - public CBehavior reset(final CSimulation game, final AbilityPointTarget target) { - this.doneEffect = false; - this.castStartTick = 0; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - this.orderId = this.ability.getBaseOrderId(); - this.preventReInterrupt = false; - return innerReset(game, target, false); - } - - public CBehavior reset(final CSimulation game, final AbilityPointTarget target, int orderId) { - this.doneEffect = false; - this.castStartTick = 0; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - this.orderId = orderId; - this.preventReInterrupt = false; - return innerReset(game, target, false); - } - - public ABBehavior reset() { - return null; - } - - public ABBehavior reset(int orderId) { - return null; - } - - @Override - public CBehavior update(final CSimulation game, boolean withinFacingWindow) { - boolean wasChanneling = this.channeling; - if (this.castStartTick == 0) { - CBehavior prevBeh = this.unit.getCurrentBehavior(); - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this.ability, this.target); - if (this.unit.getCurrentBehavior() != prevBeh) { - return this.unit.getCurrentBehavior(); - } else if (this.unit.isPaused()) { - return this; - } - - this.castStartTick = game.getGameTurnTick(); - this.castBehaviorNotifyTick = (int) (this.castStartTick + 0.5/WarsmashConstants.SIMULATION_STEP_TIME); - - if (!this.target.visit(this.preCastTargetableVisitor.reset(game, this.unit, ability, false, orderId))) { - return this.unit.pollNextOrderBehavior(game); - } - - if (!this.unit.chargeMana(this.ability.getChargedManaCost())) { - game.getCommandErrorListener().showInterfaceError(this.unit.getPlayerIndex(), - CommandStringErrorKeys.NOT_ENOUGH_MANA); - return this.unit.pollNextOrderBehavior(game); - } - this.ability.startCooldown(game, this.unit); - - this.ability.runBeginCastingActions(game, unit, orderId); - - CBehavior newBehavior = (CBehavior) localStore.get(ABLocalStoreKeys.NEWBEHAVIOR); - if (newBehavior != null) { - cleanupInputs(); - localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); - return newBehavior; - } - if (!instant) { - this.unit.getUnitAnimationListener().playAnimation(false, this.ability.getCastingPrimaryTag(), - this.ability.getCastingSecondaryTags(), 1.0f, true); - } - this.channeling = (boolean) localStore.get(ABLocalStoreKeys.CHANNELING); - } - - - if (instant) { - CBehavior beh = tryDoEffect(game, wasChanneling); - if (beh != null) { - return beh; - } - CBehavior newBehavior = (CBehavior) localStore.get(ABLocalStoreKeys.NEWBEHAVIOR); - if (newBehavior != null) { - cleanupInputs(); - localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); - return newBehavior; - } - - if (!this.channeling) { - cleanupInputs(); - return this.unit.pollNextOrderBehavior(game); - } - } else { - final int ticksSinceCast = game.getGameTurnTick() - this.castStartTick; - final int castPointTicks = (int) (this.unit.getUnitType().getCastPoint() - / WarsmashConstants.SIMULATION_STEP_TIME); - final int backswingTicks = (int) (this.unit.getUnitType().getCastBackswingPoint() - / WarsmashConstants.SIMULATION_STEP_TIME); - if ((ticksSinceCast >= castPointTicks) || (ticksSinceCast >= backswingTicks)) { - CBehavior beh = tryDoEffect(game, wasChanneling); - if (beh != null) { - return beh; - } - CBehavior newBehavior = (CBehavior) localStore.get(ABLocalStoreKeys.NEWBEHAVIOR); - if (newBehavior != null) { - cleanupInputs(); - localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); - return newBehavior; - } - } - if ((ticksSinceCast >= backswingTicks) && !this.channeling) { - cleanupInputs(); - return this.unit.pollNextOrderBehavior(game); - } - } - return this; - } - - private void cleanupInputs() { - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDITEM + castId); - this.localStore.remove(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + castId); - } - - private CBehavior tryDoEffect(CSimulation game, boolean wasChanneling) { - boolean wasEffectDone = this.doneEffect; - if (!wasEffectDone) { - CBehavior prevBeh = this.unit.getCurrentBehavior(); - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, this.ability, this.target); - if (this.unit.getCurrentBehavior() != prevBeh) { - return this.unit.getCurrentBehavior(); - } else if (this.unit.isPaused()) { - return this; - } - if (this.channeling) { - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CHANNEL, this.ability, this.target); - if (this.unit.getCurrentBehavior() != prevBeh) { - return this.unit.getCurrentBehavior(); - } else if (this.unit.isPaused()) { - return this; - } - game.unitLoopSoundEffectEvent(this.unit, this.ability.getAlias()); - } - else { - game.unitSoundEffectEvent(this.unit, this.ability.getAlias()); - } - this.doneEffect = true; - - this.ability.runEndCastingActions(game, unit, orderId); - this.channeling = (boolean) localStore.get(ABLocalStoreKeys.CHANNELING); - - } - this.channeling = this.channeling && this.doChannelTick(game, this.unit, this.target); - if (wasEffectDone && wasChanneling && !this.channeling) { - endChannel(game, false); - } - return null; - } - - @Override - public void begin(final CSimulation game) { - } - - public boolean doChannelTick(CSimulation game, CUnit caster, AbilityTarget target) { - this.ability.runChannelTickActions(game, caster, orderId); - return (boolean) localStore.get(ABLocalStoreKeys.CHANNELING); - } - - @Override - public void end(final CSimulation game, boolean interrupted) { - checkEndChannel(game, interrupted); - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this.ability, this.target); - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this.ability, this.target); - } - - private void checkEndChannel(final CSimulation game, final boolean interrupted) { - if (this.channeling) { - this.channeling = false; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - endChannel(game, interrupted); - } - } - - private void endChannel(CSimulation game, boolean interrupted) { - this.localStore.put(ABLocalStoreKeys.INTERRUPTED, interrupted); - game.unitStopSoundEffectEvent(this.unit, this.ability.getAlias()); - this.ability.runEndChannelActions(game, unit, orderId); - cleanupInputs(); - } - - @Override - public int getHighlightOrderId() { - return this.ability.getBaseOrderId(); - } - - @Override - public boolean isWithinRange(CSimulation simulation) { - return this.unit.canReach(this.target, this.ability.getCastRange()); - } - - @Override - public void endMove(CSimulation game, boolean interrupted) { - if (interrupted && !preventReInterrupt) { - preventReInterrupt = true; - this.ability.runCancelPreCastActions(game, unit, orderId); - checkEndChannel(game, interrupted); - } - } - - @Override - protected CBehavior updateOnInvalidTarget(CSimulation simulation) { - return this.unit.pollNextOrderBehavior(simulation); - } - - @Override - protected boolean checkTargetStillValid(CSimulation simulation) { - return this.doneEffect || this.target.visit(this.preCastTargetableVisitor.reset(simulation, this.unit, this.ability, this.channeling, orderId)); - } - - @Override - protected void resetBeforeMoving(CSimulation simulation) { - this.castStartTick = 0; - } - - public void setCastId(int castId) { - this.castId = castId; - } - - @Override - public boolean interruptable() { - return true; - } - - @Override - public CBehaviorCategory getBehaviorCategory() { - if (this.behaviorCategory != null) { - return this.behaviorCategory ; - } - return CBehaviorCategory.SPELL; - } - - @Override - public CAbility getAbility() { - return ability; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorAbilityBuilderNoTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorAbilityBuilderNoTarget.java deleted file mode 100644 index fce1d117e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorAbilityBuilderNoTarget.java +++ /dev/null @@ -1,249 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior; - -import java.util.Map; - -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; - -public class CBehaviorAbilityBuilderNoTarget implements ABBehavior { - private Map localStore; - private AbilityBuilderActiveAbility ability; - - private int castStartTick = 0; - private boolean doneEffect = false; - private boolean channeling = false; - - private CUnit unit; - private int orderId; - - private boolean instant = false; - private CBehaviorCategory behaviorCategory = null; - - public CBehaviorAbilityBuilderNoTarget(final CUnit unit, - final Map localStore, AbilityBuilderActiveAbility ability) { - this.unit = unit; - this.localStore = localStore; - this.ability = ability; - } - - public void setInstant(boolean instant) { - this.instant = instant; - } - - public void setBehaviorCategory(CBehaviorCategory behaviorCategory) { - this.behaviorCategory = behaviorCategory; - } - - @Override - public ABBehavior reset(final CSimulation game, final CWidget target) { - return null; - } - - @Override - public ABBehavior reset(final CSimulation game, CWidget target, int orderId) { - return null; - } - - @Override - public ABBehavior reset(final CSimulation game, final AbilityPointTarget target) { - return null; - } - - @Override - public ABBehavior reset(final CSimulation game, AbilityPointTarget target, int orderId) { - return null; - } - - @Override - public ABBehavior reset() { - this.doneEffect = false; - this.castStartTick = 0; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - this.orderId = this.ability.getBaseOrderId(); - return this; - } - - @Override - public ABBehavior reset(int orderId) { - this.doneEffect = false; - this.castStartTick = 0; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - this.orderId = orderId; - return this; - } - - @Override - public CBehavior update(final CSimulation game) { - boolean wasChanneling = this.channeling; - if (this.castStartTick == 0) { - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this.ability, null); - if (this.unit.getCurrentBehavior() != this) { - return this.unit.getCurrentBehavior(); - } else if (this.unit.isPaused()) { - return this; - } - this.castStartTick = game.getGameTurnTick(); - - if (!this.unit.chargeMana(this.ability.getChargedManaCost())) { - game.getCommandErrorListener().showInterfaceError(this.unit.getPlayerIndex(), - CommandStringErrorKeys.NOT_ENOUGH_MANA); - return this.unit.pollNextOrderBehavior(game); - } - this.ability.startCooldown(game, this.unit); - - this.ability.runBeginCastingActions(game, unit, orderId); - CBehavior newBehavior = (CBehavior) localStore.get(ABLocalStoreKeys.NEWBEHAVIOR); - if (newBehavior != null) { - localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); - return newBehavior; - } - if (!instant) { - this.unit.getUnitAnimationListener().playAnimation(false, this.ability.getCastingPrimaryTag(), - this.ability.getCastingSecondaryTags(), 1.0f, true); - } - this.channeling = (boolean) localStore.get(ABLocalStoreKeys.CHANNELING); - } - - if (instant) { - CBehavior beh = tryDoEffect(game, wasChanneling); - if (beh != null) { - return beh; - } - CBehavior newBehavior = (CBehavior) localStore.get(ABLocalStoreKeys.NEWBEHAVIOR); - if (newBehavior != null) { - localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); - return newBehavior; - } - if (!this.channeling) { - return this.unit.pollNextOrderBehavior(game); - } - } else { - final int ticksSinceCast = game.getGameTurnTick() - this.castStartTick; - final int castPointTicks = (int) (this.unit.getUnitType().getCastPoint() - / WarsmashConstants.SIMULATION_STEP_TIME); - final int backswingTicks = (int) (this.unit.getUnitType().getCastBackswingPoint() - / WarsmashConstants.SIMULATION_STEP_TIME); - if ((ticksSinceCast >= castPointTicks) || (ticksSinceCast >= backswingTicks)) { - CBehavior beh = tryDoEffect(game, wasChanneling); - if (beh != null) { - return beh; - } - CBehavior newBehavior = (CBehavior) localStore.get(ABLocalStoreKeys.NEWBEHAVIOR); - if (newBehavior != null) { - localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); - return newBehavior; - } - } - if ((ticksSinceCast >= backswingTicks) && !this.channeling) { - return this.unit.pollNextOrderBehavior(game); - } - } - return this; - } - - private CBehavior tryDoEffect(CSimulation game, boolean wasChanneling) { - boolean wasEffectDone = this.doneEffect; - if (!wasEffectDone) { - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, this.ability, null); - if (this.unit.getCurrentBehavior() != this) { - return this.unit.getCurrentBehavior(); - } else if (this.unit.isPaused()) { - return this; - } - if (this.channeling) { - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CHANNEL, this.ability, null); - if (this.unit.getCurrentBehavior() != this) { - return this.unit.getCurrentBehavior(); - } else if (this.unit.isPaused()) { - return this; - } - game.unitLoopSoundEffectEvent(this.unit, this.ability.getAlias()); - } - else { - game.unitSoundEffectEvent(this.unit, this.ability.getAlias()); - } - this.doneEffect = true; - - this.ability.runEndCastingActions(game, unit, orderId); - this.channeling = (boolean) localStore.get(ABLocalStoreKeys.CHANNELING); - - } - this.channeling = this.channeling && this.doChannelTick(game, this.unit); - if (wasEffectDone && wasChanneling && !this.channeling) { - endChannel(game, false); - } - return null; - } - - @Override - public void begin(final CSimulation game) { - } - - public boolean doChannelTick(CSimulation game, CUnit caster) { - this.ability.runChannelTickActions(game, caster, orderId); - return (boolean) localStore.get(ABLocalStoreKeys.CHANNELING); - } - - @Override - public void end(final CSimulation game, boolean interrupted) { - checkEndChannel(game, interrupted); - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this.ability, null); - this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this.ability, null); - } - - private void checkEndChannel(final CSimulation game, final boolean interrupted) { - if (this.channeling) { - this.channeling = false; - this.localStore.put(ABLocalStoreKeys.CHANNELING, false); - endChannel(game, interrupted); - } - } - - private void endChannel(CSimulation game, boolean interrupted) { - this.localStore.put(ABLocalStoreKeys.INTERRUPTED, interrupted); - game.unitStopSoundEffectEvent(this.unit, this.ability.getAlias()); - this.ability.runEndChannelActions(game, unit, orderId); - } - - @Override - public int getHighlightOrderId() { - return this.ability.getBaseOrderId(); - } - - public void setCastId(int castId) { - } - - @Override - public boolean interruptable() { - return true; - } - - @Override - public CBehaviorCategory getBehaviorCategory() { - if (this.behaviorCategory != null) { - return this.behaviorCategory ; - } - return CBehaviorCategory.SPELL; - } - - @Override - public CAbility getAbility() { - return ability; - } - - @Override - public T visit(final CBehaviorVisitor visitor) { - return visitor.accept(this); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorFinishTransformation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorFinishTransformation.java deleted file mode 100644 index 8d8c3875d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorFinishTransformation.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorVisitor; - -public class CBehaviorFinishTransformation implements CBehavior { - private Map localStore; - private OnTransformationActions actions; - private CUnit unit; - private AbilityBuilderActiveAbility ability; - private CUnitType baseTypeForDuration; - private CUnitType newType; - private int visibleOrderId; - private boolean permanent; - private float duration; - private int transformationTickDuration; - private float altitudeAdjustmentDelay; - private float altitudeAdjustmentDuration; - private float landingDelay; - - private boolean immediateLanding; - private boolean immediateTakeoff; - - private boolean addAlternateTagAfter; - - private boolean takingOff; - private boolean landing; - - private War3ID buffId; - private float transformationTime; - private boolean instantTransformAtDurationEnd; - - private int castStartTick = 0; - - public CBehaviorFinishTransformation(Map localStore, final CUnit unit, - AbilityBuilderActiveAbility ability, CUnitType newType, OnTransformationActions actions, - boolean addAlternateTagAfter, final int visibleOrderId, boolean permanent, float duration, - float transformationTime, float landingDelay, float altitudeAdjustmentDelay, - float altitudeAdjustmentDuration, boolean immediateLanding, boolean immediateTakeoff, War3ID buffId, - CUnitType baseTypeForDuration, boolean instantTransformAtDurationEnd) { - this.localStore = localStore; - this.actions = actions; - this.unit = unit; - this.ability = ability; - this.newType = newType; - this.visibleOrderId = visibleOrderId; - this.permanent = permanent; - this.duration = duration; - this.transformationTime = transformationTime; - this.transformationTickDuration = Math.round(transformationTime / WarsmashConstants.SIMULATION_STEP_TIME); - this.altitudeAdjustmentDelay = altitudeAdjustmentDelay; - this.altitudeAdjustmentDuration = altitudeAdjustmentDuration; - this.landingDelay = landingDelay; - - this.immediateLanding = immediateLanding; - this.immediateTakeoff = immediateTakeoff; - - this.addAlternateTagAfter = addAlternateTagAfter; - - this.buffId = buffId; - this.baseTypeForDuration = baseTypeForDuration; - this.instantTransformAtDurationEnd = instantTransformAtDurationEnd; - - this.takingOff = unit.getMovementType() != MovementType.FLY && newType.getMovementType() == MovementType.FLY; - this.landing = unit.getMovementType() == MovementType.FLY && newType.getMovementType() != MovementType.FLY; - - if (this.landing) { - this.transformationTickDuration += this.landingDelay > 0 - ? Math.round(altitudeAdjustmentDuration / WarsmashConstants.SIMULATION_STEP_TIME) - : 0; - } - } - - @Override - public CBehavior update(CSimulation game) { - if (this.castStartTick == 0) { - this.castStartTick = game.getGameTurnTick(); - TransformationHandler.startSlowTransformation(game, localStore, unit, newType, actions, ability, - addAlternateTagAfter, takingOff, landing, immediateTakeoff, immediateLanding, - altitudeAdjustmentDelay, landingDelay, altitudeAdjustmentDuration); - } - - final int ticksSinceCast = game.getGameTurnTick() - this.castStartTick; - if (ticksSinceCast > this.transformationTickDuration) { - TransformationHandler.finishSlowTransformation(game, localStore, unit, newType, actions, ability, - addAlternateTagAfter, permanent, takingOff); - - if (instantTransformAtDurationEnd) { - TransformationHandler.createInstantTransformBackBuff(game, localStore, unit, baseTypeForDuration, - actions.createUntransformActions(), ability, buffId, - addAlternateTagAfter, transformationTime, duration, permanent); - } else { - TransformationHandler.createSlowTransformBackBuff(game, localStore, unit, baseTypeForDuration, - actions.createUntransformActions(), ability, buffId, - addAlternateTagAfter, transformationTime, duration, permanent, takingOff, landing, - immediateTakeoff, immediateLanding, altitudeAdjustmentDelay, landingDelay, - altitudeAdjustmentDuration); - } - - return this.unit.pollNextOrderBehavior(game); - } - return this; - } - - @Override - public void begin(CSimulation game) { - } - - @Override - public void end(CSimulation game, boolean interrupted) { - } - - @Override - public int getHighlightOrderId() { - return visibleOrderId; - } - - @Override - public boolean interruptable() { - return false; - } - - @Override - public T visit(final CBehaviorVisitor visitor) { - return visitor.accept(this); - } - - @Override - public CBehaviorCategory getBehaviorCategory() { - return CBehaviorCategory.SPELL; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorSendOrder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorSendOrder.java deleted file mode 100644 index f9b0ee20c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/CBehaviorSendOrder.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorVisitor; - -public class CBehaviorSendOrder implements CBehavior { - - private CUnit unit; - private CAbility ability; - private int orderId; - private int visibleOrderId; - private CWidget target; - - public CBehaviorSendOrder(final CUnit unit, CAbility ability, final int orderId, final int visibleOrderId, - final CWidget target) { - this.unit = unit; - this.ability = ability; - this.orderId = orderId; - this.visibleOrderId = visibleOrderId; - this.target = target; - } - - @Override - public CBehavior update(CSimulation game) { - return ability.begin(game, unit, orderId, target); - } - - @Override - public void begin(CSimulation game) { - } - - @Override - public void end(CSimulation game, boolean interrupted) { - } - - @Override - public int getHighlightOrderId() { - return visibleOrderId; - } - - @Override - public boolean interruptable() { - return true; - } - - @Override - public T visit(final CBehaviorVisitor visitor) { - return visitor.accept(this); - } - - @Override - public CBehaviorCategory getBehaviorCategory() { - return CBehaviorCategory.IDLE; - } - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/COrderStartTransformation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/COrderStartTransformation.java deleted file mode 100644 index 192ce1f9a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/COrderStartTransformation.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.COrderNoTarget; - -public class COrderStartTransformation extends COrderNoTarget { - private CBehavior transformBehavior; - - public COrderStartTransformation(final CBehavior transformBehavior, final int orderId) { - super(0, orderId, false); - this.transformBehavior = transformBehavior; - } - - @Override - public CBehavior begin(final CSimulation game, final CUnit caster) { - caster.fireOrderEvents(game, this); - return transformBehavior; - } - - @Override - public AbilityTarget getTarget(final CSimulation game) { - return null; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = (prime * result) + this.transformBehavior.hashCode(); - result = (prime * result) + this.getOrderId(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final COrderStartTransformation other = (COrderStartTransformation) obj; - if (this.transformBehavior.equals(other.transformBehavior)) { - return false; - } - if (this.getOrderId() != other.getOrderId()) { - return false; - } - return true; - } - - @Override - public void fireEvents(final CSimulation game, final CUnit unit) { - unit.fireOrderEvents(game, this); - } - -} - diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionAddAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionAddAbility.java deleted file mode 100644 index 24a8fe763..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionAddAbility.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.ABAbilityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddAbility implements ABSingleAction { - - private ABUnitCallback targetUnit; - private ABAbilityCallback abilityToAdd; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CAbility ability = this.abilityToAdd.callback(game, caster, localStore, castId); - this.targetUnit.callback(game, caster, localStore, castId).add(game, ability); - localStore.put(ABLocalStoreKeys.LASTADDEDABILITY, ability); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "AddUnitAbilityAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.abilityToAdd.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionAddStunBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionAddStunBuff.java deleted file mode 100644 index ac4040829..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionAddStunBuff.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.util.CBuffStun; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddStunBuff implements ABSingleAction { - - private ABUnitCallback target; - private ABIDCallback buffId; - private ABFloatCallback duration; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CAbility ability = new CBuffStun(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId)); - this.target.callback(game, caster, localStore, castId).add(game, ability); - localStore.put(ABLocalStoreKeys.LASTADDEDBUFF, ability); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "AddUnitAbility(" + this.target.generateJassEquivalent(jassTextGenerator) + ", CreateStunBuffAU(" - + jassTextGenerator.getTriggerLocalStore() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + "))"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCleanUpCastInstance.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCleanUpCastInstance.java deleted file mode 100644 index 8de038866..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCleanUpCastInstance.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCleanUpCastInstance implements ABSingleAction { - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Set keySet = new HashSet<>(localStore.keySet()); - for (final String key : keySet) { - if (key.contains("#" + castId)) { - localStore.remove(key); - } - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "LocalStoreCleanUpCastInstance(" + jassTextGenerator.getTriggerLocalStore() + ", " - + jassTextGenerator.getCastId() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateAbilityFromId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateAbilityFromId.java deleted file mode 100644 index f3e310539..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateAbilityFromId.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateAbilityFromId implements ABSingleAction { - - private ABIDCallback abilityId; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CAbility ability = game.getAbilityData() - .getAbilityType(this.abilityId.callback(game, caster, localStore, castId)) - .createAbility(game.getHandleIdAllocator().createId()); - localStore.put(ABLocalStoreKeys.LASTCREATEDABILITY, ability); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "CreateAbilityFromIdAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.abilityId.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateLightningEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateLightningEffect.java deleted file mode 100644 index 2c82a53cb..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateLightningEffect.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; - -public class ABActionCreateLightningEffect implements ABAction { - - private ABUnitCallback origin; - private ABUnitCallback target; - private ABIDCallback id; - private ABFloatCallback duration; - private ABIntegerCallback index; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - int i = 0; - if (index != null) { - i = index.callback(game, caster, localStore, castId); - } - if (duration != null) { - SimulationRenderComponentLightning ret = game.createAbilityLightning( - origin.callback(game, caster, localStore, castId), this.id.callback(game, caster, localStore, castId), i, - target.callback(game, caster, localStore, castId), duration.callback(game, caster, localStore, castId)); - localStore.put(ABLocalStoreKeys.LASTCREATEDLIGHTNING, ret); - } else { - SimulationRenderComponentLightning ret = game.createAbilityLightning( - origin.callback(game, caster, localStore, castId), this.id.callback(game, caster, localStore, castId), i, - target.callback(game, caster, localStore, castId)); - localStore.put(ABLocalStoreKeys.LASTCREATEDLIGHTNING, ret); - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateLoopingSoundEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateLoopingSoundEffectOnUnit.java deleted file mode 100644 index 63765b03c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateLoopingSoundEffectOnUnit.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABActionCreateLoopingSoundEffectOnUnit implements ABAction { - - private ABUnitCallback unit; - private ABIDCallback id; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - SimulationRenderComponent ret = game.unitLoopSoundEffectEvent( - (unit.callback(game, caster, localStore, castId)), this.id.callback(game, caster, localStore, castId)); - localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSoundEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSoundEffectOnUnit.java deleted file mode 100644 index 32db8f65d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSoundEffectOnUnit.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABActionCreateSoundEffectOnUnit implements ABAction { - - private ABUnitCallback unit; - private ABIDCallback id; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - SimulationRenderComponent ret = game.unitSoundEffectEvent( - (unit.callback(game, caster, localStore, castId)), this.id.callback(game, caster, localStore, castId)); - localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectAtLocation.java deleted file mode 100644 index 98a6dcafd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectAtLocation.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABActionCreateSpellEffectAtLocation implements ABAction { - - private ABLocationCallback location; - private ABFloatCallback facing; - private ABIDCallback id; - private CEffectType effectType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityPointTarget loc = this.location.callback(game, caster, localStore, castId); - float dir = 0; - if (this.facing != null) { - dir = this.facing.callback(game, caster, localStore, castId); - } - final SimulationRenderComponent ret = game.spawnSpellEffectOnPoint(loc.getX(), loc.getY(), dir, - this.id.callback(game, caster, localStore, castId), this.effectType, 0); - localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectAtPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectAtPoint.java deleted file mode 100644 index 2ff3b1649..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectAtPoint.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABActionCreateSpellEffectAtPoint implements ABAction { - - private ABFloatCallback x; - private ABFloatCallback y; - private ABFloatCallback facing; - private ABIDCallback id; - private CEffectType effectType; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float dir = 0; - if (facing != null) { - dir = facing.callback(game, caster, localStore, castId); - } - SimulationRenderComponent ret = game.spawnSpellEffectOnPoint(x.callback(game, caster, localStore, castId), - y.callback(game, caster, localStore, castId), dir, this.id.callback(game, caster, localStore, castId), - effectType, 0); - localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectOnUnit.java deleted file mode 100644 index 85ebd97b8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateSpellEffectOnUnit.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABActionCreateSpellEffectOnUnit implements ABAction { - - private ABUnitCallback target; - private ABIDCallback id; - private CEffectType effectType; - private ABIntegerCallback index; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - if (index == null) { - SimulationRenderComponent ret = game.createPersistentSpellEffectOnUnit( - (target.callback(game, caster, localStore, castId)), this.id.callback(game, caster, localStore, castId), - this.effectType); - localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); - } else { - SimulationRenderComponent ret = game.createPersistentSpellEffectOnUnit( - (target.callback(game, caster, localStore, castId)), this.id.callback(game, caster, localStore, castId), - this.effectType, this.index.callback(game, caster, localStore, castId)); - localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectAtLocation.java deleted file mode 100644 index 7c053b276..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectAtLocation.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTemporarySpellEffectAtLocation implements ABSingleAction { - - private ABLocationCallback location; - private ABFloatCallback facing; - private ABIDCallback id; - private CEffectType effectType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityPointTarget loc = this.location.callback(game, caster, localStore, castId); - float dir = 0; - if (this.facing != null) { - dir = this.facing.callback(game, caster, localStore, castId); - } - game.spawnTemporarySpellEffectOnPoint(loc.getX(), loc.getY(), dir, - this.id.callback(game, caster, localStore, castId), this.effectType, 0); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.facing != null) { - throw new UnsupportedOperationException("AddSpellEffectByIdLoc with facing"); - } - return "DestroyEffect(AddSpellEffectByIdLoc(" + this.id.generateJassEquivalent(jassTextGenerator) - + ", EFFECT_TYPE_" + this.effectType.name() + ", " - + this.location.generateJassEquivalent(jassTextGenerator) + ", null))"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectAtPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectAtPoint.java deleted file mode 100644 index 2131a1b6f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectAtPoint.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTemporarySpellEffectAtPoint implements ABSingleAction { - - private ABFloatCallback x; - private ABFloatCallback y; - private ABFloatCallback facing; - private ABIDCallback id; - private CEffectType effectType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float dir = 0; - if (this.facing != null) { - dir = this.facing.callback(game, caster, localStore, castId); - } - game.spawnTemporarySpellEffectOnPoint(this.x.callback(game, caster, localStore, castId), - this.y.callback(game, caster, localStore, castId), dir, - this.id.callback(game, caster, localStore, castId), this.effectType, 0); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.facing != null) { - throw new UnsupportedOperationException("AddSpellEffectByIdLoc with facing"); - } - return "DestroyEffect(AddSpellEffectById(" + this.id.generateJassEquivalent(jassTextGenerator) - + ", EFFECT_TYPE_" + this.effectType.name() + ", " + this.x.generateJassEquivalent(jassTextGenerator) - + ", " + this.y.generateJassEquivalent(jassTextGenerator) + ", null))"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectOnUnit.java deleted file mode 100644 index e053cb54c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionCreateTemporarySpellEffectOnUnit.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTemporarySpellEffectOnUnit implements ABSingleAction { - - private ABUnitCallback target; - private ABIDCallback id; - private CEffectType effectType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - game.createTemporarySpellEffectOnUnit((this.target.callback(game, caster, localStore, castId)), - this.id.callback(game, caster, localStore, castId), this.effectType); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "DestroyEffect(AddSpellEffectTargetById(" + this.id.generateJassEquivalent(jassTextGenerator) - + ", EFFECT_TYPE_" + this.effectType.name() + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", null))"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveAbility.java deleted file mode 100644 index d4cbf2b6b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveAbility.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.ABAbilityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveAbility implements ABSingleAction { - - private ABUnitCallback targetUnit; - private ABAbilityCallback abilityToRemove; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - (this.targetUnit.callback(game, caster, localStore, castId)).remove(game, - this.abilityToRemove.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "RemoveUnitAbility(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.abilityToRemove.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveLightningEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveLightningEffect.java deleted file mode 100644 index 36cd86977..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveLightningEffect.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks.ABLightningCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveLightningEffect implements ABAction { - - private ABLightningCallback effect; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - effect.callback(game, caster, localStore, castId).remove(); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveSpellEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveSpellEffect.java deleted file mode 100644 index bcdea676e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ABActionRemoveSpellEffect.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks.ABFXCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveSpellEffect implements ABSingleAction { - - private ABFXCallback effectToRemove; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - this.effectToRemove.callback(game, caster, localStore, castId).remove(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "DestroyEffect(" + this.effectToRemove.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionActivateToggledAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionActivateToggledAbility.java deleted file mode 100644 index d8eaba0cf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionActivateToggledAbility.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionActivateToggledAbility implements ABSingleAction { - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityBuilderActiveAbility ability = (AbilityBuilderActiveAbility) localStore - .get(ABLocalStoreKeys.TOGGLEDABILITY); - ability.activate(game, caster); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AbilityActivate(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_TOGGLEDABILITY", JassTextGeneratorType.AbilityHandle) - + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionAddTargetAllowed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionAddTargetAllowed.java deleted file mode 100644 index 33d941ab7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionAddTargetAllowed.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; - -public class ABActionAddTargetAllowed implements ABSingleAction { - - private CTargetType targetType; - - @Override - @SuppressWarnings("unchecked") - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final EnumSet targetsAllowed = levelData - .get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getTargetsAllowed(); - targetsAllowed.add(this.targetType); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AbilityTypeLevelDataAddTargetAllowed(" - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LEVELDATA", - JassTextGeneratorType.AbilityTypeLevelDataHandle) - + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_CURRENTLEVEL", JassTextGeneratorType.Integer) - + " - 1, TARGET_TYPE_" + this.targetType.name() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionBeginChanneling.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionBeginChanneling.java deleted file mode 100644 index 7cbc7616d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionBeginChanneling.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionBeginChanneling implements ABSingleAction { - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - localStore.put(ABLocalStoreKeys.CHANNELING, true); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.setUserData(ABLocalStoreKeys.CHANNELING, JassTextGeneratorType.Boolean, "true"); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionDeactivateToggledAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionDeactivateToggledAbility.java deleted file mode 100644 index 02a527dc9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionDeactivateToggledAbility.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionDeactivateToggledAbility implements ABSingleAction { - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityBuilderActiveAbility ability = (AbilityBuilderActiveAbility) localStore - .get(ABLocalStoreKeys.TOGGLEDABILITY); - ability.deactivate(game, caster); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AbilityDeactivate(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_TOGGLEDABILITY", JassTextGeneratorType.AbilityHandle) - + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionFinishChanneling.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionFinishChanneling.java deleted file mode 100644 index 61eaa9c34..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionFinishChanneling.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionFinishChanneling implements ABSingleAction { - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - localStore.put(ABLocalStoreKeys.CHANNELING, false); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.setUserData(ABLocalStoreKeys.CHANNELING, JassTextGeneratorType.Boolean, "false"); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionRemoveTargetAllowed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionRemoveTargetAllowed.java deleted file mode 100644 index c44eba1ed..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionRemoveTargetAllowed.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; - -public class ABActionRemoveTargetAllowed implements ABSingleAction { - - private CTargetType targetType; - - @Override - @SuppressWarnings("unchecked") - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final EnumSet targetsAllowed = levelData - .get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getTargetsAllowed(); - targetsAllowed.remove(this.targetType); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AbilityTypeLevelDataRemoveTargetAllowed(" - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LEVELDATA", - JassTextGeneratorType.AbilityTypeLevelDataHandle) - + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_CURRENTLEVEL", JassTextGeneratorType.Integer) - + " - 1, TARGET_TYPE_" + this.targetType.name() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionResetCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionResetCooldown.java deleted file mode 100644 index 7ba392619..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionResetCooldown.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.GetABAbilityByRawcodeVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionResetCooldown implements ABSingleAction { - - private ABIDCallback alias; - private ABUnitCallback unit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - CUnit theUnit = caster; - if (this.unit != null) { - theUnit = this.unit.callback(game, caster, localStore, castId); - } - if (this.alias != null) { - final War3ID aliasId = this.alias.callback(game, caster, localStore, castId); - final AbilityBuilderAbility abil = theUnit - .getAbility(GetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); - if (abil != null) { - abil.resetCooldown(game, theUnit); - } - } - else { - final AbilityBuilderAbility abil = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - abil.resetCooldown(game, theUnit); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - String unitExpression; - if (this.unit != null) { - unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); - } - else { - unitExpression = jassTextGenerator.getCaster(); - } - if (this.alias != null) { - return "EndUnitAbilityCooldown(" + unitExpression + ", " - + this.alias.generateJassEquivalent(jassTextGenerator) + ")"; - } - else { - return "EndAbilityCooldown(" + unitExpression + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) - + ")"; - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAbilityCastRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAbilityCastRange.java deleted file mode 100644 index 8efcb1cfd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAbilityCastRange.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetAbilityCastRange implements ABSingleAction { - - private ABFloatCallback range; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityBuilderActiveAbility ability = (AbilityBuilderActiveAbility) localStore - .get(ABLocalStoreKeys.TOGGLEDABILITY); - ability.setCastRange(this.range.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetAbilityCastRange(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_TOGGLEDABILITY", JassTextGeneratorType.AbilityHandle) - + ", " + this.range.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAutoTargetDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAutoTargetDestructable.java deleted file mode 100644 index 2c39b23be..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAutoTargetDestructable.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable.ABDestructableCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetAutoTargetDestructable implements ABSingleAction { - - private ABDestructableCallback dest; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + castId, - this.dest.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.setUserData( - ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + " + " + jassTextGenerator.getCastId(), - JassTextGeneratorType.DestructableHandle, this.dest.generateJassEquivalent(jassTextGenerator)); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAutoTargetUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAutoTargetUnit.java deleted file mode 100644 index 2c785c985..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionSetAutoTargetUnit.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetAutoTargetUnit implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - localStore.put(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId, - this.unit.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.setUserData( - ABLocalStoreKeys.ABILITYTARGETEDUNIT + " + " + jassTextGenerator.getCastId(), - JassTextGeneratorType.UnitHandle, this.unit.generateJassEquivalent(jassTextGenerator)); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionStartCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionStartCooldown.java deleted file mode 100644 index e9370583f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/ability/ABActionStartCooldown.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.GetABAbilityByRawcodeVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionStartCooldown implements ABSingleAction { - - private ABIDCallback alias; - private ABUnitCallback unit; - private ABFloatCallback cooldown; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - CUnit theUnit = caster; - if (this.unit != null) { - theUnit = this.unit.callback(game, caster, localStore, castId); - } - if (this.alias != null) { - final War3ID aliasId = this.alias.callback(game, caster, localStore, castId); - if (this.cooldown != null) { - theUnit.beginCooldown(game, aliasId, this.cooldown.callback(game, caster, localStore, castId)); - } - else { - final AbilityBuilderAbility abil = theUnit - .getAbility(GetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); - if (abil != null) { - abil.startCooldown(game, theUnit); - } - } - } - else { - if (this.cooldown != null) { - final War3ID aliasId = (War3ID) localStore.get(ABLocalStoreKeys.ALIAS); - theUnit.beginCooldown(game, aliasId, this.cooldown.callback(game, caster, localStore, castId)); - } - else { - final AbilityBuilderAbility abil = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - abil.startCooldown(game, theUnit); - } - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - String unitExpression; - if (this.unit != null) { - unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); - } - else { - unitExpression = jassTextGenerator.getCaster(); - } - if (this.alias != null) { - final String aliasExpression = this.alias.generateJassEquivalent(jassTextGenerator); - if (this.cooldown != null) { - return "StartUnitAbilityCooldown(" + unitExpression + ", " + aliasExpression + ", " - + this.cooldown.generateJassEquivalent(jassTextGenerator) + ")"; - } - else { - return "StartUnitAbilityDefaultCooldown(" + unitExpression + ", " + aliasExpression + ")"; - } - } - else { - if (this.cooldown != null) { - return "StartUnitAbilityCooldown(" + unitExpression + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ALIAS", JassTextGeneratorType.Integer) - + ", " + this.cooldown.generateJassEquivalent(jassTextGenerator) + ")"; - } - else { - return "StartAbilityDefaultCooldown(" + unitExpression + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) - + ")"; - } - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionAddBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionAddBuff.java deleted file mode 100644 index dac7dd21c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionAddBuff.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks.ABBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddBuff implements ABSingleAction { - - private ABUnitCallback target; - private ABBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CBuff ability = this.buff.callback(game, caster, localStore, castId); - this.target.callback(game, caster, localStore, castId).add(game, ability); - localStore.put(ABLocalStoreKeys.LASTADDEDBUFF, ability); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AddUnitBuffAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + this.buff.generateJassEquivalent(jassTextGenerator) - + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionAddNonStackingDisplayBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionAddNonStackingDisplayBuff.java deleted file mode 100644 index b60ffee8b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionAddNonStackingDisplayBuff.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks.ABBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddNonStackingDisplayBuff implements ABSingleAction { - - private ABUnitCallback target; - private ABStringCallback key; - private ABBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CBuff ability = this.buff.callback(game, caster, localStore, castId); - this.target.callback(game, caster, localStore, castId).addNonStackingDisplayBuff(game, - this.key.callback(game, caster, localStore, castId), ability); - localStore.put(ABLocalStoreKeys.LASTADDEDBUFF, ability); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AddUnitNonStackingDisplayBuffAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + this.key.generateJassEquivalent(jassTextGenerator) - + ", " + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreatePassiveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreatePassiveBuff.java deleted file mode 100644 index cc46b570b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreatePassiveBuff.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABPermanentPassiveBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreatePassiveBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABBooleanCallback showIcon; - private List onAddActions; - private List onRemoveActions; - private CEffectType artType; - - private ABBooleanCallback showFx; - private ABBooleanCallback playSfx; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - ABPermanentPassiveBuff ability = null; - if (this.showIcon != null) { - ability = new ABPermanentPassiveBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), localStore, this.onAddActions, - this.onRemoveActions, this.showIcon.callback(game, caster, localStore, castId), castId); - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - else { - ability = new ABPermanentPassiveBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), localStore, this.onAddActions, - this.onRemoveActions, true, castId); - - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - if (this.artType != null) { - ability.setArtType(this.artType); - } - if (this.showFx != null) { - ability.setShowFx(this.showFx.callback(game, caster, localStore, castId)); - } - if (this.playSfx != null) { - ability.setPlaySfx(this.playSfx.callback(game, caster, localStore, castId)); - } - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, - "CreatePassiveBuffAU_OnAddActions"); - final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, - "CreatePassiveBuffAU_OnRemoveActions"); - - return "CreatePassiveBuffAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() - + ", " + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.showIcon.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.functionPointerByName(addFunctionName) + ", " - + jassTextGenerator.functionPointerByName(removeFunctionName) + ", EFFECT_TYPE_" + this.artType.name() - + ", " + this.showFx.generateJassEquivalent(jassTextGenerator) + ", " - + this.playSfx.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTargetingBuff.java deleted file mode 100644 index 27b13651b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTargetingBuff.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTargetingBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateTargetingBuff implements ABSingleAction { - - private ABIDCallback buffId; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CBuff ability = new ABTargetingBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId)); - - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "CreateTargetingBuffAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedArtBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedArtBuff.java deleted file mode 100644 index e706d2af0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedArtBuff.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedArtBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTimedArtBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABFloatCallback duration; - private ABBooleanCallback showIcon; - private CEffectType artType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - - if (this.showIcon != null) { - final ABTimedArtBuff ability = new ABTimedArtBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), - this.showIcon.callback(game, caster, localStore, castId)); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - else { - final ABTimedArtBuff ability = new ABTimedArtBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId)); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - CEffectType artTypeUsed; - if (this.artType != null) { - artTypeUsed = this.artType; - } - else { - artTypeUsed = CEffectType.TARGET; - } - final String artTypeJass = "EFFECT_TYPE_" + artTypeUsed.name(); - String showIconJass; - if (this.showIcon != null) { - showIconJass = this.showIcon.generateJassEquivalent(jassTextGenerator); - } - else { - showIconJass = "true"; - } - return "CreateTimedArtBuffAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() - + ", " + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showIconJass + ", " + artTypeJass - + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedBuff.java deleted file mode 100644 index 230c94d5f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedBuff.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTimedBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABFloatCallback duration; - private ABBooleanCallback showTimedLifeBar; - private List onAddActions; - private List onRemoveActions; - private List onExpireActions; - private ABBooleanCallback showIcon; - private CEffectType artType; - private ABBooleanCallback hideArt; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - boolean showTimedLife = false; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.callback(game, caster, localStore, castId); - } - - if (this.showIcon != null) { - final ABTimedBuff ability = new ABTimedBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, - this.showIcon.callback(game, caster, localStore, castId), castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - if ((this.hideArt != null) && this.hideArt.callback(game, caster, localStore, castId)) { - ability.setArtType(null); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - else { - final ABTimedBuff ability = new ABTimedBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - if ((this.hideArt != null) && this.hideArt.callback(game, caster, localStore, castId)) { - ability.setArtType(null); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, - "CreateTimedBuffAU_OnAddActions"); - final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, - "CreateTimedBuffAU_OnRemoveActions"); - final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, - "CreateTimedBuffAU_OnExpireActions"); - - String showTimedLife = "false"; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); - } - - String showIconExpression; - if (this.showIcon != null) { - showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); - } - else { - showIconExpression = "true"; - } - - CEffectType artTypeUsed = CEffectType.TARGET; - if (this.artType != null) { - artTypeUsed = this.artType; - } - String artTypeExpression; - if (this.hideArt != null) { - artTypeExpression = "null"; - } - else { - artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); - } - - return "CreateTimedBuffAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() - + ", " + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " - + jassTextGenerator.functionPointerByName(addFunctionName) + ", " - + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " - + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " + showIconExpression + ", " - + artTypeExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedLifeBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedLifeBuff.java deleted file mode 100644 index ea333a678..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedLifeBuff.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.util.CBuffTimedLife; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateTimedLifeBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABFloatCallback duration; - private ABBooleanCallback explode; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CBuffTimedLife ability = new CBuffTimedLife(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), - this.explode.callback(game, caster, localStore, castId)); - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "CreateTimedLifeBuffAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ", " - + this.explode.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTargetingBuff.java deleted file mode 100644 index 7b99f34d8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTargetingBuff.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTargetingBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateTimedTargetingBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABFloatCallback duration; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CBuff ability = new ABTimedTargetingBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId)); - - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "CreateTimedTargetingBuffAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingBuff.java deleted file mode 100644 index 0d38e5e06..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingBuff.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTickingBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTimedTickingBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABFloatCallback duration; - private ABBooleanCallback showTimedLifeBar; - private List onAddActions; - private List onRemoveActions; - private List onExpireActions; - private List onTickActions; - private ABBooleanCallback showIcon; - private CEffectType artType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - boolean showTimedLife = false; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.callback(game, caster, localStore, castId); - } - - if (this.showIcon != null) { - final ABTimedTickingBuff ability = new ABTimedTickingBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, this.onTickActions, - this.showIcon.callback(game, caster, localStore, castId), castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - else { - final ABTimedTickingBuff ability = new ABTimedTickingBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, this.onTickActions, castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, - "CreateTimedTickingBuffAU_OnAddActions"); - final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, - "CreateTimedTickingBuffAU_OnRemoveActions"); - final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, - "CreateTimedTickingBuffAU_OnExpireActions"); - final String tickFunctionName = jassTextGenerator.createAnonymousFunction(this.onTickActions, - "CreateTimedTickingBuffAU_OnTickActions"); - - String showTimedLife = "false"; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); - } - - String showIconExpression; - if (this.showIcon != null) { - showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); - } - else { - showIconExpression = "true"; - } - - CEffectType artTypeUsed = CEffectType.TARGET; - if (this.artType != null) { - artTypeUsed = this.artType; - } - String artTypeExpression; - artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); - - return "CreateTimedTickingBuffAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " - + jassTextGenerator.functionPointerByName(addFunctionName) + ", " - + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " - + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " - + jassTextGenerator.functionPointerByName(tickFunctionName) + ", " + showIconExpression + ", " - + artTypeExpression + ", " + jassTextGenerator.getCastId() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingPausedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingPausedBuff.java deleted file mode 100644 index ec57244dc..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingPausedBuff.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTickingPausedBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTimedTickingPausedBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABFloatCallback duration; - private ABBooleanCallback showTimedLifeBar; - private List onAddActions; - private List onRemoveActions; - private List onExpireActions; - private List onTickActions; - private ABBooleanCallback showIcon; - private CEffectType artType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - boolean showTimedLife = false; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.callback(game, caster, localStore, castId); - } - - if (this.showIcon != null) { - final ABTimedTickingPausedBuff ability = new ABTimedTickingPausedBuff( - game.getHandleIdAllocator().createId(), this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, this.onTickActions, - this.showIcon.callback(game, caster, localStore, castId), castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - else { - final ABTimedTickingPausedBuff ability = new ABTimedTickingPausedBuff( - game.getHandleIdAllocator().createId(), this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, this.onTickActions, castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, - "CreateTimedTickingPausedBuffAU_OnAddActions"); - final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, - "CreateTimedTickingPausedBuffAU_OnRemoveActions"); - final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, - "CreateTimedTickingPausedBuffAU_OnExpireActions"); - final String tickFunctionName = jassTextGenerator.createAnonymousFunction(this.onTickActions, - "CreateTimedTickingPausedBuffAU_OnTickActions"); - - String showTimedLife = "false"; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); - } - - String showIconExpression; - if (this.showIcon != null) { - showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); - } - else { - showIconExpression = "true"; - } - - CEffectType artTypeUsed = CEffectType.TARGET; - if (this.artType != null) { - artTypeUsed = this.artType; - } - String artTypeExpression; - artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); - - return "CreateTimedTickingPausedBuffAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " - + jassTextGenerator.functionPointerByName(addFunctionName) + ", " - + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " - + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " - + jassTextGenerator.functionPointerByName(tickFunctionName) + ", " + showIconExpression + ", " - + artTypeExpression + ", " + jassTextGenerator.getCastId() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingPostDeathBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingPostDeathBuff.java deleted file mode 100644 index 3c15515b5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionCreateTimedTickingPostDeathBuff.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTickingPostDeathBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateTimedTickingPostDeathBuff implements ABSingleAction { - - private ABIDCallback buffId; - private ABFloatCallback duration; - private ABBooleanCallback showTimedLifeBar; - private List onAddActions; - private List onRemoveActions; - private List onExpireActions; - private List onTickActions; - private ABBooleanCallback showIcon; - private CEffectType artType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - boolean showTimedLife = false; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.callback(game, caster, localStore, castId); - } - - if (this.showIcon != null) { - final ABTimedTickingPostDeathBuff ability = new ABTimedTickingPostDeathBuff( - game.getHandleIdAllocator().createId(), this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, this.onTickActions, - this.showIcon.callback(game, caster, localStore, castId), castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - else { - final ABTimedTickingPostDeathBuff ability = new ABTimedTickingPostDeathBuff( - game.getHandleIdAllocator().createId(), this.buffId.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId), showTimedLife, localStore, - this.onAddActions, this.onRemoveActions, this.onExpireActions, this.onTickActions, castId); - if (this.artType != null) { - ability.setArtType(this.artType); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); - } - if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { - localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); - } - - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, - "CreateTimedTickingPostDeathBuffAU_OnAddActions"); - final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, - "CreateTimedTickingPostDeathBuffAU_OnRemoveActions"); - final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, - "CreateTimedTickingPostDeathBuffAU_OnExpireActions"); - final String tickFunctionName = jassTextGenerator.createAnonymousFunction(this.onTickActions, - "CreateTimedTickingPostDeathBuffAU_OnTickActions"); - - String showTimedLife = "false"; - if (this.showTimedLifeBar != null) { - showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); - } - - String showIconExpression; - if (this.showIcon != null) { - showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); - } - else { - showIconExpression = "true"; - } - - CEffectType artTypeUsed = CEffectType.TARGET; - if (this.artType != null) { - artTypeUsed = this.artType; - } - String artTypeExpression; - artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); - - return "CreateTimedTickingPostDeathBuffAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " - + jassTextGenerator.functionPointerByName(addFunctionName) + ", " - + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " - + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " - + jassTextGenerator.functionPointerByName(tickFunctionName) + ", " + showIconExpression + ", " - + artTypeExpression + ", " + jassTextGenerator.getCastId() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionRemoveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionRemoveBuff.java deleted file mode 100644 index f9386a232..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionRemoveBuff.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks.ABBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveBuff implements ABSingleAction { - - private ABUnitCallback target; - private ABBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CBuff theBuff = this.buff.callback(game, caster, localStore, castId); - if (theBuff != null) { - (this.target.callback(game, caster, localStore, castId)).remove(game, theBuff); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RemoveUnitAbility(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionRemoveNonStackingDisplayBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionRemoveNonStackingDisplayBuff.java deleted file mode 100644 index 3aa5a9701..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/buff/ABActionRemoveNonStackingDisplayBuff.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks.ABBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveNonStackingDisplayBuff implements ABSingleAction { - - private ABUnitCallback target; - private ABStringCallback key; - private ABBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CBuff ability = this.buff.callback(game, caster, localStore, castId); - this.target.callback(game, caster, localStore, castId).removeNonStackingDisplayBuff(game, - this.key.callback(game, caster, localStore, castId), ability); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RemoveUnitNonStackingDisplayBuff(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " - + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionAddDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionAddDestructableBuff.java deleted file mode 100644 index 9499f0644..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionAddDestructableBuff.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.destructable; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable.ABDestructableCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructablebuff.ABDestructableBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddDestructableBuff implements ABSingleAction { - - private ABDestructableCallback target; - private ABDestructableBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CDestructableBuff ability = this.buff.callback(game, caster, localStore, castId); - this.target.callback(game, caster, localStore, castId).add(game, ability); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AddDestructableBuff(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionCreateDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionCreateDestructableBuff.java deleted file mode 100644 index 9ec74b54d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionCreateDestructableBuff.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.destructable; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateDestructableBuff implements ABSingleAction { - - private ABIDCallback buffId; - private List onAddActions; - private List onRemoveActions; - private List onDeathActions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CDestructableBuff ability = new ABDestructableBuff(game.getHandleIdAllocator().createId(), - this.buffId.callback(game, caster, localStore, castId), - (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL), localStore, this.onAddActions, - this.onRemoveActions, this.onDeathActions, castId, caster); - - localStore.put(ABLocalStoreKeys.LASTCREATEDDESTBUFF, ability); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, - "CreateDestructableBuffAU_OnAddActions"); - final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, - "CreateDestructableBuffAU_OnRemoveActions"); - final String deathFunctionName = jassTextGenerator.createAnonymousFunction(this.onDeathActions, - "CreateDestructableBuffAU_OnDeathActions"); - - return "CreateDestructableBuffAU(" + jassTextGenerator.getCaster() + ", " - + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " - + jassTextGenerator.functionPointerByName(addFunctionName) + ", " - + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " - + jassTextGenerator.functionPointerByName(deathFunctionName) + ", " + jassTextGenerator.getCastId() - + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionDamageDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionDamageDestructable.java deleted file mode 100644 index 8be37653b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionDamageDestructable.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.destructable; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable.ABDestructableCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAttackTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABDamageTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; - -public class ABActionDamageDestructable implements ABSingleAction { - - private ABUnitCallback source; - private ABDestructableCallback target; - private ABBooleanCallback isAttack; - private ABBooleanCallback isRanged; - private ABAttackTypeCallback attackType; - private ABDamageTypeCallback damageType; - private ABFloatCallback damage; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - boolean isItAttack = false; - boolean isItRanged = true; - CAttackType theAttackType = CAttackType.SPELLS; - CDamageType theDamageType = CDamageType.MAGIC; - - if (this.isAttack != null) { - isItAttack = this.isAttack.callback(game, caster, localStore, castId); - } - if (this.isRanged != null) { - isItRanged = this.isRanged.callback(game, caster, localStore, castId); - } - if (this.attackType != null) { - theAttackType = this.attackType.callback(game, caster, localStore, castId); - } - if (this.damageType != null) { - theDamageType = this.damageType.callback(game, caster, localStore, castId); - } - - this.target.callback(game, caster, localStore, castId).damage(game, - this.source.callback(game, caster, localStore, castId), isItAttack, isItRanged, theAttackType, - theDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), - this.damage.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - // TODO Auto-generated method stub -// native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean - - String attackExpression = "false"; - if (this.isAttack != null) { - attackExpression = this.isAttack.generateJassEquivalent(jassTextGenerator); - } - String rangedExpression = "true"; - if (this.isRanged != null) { - rangedExpression = this.isRanged.generateJassEquivalent(jassTextGenerator); - } - String attackTypeExpression = "ATTACK_TYPE_SPELLS"; - String damageTypeExpression = "DAMAGE_TYPE_MAGIC"; - if (this.attackType != null) { - attackTypeExpression = this.attackType.generateJassEquivalent(jassTextGenerator); - } - if (this.damageType != null) { - damageTypeExpression = this.damageType.generateJassEquivalent(jassTextGenerator); - } - - return "UnitDamageTarget(" + this.source.generateJassEquivalent(jassTextGenerator) + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.damage.generateJassEquivalent(jassTextGenerator) + ", " + attackExpression + ", " - + rangedExpression + ", " + attackTypeExpression + ", " + damageTypeExpression - + ", WEAPON_TYPE_WHOKNOWS)"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionIterateDestructablesInRangeOfLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionIterateDestructablesInRangeOfLocation.java deleted file mode 100644 index eb85f58aa..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionIterateDestructablesInRangeOfLocation.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.destructable; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructableEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionIterateDestructablesInRangeOfLocation implements ABAction { - - private static final Rectangle recycleRect = new Rectangle(); - - private ABLocationCallback location; - private ABFloatCallback range; - private List iterationActions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityPointTarget target = this.location.callback(game, caster, localStore, castId); - final Float rangeVal = this.range.callback(game, caster, localStore, castId); - - recycleRect.set(target.getX() - rangeVal, target.getY() - rangeVal, rangeVal * 2, rangeVal * 2); - game.getWorldCollision().enumDestructablesInRect(recycleRect, new CDestructableEnumFunction() { - @Override - public boolean call(final CDestructable enumDest) { - if (enumDest.distance(target.getX(), target.getY()) < rangeVal) { - localStore.put(ABLocalStoreKeys.ENUMDESTRUCTABLE + castId, enumDest); - for (final ABAction iterationAction : ABActionIterateDestructablesInRangeOfLocation.this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); - } - } - return false; - } - }); - localStore.remove(ABLocalStoreKeys.ENUMDESTRUCTABLE + castId); - } - - @Override - public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { - final List modifiedActionList = new ArrayList<>(this.iterationActions); - modifiedActionList.add(0, new JassTextGeneratorCallStmt() { - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetLocalStoreDestructableHandle(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMDESTRUCTABLE + I2S(" + jassTextGenerator.getCastId() + "), " - + "GetEnumDestructable()" + ")"; - } - }); - final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, - "DestsInRangeEnumActions"); - - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - // TODO this BJ function uses <= range instead of < range - sb.append("call EnumDestructablesInCircleBJ(" + this.range.generateJassEquivalent(jassTextGenerator) + ", " - + this.location.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.functionPointerByName(iterationActionsName) + ")"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMDESTRUCTABLE + I2S(" + jassTextGenerator.getCastId() + "))"); - jassTextGenerator.println(sb.toString()); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionRemoveDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionRemoveDestructableBuff.java deleted file mode 100644 index 2f0214bc2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/destructable/ABActionRemoveDestructableBuff.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.destructable; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable.ABDestructableCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructablebuff.ABDestructableBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveDestructableBuff implements ABSingleAction { - - private ABDestructableCallback target; - private ABDestructableBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CDestructableBuff ability = this.buff.callback(game, caster, localStore, castId); - this.target.callback(game, caster, localStore, castId).remove(game, ability); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RemoveDestructableBuff(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionCreateTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionCreateTimeOfDayEvent.java deleted file mode 100644 index 50e8b0aff..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionCreateTimeOfDayEvent.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.events; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event.ABTimeOfDayEvent; - -public class ABActionCreateTimeOfDayEvent implements ABSingleAction { - - private List actions; - private ABFloatCallback startTime; - private ABFloatCallback endTime; - - private ABStringCallback equalityId; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - String eqId = null; - float st = 0; - float et = Float.MAX_VALUE; - if (this.equalityId != null) { - eqId = this.equalityId.callback(game, caster, localStore, castId); - } - if (this.startTime != null) { - st = this.startTime.callback(game, caster, localStore, castId); - } - if (this.endTime != null) { - et = this.endTime.callback(game, caster, localStore, castId); - } - - final ABTimeOfDayEvent event = new ABTimeOfDayEvent(game, caster, localStore, castId, this.actions, st, et, - eqId); - - localStore.put(ABLocalStoreKeys.LASTCREATEDTODEVENT, event); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String actionsFuncName = jassTextGenerator.createAnonymousFunction(this.actions, - "CreateABTimeOfDayEventAU_Actions"); - - String startTimeExpression = "0"; - String endTimeExpression = Long.toString(Long.MAX_VALUE) + ".0"; - String equalityIdExpression = null; - if (this.equalityId != null) { - equalityIdExpression = this.equalityId.generateJassEquivalent(jassTextGenerator); - } - if (this.startTime != null) { - startTimeExpression = this.startTime.generateJassEquivalent(jassTextGenerator); - } - if (this.endTime != null) { - endTimeExpression = this.endTime.generateJassEquivalent(jassTextGenerator); - } - - return "CreateABTimeOfDayEventAU(" + jassTextGenerator.functionPointerByName(actionsFuncName) + ", " - + startTimeExpression + ", " + endTimeExpression + ", " + this.equalityId + ", " - + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + ", " - + jassTextGenerator.getCastId() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionRegisterTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionRegisterTimeOfDayEvent.java deleted file mode 100644 index 5941b65e9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionRegisterTimeOfDayEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.events; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.eventcallbacks.timeeventcallbacks.ABTimeOfDayEventCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRegisterTimeOfDayEvent implements ABSingleAction { - - private ABTimeOfDayEventCallback event; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - game.registerTimeOfDayEvent(this.event.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RegisterABTimeOfDayEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionRegisterUniqueTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionRegisterUniqueTimeOfDayEvent.java deleted file mode 100644 index 8038814fa..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionRegisterUniqueTimeOfDayEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.events; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.eventcallbacks.timeeventcallbacks.ABTimeOfDayEventCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event.ABTimeOfDayEvent; - -public class ABActionRegisterUniqueTimeOfDayEvent implements ABSingleAction { - - private ABTimeOfDayEventCallback event; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final ABTimeOfDayEvent ev = this.event.callback(game, caster, localStore, castId); - if (!game.isTimeOfDayEventRegistered(ev)) { - game.registerTimeOfDayEvent(ev); - } - - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RegisterUniqueABTimeOfDayEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionUnregisterTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionUnregisterTimeOfDayEvent.java deleted file mode 100644 index 1977c11a2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/events/ABActionUnregisterTimeOfDayEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.events; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.eventcallbacks.timeeventcallbacks.ABTimeOfDayEventCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionUnregisterTimeOfDayEvent implements ABSingleAction { - - private ABTimeOfDayEventCallback event; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - game.unregisterTimeOfDayEvent(this.event.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "UnregisterABTimeOfDayEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/floatingtext/ABActionCreateFloatingTextOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/floatingtext/ABActionCreateFloatingTextOnUnit.java deleted file mode 100644 index 1cec1e9da..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/floatingtext/ABActionCreateFloatingTextOnUnit.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.floatingtext; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.TextTagConfigType; - -public class ABActionCreateFloatingTextOnUnit implements ABSingleAction { - - private ABUnitCallback target; - private TextTagConfigType textType; - private ABStringCallback message; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - game.spawnTextTag(this.target.callback(game, caster, localStore, castId), caster.getPlayerIndex(), - this.textType, this.message.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "CreateTextTagFromConfig(" + this.target.generateJassEquivalent(jassTextGenerator) - + ", TEXT_TAG_CONFIG_TYPE_" + this.textType.name() + ", " - + this.message.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/floatingtext/ABActionCreateNumericFloatingTextOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/floatingtext/ABActionCreateNumericFloatingTextOnUnit.java deleted file mode 100644 index 7f174d122..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/floatingtext/ABActionCreateNumericFloatingTextOnUnit.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.floatingtext; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.TextTagConfigType; - -public class ABActionCreateNumericFloatingTextOnUnit implements ABSingleAction { - - private ABUnitCallback target; - private TextTagConfigType textType; - private ABFloatCallback amount; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float theAmount = 0; - if (this.amount != null) { - theAmount = this.amount.callback(game, caster, localStore, castId); - } - - game.spawnTextTag(this.target.callback(game, caster, localStore, castId), caster.getPlayerIndex(), - this.textType, (int) (theAmount)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "CreateIntTextTagFromConfig(" + this.target.generateJassEquivalent(jassTextGenerator) - + ", TEXT_TAG_CONFIG_TYPE_" + this.textType.name() + ", R2I(" - + this.amount.generateJassEquivalent(jassTextGenerator) + "))"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/gamestate/ABActionSetFalseTimeOfDay.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/gamestate/ABActionSetFalseTimeOfDay.java deleted file mode 100644 index 31112cf14..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/gamestate/ABActionSetFalseTimeOfDay.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.gamestate; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetFalseTimeOfDay implements ABSingleAction { - - private ABIntegerCallback hour; - private ABIntegerCallback minute; - private ABFloatCallback duration; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - game.addFalseTimeOfDay(this.hour.callback(game, caster, localStore, castId), - this.minute.callback(game, caster, localStore, castId), - this.duration.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetFalseTimeOfDay(" + this.hour.generateJassEquivalent(jassTextGenerator) + ", " - + this.minute.generateJassEquivalent(jassTextGenerator) + ", " - + this.duration.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/item/ABActionChargeItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/item/ABActionChargeItem.java deleted file mode 100644 index 79c8febb4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/item/ABActionChargeItem.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.item; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.item.ABItemCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionChargeItem implements ABSingleAction { - - private ABItemCallback item; - private ABBooleanCallback checkForPerish; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - CItem it = null; - if (this.item == null) { - final AbilityBuilderAbility ability = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - it = ability.getItem(); - } - else { - it = this.item.callback(game, caster, localStore, castId); - } - - it.setCharges(it.getCharges() - 1); - if ((this.checkForPerish != null) && this.checkForPerish.callback(game, caster, localStore, castId) - && it.getItemType().isPerishable() && (it.getCharges() == 0)) { - it.forceDropIfHeld(game); - game.removeItem(it); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - String itemExpression = "null"; - if (this.item != null) { - itemExpression = this.item.generateJassEquivalent(jassTextGenerator); - } - String checkForPerishExpression = "false"; - if (this.checkForPerish != null) { - checkForPerishExpression = this.checkForPerish.generateJassEquivalent(jassTextGenerator); - } - return "ChargeItemAU(" + itemExpression + ", " + checkForPerishExpression + ", " - + jassTextGenerator.getTriggerLocalStore() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/player/ABActionGiveResourcesToPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/player/ABActionGiveResourcesToPlayer.java deleted file mode 100644 index 160d3b2e5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/player/ABActionGiveResourcesToPlayer.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.player; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.ABPlayerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; - -public class ABActionGiveResourcesToPlayer implements ABSingleAction { - - private ABPlayerCallback player; - private ABIntegerCallback gold; - private ABIntegerCallback lumber; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CPlayer p = this.player.callback(game, caster, localStore, castId); - if (this.gold != null) { - p.addGold(this.gold.callback(game, caster, localStore, castId)); - } - if (this.lumber != null) { - p.addLumber(this.lumber.callback(game, caster, localStore, castId)); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - String goldExpression = "0"; - if (this.gold != null) { - goldExpression = this.gold.generateJassEquivalent(jassTextGenerator); - } - String lumberExpression = "0"; - if (this.lumber != null) { - lumberExpression = this.lumber.generateJassEquivalent(jassTextGenerator); - } - - return "GiveResourcesToPlayerAU(" + this.player.generateJassEquivalent(jassTextGenerator) + ", " - + goldExpression + ", " + lumberExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/player/ABActionSetAbilityEnabledForPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/player/ABActionSetAbilityEnabledForPlayer.java deleted file mode 100644 index 792895490..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/player/ABActionSetAbilityEnabledForPlayer.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.player; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.ABPlayerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; - -public class ABActionSetAbilityEnabledForPlayer implements ABSingleAction { - - private ABPlayerCallback player; - private ABIDCallback abilityId; - private ABBooleanCallback enabled; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CPlayer p = this.player.callback(game, caster, localStore, castId); - boolean e = true; - if (this.enabled != null) { - e = this.enabled.callback(game, caster, localStore, castId); - } - p.setAbilityEnabled(game, this.abilityId.callback(game, caster, localStore, castId), e); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - String enabledExpression = "true"; - if (this.enabled != null) { - enabledExpression = this.enabled.generateJassEquivalent(jassTextGenerator); - } - return "SetPlayerAbilityAvailable(" + this.player.generateJassEquivalent(jassTextGenerator) + ", " - + this.abilityId.generateJassEquivalent(jassTextGenerator) + ", " + enabledExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedCollisionProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedCollisionProjectile.java deleted file mode 100644 index fa3c8b375..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedCollisionProjectile.java +++ /dev/null @@ -1,221 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABCollisionProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionCreateLocationTargetedCollisionProjectile implements ABSingleAction { - - private ABUnitCallback source; - private ABLocationCallback sourceLoc; - private ABLocationCallback target; - private ABIDCallback id; - private ABFloatCallback speed; - private ABBooleanCallback homing; - - private List onLaunch; - private List onPreHits; - private List canHitTarget; - private List onHit; - - private ABIntegerCallback maxHits; - private ABIntegerCallback hitsPerTarget; - private ABFloatCallback radius; - private ABFloatCallback startingRadius; - private ABFloatCallback endingRadius; - private ABFloatCallback collisionInterval; - private ABBooleanCallback provideCounts; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float theSpeed = 0; - boolean isHoming = true; - int theMaxHits = 0; - int theHitsPerTarget = 1; - float theStartingRadius = 0; - float theEndingRadius = 0; - float theCollisionInterval = 0.05f; - boolean isProvideCounts = false; - final CUnit theSource = this.source.callback(game, caster, localStore, castId); - AbilityTarget sourceLocation = theSource; - - if (this.sourceLoc != null) { - sourceLocation = this.sourceLoc.callback(game, caster, localStore, castId); - } - if (this.maxHits != null) { - theMaxHits = this.maxHits.callback(game, caster, localStore, castId); - } - if (this.hitsPerTarget != null) { - theHitsPerTarget = this.hitsPerTarget.callback(game, caster, localStore, castId); - } - if (this.radius != null) { - final float rad = this.radius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - else { - if (this.endingRadius != null) { - theStartingRadius = this.startingRadius.callback(game, caster, localStore, castId); - theEndingRadius = this.endingRadius.callback(game, caster, localStore, castId); - } - else { - final float rad = this.startingRadius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - } - if (this.collisionInterval != null) { - theCollisionInterval = this.collisionInterval.callback(game, caster, localStore, castId); - } - if (this.provideCounts != null) { - isProvideCounts = this.provideCounts.callback(game, caster, localStore, castId); - } - - final GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - if (this.speed != null) { - theSpeed = this.speed.callback(game, caster, localStore, castId); - } - else { - theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); - } - if (this.homing != null) { - isHoming = this.homing.callback(game, caster, localStore, castId); - } - else { - isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); - } - - final AbilityPointTarget theTarget = this.target.callback(game, caster, localStore, castId); - - final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, - this.canHitTarget, this.onHit, caster, localStore, castId); - - final CProjectile proj = game.createCollisionProjectile(theSource, - this.id.callback(game, caster, localStore, castId), sourceLocation.getX(), sourceLocation.getY(), - (float) theSource.angleTo(theTarget), theSpeed, isHoming, theTarget, theMaxHits, theHitsPerTarget, - theStartingRadius, theEndingRadius, theCollisionInterval, listener, isProvideCounts); - - localStore.put(ABLocalStoreKeys.LASTCREATEDPROJECTILE + castId, proj); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, - "CreateLocationTargetedCollisionProjectileAU_OnLaunch"); - final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, - "CreateLocationTargetedCollisionProjectileAU_OnPreHits"); - final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, - "CreateLocationTargetedCollisionProjectileAU_CanHitTarget"); - final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, - "CreateLocationTargetedCollisionProjectileAU_OnHit"); - - final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); - String sourceLocExpression; - if (this.sourceLoc != null) { - sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); - } - else { - sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; - } - - String maxHitsExpression = "0"; - if (this.maxHits != null) { - maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); - } - - String hitsPerTargetExpression = "1"; - if (this.hitsPerTarget != null) { - hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); - } - - String startingRadiusExpression; - String endingRadiusExpression; - if (this.radius != null) { - final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - else { - if (this.endingRadius != null) { - startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); - } - else { - final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - } - - String collisionIntervalExpression = "0.05"; - if (this.collisionInterval != null) { - collisionIntervalExpression = this.collisionInterval.generateJassEquivalent(jassTextGenerator); - } - - String provideCountsExpression = "false"; - if (this.provideCounts != null) { - provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); - } - if (this.speed != null) { - if (this.homing != null) { - String homingExpression = "true"; - if (this.homing != null) { - homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); - } - return "CreateLocationTargetedCollisionProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + homingExpression + ", " - + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression - + ", " + collisionIntervalExpression + ", " + provideCountsExpression + ")"; - - } - else { - throw new UnsupportedOperationException(); - } - } - else if (this.homing != null) { - throw new UnsupportedOperationException(); - } - - return "CreateLocationTargetedCollisionProjectileAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " - + collisionIntervalExpression + ", " + provideCountsExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedProjectile.java deleted file mode 100644 index f20a695be..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedProjectile.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionCreateLocationTargetedProjectile implements ABSingleAction { - - private ABUnitCallback source; - private ABLocationCallback sourceLoc; - private ABLocationCallback target; - private ABIDCallback id; - private ABFloatCallback speed; - private ABBooleanCallback homing; - - private List onLaunch; - private List onHit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float theSpeed = 0; - boolean isHoming = true; - final CUnit theSource = this.source.callback(game, caster, localStore, castId); - AbilityTarget sourceLocation = theSource; - - final GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - if (this.sourceLoc != null) { - sourceLocation = this.sourceLoc.callback(game, caster, localStore, castId); - } - if (this.speed != null) { - theSpeed = this.speed.callback(game, caster, localStore, castId); - } - else { - theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); - } - if (this.homing != null) { - isHoming = this.homing.callback(game, caster, localStore, castId); - } - else { - isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); - } - - final AbilityPointTarget theTarget = this.target.callback(game, caster, localStore, castId); - - final CAbilityProjectileListener listener = new ABProjectileListener(this.onLaunch, this.onHit, caster, - localStore, castId); - - final CProjectile proj = game.createProjectile(theSource, this.id.callback(game, caster, localStore, castId), - sourceLocation.getX(), sourceLocation.getY(), (float) theSource.angleTo(theTarget), theSpeed, isHoming, - theTarget, listener); - - localStore.put(ABLocalStoreKeys.LASTCREATEDPROJECTILE + castId, proj); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, - "CreateLocationTargetedProjectileAU_OnLaunch"); - final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, - "CreateLocationTargetedProjectileAU_OnHit"); - - final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); - String sourceLocExpression; - if (this.sourceLoc != null) { - sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); - } - else { - sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; - } - - if (this.speed != null) { - if (this.homing != null) { - String homingExpression = "true"; - if (this.homing != null) { - homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); - } - return "CreateLocationTargetedProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + homingExpression + ", " - + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ")"; - - } - else { - throw new UnsupportedOperationException(); - } - } - else if (this.homing != null) { - throw new UnsupportedOperationException(); - } - - return "CreateLocationTargetedProjectileAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedPseudoProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedPseudoProjectile.java deleted file mode 100644 index 3e5c9467d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateLocationTargetedPseudoProjectile.java +++ /dev/null @@ -1,255 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABCollisionProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateLocationTargetedPseudoProjectile implements ABSingleAction { - - private ABUnitCallback source; - private ABLocationCallback sourceLoc; - private ABLocationCallback target; - private ABIDCallback id; - private CEffectType effectType; - private ABIntegerCallback effectArtIndex; - private ABFloatCallback speed; - private ABBooleanCallback homing; - - private List onLaunch; - private List onPreHits; - private List canHitTarget; - private List onHit; - - private ABIntegerCallback maxHits; - private ABIntegerCallback hitsPerTarget; - private ABFloatCallback radius; - private ABFloatCallback startingRadius; - private ABFloatCallback endingRadius; - private ABFloatCallback projectileStepInterval; - private ABIntegerCallback projectileArtSkip; - private ABBooleanCallback provideCounts; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float theSpeed = 0; - boolean isHoming = true; - int theMaxHits = 0; - int theHitsPerTarget = 1; - float theStartingRadius = 0; - float theEndingRadius = 0; - float theCollisionInterval = 0.25f; - CEffectType theEffectType = CEffectType.SPECIAL; - int theEffectArtIndex = 0; - boolean isProvideCounts = false; - final CUnit theSource = this.source.callback(game, caster, localStore, castId); - AbilityTarget sourceLocation = theSource; - int theArtSkip = 1; - - if (this.sourceLoc != null) { - sourceLocation = this.sourceLoc.callback(game, caster, localStore, castId); - } - if (this.effectType != null) { - theEffectType = this.effectType; - } - if (this.effectArtIndex != null) { - theEffectArtIndex = this.effectArtIndex.callback(game, caster, localStore, castId); - } - - if (this.maxHits != null) { - theMaxHits = this.maxHits.callback(game, caster, localStore, castId); - } - if (this.hitsPerTarget != null) { - theHitsPerTarget = this.hitsPerTarget.callback(game, caster, localStore, castId); - } - if (this.radius != null) { - final float rad = this.radius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - else { - if (this.endingRadius != null) { - theStartingRadius = this.startingRadius.callback(game, caster, localStore, castId); - theEndingRadius = this.endingRadius.callback(game, caster, localStore, castId); - } - else { - final float rad = this.startingRadius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - } - if (this.projectileStepInterval != null) { - theCollisionInterval = this.projectileStepInterval.callback(game, caster, localStore, castId); - } - if (this.projectileArtSkip != null) { - theArtSkip = this.projectileArtSkip.callback(game, caster, localStore, castId); - } - if (this.provideCounts != null) { - isProvideCounts = this.provideCounts.callback(game, caster, localStore, castId); - } - - final GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - if (this.speed != null) { - theSpeed = this.speed.callback(game, caster, localStore, castId); - } - else { - theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); - } - if (this.homing != null) { - isHoming = this.homing.callback(game, caster, localStore, castId); - } - else { - isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); - } - - final AbilityPointTarget theTarget = this.target.callback(game, caster, localStore, castId); - - final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, - this.canHitTarget, this.onHit, caster, localStore, castId); - - final CProjectile proj = game.createPseudoProjectile(theSource, - this.id.callback(game, caster, localStore, castId), theEffectType, theEffectArtIndex, - sourceLocation.getX(), sourceLocation.getY(), (float) theSource.angleTo(theTarget), theSpeed, - theCollisionInterval, theArtSkip, isHoming, theTarget, theMaxHits, theHitsPerTarget, theStartingRadius, - theEndingRadius, listener, isProvideCounts); - - localStore.put(ABLocalStoreKeys.LASTCREATEDPROJECTILE + castId, proj); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, - "CreateLocationTargetedPseudoProjectileAU_OnLaunch"); - final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, - "CreateLocationTargetedPseudoProjectileAU_OnPreHits"); - final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, - "CreateLocationTargetedPseudoProjectileAU_CanHitTarget"); - final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, - "CreateLocationTargetedPseudoProjectileAU_OnHit"); - - CEffectType theEffectType = CEffectType.SPECIAL; - if (this.effectType != null) { - theEffectType = this.effectType; - } - final String effectTypeExpression = "EFFECT_TYPE_" + theEffectType.name(); - String theEffectArtIndex = "0"; - if (this.effectArtIndex != null) { - theEffectArtIndex = this.effectArtIndex.generateJassEquivalent(jassTextGenerator); - } - - final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); - String sourceLocExpression; - if (this.sourceLoc != null) { - sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); - } - else { - sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; - } - - String maxHitsExpression = "0"; - if (this.maxHits != null) { - maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); - } - - String hitsPerTargetExpression = "1"; - if (this.hitsPerTarget != null) { - hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); - } - - String startingRadiusExpression; - String endingRadiusExpression; - if (this.radius != null) { - final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - else { - if (this.endingRadius != null) { - startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); - } - else { - final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - } - - String collisionIntervalExpression = "0.25"; - if (this.projectileStepInterval != null) { - collisionIntervalExpression = this.projectileStepInterval.generateJassEquivalent(jassTextGenerator); - } - - String artSkipExpression = "1"; - if (this.projectileArtSkip != null) { - artSkipExpression = this.projectileArtSkip.generateJassEquivalent(jassTextGenerator); - } - - String provideCountsExpression = "false"; - if (this.provideCounts != null) { - provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); - } - if (this.speed != null) { - if (this.homing != null) { - String homingExpression = "true"; - if (this.homing != null) { - homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); - } - return "CreateLocationTargetedPseudoProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " - + theEffectArtIndex + ", " + this.speed.generateJassEquivalent(jassTextGenerator) + ", " - + homingExpression + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression - + ", " + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression - + ")"; - - } - else { - throw new UnsupportedOperationException(); - } - } - else if (this.homing != null) { - throw new UnsupportedOperationException(); - } - - return "CreateLocationTargetedPseudoProjectileAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " - + theEffectArtIndex + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " - + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedCollisionProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedCollisionProjectile.java deleted file mode 100644 index c6f9e8ea2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedCollisionProjectile.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABCollisionProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionCreateUnitTargetedCollisionProjectile implements ABSingleAction { - - private ABUnitCallback source; - private ABLocationCallback sourceLoc; - private ABUnitCallback target; - private ABIDCallback id; - private ABFloatCallback speed; - private ABBooleanCallback homing; - - private List onLaunch; - private List onPreHits; - private List canHitTarget; - private List onHit; - - private ABIntegerCallback maxHits; - private ABIntegerCallback hitsPerTarget; - private ABFloatCallback radius; - private ABFloatCallback startingRadius; - private ABFloatCallback endingRadius; - private ABFloatCallback collisionInterval; - private ABBooleanCallback provideCounts; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float theSpeed = 0; - boolean isHoming = true; - int theMaxHits = 0; - int theHitsPerTarget = 1; - float theStartingRadius = 0; - float theEndingRadius = 0; - float theCollisionInterval = 0.05f; - boolean isProvideCounts = false; - final CUnit theSource = this.source.callback(game, caster, localStore, castId); - AbilityTarget sourceLocation = theSource; - - if (this.sourceLoc != null) { - sourceLocation = this.sourceLoc.callback(game, caster, localStore, castId); - } - if (this.maxHits != null) { - theMaxHits = this.maxHits.callback(game, caster, localStore, castId); - } - if (this.hitsPerTarget != null) { - theHitsPerTarget = this.hitsPerTarget.callback(game, caster, localStore, castId); - } - if (this.radius != null) { - final float rad = this.radius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - else { - if (this.endingRadius != null) { - theStartingRadius = this.startingRadius.callback(game, caster, localStore, castId); - theEndingRadius = this.endingRadius.callback(game, caster, localStore, castId); - } - else { - final float rad = this.startingRadius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - } - if (this.collisionInterval != null) { - theCollisionInterval = this.collisionInterval.callback(game, caster, localStore, castId); - } - if (this.provideCounts != null) { - isProvideCounts = this.provideCounts.callback(game, caster, localStore, castId); - } - - final GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - if (this.speed != null) { - theSpeed = this.speed.callback(game, caster, localStore, castId); - } - else { - theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); - } - if (this.homing != null) { - isHoming = this.homing.callback(game, caster, localStore, castId); - } - else { - isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); - } - - final CUnit theTarget = this.target.callback(game, caster, localStore, castId); - - final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, - this.canHitTarget, this.onHit, caster, localStore, castId); - - final CProjectile proj = game.createCollisionProjectile(theSource, - this.id.callback(game, caster, localStore, castId), sourceLocation.getX(), sourceLocation.getY(), - (float) theSource.angleTo(theTarget), theSpeed, isHoming, theTarget, theMaxHits, theHitsPerTarget, - theStartingRadius, theEndingRadius, theCollisionInterval, listener, isProvideCounts); - - localStore.put(ABLocalStoreKeys.LASTCREATEDPROJECTILE + castId, proj); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, - "CreateLocationTargetedCollisionProjectileAU_OnLaunch"); - final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, - "CreateLocationTargetedCollisionProjectileAU_OnPreHits"); - final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, - "CreateLocationTargetedCollisionProjectileAU_CanHitTarget"); - final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, - "CreateLocationTargetedCollisionProjectileAU_OnHit"); - - final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); - String sourceLocExpression; - if (this.sourceLoc != null) { - sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); - } - else { - sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; - } - - String maxHitsExpression = "0"; - if (this.maxHits != null) { - maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); - } - - String hitsPerTargetExpression = "1"; - if (this.hitsPerTarget != null) { - hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); - } - - String startingRadiusExpression; - String endingRadiusExpression; - if (this.radius != null) { - final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - else { - if (this.endingRadius != null) { - startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); - } - else { - final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - } - - String collisionIntervalExpression = "0.05"; - if (this.collisionInterval != null) { - collisionIntervalExpression = this.collisionInterval.generateJassEquivalent(jassTextGenerator); - } - - String provideCountsExpression = "false"; - if (this.provideCounts != null) { - provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); - } - if (this.speed != null) { - if (this.homing != null) { - String homingExpression = "true"; - if (this.homing != null) { - homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); - } - return "CreateUnitTargetedCollisionProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + homingExpression + ", " - + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression - + ", " + collisionIntervalExpression + ", " + provideCountsExpression + ")"; - - } - else { - throw new UnsupportedOperationException(); - } - } - else if (this.homing != null) { - throw new UnsupportedOperationException(); - } - - return "CreateUnitTargetedCollisionProjectileAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " - + collisionIntervalExpression + ", " + provideCountsExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedProjectile.java deleted file mode 100644 index a2f546e1c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedProjectile.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionCreateUnitTargetedProjectile implements ABSingleAction { - - private ABUnitCallback source; - private ABLocationCallback sourceLoc; - private ABUnitCallback target; - private ABIDCallback id; - private ABFloatCallback speed; - private ABBooleanCallback homing; - - private List onLaunch; - private List onHit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float theSpeed = 0; - boolean isHoming = true; - final CUnit theSource = this.source.callback(game, caster, localStore, castId); - AbilityTarget sourceLocation = theSource; - - final GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - if (this.sourceLoc != null) { - sourceLocation = this.sourceLoc.callback(game, caster, localStore, castId); - } - if (this.speed != null) { - theSpeed = this.speed.callback(game, caster, localStore, castId); - } - else { - theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); - } - if (this.homing != null) { - isHoming = this.homing.callback(game, caster, localStore, castId); - } - else { - isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); - } - - final CUnit theTarget = this.target.callback(game, caster, localStore, castId); - - final CAbilityProjectileListener listener = new ABProjectileListener(this.onLaunch, this.onHit, caster, - localStore, castId); - - final CProjectile proj = game.createProjectile(theSource, this.id.callback(game, caster, localStore, castId), - sourceLocation.getX(), sourceLocation.getY(), (float) theSource.angleTo(theTarget), theSpeed, isHoming, - theTarget, listener); - - localStore.put(ABLocalStoreKeys.LASTCREATEDPROJECTILE + castId, proj); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String onLaunchFunc = jassTextGenerator.createAnonymousFunction(this.onLaunch, - "CreateUnitTargetedProjectileAU_OnLaunch"); - final String onHitFunc = jassTextGenerator.createAnonymousFunction(this.onHit, - "CreateUnitTargetedProjectileAU_OnHit"); - - final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); - String sourceLocExpression; - if (this.sourceLoc != null) { - sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); - } - else { - sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; - } - - if (this.speed != null) { - if (this.homing != null) { - return "CreateUnitTargetedProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + sourceUnitExpression + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + this.speed.generateJassEquivalent(jassTextGenerator) + ", " - + this.homing.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.functionPointerByName(onLaunchFunc) + ", " - + jassTextGenerator.functionPointerByName(onHitFunc) + ")"; - - } - else { - throw new UnsupportedOperationException(); - } - } - else if (this.homing != null) { - throw new UnsupportedOperationException(); - } - - return "CreateUnitTargetedProjectileAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + sourceUnitExpression + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.functionPointerByName(onLaunchFunc) + ", " - + jassTextGenerator.functionPointerByName(onHitFunc) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedPseudoProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedPseudoProjectile.java deleted file mode 100644 index 8ed0f2a4b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionCreateUnitTargetedPseudoProjectile.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile.ABCollisionProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class ABActionCreateUnitTargetedPseudoProjectile implements ABSingleAction { - - private ABUnitCallback source; - private ABLocationCallback sourceLoc; - private ABUnitCallback target; - private ABIDCallback id; - private CEffectType effectType; - private ABIntegerCallback effectArtIndex; - private ABFloatCallback speed; - private ABBooleanCallback homing; - - private List onLaunch; - private List onPreHits; - private List canHitTarget; - private List onHit; - - private ABIntegerCallback maxHits; - private ABIntegerCallback hitsPerTarget; - private ABFloatCallback radius; - private ABFloatCallback startingRadius; - private ABFloatCallback endingRadius; - private ABFloatCallback projectileStepInterval; - private ABIntegerCallback projectileArtSkip; - private ABBooleanCallback provideCounts; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - float theSpeed = 0; - boolean isHoming = true; - int theMaxHits = 0; - int theHitsPerTarget = 1; - float theStartingRadius = 0; - float theEndingRadius = 0; - float theCollisionInterval = 0.25f; - CEffectType theEffectType = CEffectType.SPECIAL; - int theEffectArtIndex = 0; - boolean isProvideCounts = false; - final CUnit theSource = this.source.callback(game, caster, localStore, castId); - AbilityTarget sourceLocation = theSource; - int theArtSkip = 1; - - if (this.sourceLoc != null) { - sourceLocation = this.sourceLoc.callback(game, caster, localStore, castId); - } - if (this.effectType != null) { - theEffectType = this.effectType; - } - if (this.effectArtIndex != null) { - theEffectArtIndex = this.effectArtIndex.callback(game, caster, localStore, castId); - } - - if (this.maxHits != null) { - theMaxHits = this.maxHits.callback(game, caster, localStore, castId); - } - if (this.hitsPerTarget != null) { - theHitsPerTarget = this.hitsPerTarget.callback(game, caster, localStore, castId); - } - if (this.radius != null) { - final float rad = this.radius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - else { - if (this.endingRadius != null) { - theStartingRadius = this.startingRadius.callback(game, caster, localStore, castId); - theEndingRadius = this.endingRadius.callback(game, caster, localStore, castId); - } - else { - final float rad = this.startingRadius.callback(game, caster, localStore, castId); - theStartingRadius = rad; - theEndingRadius = rad; - } - } - if (this.projectileStepInterval != null) { - theCollisionInterval = this.projectileStepInterval.callback(game, caster, localStore, castId); - } - if (this.projectileArtSkip != null) { - theArtSkip = this.projectileArtSkip.callback(game, caster, localStore, castId); - } - if (this.provideCounts != null) { - isProvideCounts = this.provideCounts.callback(game, caster, localStore, castId); - } - - final GameObject editorData = (GameObject) localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - if (this.speed != null) { - theSpeed = this.speed.callback(game, caster, localStore, castId); - } - else { - theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); - } - if (this.homing != null) { - isHoming = this.homing.callback(game, caster, localStore, castId); - } - else { - isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); - } - - final CUnit theTarget = this.target.callback(game, caster, localStore, castId); - - final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, - this.canHitTarget, this.onHit, caster, localStore, castId); - - final CProjectile proj = game.createPseudoProjectile(theSource, - this.id.callback(game, caster, localStore, castId), theEffectType, theEffectArtIndex, - sourceLocation.getX(), sourceLocation.getY(), (float) theSource.angleTo(theTarget), theSpeed, - theCollisionInterval, theArtSkip, isHoming, theTarget, theMaxHits, theHitsPerTarget, theStartingRadius, - theEndingRadius, listener, isProvideCounts); - - localStore.put(ABLocalStoreKeys.LASTCREATEDPROJECTILE + castId, proj); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, - "CreateUnitTargetedPseudoProjectileAU_OnLaunch"); - final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, - "CreateUnitTargetedPseudoProjectileAU_OnPreHits"); - final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, - "CreateUnitTargetedPseudoProjectileAU_CanHitTarget"); - final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, - "CreateUnitTargetedPseudoProjectileAU_OnHit"); - - CEffectType theEffectType = CEffectType.SPECIAL; - if (this.effectType != null) { - theEffectType = this.effectType; - } - final String effectTypeExpression = "EFFECT_TYPE_" + theEffectType.name(); - String theEffectArtIndex = "0"; - if (this.effectArtIndex != null) { - theEffectArtIndex = this.effectArtIndex.generateJassEquivalent(jassTextGenerator); - } - - final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); - String sourceLocExpression; - if (this.sourceLoc != null) { - sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); - } - else { - sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; - } - - String maxHitsExpression = "0"; - if (this.maxHits != null) { - maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); - } - - String hitsPerTargetExpression = "1"; - if (this.hitsPerTarget != null) { - hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); - } - - String startingRadiusExpression; - String endingRadiusExpression; - if (this.radius != null) { - final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - else { - if (this.endingRadius != null) { - startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); - } - else { - final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); - startingRadiusExpression = radiusExpression; - endingRadiusExpression = radiusExpression; - } - } - - String collisionIntervalExpression = "0.25"; - if (this.projectileStepInterval != null) { - collisionIntervalExpression = this.projectileStepInterval.generateJassEquivalent(jassTextGenerator); - } - - String artSkipExpression = "1"; - if (this.projectileArtSkip != null) { - artSkipExpression = this.projectileArtSkip.generateJassEquivalent(jassTextGenerator); - } - - String provideCountsExpression = "false"; - if (this.provideCounts != null) { - provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); - } - if (this.speed != null) { - if (this.homing != null) { - String homingExpression = "true"; - if (this.homing != null) { - homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); - } - return "CreateUnitTargetedPseudoProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " - + theEffectArtIndex + ", " + this.speed.generateJassEquivalent(jassTextGenerator) + ", " - + homingExpression + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression - + ", " + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression - + ")"; - - } - else { - throw new UnsupportedOperationException(); - } - } - else if (this.homing != null) { - throw new UnsupportedOperationException(); - } - - return "CreateUnitTargetedPseudoProjectileAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " - + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " - + theEffectArtIndex + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " - + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" - + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " - + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " - + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " - + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetAttackProjectileDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetAttackProjectileDamage.java deleted file mode 100644 index 8ce767a8a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetAttackProjectileDamage.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile.ABProjectileCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionSetAttackProjectileDamage implements ABSingleAction { - - private ABProjectileCallback projectile; - private ABFloatCallback damage; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - - final CProjectile proj = this.projectile.callback(game, caster, localStore, castId); - - if ((proj != null) && (proj instanceof CAttackProjectile)) { - final float dm = this.damage.callback(game, caster, localStore, castId); - System.err.println("Setting proj damage from " + ((CAttackProjectile) proj).getDamage() + " to " + dm); - ((CAttackProjectile) proj).setDamage(dm); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetAttackProjectileDamage(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " - + this.damage.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileDone.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileDone.java deleted file mode 100644 index 4ccc31b54..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileDone.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile.ABProjectileCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionSetProjectileDone implements ABSingleAction { - - private ABProjectileCallback projectile; - private ABBooleanCallback done; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - - final CProjectile proj = this.projectile.callback(game, caster, localStore, castId); - - proj.setDone(this.done.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetProjectileDone(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " - + this.done.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileReflected.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileReflected.java deleted file mode 100644 index 281b436be..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileReflected.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile.ABProjectileCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionSetProjectileReflected implements ABSingleAction { - - private ABProjectileCallback projectile; - private ABBooleanCallback reflected; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - - final CProjectile proj = this.projectile.callback(game, caster, localStore, castId); - - if (this.reflected != null) { - proj.setReflected(this.reflected.callback(game, caster, localStore, castId)); - } - else { - proj.setReflected(true); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - String reflectedExpression = "true"; - if (this.reflected != null) { - reflectedExpression = this.reflected.generateJassEquivalent(jassTextGenerator); - } - return "SetProjectileReflected(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " - + reflectedExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileTarget.java deleted file mode 100644 index 89e93768b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/projectile/ABActionSetProjectileTarget.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile.ABProjectileCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABActionSetProjectileTarget implements ABSingleAction { - - private ABProjectileCallback projectile; - private ABUnitCallback target; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - - final CProjectile proj = this.projectile.callback(game, caster, localStore, castId); - - proj.setTarget(this.target.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetProjectileTargetUnit(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionAddDefenseBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionAddDefenseBonus.java deleted file mode 100644 index 4192e8e55..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionAddDefenseBonus.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddDefenseBonus implements ABSingleAction { - - private ABUnitCallback targetUnit; - private ABFloatCallback defenseValue; - private ABBooleanCallback percentage; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit target = this.targetUnit.callback(game, caster, localStore, castId); - - if (this.percentage.callback(game, caster, localStore, castId)) { - // TODO need to fix percents - target.setTemporaryDefenseBonus( - target.getTemporaryDefenseBonus() + this.defenseValue.callback(game, caster, localStore, castId)); - } - else { - target.setTemporaryDefenseBonus( - target.getTemporaryDefenseBonus() + this.defenseValue.callback(game, caster, localStore, castId)); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "UnitAddDefenseBonus(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.defenseValue.generateJassEquivalent(jassTextGenerator) + ")//, " - + this.percentage.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionAddNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionAddNonStackingStatBuff.java deleted file mode 100644 index 4cd3db00b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionAddNonStackingStatBuff.java +++ /dev/null @@ -1,31 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statbuffcallbacks.ABNonStackingStatBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddNonStackingStatBuff implements ABSingleAction { - - private ABUnitCallback targetUnit; - private ABNonStackingStatBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit target = this.targetUnit.callback(game, caster, localStore, castId); - - target.addNonStackingStatBuff(this.buff.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AddUnitNonStackingStatBuff(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionCreateNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionCreateNonStackingStatBuff.java deleted file mode 100644 index 2592b890f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionCreateNonStackingStatBuff.java +++ /dev/null @@ -1,40 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABNonStackingStatBuffTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; - -public class ABActionCreateNonStackingStatBuff implements ABSingleAction { - - private ABNonStackingStatBuffTypeCallback buffType; - private ABStringCallback stackingKey; - private ABFloatCallback value; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final NonStackingStatBuff buff = new NonStackingStatBuff( - this.buffType.callback(game, caster, localStore, castId), - this.stackingKey.callback(game, caster, localStore, castId), - this.value.callback(game, caster, localStore, castId)); - - localStore.put(ABLocalStoreKeys.LASTCREATEDNSSB, buff); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "CreateNonStackingStatBuffAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.buffType.generateJassEquivalent(jassTextGenerator) + ", " - + this.stackingKey.generateJassEquivalent(jassTextGenerator) + ", " - + this.value.generateJassEquivalent(jassTextGenerator) + ")"; - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRecomputeStatBuffsOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRecomputeStatBuffsOnUnit.java deleted file mode 100644 index 531e85938..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRecomputeStatBuffsOnUnit.java +++ /dev/null @@ -1,30 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABNonStackingStatBuffTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRecomputeStatBuffsOnUnit implements ABSingleAction { - - private ABUnitCallback targetUnit; - private ABNonStackingStatBuffTypeCallback buffType; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit unit = this.targetUnit.callback(game, caster, localStore, castId); - unit.computeDerivedFields(this.buffType.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RecomputeStatBuffsOnUnit(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.buffType.generateJassEquivalent(jassTextGenerator) + ")"; - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRemoveDefenseBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRemoveDefenseBonus.java deleted file mode 100644 index 15bef3180..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRemoveDefenseBonus.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveDefenseBonus implements ABSingleAction { - - private ABUnitCallback targetUnit; - private ABFloatCallback defenseValue; - private ABBooleanCallback percentage; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit target = this.targetUnit.callback(game, caster, localStore, castId); - - if (this.percentage.callback(game, caster, localStore, castId)) { - // TODO need to fix percents - target.setTemporaryDefenseBonus( - target.getTemporaryDefenseBonus() - this.defenseValue.callback(game, caster, localStore, castId)); - } - else { - target.setTemporaryDefenseBonus( - target.getTemporaryDefenseBonus() - this.defenseValue.callback(game, caster, localStore, castId)); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "UnitAddDefenseBonus(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", -(" - + this.defenseValue.generateJassEquivalent(jassTextGenerator) + "))//, " - + this.percentage.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRemoveNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRemoveNonStackingStatBuff.java deleted file mode 100644 index b51fa850f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionRemoveNonStackingStatBuff.java +++ /dev/null @@ -1,31 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statbuffcallbacks.ABNonStackingStatBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveNonStackingStatBuff implements ABSingleAction { - - private ABUnitCallback targetUnit; - private ABNonStackingStatBuffCallback buff; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit target = this.targetUnit.callback(game, caster, localStore, castId); - - target.removeNonStackingStatBuff(this.buff.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RemoveUnitNonStackingStatBuff(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionUpdateNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionUpdateNonStackingStatBuff.java deleted file mode 100644 index ca3c9d1ae..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/stats/ABActionUpdateNonStackingStatBuff.java +++ /dev/null @@ -1,31 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statbuffcallbacks.ABNonStackingStatBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; - -public class ABActionUpdateNonStackingStatBuff implements ABSingleAction { - - private ABNonStackingStatBuffCallback buff; - private ABFloatCallback value; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final NonStackingStatBuff buffObj = this.buff.callback(game, caster, localStore, castId); - buffObj.setValue(this.value.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "UpdateNonStackingStatBuff(" + this.buff.generateJassEquivalent(jassTextGenerator) + ", " - + this.value.generateJassEquivalent(jassTextGenerator) + ")"; - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionBreak.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionBreak.java deleted file mode 100644 index 172163c9a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionBreak.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionBreak implements ABSingleAction { - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - localStore.put(ABLocalStoreKeys.BREAK, true); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.setUserDataExpr("AB_LOCAL_STORE_KEY_BREAK", JassTextGeneratorType.Boolean, "true"); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionCreateSubroutine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionCreateSubroutine.java deleted file mode 100644 index f9ce58ede..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionCreateSubroutine.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateSubroutine implements ABSingleAction { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - private List actions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - localStore.put(ABLocalStoreKeys.combineSubroutineInstanceKey( - this.key.callback(game, caster, localStore, castId), castId), this.actions); - } - else { - localStore.put( - ABLocalStoreKeys.combineSubroutineKey(this.key.callback(game, caster, localStore, castId), castId), - this.actions); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - final String subroutineFunctionName = jassTextGenerator.createAnonymousFunction(this.actions, - "CreateSubroutineAU"); - - String instanceValueExpression = "true"; - if (this.instanceValue == null) { - instanceValueExpression = this.instanceValue.generateJassEquivalent(jassTextGenerator); - } - - return "CreateSubroutineAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + instanceValueExpression + ", " + jassTextGenerator.functionPointerByName(subroutineFunctionName) - + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionFor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionFor.java deleted file mode 100644 index 08f01d0ad..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionFor.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionFor implements ABAction { - - private ABIntegerCallback times; - private List actions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final int max = this.times.callback(game, caster, localStore, castId); - for (int i = 0; i < max; i++) { - localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ITERATORCOUNT, castId), i); - for (final ABAction iterationAction : this.actions) { - iterationAction.runAction(game, caster, localStore, castId); - } - final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); - if ((brk != null) && brk) { - break; - } - } - } - - @Override - public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - - final String keyExpression = "AB_LOCAL_STORE_KEY_ITERATORCOUNT + I2S(" + jassTextGenerator.getCastId() + ")"; - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call " + jassTextGenerator.setUserDataExpr(keyExpression, JassTextGeneratorType.Integer, "0")); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("loop"); - jassTextGenerator.println(sb.toString()); - final int childIndent = indent + 1; - sb.setLength(0); - JassTextGenerator.Util.indent(childIndent, sb); - sb.append("exitwhen "); - sb.append(jassTextGenerator.getUserDataExpr(keyExpression, JassTextGeneratorType.Integer)); - sb.append(" >= "); - sb.append(this.times.generateJassEquivalent(jassTextGenerator)); - jassTextGenerator.println(sb.toString()); - - for (final ABAction action : this.actions) { - action.generateJassEquivalent(childIndent, jassTextGenerator); - } - - sb.setLength(0); - JassTextGenerator.Util.indent(childIndent, sb); - sb.append("if "); - sb.append(jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_BREAK", JassTextGeneratorType.Boolean)); - sb.append(" then"); - jassTextGenerator.println(sb.toString()); - - final int breakBranchIndent = childIndent + 1; - sb.setLength(0); - JassTextGenerator.Util.indent(breakBranchIndent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_BREAK)"); - jassTextGenerator.println(sb.toString()); - sb.setLength(0); - JassTextGenerator.Util.indent(breakBranchIndent, sb); - sb.append("exitwhen true // break"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(childIndent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(childIndent, sb); - sb.append("call " + jassTextGenerator.setUserDataExpr(keyExpression, JassTextGeneratorType.Integer, - jassTextGenerator.getUserDataExpr(keyExpression, JassTextGeneratorType.Integer) + " + 1")); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endloop"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIf.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIf.java deleted file mode 100644 index 18fd34178..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIf.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABActionIf implements ABAction { - - private ABCondition condition; - private List thenActions; - private List elseActions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - if (this.condition.evaluate(game, caster, localStore, castId)) { - for (final ABAction periodicAction : this.thenActions) { - periodicAction.runAction(game, caster, localStore, castId); - } - } - else { - for (final ABAction periodicAction : this.elseActions) { - periodicAction.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("if "); - sb.append(this.condition.generateJassEquivalent(jassTextGenerator)); - sb.append(" then"); - jassTextGenerator.println(sb.toString()); - final int childIndent = indent + 1; - if (this.thenActions != null) { - for (final ABAction action : this.thenActions) { - action.generateJassEquivalent(childIndent, jassTextGenerator); - } - } - if (this.elseActions != null) { - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("else"); - jassTextGenerator.println(sb.toString()); - for (final ABAction action : this.elseActions) { - action.generateJassEquivalent(childIndent, jassTextGenerator); - } - } - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfLocation.java deleted file mode 100644 index 976ee6e0a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfLocation.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionIterateUnitsInRangeOfLocation implements ABAction { - - private static final Rectangle recycleRect = new Rectangle(); - - private ABLocationCallback location; - private ABFloatCallback range; - private List iterationActions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityPointTarget target = this.location.callback(game, caster, localStore, castId); - final Float rangeVal = this.range.callback(game, caster, localStore, castId); - - recycleRect.set(target.getX() - rangeVal, target.getY() - rangeVal, rangeVal * 2, rangeVal * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (enumUnit.canReach(target, rangeVal)) { - localStore.put(ABLocalStoreKeys.ENUMUNIT + castId, enumUnit); - for (final ABAction iterationAction : ABActionIterateUnitsInRangeOfLocation.this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); - } - } - return false; - } - }); - localStore.remove(ABLocalStoreKeys.ENUMUNIT + castId); - } - - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final List modifiedActionList = new ArrayList<>(this.iterationActions); - modifiedActionList.add(0, new JassTextGeneratorCallStmt() { - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " - + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; - } - }); - modifiedActionList.add(new JassTextGeneratorStmt() { - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("return false"); - jassTextGenerator.println(sb.toString()); - } - }); - final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, - "UnitsInRangeOfLocEnumActions"); - - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("// TODO: use a global filter"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call GroupEnumUnitsInRangeOfLoc(au_tempGroup, " - + this.location.generateJassEquivalent(jassTextGenerator) + ", " - + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" - + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfLocationMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfLocationMatchingCondition.java deleted file mode 100644 index 0cc0d1c99..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfLocationMatchingCondition.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionIterateUnitsInRangeOfLocationMatchingCondition implements ABAction { - - private static final Rectangle recycleRect = new Rectangle(); - - private ABLocationCallback location; - private ABFloatCallback range; - private List iterationActions; - private ABCondition condition; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final AbilityPointTarget target = this.location.callback(game, caster, localStore, castId); - final Float rangeVal = this.range.callback(game, caster, localStore, castId); - - recycleRect.set(target.getX() - rangeVal, target.getY() - rangeVal, rangeVal * 2, rangeVal * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (enumUnit.canReach(target, rangeVal)) { - localStore.put(ABLocalStoreKeys.MATCHINGUNIT + castId, enumUnit); - if ((ABActionIterateUnitsInRangeOfLocationMatchingCondition.this.condition == null) - || ABActionIterateUnitsInRangeOfLocationMatchingCondition.this.condition.evaluate(game, - caster, localStore, castId)) { - localStore.put(ABLocalStoreKeys.ENUMUNIT + castId, enumUnit); - for (final ABAction iterationAction : ABActionIterateUnitsInRangeOfLocationMatchingCondition.this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); - } - } - } - return false; - } - }); - localStore.remove(ABLocalStoreKeys.ENUMUNIT + castId); - localStore.remove(ABLocalStoreKeys.MATCHINGUNIT + castId); - } - - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final List modifiedActionList = new ArrayList<>(this.iterationActions); - modifiedActionList.add(0, new JassTextGeneratorCallStmt() { - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " - + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; - } - }); - if (this.condition != null) { - modifiedActionList.add(0, new JassTextGeneratorStmt() { - @Override - public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "), " - + "GetFilterUnit()" + ")"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("if not "); - sb.append(ABActionIterateUnitsInRangeOfLocationMatchingCondition.this.condition - .generateJassEquivalent(jassTextGenerator)); - sb.append(" then"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent + 1, sb); - sb.append("return false"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - } - }); - } - modifiedActionList.add(new JassTextGeneratorStmt() { - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("return false"); - jassTextGenerator.println(sb.toString()); - } - }); - final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, - "UnitsInRangeOfLocEnumActions"); - - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("// TODO: use a global filter"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call GroupEnumUnitsInRangeOfLoc(au_tempGroup, " - + this.location.generateJassEquivalent(jassTextGenerator) + ", " - + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" - + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfUnit.java deleted file mode 100644 index 3df21066e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfUnit.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionIterateUnitsInRangeOfUnit implements ABAction { - - private static final Rectangle recycleRect = new Rectangle(); - private List iterationActions; - - private ABUnitCallback originUnit; - private ABFloatCallback range; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit originUnitTarget = this.originUnit.callback(game, caster, localStore, castId); - final Float rangeVal = this.range.callback(game, caster, localStore, castId); - - recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (originUnitTarget.canReach(enumUnit, rangeVal)) { - localStore.put(ABLocalStoreKeys.ENUMUNIT + castId, enumUnit); - for (final ABAction iterationAction : ABActionIterateUnitsInRangeOfUnit.this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); - } - } - return false; - } - }); - localStore.remove(ABLocalStoreKeys.ENUMUNIT + castId); - } - - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final List modifiedActionList = new ArrayList<>(this.iterationActions); - modifiedActionList.add(0, new JassTextGeneratorCallStmt() { - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " - + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; - } - }); - modifiedActionList.add(new JassTextGeneratorStmt() { - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("return false"); - jassTextGenerator.println(sb.toString()); - } - }); - final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, - "UnitsInRangeOfUnitEnumActions"); - - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("// TODO: use a global filter"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call GroupEnumUnitsInRangeOfUnit(au_tempGroup, " - + this.originUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" - + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfUnitMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfUnitMatchingCondition.java deleted file mode 100644 index 7aee0b912..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRangeOfUnitMatchingCondition.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionIterateUnitsInRangeOfUnitMatchingCondition implements ABAction { - - private static final Rectangle recycleRect = new Rectangle(); - private List iterationActions; - private ABCondition condition; - - private ABUnitCallback originUnit; - private ABFloatCallback range; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit originUnitTarget = this.originUnit.callback(game, caster, localStore, castId); - final Float rangeVal = this.range.callback(game, caster, localStore, castId); - - recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (originUnitTarget.canReach(enumUnit, rangeVal)) { - localStore.put(ABLocalStoreKeys.MATCHINGUNIT + castId, enumUnit); - if ((ABActionIterateUnitsInRangeOfUnitMatchingCondition.this.condition == null) - || ABActionIterateUnitsInRangeOfUnitMatchingCondition.this.condition.evaluate(game, caster, - localStore, castId)) { - localStore.put(ABLocalStoreKeys.ENUMUNIT + castId, enumUnit); - for (final ABAction iterationAction : ABActionIterateUnitsInRangeOfUnitMatchingCondition.this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); - } - } - } - return false; - } - }); - localStore.remove(ABLocalStoreKeys.ENUMUNIT + castId); - localStore.remove(ABLocalStoreKeys.MATCHINGUNIT + castId); - } - - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final List modifiedActionList = new ArrayList<>(this.iterationActions); - modifiedActionList.add(0, new JassTextGeneratorCallStmt() { - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " - + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; - } - }); - if (this.condition != null) { - modifiedActionList.add(0, new JassTextGeneratorStmt() { - @Override - public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "), " - + "GetFilterUnit()" + ")"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("if not "); - sb.append(ABActionIterateUnitsInRangeOfUnitMatchingCondition.this.condition - .generateJassEquivalent(jassTextGenerator)); - sb.append(" then"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent + 1, sb); - sb.append("return false"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - } - }); - } - modifiedActionList.add(new JassTextGeneratorStmt() { - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("return false"); - jassTextGenerator.println(sb.toString()); - } - }); - final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, - "UnitsInRangeOfUnitEnumActions"); - - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("// TODO: use a global filter"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call GroupEnumUnitsInRangeOfUnit(au_tempGroup, " - + this.originUnit.generateJassEquivalent(jassTextGenerator) + ", " - + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" - + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionPeriodicExecute.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionPeriodicExecute.java deleted file mode 100644 index 8de183363..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionPeriodicExecute.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionPeriodicExecute implements ABAction { - - private List periodicActions; - private ABFloatCallback delaySeconds; - private ABBooleanCallback initialTick; - - private ABCallback unique; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - int nextActiveTick = 0; - Object u = null; - if (this.unique != null) { - u = this.unique.callback(game, caster, localStore, castId); - if (localStore.containsKey(ABLocalStoreKeys.PERIODICNEXTTICK + castId + "$" + u)) { - nextActiveTick = (int) localStore.get(ABLocalStoreKeys.PERIODICNEXTTICK + castId + "$" + u); - } - } - else { - if (localStore.containsKey(ABLocalStoreKeys.PERIODICNEXTTICK + castId)) { - nextActiveTick = (int) localStore.get(ABLocalStoreKeys.PERIODICNEXTTICK + castId); - } - } - - final int currentTick = game.getGameTurnTick(); - if (currentTick >= nextActiveTick) { - final int delayTicks = (int) (this.delaySeconds.callback(game, caster, localStore, castId) - / WarsmashConstants.SIMULATION_STEP_TIME); - if (nextActiveTick == 0) { - nextActiveTick = currentTick + delayTicks; - if ((this.initialTick != null) && this.initialTick.callback(game, caster, localStore, castId)) { - for (final ABAction periodicAction : this.periodicActions) { - periodicAction.runAction(game, caster, localStore, castId); - } - } - } - else { - nextActiveTick = currentTick + delayTicks; - for (final ABAction periodicAction : this.periodicActions) { - periodicAction.runAction(game, caster, localStore, castId); - } - } - } - - if (this.unique != null) { - localStore.put(ABLocalStoreKeys.PERIODICNEXTTICK + castId + "$" + u, nextActiveTick); - } - else { - localStore.put(ABLocalStoreKeys.PERIODICNEXTTICK + castId, nextActiveTick); - } - } - - @Override - public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { - String uniquenessKeyExpression; - if (this.unique != null) { - uniquenessKeyExpression = "I2S(" + jassTextGenerator.getCastId() + ") + \"$\" + " - + this.unique.generateJassEquivalent(jassTextGenerator); - } - else { - uniquenessKeyExpression = "I2S(" + jassTextGenerator.getCastId() + ")"; - } - String initialTickExpression; - if (this.initialTick != null) { - initialTickExpression = this.initialTick.generateJassEquivalent(jassTextGenerator); - } - else { - initialTickExpression = "false"; - } - - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("if PeriodicExecuteAU("); - sb.append(jassTextGenerator.getTriggerLocalStore()); - sb.append(", "); - sb.append(this.delaySeconds.generateJassEquivalent(jassTextGenerator)); - sb.append(", "); - sb.append(initialTickExpression); - sb.append(", "); - sb.append(uniquenessKeyExpression); - sb.append(") then"); - jassTextGenerator.println(sb.toString()); - final int childIndent = indent + 1; - if (this.periodicActions != null) { - for (final ABAction action : this.periodicActions) { - action.generateJassEquivalent(childIndent, jassTextGenerator); - } - } - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionRunSubroutine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionRunSubroutine.java deleted file mode 100644 index cf8448f8d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionRunSubroutine.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRunSubroutine implements ABSingleAction { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - @SuppressWarnings("unchecked") - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - List actions; - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - actions = (List) localStore.get(ABLocalStoreKeys - .combineSubroutineInstanceKey(this.key.callback(game, caster, localStore, castId), castId)); - } - else { - actions = (List) localStore.get( - ABLocalStoreKeys.combineSubroutineKey(this.key.callback(game, caster, localStore, castId), castId)); - } - System.err.println("RUNNING SUBROUTINE: " + this.key.callback(game, caster, localStore, castId)); - if (actions != null) { - for (final ABAction action : actions) { - action.runAction(game, caster, localStore, castId); - } - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String instanceValueExpression = "true"; - if (this.instanceValue != null) { - instanceValueExpression = this.instanceValue.generateJassEquivalent(jassTextGenerator); - } - - return "RunSubroutineAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() - + ", " + jassTextGenerator.getCastId() + ", " + this.key.generateJassEquivalent(jassTextGenerator) - + ", " + instanceValueExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionStoreValueLocally.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionStoreValueLocally.java deleted file mode 100644 index b3dcab44d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionStoreValueLocally.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionStoreValueLocally implements ABSingleAction { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - private ABCallback valueToStore; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - localStore.put(ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(game, caster, localStore, castId), - castId), this.valueToStore.callback(game, caster, localStore, castId)); - } - else { - localStore.put(ABLocalStoreKeys.combineUserKey(this.key.callback(game, caster, localStore, castId), castId), - this.valueToStore.callback(game, caster, localStore, castId)); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String args = jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + this.valueToStore.generateJassEquivalent(jassTextGenerator); - - if (this.valueToStore instanceof ABStringCallback) { - if (this.instanceValue == null) { - return "SetLocalStoreUserCastStringAU(" + args + ")"; - } - else { - return "StoreStringLocallyAU(" + args + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - } - else if ((this.valueToStore instanceof ABIntegerCallback) || (this.valueToStore instanceof ABIDCallback)) { - if (this.instanceValue == null) { - return "SetLocalStoreUserCastIntegerAU(" + args + ")"; - } - else { - return "StoreIntegerLocallyAU(" + args + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - } - else if (this.valueToStore instanceof ABBooleanCallback) { - if (this.instanceValue == null) { - return "SetLocalStoreUserCastBooleanAU(" + args + ")"; - } - else { - return "StoreBooleanLocallyAU(" + args + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - } - else if (this.valueToStore instanceof ABFloatCallback) { - if (this.instanceValue == null) { - return "SetLocalStoreUserCastRealAU(" + args + ")"; - } - else { - return "StoreRealLocallyAU(" + args + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - } - else { - if (this.instanceValue == null) { - return "SetLocalStoreUserCastHandleAU(" + args + ")"; - } - else { - return "StoreHandleLocallyAU(" + args + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionWhile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionWhile.java deleted file mode 100644 index f5262f2bf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionWhile.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionWhile implements ABAction { - - private ABCondition condition; - private List loopActions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - while (this.condition.evaluate(game, caster, localStore, castId)) { - for (final ABAction periodicAction : this.loopActions) { - periodicAction.runAction(game, caster, localStore, castId); - } - final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); - if ((brk != null) && brk) { - break; - } - } - } - - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("loop"); - jassTextGenerator.println(sb.toString()); - final int childIndent = indent + 1; - sb.setLength(0); - JassTextGenerator.Util.indent(childIndent, sb); - sb.append("exitwhen not "); - sb.append(this.condition.generateJassEquivalent(jassTextGenerator)); - jassTextGenerator.println(sb.toString()); - - for (final ABAction action : this.loopActions) { - action.generateJassEquivalent(childIndent, jassTextGenerator); - } - - sb.setLength(0); - JassTextGenerator.Util.indent(childIndent, sb); - sb.append("if "); - sb.append(jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_BREAK", JassTextGeneratorType.Boolean)); - sb.append(" then"); - jassTextGenerator.println(sb.toString()); - - final int breakBranchIndent = childIndent + 1; - sb.setLength(0); - JassTextGenerator.Util.indent(breakBranchIndent, sb); - sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() - + ", AB_LOCAL_STORE_KEY_BREAK)"); - jassTextGenerator.println(sb.toString()); - sb.setLength(0); - JassTextGenerator.Util.indent(breakBranchIndent, sb); - sb.append("exitwhen true // break"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(childIndent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endloop"); - jassTextGenerator.println(sb.toString()); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionCreateTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionCreateTimer.java deleted file mode 100644 index 15814b308..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionCreateTimer.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.timer; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.ABTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABActionCreateTimer implements ABSingleAction { - - private ABFloatCallback timeout; - private ABBooleanCallback repeats; - private List actions; - private ABBooleanCallback startTimer; - private ABFloatCallback delay; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - - final CTimer timer = new ABTimer(caster, localStore, this.actions, castId); - timer.setTimeoutTime(this.timeout.callback(game, caster, localStore, castId)); - localStore.put(ABLocalStoreKeys.LASTCREATEDTIMER, timer); - - if ((this.repeats != null) && this.repeats.callback(game, caster, localStore, castId)) { - timer.setRepeats(true); - if ((this.startTimer == null) || this.startTimer.callback(game, caster, localStore, castId)) { - if (this.delay != null) { - timer.startRepeatingTimerWithDelay(game, this.delay.callback(game, caster, localStore, castId)); - } - else { - timer.start(game); - } - localStore.put(ABLocalStoreKeys.LASTSTARTEDTIMER, timer); - } - } - else { - if ((this.startTimer == null) || this.startTimer.callback(game, caster, localStore, castId)) { - timer.start(game); - localStore.put(ABLocalStoreKeys.LASTSTARTEDTIMER, timer); - } - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - final String funcName = jassTextGenerator.createAnonymousFunction(this.actions, "CreateTimerAU_OnTimerFire"); - - String repeatsExpression = "false"; - if (this.repeats != null) { - repeatsExpression = this.repeats.generateJassEquivalent(jassTextGenerator); - } - - String startTimerExpression = "true"; - if (this.startTimer != null) { - startTimerExpression = this.startTimer.generateJassEquivalent(jassTextGenerator); - } - - final String args = jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + ", " - + jassTextGenerator.getCastId() + ", " + this.timeout.generateJassEquivalent(jassTextGenerator) + ", " - + repeatsExpression + ", " + jassTextGenerator.functionPointerByName(funcName) + ", " - + startTimerExpression; - - if (this.delay != null) { - return "CreateTimerDelayedAU(" + args + ", " + this.delay.generateJassEquivalent(jassTextGenerator) + ")"; - } - else { - return "CreateTimerAU(" + args + ")"; - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionRemoveTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionRemoveTimer.java deleted file mode 100644 index 403c5bcc5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionRemoveTimer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.timer; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks.ABTimerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveTimer implements ABSingleAction { - - private ABTimerCallback timer; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - this.timer.callback(game, caster, localStore, castId).pause(game); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "PauseTimer(" + this.timer.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionStartTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionStartTimer.java deleted file mode 100644 index fcb9ee11a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionStartTimer.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.timer; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks.ABTimerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABActionStartTimer implements ABSingleAction { - - private ABTimerCallback timer; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CTimer t = this.timer.callback(game, caster, localStore, castId); - t.start(game); - localStore.put(ABLocalStoreKeys.LASTSTARTEDTIMER, t); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "StartTimerAU(" + this.timer.generateJassEquivalent(jassTextGenerator) + ", " - + jassTextGenerator.getTriggerLocalStore() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionUpdateTimerTimeout.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionUpdateTimerTimeout.java deleted file mode 100644 index f81aea79b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/timer/ABActionUpdateTimerTimeout.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.timer; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks.ABTimerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionUpdateTimerTimeout implements ABSingleAction { - - private ABTimerCallback timer; - private ABFloatCallback timeout; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - this.timer.callback(game, caster, localStore, castId) - .setTimeoutTime(this.timeout.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "ABTimerSetTimeoutTime(" + this.timer.generateJassEquivalent(jassTextGenerator) + ", " - + this.timeout.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddMp.java deleted file mode 100644 index 3dfba18ed..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddMp.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddMp implements ABSingleAction { - - private ABUnitCallback target; - private ABFloatCallback amount; - private ABBooleanCallback isPercent; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - boolean percent = false; - if (this.isPercent != null) { - percent = this.isPercent.callback(game, caster, localStore, castId); - } - final CUnit targetUnit = this.target.callback(game, caster, localStore, castId); - if (percent) { - targetUnit.setMana(Math.max(Math.min( - targetUnit.getMana() - + (this.amount.callback(game, caster, localStore, castId) * targetUnit.getMaximumMana()), - targetUnit.getMaximumMana()), 0)); - } - else { - targetUnit.setMana( - Math.max(Math.min(targetUnit.getMana() + this.amount.callback(game, caster, localStore, castId), - targetUnit.getMaximumMana()), 0)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String percentExpression = "false"; - if (this.isPercent != null) { - percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); - } - return "AddMpAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddNewAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddNewAbility.java deleted file mode 100644 index 6436fe00c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddNewAbility.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddNewAbility implements ABSingleAction { - - private ABUnitCallback unit; - private ABIDCallback id; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CAbility ability = game.getAbilityData() - .getAbilityType(this.id.callback(game, caster, localStore, castId)) - .createAbility(game.getHandleIdAllocator().createId()); - localStore.put(ABLocalStoreKeys.LASTCREATEDABILITY, ability); - this.unit.callback(game, caster, localStore, castId).add(game, ability); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "AddNewAbilityAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddRallyAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddRallyAbility.java deleted file mode 100644 index 28fb8dd4b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionAddRallyAbility.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddRallyAbility implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CAbility ability = new CAbilityRally(game.getHandleIdAllocator().createId()); - this.unit.callback(game, caster, localStore, castId).add(game, ability); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "UnitAddAbility(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", 'ARal')"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCheckAbilityEffectReaction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCheckAbilityEffectReaction.java deleted file mode 100644 index ad2ce3c04..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCheckAbilityEffectReaction.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCheckAbilityEffectReaction implements ABSingleAction { - - private ABUnitCallback target; - private List onHitActions; - private List onBlockActions; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - CUnit tarU = caster; - if (this.target != null) { - tarU = this.target.callback(game, caster, localStore, castId); - } - if (tarU.checkForAbilityEffectReaction(game, caster, (CAbility) localStore.get(ABLocalStoreKeys.ABILITY))) { - if (this.onHitActions != null) { - for (final ABAction periodicAction : this.onHitActions) { - periodicAction.runAction(game, caster, localStore, castId); - } - } - } - else { - if (this.onBlockActions != null) { - for (final ABAction periodicAction : this.onBlockActions) { - periodicAction.runAction(game, caster, localStore, castId); - } - } - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - final String onBlockFunc = jassTextGenerator.createAnonymousFunction(this.onBlockActions, - "CheckAbilityEffectReactionAU_OnBlock"); - final String onHitFunc = jassTextGenerator.createAnonymousFunction(this.onHitActions, - "CheckAbilityEffectReactionAU_OnHit"); - String tarU; - if (this.target != null) { - tarU = this.target.generateJassEquivalent(jassTextGenerator); - } - else { - tarU = jassTextGenerator.getCaster(); - } - return "CheckAbilityEffectReactionAU(" + jassTextGenerator.getCaster() + ", " - + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + tarU + ", " - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) + ", " - + jassTextGenerator.functionPointerByName(onHitFunc) + ", " - + jassTextGenerator.functionPointerByName(onBlockFunc) + ")"; - } - - @Override - public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { - String tarU; - if (this.target != null) { - tarU = this.target.generateJassEquivalent(jassTextGenerator); - } - else { - tarU = jassTextGenerator.getCaster(); - } - - final StringBuilder sb = new StringBuilder(); - if ((this.onHitActions == null) || this.onHitActions.isEmpty()) { - if ((this.onBlockActions != null) && !this.onBlockActions.isEmpty()) { - JassTextGenerator.Util.indent(indent, sb); - sb.append("if not CheckUnitForAbilityEffectReaction("); - sb.append(tarU); - sb.append(", "); - sb.append(jassTextGenerator.getCaster()); - sb.append(", "); - sb.append( - jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle)); - sb.append(") then"); - jassTextGenerator.println(sb.toString()); - - for (final ABAction onHitAction : this.onBlockActions) { - onHitAction.generateJassEquivalent(indent + 1, jassTextGenerator); - } - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - } - } - else { - JassTextGenerator.Util.indent(indent, sb); - sb.append("if CheckUnitForAbilityEffectReaction("); - sb.append(tarU); - sb.append(", "); - sb.append(jassTextGenerator.getCaster()); - sb.append(", "); - sb.append(jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle)); - sb.append(") then"); - jassTextGenerator.println(sb.toString()); - - for (final ABAction onHitAction : this.onHitActions) { - onHitAction.generateJassEquivalent(indent + 1, jassTextGenerator); - } - - if ((this.onBlockActions != null) && !this.onBlockActions.isEmpty()) { - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("else"); - jassTextGenerator.println(sb.toString()); - - for (final ABAction onHitAction : this.onBlockActions) { - onHitAction.generateJassEquivalent(indent + 1, jassTextGenerator); - } - } - - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("endif"); - jassTextGenerator.println(sb.toString()); - } - - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCreateUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCreateUnit.java deleted file mode 100644 index 949faad72..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCreateUnit.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateUnit implements ABSingleAction { - - private ABIDCallback id; - private ABIntegerCallback playerIndex; - private ABLocationCallback loc; - private ABFloatCallback facing; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - int thePlayerId = caster.getPlayerIndex(); - float theFacing = 0; - if (this.playerIndex != null) { - thePlayerId = this.playerIndex.callback(game, caster, localStore, castId); - } - if (this.facing != null) { - theFacing = this.facing.callback(game, caster, localStore, castId); - } - final AbilityPointTarget location = this.loc.callback(game, caster, localStore, castId); - final CUnit createdUnit = game.createUnitSimple(this.id.callback(game, caster, localStore, castId), thePlayerId, - location.getX(), location.getY(), theFacing); - - localStore.put(ABLocalStoreKeys.LASTCREATEDUNIT, createdUnit); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String playerIndexExpression; - if (this.playerIndex != null) { - playerIndexExpression = this.playerIndex.generateJassEquivalent(jassTextGenerator); - } - else { - playerIndexExpression = "GetOwningPlayer(" + jassTextGenerator.getCaster() + ")"; - } - - String facingExpression = "bj_UNIT_FACING"; - if (this.facing != null) { - facingExpression = this.facing.generateJassEquivalent(jassTextGenerator); - } - - return "CreateUnitAtLoc(" + playerIndexExpression + ", " + this.id.generateJassEquivalent(jassTextGenerator) - + ", " + this.loc.generateJassEquivalent(jassTextGenerator) + ", " + facingExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionDamageTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionDamageTarget.java deleted file mode 100644 index a73c206e8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionDamageTarget.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAttackTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABDamageTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; - -public class ABActionDamageTarget implements ABSingleAction { - - private ABUnitCallback source; - private ABUnitCallback target; - private ABBooleanCallback isAttack; - private ABBooleanCallback isRanged; - private ABAttackTypeCallback attackType; - private ABDamageTypeCallback damageType; - private ABFloatCallback damage; - - private ABBooleanCallback ignoreLTEZero; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - boolean isItAttack = false; - boolean isItRanged = true; - CAttackType theAttackType = CAttackType.SPELLS; - CDamageType theDamageType = CDamageType.MAGIC; - - final float theDamage = this.damage.callback(game, caster, localStore, castId); - - if (this.isAttack != null) { - isItAttack = this.isAttack.callback(game, caster, localStore, castId); - } - if (this.isRanged != null) { - isItRanged = this.isRanged.callback(game, caster, localStore, castId); - } - if (this.attackType != null) { - theAttackType = this.attackType.callback(game, caster, localStore, castId); - } - if (this.damageType != null) { - theDamageType = this.damageType.callback(game, caster, localStore, castId); - } - if ((this.ignoreLTEZero == null) || !this.ignoreLTEZero.callback(game, caster, localStore, castId) - || (theDamage > 0)) { - this.target.callback(game, caster, localStore, castId).damage(game, - this.source.callback(game, caster, localStore, castId), isItAttack, isItRanged, theAttackType, - theDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), - this.damage.callback(game, caster, localStore, castId)); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - String attackExpression = "false"; - String rangedExpression = "true"; - String attackTypeExpression = "ATTACK_TYPE_NORMAL"; - String damageTypeExpression = "DAMAGE_TYPE_MAGIC"; - if (this.isAttack != null) { - attackExpression = this.isAttack.generateJassEquivalent(jassTextGenerator); - } - if (this.isRanged != null) { - rangedExpression = this.isRanged.generateJassEquivalent(jassTextGenerator); - } - if (this.attackType != null) { - attackTypeExpression = this.attackType.generateJassEquivalent(jassTextGenerator); - } - if (this.damageType != null) { - damageTypeExpression = this.damageType.generateJassEquivalent(jassTextGenerator); - } - if (this.ignoreLTEZero == null) { - return "UnitDamageTarget(" + this.source.generateJassEquivalent(jassTextGenerator) + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.damage.generateJassEquivalent(jassTextGenerator) + ", " + attackExpression + ", " - + rangedExpression + ", " + attackTypeExpression + ", " + damageTypeExpression + ", " - + "WEAPON_TYPE_WHOKNOWS)"; - } - return "UnitDamageTargetAU(" + this.source.generateJassEquivalent(jassTextGenerator) + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.damage.generateJassEquivalent(jassTextGenerator) + ", " + attackExpression + ", " - + rangedExpression + ", " + attackTypeExpression + ", " + damageTypeExpression + ", " - + this.ignoreLTEZero.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionHeal.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionHeal.java deleted file mode 100644 index dab4e98a0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionHeal.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionHeal implements ABSingleAction { - - private ABUnitCallback target; - private ABFloatCallback amount; - private ABBooleanCallback isPercent; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - boolean percent = false; - if (this.isPercent != null) { - percent = this.isPercent.callback(game, caster, localStore, castId); - } - if (percent) { - final CUnit targetUnit = this.target.callback(game, caster, localStore, castId); - targetUnit.heal(game, this.amount.callback(game, caster, localStore, castId) * targetUnit.getMaximumLife()); - } - else { - this.target.callback(game, caster, localStore, castId).heal(game, - this.amount.callback(game, caster, localStore, castId)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String percentExpression = "false"; - if (this.isPercent != null) { - percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); - } - return "HealUnitAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionHideUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionHideUnit.java deleted file mode 100644 index b0f280206..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionHideUnit.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionHideUnit implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - targetUnit.setHidden(true); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "ShowUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", false)"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionInstantReturnResources.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionInstantReturnResources.java deleted file mode 100644 index a6b4a50f1..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionInstantReturnResources.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityHarvest; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.ResourceType; - -public class ABActionInstantReturnResources implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit targetUnit = caster; - if (this.unit != null) { - targetUnit = this.unit.callback(game, caster, localStore, castId); - } - - final CAbilityHarvest harv = targetUnit.getFirstAbilityOfType(CAbilityHarvest.class); - if ((harv != null) && (harv.getCarriedResourceType() != null) && (harv.getCarriedResourceAmount() > 0)) { - final CPlayer pl = game.getPlayer(targetUnit.getPlayerIndex()); - switch (harv.getCarriedResourceType()) { - case FOOD: - // This might be a bad idea? Not sure it will ever matter - pl.setFoodCap(Math.min(pl.getFoodCap() + harv.getCarriedResourceAmount(), pl.getFoodCapCeiling())); - game.unitGainResourceEvent(targetUnit, pl.getId(), harv.getCarriedResourceType(), - harv.getCarriedResourceAmount()); - harv.setCarriedResources(ResourceType.FOOD, 0); - break; - case GOLD: - pl.addGold(harv.getCarriedResourceAmount()); - game.unitGainResourceEvent(targetUnit, pl.getId(), harv.getCarriedResourceType(), - harv.getCarriedResourceAmount()); - harv.setCarriedResources(ResourceType.GOLD, 0); - break; - case LUMBER: - pl.addLumber(harv.getCarriedResourceAmount()); - game.unitGainResourceEvent(targetUnit, pl.getId(), harv.getCarriedResourceType(), - harv.getCarriedResourceAmount()); - harv.setCarriedResources(ResourceType.LUMBER, 0); - break; - case MANA: - // ?? - break; - default: - break; - - } - } - - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String targetExpression; - if (this.unit != null) { - targetExpression = this.unit.generateJassEquivalent(jassTextGenerator); - } - else { - targetExpression = jassTextGenerator.getCaster(); - } - return "UnitInstantReturnResources(" + targetExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionIssueStopOrder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionIssueStopOrder.java deleted file mode 100644 index 30caae4ff..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionIssueStopOrder.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionIssueStopOrder implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - targetUnit.performDefaultBehavior(game); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "DoStopOrder(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionKillUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionKillUnit.java deleted file mode 100644 index d4b124a56..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionKillUnit.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionKillUnit implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - targetUnit.kill(game); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "KillUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionMergeUnits.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionMergeUnits.java deleted file mode 100644 index 692ce6f06..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionMergeUnits.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionMergeUnits implements ABSingleAction { - - private ABUnitCallback unit1; - private ABUnitCallback unit2; - private ABIDCallback newUnitId; - private ABLocationCallback location; - private ABFloatCallback facing; - - private ABIntegerCallback playerIndex; - private ABBooleanCallback resetHpMp; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - int thePlayerId = caster.getPlayerIndex(); - float theFacing = caster.getFacing(); - AbilityPointTarget loc = null; - if (this.playerIndex != null) { - thePlayerId = this.playerIndex.callback(game, caster, localStore, castId); - } - if (this.facing != null) { - theFacing = this.facing.callback(game, caster, localStore, castId); - } - if (this.location != null) { - loc = this.location.callback(game, caster, localStore, castId); - } - else { - loc = new AbilityPointTarget(caster.getX(), caster.getY()); - } - - final CUnit u1 = this.unit1.callback(game, caster, localStore, castId); - final CUnit u2 = this.unit2.callback(game, caster, localStore, castId); - - final float newHPPcnt = ((u1.getLife() / u1.getMaximumLife()) + (u2.getLife() / u2.getMaximumLife())) / 2; - final float newMPPcnt = ((u1.getMana() / u1.getMaximumMana()) + (u2.getMana() / u2.getMaximumMana())) / 2; - - final CUnit createdUnit = game.createUnit(this.newUnitId.callback(game, caster, localStore, castId), - thePlayerId, loc.getX(), loc.getY(), theFacing); - if ((this.resetHpMp == null) || !this.resetHpMp.callback(game, caster, localStore, castId)) { - createdUnit.setLife(game, newHPPcnt * createdUnit.getMaximumLife()); - createdUnit.setMana(newMPPcnt * createdUnit.getMaximumMana()); - } - game.unitPreferredSelectionReplacement(u1, createdUnit); - game.unitPreferredSelectionReplacement(u2, createdUnit); - - game.removeUnit(u1); - game.removeUnit(u2); - - localStore.put(ABLocalStoreKeys.LASTCREATEDUNIT, createdUnit); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String playerExpression; - if (this.playerIndex != null) { - playerExpression = "Player(" + this.playerIndex.generateJassEquivalent(jassTextGenerator) + ")"; - } - else { - playerExpression = "GetOwningPlayer(" + jassTextGenerator.getCaster() + ")"; - } - String facingExpression; - if (this.facing != null) { - facingExpression = this.facing.generateJassEquivalent(jassTextGenerator); - } - else { - facingExpression = "GetUnitFacing(" + jassTextGenerator.getCaster() + ")"; - } - String locExpression; - if (this.location != null) { - locExpression = this.location.generateJassEquivalent(jassTextGenerator); - } - else { - locExpression = "GetUnitLoc(" + jassTextGenerator.getCaster() + ")"; - } - - String resetHpMpExpression = "false"; - if (this.resetHpMp != null) { - resetHpMpExpression = this.resetHpMp.generateJassEquivalent(jassTextGenerator); - } - - return "MergeUnitsAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.unit1.generateJassEquivalent(jassTextGenerator) + ", " - + this.unit2.generateJassEquivalent(jassTextGenerator) + ", " - + this.newUnitId.generateJassEquivalent(jassTextGenerator) + ", " + locExpression + ", " - + facingExpression + ", " + playerExpression + ", " + resetHpMpExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionRemoveUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionRemoveUnit.java deleted file mode 100644 index 6a00b7e83..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionRemoveUnit.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveUnit implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - game.removeUnit(targetUnit); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "RemoveUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionResurrect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionResurrect.java deleted file mode 100644 index 9972da925..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionResurrect.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionResurrect implements ABSingleAction { - - private ABUnitCallback target; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.target.callback(game, caster, localStore, castId); - if (targetUnit.isDead()) { - targetUnit.resurrect(game); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "ResurrectUnit(" + this.target.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSendUnitBackToWork.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSendUnitBackToWork.java deleted file mode 100644 index ba326ad46..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSendUnitBackToWork.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.ABTimer; - -public class ABActionSendUnitBackToWork implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit; - if (this.unit != null) { - targetUnit = this.unit.callback(game, caster, localStore, castId); - } - else { - targetUnit = caster; - } - - final ABTimer timer = new ABTimer(caster, localStore, null, castId) { - @Override - public void onFire(CSimulation simulation) { - targetUnit.backToWork(game, null); - } - }; - timer.setRepeats(false); - timer.setTimeoutTime(0f); - timer.start(game); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String unitExpression; - if (this.unit != null) { - unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); - } - else { - unitExpression = jassTextGenerator.getCaster(); - } - return "SendUnitBackToWorkAU(" + unitExpression + ", " + jassTextGenerator.getTriggerLocalStore() + ", " - + jassTextGenerator.getCastId() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetExplodesOnDeath.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetExplodesOnDeath.java deleted file mode 100644 index 2ebaa8037..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetExplodesOnDeath.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionSetExplodesOnDeath implements ABAction { - - private ABUnitCallback unit; - private ABBooleanCallback explodes; - private ABIDCallback buffId; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - targetUnit.setExplodesOnDeath(this.explodes.callback(game, caster, localStore, castId)); - if (this.buffId != null) { - targetUnit.setExplodesOnDeathBuffId(this.buffId.callback(game, caster, localStore, castId)); - } - } - - @Override - public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { - final StringBuilder sb = new StringBuilder(); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call SetUnitExploded("); - sb.append(this.unit.generateJassEquivalent(jassTextGenerator)); - sb.append(", "); - sb.append(this.explodes.generateJassEquivalent(jassTextGenerator)); - sb.append(")"); - jassTextGenerator.println(sb.toString()); - - if (this.buffId != null) { - sb.setLength(0); - JassTextGenerator.Util.indent(indent, sb); - sb.append("call SetUnitExplodeOnDeathBuffId("); - sb.append(this.unit.generateJassEquivalent(jassTextGenerator)); - sb.append(", "); - sb.append(this.buffId.generateJassEquivalent(jassTextGenerator)); - sb.append(")"); - jassTextGenerator.println(sb.toString()); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetHp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetHp.java deleted file mode 100644 index 67986dbb6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetHp.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetHp implements ABSingleAction { - - private ABUnitCallback target; - private ABFloatCallback amount; - private ABBooleanCallback isPercent; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - boolean percent = false; - if (this.isPercent != null) { - percent = this.isPercent.callback(game, caster, localStore, castId); - } - if (percent) { - final CUnit targetUnit = this.target.callback(game, caster, localStore, castId); - targetUnit.setCurrentHp(game, - this.amount.callback(game, caster, localStore, castId) * targetUnit.getMaximumLife()); - } - else { - this.target.callback(game, caster, localStore, castId).setCurrentHp(game, - this.amount.callback(game, caster, localStore, castId)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String percentExpression = "false"; - if (this.isPercent != null) { - percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); - } - return "SetUnitHpAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetMp.java deleted file mode 100644 index b3b21c923..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSetMp.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetMp implements ABSingleAction { - - private ABUnitCallback target; - private ABFloatCallback amount; - private ABBooleanCallback isPercent; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - boolean percent = false; - if (this.isPercent != null) { - percent = this.isPercent.callback(game, caster, localStore, castId); - } - final CUnit targetUnit = this.target.callback(game, caster, localStore, castId); - if (percent) { - targetUnit.setMana(Math - .max(Math.min(this.amount.callback(game, caster, localStore, castId) * targetUnit.getMaximumMana(), - targetUnit.getMaximumMana()), 0)); - } - else { - targetUnit.setMana(Math.max( - Math.min(this.amount.callback(game, caster, localStore, castId), targetUnit.getMaximumMana()), 0)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String percentExpression = "false"; - if (this.isPercent != null) { - percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); - } - return "SetUnitMpAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " - + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionStartSacrificingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionStartSacrificingUnit.java deleted file mode 100644 index cf559772d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionStartSacrificingUnit.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionStartSacrificingUnit implements ABSingleAction { - - private ABUnitCallback unit; - private ABUnitCallback sacrifice; - private ABIDCallback id; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit theUnit = this.unit.callback(game, caster, localStore, castId); - theUnit.queueSacrificingUnit(game, this.id.callback(game, caster, localStore, castId), - this.sacrifice.callback(game, caster, localStore, castId)); - theUnit.notifyOrdersChanged(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "StartSacrificingUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + this.sacrifice.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionStartTrainingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionStartTrainingUnit.java deleted file mode 100644 index 57dc462c2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionStartTrainingUnit.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionStartTrainingUnit implements ABSingleAction { - - private ABUnitCallback unit; - private ABIDCallback id; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit theUnit = this.unit.callback(game, caster, localStore, castId); - theUnit.queueTrainingUnit(game, this.id.callback(game, caster, localStore, castId)); - theUnit.notifyOrdersChanged(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "StartTrainingUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + this.id.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSubtractMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSubtractMp.java deleted file mode 100644 index 9626d313e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionSubtractMp.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSubtractMp implements ABSingleAction { - - private ABUnitCallback target; - private ABFloatCallback amount; - private ABBooleanCallback isPercent; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - boolean percent = false; - if (this.isPercent != null) { - percent = this.isPercent.callback(game, caster, localStore, castId); - } - final CUnit targetUnit = this.target.callback(game, caster, localStore, castId); - if (percent) { - targetUnit.setMana(Math.max(Math.min( - targetUnit.getMana() - - (this.amount.callback(game, caster, localStore, castId) * targetUnit.getMaximumMana()), - targetUnit.getMaximumMana()), 0)); - } - else { - targetUnit.setMana( - Math.max(Math.min(targetUnit.getMana() - this.amount.callback(game, caster, localStore, castId), - targetUnit.getMaximumMana()), 0)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String percentExpression = "false"; - if (this.isPercent != null) { - percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); - } - return "AddMpAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", -(" - + this.amount.generateJassEquivalent(jassTextGenerator) + "), " + percentExpression + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformUnit.java deleted file mode 100644 index ad6fc6d70..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformUnit.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorFinishTransformation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; - -public class ABActionTransformUnit implements ABAction { - - private ABUnitCallback unit; - private ABIDCallback baseUnitId; - private ABIDCallback alternateUnitId; - - private ABBooleanCallback immediateLanding; // true: play morph immediately, false: play morph after - private ABBooleanCallback immediateTakeOff; // true: play morph immediately, false: play morph after - private ABBooleanCallback permanent; // remove ability after transform - private ABBooleanCallback requiresPayment; -// private ABBooleanCallback uninterruptable; - - private ABFloatCallback altitudeAdjustmentDelay; // time before the unit starts changing height, only applies if - // going not flying->flying - private ABFloatCallback altitudeAdjustmentTime; // the time spent changing height, only applies if one type is - // flying - private ABFloatCallback landingDelayTime; // Added to the transform time, only applies when going flying->not flying - - private ABFloatCallback transformTime; // the time the unit is locked for the transformation - - private ABFloatCallback duration; // the time before the unit is forced to change back (doesn't charge for it) - private ABIDCallback buffId; - private ABBooleanCallback instantTransformAtDurationEnd; - - private List onTransformActions; - private List onUntransformActions; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit u1 = caster; - if (unit != null) { - u1 = unit.callback(game, caster, localStore, castId); - } - War3ID baseId = baseUnitId.callback(game, caster, localStore, castId); - War3ID altId = alternateUnitId.callback(game, caster, localStore, castId); - CPlayer pl = game.getPlayer(u1.getPlayerIndex()); - boolean charge = false; - boolean addAlternateTagAfter = false; - if (this.requiresPayment != null) { - charge = this.requiresPayment.callback(game, caster, localStore, castId); - } - AbilityBuilderActiveAbility abil = (AbilityBuilderActiveAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - if (baseId == null || altId == null) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - - CUnitType targetType = null; - - if (u1.getTypeId().equals(altId)) { - // Transforming back - targetType = game.getUnitData().getUnitType(baseId); - if (targetType.equals(u1.getUnitType())) { - // No need to do anything - return; - } - } else { - // Transforming to alt - addAlternateTagAfter = true; - targetType = game.getUnitData().getUnitType(altId); - } - - int goldCost = 0; - int lumberCost = 0; - Integer foodCost = null; - if (charge) { - if (game.getGameplayConstants().isRelativeUpgradeCosts()) { - goldCost = targetType.getGoldCost() - u1.getUnitType().getGoldCost(); - lumberCost = targetType.getLumberCost() - u1.getUnitType().getLumberCost(); - if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - } else { - goldCost = targetType.getGoldCost(); - lumberCost = targetType.getLumberCost(); - if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - } - foodCost = Math.max(targetType.getFoodUsed() - u1.getUnitType().getFoodUsed(), 0); - if (foodCost > 0 && pl.getFoodUsed() + foodCost > pl.getFoodCap()) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - } - OnTransformationActions actions = new OnTransformationActions(goldCost, lumberCost, foodCost, onTransformActions, onUntransformActions); - - boolean perm = false; - float dur = 0; - float transTime = 0; - float landTime = 0; - float atlAdDelay = 0; - float altAdTime = 0; - boolean imLand = false; - boolean imTakeOff = false; - War3ID theBuffId = null; - boolean instant = false; - if (permanent != null) { - perm = permanent.callback(game, caster, localStore, castId); - } - if (duration != null) { - dur = duration.callback(game, caster, localStore, castId); - } - if (transformTime != null) { - transTime = transformTime.callback(game, caster, localStore, castId); - } - if (landingDelayTime != null) { - landTime = landingDelayTime.callback(game, caster, localStore, castId); - } - if (altitudeAdjustmentDelay != null) { - atlAdDelay = altitudeAdjustmentDelay.callback(game, caster, localStore, castId); - } - if (altitudeAdjustmentTime != null) { - altAdTime = altitudeAdjustmentTime.callback(game, caster, localStore, castId); - } - if (immediateLanding != null) { - imLand = immediateLanding.callback(game, caster, localStore, castId); - } - if (immediateTakeOff != null) { - imTakeOff = immediateTakeOff.callback(game, caster, localStore, castId); - } - if (buffId != null) { - theBuffId = buffId.callback(game, caster, localStore, castId); - } - if (instantTransformAtDurationEnd != null) { - instant = instantTransformAtDurationEnd.callback(game, caster, localStore, castId); - } - - localStore.put(ABLocalStoreKeys.TRANSFORMINGTOALT + castId, addAlternateTagAfter); - localStore.put(ABLocalStoreKeys.NEWBEHAVIOR, - new CBehaviorFinishTransformation(localStore, u1, abil, targetType, actions, addAlternateTagAfter, - addAlternateTagAfter ? abil.getBaseOrderId() : abil.getOffOrderId(), perm, dur, transTime, - landTime, atlAdDelay, altAdTime, imLand, imTakeOff, theBuffId, - game.getUnitData().getUnitType(baseId), instant)); - - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformUnitInstant.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformUnitInstant.java deleted file mode 100644 index 1f15f2515..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformUnitInstant.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.DelayInstantTransformationTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; - -public class ABActionTransformUnitInstant implements ABAction { - - private ABUnitCallback unit; - private ABIDCallback baseUnitId; - private ABIDCallback alternateUnitId; - - private ABBooleanCallback permanent; // remove ability after transform - private ABBooleanCallback requiresPayment; - - private ABFloatCallback transformTime; // the time the unit is locked for the transformation - - private ABFloatCallback duration; // the time before the unit is forced to change back (doesn't charge for it) - private ABIDCallback buffId; - - private List onTransformActions; - private List onUntransformActions; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit u1 = caster; - if (unit != null) { - u1 = unit.callback(game, caster, localStore, castId); - } - War3ID baseId = null; - War3ID altId = alternateUnitId.callback(game, caster, localStore, castId); - CPlayer pl = game.getPlayer(u1.getPlayerIndex()); - boolean charge = false; - boolean addAlternateTagAfter = false; - boolean perm = false; - if (permanent != null) { - perm = permanent.callback(game, caster, localStore, castId); - } - if (this.requiresPayment != null) { - charge = this.requiresPayment.callback(game, caster, localStore, castId); - } - AbilityBuilderAbility abil = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - CUnitType baseType = null; - if (baseUnitId == null) { - baseId = u1.getUnitType().getTypeId(); - baseType = u1.getUnitType(); - } else { - baseId = baseUnitId.callback(game, caster, localStore, castId); - baseType = game.getUnitData().getUnitType(baseId); - - } - - if (baseId == null || altId == null) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - - CUnitType targetType = null; - - if (u1.getTypeId().equals(altId)) { - // Transforming back - targetType = baseType; - if (perm || targetType.equals(u1.getUnitType())) { - // No need to do anything - return; - } - - } else { - // Transforming to alt - addAlternateTagAfter = true; - targetType = game.getUnitData().getUnitType(altId); - } - - int goldCost = 0; - int lumberCost = 0; - Integer foodCost = null; - if (charge) { - if (game.getGameplayConstants().isRelativeUpgradeCosts()) { - goldCost = targetType.getGoldCost() - u1.getUnitType().getGoldCost(); - lumberCost = targetType.getLumberCost() - u1.getUnitType().getLumberCost(); - if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - } else { - goldCost = targetType.getGoldCost(); - lumberCost = targetType.getLumberCost(); - if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - } - foodCost = Math.max(targetType.getFoodUsed() - u1.getUnitType().getFoodUsed(), 0); - if (foodCost > 0 && pl.getFoodUsed() + foodCost > pl.getFoodCap()) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - } - OnTransformationActions actions = new OnTransformationActions(goldCost, lumberCost, foodCost, - onTransformActions, onUntransformActions); - OnTransformationActions unActions = new OnTransformationActions(-goldCost, -lumberCost, null, - null, onUntransformActions); - - float dur = 0; - float transTime = 0; - War3ID theBuffId = null; - if (permanent != null) { - perm = permanent.callback(game, caster, localStore, castId); - } - if (duration != null) { - dur = duration.callback(game, caster, localStore, castId); - } - if (transformTime != null) { - transTime = transformTime.callback(game, caster, localStore, castId); - } - if (buffId != null) { - theBuffId = buffId.callback(game, caster, localStore, castId); - } - - localStore.put(ABLocalStoreKeys.TRANSFORMINGTOALT + castId, addAlternateTagAfter); - if (transTime > 0) { - TransformationHandler.playMorphAnimation(u1, addAlternateTagAfter); - new DelayInstantTransformationTimer(game, localStore, u1, actions, addAlternateTagAfter, transTime, - baseType, targetType, abil, theBuffId, transTime, dur).start(game); - } else { - TransformationHandler.instantTransformation(game, localStore, u1, targetType, actions, abil, - addAlternateTagAfter, perm, true); - if (dur > 0) { - TransformationHandler.createInstantTransformBackBuff(game, localStore, u1, baseType, - unActions, abil, theBuffId, addAlternateTagAfter, - transTime, dur, perm); - } - } - - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformedUnitAbilityAdd.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformedUnitAbilityAdd.java deleted file mode 100644 index 456887dea..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformedUnitAbilityAdd.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; - -public class ABActionTransformedUnitAbilityAdd implements ABAction { - - private ABUnitCallback unit; - private ABIDCallback baseUnitId; - private ABIDCallback alternateUnitId; - - private ABBooleanCallback instantTransformAtDurationEnd; // should the transform back be instant? - - private ABBooleanCallback permanent; // remove ability after transform - private ABBooleanCallback requiresPayment; - private ABFloatCallback duration; // the time before the unit is forced to change back (doesn't charge for it) - private ABFloatCallback transformTime; // the time the unit is locked for the transformation (for slow) or spends - // animating (for instant) - private ABIDCallback buffId; - - // Used for slow transform back - private ABBooleanCallback immediateLanding; // true: play morph immediately, false: play morph after - private ABBooleanCallback immediateTakeOff; // true: play morph immediately, false: play morph after - private ABFloatCallback altitudeAdjustmentDelay; // time before the unit starts changing height, only applies if - // going not flying->flying - private ABFloatCallback altitudeAdjustmentTime; // the time spent changing height, only applies if one type is - // flying - private ABFloatCallback landingDelayTime; // Added to the transform time, only applies when going flying->not flying - - private List onTransformActions; - private List onUntransformActions; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit u1 = caster; - if (unit != null) { - u1 = unit.callback(game, caster, localStore, castId); - } - War3ID baseId = baseUnitId.callback(game, caster, localStore, castId); - War3ID altId = alternateUnitId.callback(game, caster, localStore, castId); - AbilityBuilderActiveAbility abil = (AbilityBuilderActiveAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - if (baseId == null || altId == null) { - localStore.put(ABLocalStoreKeys.FAILEDTOCAST + castId, true); - return; - } - - CUnitType baseType = game.getUnitData().getUnitType(baseId); - - // Always Transforming back - CUnitType targetType = baseType; - if (targetType.equals(u1.getUnitType())) { - // No need to do anything - return; - } - - boolean instant = false; - boolean perm = false; - boolean charge = false; - float dur = 0; - float transTime = 0; - float landTime = 0; - float atlAdDelay = 0; - float altAdTime = 0; - boolean imLand = false; - boolean imTakeOff = false; - War3ID theBuffId = null; - if (instantTransformAtDurationEnd != null) { - instant = instantTransformAtDurationEnd.callback(game, caster, localStore, castId); - } - if (permanent != null) { - perm = permanent.callback(game, caster, localStore, castId); - } - if (this.requiresPayment != null) { - charge = this.requiresPayment.callback(game, caster, localStore, castId); - } - if (duration != null) { - dur = duration.callback(game, caster, localStore, castId); - } - if (transformTime != null) { - transTime = transformTime.callback(game, caster, localStore, castId); - } - if (landingDelayTime != null) { - landTime = landingDelayTime.callback(game, caster, localStore, castId); - } - if (altitudeAdjustmentDelay != null) { - atlAdDelay = altitudeAdjustmentDelay.callback(game, caster, localStore, castId); - } - if (altitudeAdjustmentTime != null) { - altAdTime = altitudeAdjustmentTime.callback(game, caster, localStore, castId); - } - if (immediateLanding != null) { - imLand = immediateLanding.callback(game, caster, localStore, castId); - } - if (immediateTakeOff != null) { - imTakeOff = immediateTakeOff.callback(game, caster, localStore, castId); - } - if (buffId != null) { - theBuffId = buffId.callback(game, caster, localStore, castId); - } - - TransformationHandler.setTags(u1, true); - if (perm) { - u1.remove(game, abil); - } - if (onTransformActions != null) { - for (ABAction action : onTransformActions) { - action.runAction(game, u1, localStore, castId); - } - } - - if (dur > 0 && !perm) { - OnTransformationActions actions; - if (charge) { - int goldCost = 0; - int lumberCost = 0; - Integer foodCost = null; - if (game.getGameplayConstants().isRelativeUpgradeCosts()) { - - goldCost = baseType.getGoldCost() - u1.getUnitType().getGoldCost(); - lumberCost = baseType.getLumberCost() - u1.getUnitType().getLumberCost(); - } else { - goldCost = baseType.getGoldCost(); - lumberCost = baseType.getLumberCost(); - } - actions = new OnTransformationActions(goldCost, lumberCost, foodCost, null, onUntransformActions); - } else { - actions = new OnTransformationActions(onUntransformActions); - } - - if (instant) { - TransformationHandler.createInstantTransformBackBuff(game, localStore, u1, baseType, - actions, abil, theBuffId, true, transTime, dur, perm); - } else { - boolean takingOff = u1.getMovementType() != MovementType.FLY - && baseType.getMovementType() == MovementType.FLY; - boolean landing = u1.getMovementType() == MovementType.FLY - && baseType.getMovementType() != MovementType.FLY; - TransformationHandler.createSlowTransformBackBuff(game, localStore, u1, baseType, - actions, abil, theBuffId, true, transTime, dur, perm, - takingOff, landing, imTakeOff, imLand, atlAdDelay, landTime, altAdTime); - } - } - - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformedUnitAbilityRemove.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformedUnitAbilityRemove.java deleted file mode 100644 index 77d184a62..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionTransformedUnitAbilityRemove.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler; - -public class ABActionTransformedUnitAbilityRemove implements ABAction { - - private ABUnitCallback unit; - private ABIDCallback baseUnitId; - private ABIDCallback alternateUnitId; - - private ABBooleanCallback permanent; - - private List onUntransformActions; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - boolean perm = false; - if (permanent != null) { - perm = permanent.callback(game, caster, localStore, castId); - } - if (!perm) { - CUnit u1 = caster; - if (unit != null) { - u1 = unit.callback(game, caster, localStore, castId); - } - War3ID baseId = baseUnitId.callback(game, caster, localStore, castId); - War3ID altId = alternateUnitId.callback(game, caster, localStore, castId); - AbilityBuilderActiveAbility abil = (AbilityBuilderActiveAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - if (baseId == null || altId == null) { - return; - } - - // Only care if already transformed - CUnitType targetType = game.getUnitData().getUnitType(altId); - if (!targetType.equals(u1.getUnitType())) { - // No need to do anything - return; - } - - - CUnitType baseType = game.getUnitData().getUnitType(baseId); - - if (onUntransformActions != null) { - for (ABAction action : onUntransformActions) { - action.runAction(game, u1, localStore, castId); - } - } - TransformationHandler.setUnitID(game, localStore, u1, baseType, perm, null, abil, true); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionUnhideUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionUnhideUnit.java deleted file mode 100644 index 01c55b97b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionUnhideUnit.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionUnhideUnit implements ABSingleAction { - - private ABUnitCallback unit; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - targetUnit.setHidden(false); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "ShowUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", true)"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionAddSecondaryAnimationTag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionAddSecondaryAnimationTag.java deleted file mode 100644 index b94e9081d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionAddSecondaryAnimationTag.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.animation; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddSecondaryAnimationTag implements ABSingleAction { - - private ABUnitCallback unit; - private ABStringCallback tag; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - if (targetUnit.getUnitAnimationListener() - .addSecondaryTag(SecondaryTag.valueOf(this.tag.callback(game, caster, localStore, castId)))) { - targetUnit.getUnitAnimationListener().forceResetCurrentAnimation(); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AddUnitAnimationProperties(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + this.tag.generateJassEquivalent(jassTextGenerator) + ", true)"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionPlayAnimation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionPlayAnimation.java deleted file mode 100644 index abe7e41fa..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionPlayAnimation.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.animation; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionPlayAnimation implements ABSingleAction { - - private ABUnitCallback unit; - private ABStringCallback tag; - - private ABBooleanCallback force; - private ABFloatCallback speed; - private ABBooleanCallback allowVariations; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - boolean f = true; - float s = 1f; - boolean av = false; - if (this.force != null) { - f = this.force.callback(game, caster, localStore, castId); - } - if (this.speed != null) { - s = this.speed.callback(game, caster, localStore, castId); - } - if (this.allowVariations != null) { - av = this.allowVariations.callback(game, caster, localStore, castId); - } - - targetUnit.getUnitAnimationListener().playAnimation(f, - PrimaryTag.valueOf(this.tag.callback(game, caster, localStore, castId)), SequenceUtils.EMPTY, s, av); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - // TODO: the stuff exposed by warsmash below is not in jass yet - if ((this.force != null) && !this.force.generateJassEquivalent(jassTextGenerator).equals("true")) { - throw new UnsupportedOperationException(); - } - if ((this.allowVariations != null) - && !this.allowVariations.generateJassEquivalent(jassTextGenerator).equals("true")) { - throw new UnsupportedOperationException(); - } - if (this.speed != null) { - throw new UnsupportedOperationException(); - } - return "SetUnitAnimation(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + this.tag.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionRemoveSecondaryAnimationTag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionRemoveSecondaryAnimationTag.java deleted file mode 100644 index c2787e387..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/animation/ABActionRemoveSecondaryAnimationTag.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.animation; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveSecondaryAnimationTag implements ABSingleAction { - - private ABUnitCallback unit; - private ABStringCallback tag; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - if (targetUnit.getUnitAnimationListener() - .removeSecondaryTag(SecondaryTag.valueOf(this.tag.callback(game, caster, localStore, castId)))) { - targetUnit.getUnitAnimationListener().forceResetCurrentAnimation(); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "AddUnitAnimationProperties(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + this.tag.generateJassEquivalent(jassTextGenerator) + ", false)"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionDivideUnitAlpha.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionDivideUnitAlpha.java deleted file mode 100644 index d84744088..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionDivideUnitAlpha.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.art; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionDivideUnitAlpha implements ABSingleAction { - - private ABUnitCallback unit; - private ABFloatCallback value; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - final float[] color = game.getUnitVertexColor(targetUnit); - - game.changeUnitVertexColor(targetUnit, color[0], color[1], color[2], - color[3] / this.value.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - throw new UnsupportedOperationException(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionMultiplyUnitAlpha.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionMultiplyUnitAlpha.java deleted file mode 100644 index a62309250..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionMultiplyUnitAlpha.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.art; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionMultiplyUnitAlpha implements ABSingleAction { - - private ABUnitCallback unit; - private ABFloatCallback value; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - final float[] color = game.getUnitVertexColor(targetUnit); - - game.changeUnitVertexColor(targetUnit, color[0], color[1], color[2], - color[3] * this.value.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - throw new UnsupportedOperationException(); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionSetUnitAlpha.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionSetUnitAlpha.java deleted file mode 100644 index 7c1ab4cae..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/art/ABActionSetUnitAlpha.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.art; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetUnitAlpha implements ABSingleAction { - - private ABUnitCallback unit; - private ABFloatCallback value; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - final float[] color = game.getUnitVertexColor(targetUnit); - - game.changeUnitVertexColor(targetUnit, color[0], color[1], color[2], - this.value.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - throw new UnsupportedOperationException(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/movement/ABActionSetUnitFlyHeight.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/movement/ABActionSetUnitFlyHeight.java deleted file mode 100644 index 277fd816d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/movement/ABActionSetUnitFlyHeight.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.movement; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetUnitFlyHeight implements ABSingleAction { - - private ABUnitCallback unit; - private ABFloatCallback height; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - targetUnit.setFlyHeight(this.height.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "SetUnitFlyHeight(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + this.height.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/movement/ABActionSetUnitMovementTypeNoCollision.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/movement/ABActionSetUnitMovementTypeNoCollision.java deleted file mode 100644 index 4eb9d3f4f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/movement/ABActionSetUnitMovementTypeNoCollision.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.movement; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionSetUnitMovementTypeNoCollision implements ABSingleAction { - - private ABUnitCallback unit; - private ABBooleanCallback active; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit targetUnit = this.unit.callback(game, caster, localStore, castId); - if (this.active != null) { - targetUnit.setNoCollisionMovementType(this.active.callback(game, caster, localStore, castId)); - } - else { - targetUnit.setNoCollisionMovementType(true); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String activeExpression = "true"; - if (this.active != null) { - activeExpression = this.active.generateJassEquivalent(jassTextGenerator); - } - return "SetUnitMovementTypeNoCollision(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " - + activeExpression + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionAddUnitToGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionAddUnitToGroup.java deleted file mode 100644 index ac4a7875d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionAddUnitToGroup.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitgroup; - -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks.ABUnitGroupCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddUnitToGroup implements ABSingleAction { - - private ABUnitGroupCallback group; - private ABUnitCallback unit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Set groupSet = this.group.callback(game, caster, localStore, castId); - final CUnit rUnit = this.unit.callback(game, caster, localStore, castId); - groupSet.add(rUnit); - localStore.put(ABLocalStoreKeys.LASTADDEDUNIT, rUnit); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GroupAddUnitAU(" + this.group.generateJassEquivalent(jassTextGenerator) + ", " - + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionCreateUnitGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionCreateUnitGroup.java deleted file mode 100644 index 88b846212..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionCreateUnitGroup.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitgroup; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateUnitGroup implements ABSingleAction { - - private String name; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Set group = new HashSet<>(); - if (this.name != null) { - localStore.put("_unitgroup_" + this.name, group); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDUNITGROUP, group); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.name != null) { - return "CreateNamedGroupAU(" + jassTextGenerator.getTriggerLocalStore() + ", \"" + this.name + "\")"; - } - return "CreateGroupAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionRemoveUnitFromGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionRemoveUnitFromGroup.java deleted file mode 100644 index fc26d016c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitgroup/ABActionRemoveUnitFromGroup.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitgroup; - -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks.ABUnitGroupCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveUnitFromGroup implements ABSingleAction { - - private ABUnitGroupCallback group; - private ABUnitCallback unit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Set groupSet = this.group.callback(game, caster, localStore, castId); - final CUnit rUnit = this.unit.callback(game, caster, localStore, castId); - groupSet.remove(rUnit); - localStore.put(ABLocalStoreKeys.LASTREMOVEDDUNIT, rUnit); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GroupRemoveUnitAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.group.generateJassEquivalent(jassTextGenerator) + ", " - + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAbilityEffectReactionListener.java deleted file mode 100644 index e73957fa2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAbilityEffectReactionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAbilityEffectReactionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddAbilityEffectReactionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAbilityEffectReactionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addAbilityEffectReactionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAbilityProjReactionListener.java deleted file mode 100644 index 124d27dec..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAbilityProjReactionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAbilityProjReactionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddAbilityProjReactionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAbilityProjReactionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addAbilityProjReactionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackPostDamageListener.java deleted file mode 100644 index 5e602a24a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackPostDamageListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAttackPostDamageListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddAttackPostDamageListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAttackPostDamageListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addPostDamageListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackPreDamageListener.java deleted file mode 100644 index 8ceb23bd4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackPreDamageListener.java +++ /dev/null @@ -1,24 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAttackPreDamageListenerPriorityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAttackPreDamageListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddAttackPreDamageListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAttackPreDamageListenerPriorityCallback priority; - private ABAttackPreDamageListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addPreDamageListener(priority.callback(game, caster, localStore, castId), listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackProjReactionListener.java deleted file mode 100644 index c67d94b04..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddAttackProjReactionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAttackProjReactionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddAttackProjReactionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAttackProjReactionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addAttackProjReactionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddBehaviorChangeListener.java deleted file mode 100644 index 3fdc4e35d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddBehaviorChangeListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABBehaviorChangeListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddBehaviorChangeListener implements ABAction { - - private ABUnitCallback unit; - private ABBehaviorChangeListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = unit.callback(game, caster, localStore, castId); - - target.addBehaviorChangeListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDamageTakenListener.java deleted file mode 100644 index d262727f5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDamageTakenListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABDamageTakenListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddDamageTakenListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABDamageTakenListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addDamageTakenListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDamageTakenModificationListener.java deleted file mode 100644 index 391db54ca..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDamageTakenModificationListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABDamageTakenModificationListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddDamageTakenModificationListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABDamageTakenModificationListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addDamageTakenModificationListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDeathReplacementEffect.java deleted file mode 100644 index 44e8c7bdc..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddDeathReplacementEffect.java +++ /dev/null @@ -1,24 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABDeathReplacementPriorityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABDeathReplacementCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddDeathReplacementEffect implements ABAction { - - private ABUnitCallback target; - private ABDeathReplacementPriorityCallback priority; - private ABDeathReplacementCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit targetUnit = target.callback(game, caster, localStore, castId); - - targetUnit.addDeathReplacementEffect(priority.callback(game, caster, localStore, castId), listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddEvasionListener.java deleted file mode 100644 index 2a04f337c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddEvasionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABEvasionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddEvasionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABEvasionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.addEvasionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddFinalDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddFinalDamageTakenModificationListener.java deleted file mode 100644 index 9b5cfb7d6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionAddFinalDamageTakenModificationListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABFinalDamageTakenModificationListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionAddFinalDamageTakenModificationListener implements ABAction { - - private ABUnitCallback target; - private ABFinalDamageTakenModificationListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit targetUnit = target.callback(game, caster, localStore, castId); - - targetUnit.addFinalDamageTakenModificationListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAbilityEffectReactionListener.java deleted file mode 100644 index 39db98c54..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAbilityEffectReactionListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityEffectReactionListener; - -public class ABActionCreateAbilityEffectReactionListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABAbilityEffectReactionListener listener = new ABAbilityEffectReactionListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDAbERL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAbilityProjReactionListener.java deleted file mode 100644 index 5fdc04405..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAbilityProjReactionListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityProjReactionListener; - -public class ABActionCreateAbilityProjReactionListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABAbilityProjReactionListener listener = new ABAbilityProjReactionListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDAbPRL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackPostDamageListener.java deleted file mode 100644 index 7202aa48f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackPostDamageListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPostDamageListener; - -public class ABActionCreateAttackPostDamageListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABAttackPostDamageListener listener = new ABAttackPostDamageListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDAPoDL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackPreDamageListener.java deleted file mode 100644 index a52886f09..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackPreDamageListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPreDamageListener; - -public class ABActionCreateAttackPreDamageListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABAttackPreDamageListener listener = new ABAttackPreDamageListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDAPrDL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackProjReactionListener.java deleted file mode 100644 index 0edfd59b4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateAttackProjReactionListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackProjReactionListener; - -public class ABActionCreateAttackProjReactionListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABAttackProjReactionListener listener = new ABAttackProjReactionListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDAtkPRL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateBehaviorChangeListener.java deleted file mode 100644 index 104e1d00c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateBehaviorChangeListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABBehaviorChangeListener; - -public class ABActionCreateBehaviorChangeListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABBehaviorChangeListener listener = new ABBehaviorChangeListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDBCL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDamageTakenListener.java deleted file mode 100644 index 94dbf02d2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDamageTakenListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenListener; - -public class ABActionCreateDamageTakenListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABDamageTakenListener listener = new ABDamageTakenListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDDTL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDamageTakenModificationListener.java deleted file mode 100644 index 7f7ece915..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDamageTakenModificationListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenModificationListener; - -public class ABActionCreateDamageTakenModificationListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABDamageTakenModificationListener listener = new ABDamageTakenModificationListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDDTML, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDeathReplacementEffect.java deleted file mode 100644 index 89812f3d3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateDeathReplacementEffect.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDeathReplacementEffect; - -public class ABActionCreateDeathReplacementEffect implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABDeathReplacementEffect listener = new ABDeathReplacementEffect(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDDRE, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateEvasionListener.java deleted file mode 100644 index 21ca6a14d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateEvasionListener.java +++ /dev/null @@ -1,29 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackEvasionListener; - -public class ABActionCreateEvasionListener implements ABAction { - - private List conditions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABAttackEvasionListener listener = new ABAttackEvasionListener(localStore, conditions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDAEL, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateFinalDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateFinalDamageTakenModificationListener.java deleted file mode 100644 index 1095d6496..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionCreateFinalDamageTakenModificationListener.java +++ /dev/null @@ -1,28 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABFinalDamageTakenModificationListener; - -public class ABActionCreateFinalDamageTakenModificationListener implements ABAction { - - private List actions; - private ABBooleanCallback useCastId; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - boolean ucid = true; - if (useCastId != null) { - ucid = useCastId.callback(game, caster, localStore, castId); - } - ABFinalDamageTakenModificationListener listener = new ABFinalDamageTakenModificationListener(localStore, actions, castId, ucid); - - localStore.put(ABLocalStoreKeys.LASTCREATEDFDTML, listener); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAbilityEffectReactionListener.java deleted file mode 100644 index 1548d113c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAbilityEffectReactionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAbilityEffectReactionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveAbilityEffectReactionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAbilityEffectReactionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removeAbilityEffectReactionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAbilityProjReactionListener.java deleted file mode 100644 index c0511e89a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAbilityProjReactionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAbilityProjReactionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveAbilityProjReactionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAbilityProjReactionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removeAbilityProjReactionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackPostDamageListener.java deleted file mode 100644 index 7c51ddcb8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackPostDamageListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAttackPostDamageListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveAttackPostDamageListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAttackPostDamageListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removePostDamageListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackPreDamageListener.java deleted file mode 100644 index 4aae190e2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackPreDamageListener.java +++ /dev/null @@ -1,24 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAttackPreDamageListenerPriorityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAttackPreDamageListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveAttackPreDamageListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAttackPreDamageListenerPriorityCallback priority; - private ABAttackPreDamageListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removePreDamageListener(priority.callback(game, caster, localStore, castId), listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackProjReactionListener.java deleted file mode 100644 index de92f70c4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveAttackProjReactionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABAttackProjReactionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveAttackProjReactionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABAttackProjReactionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removeAttackProjReactionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveBehaviorChangeListener.java deleted file mode 100644 index 1c8affcea..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveBehaviorChangeListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABBehaviorChangeListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveBehaviorChangeListener implements ABAction { - - private ABUnitCallback unit; - private ABBehaviorChangeListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = unit.callback(game, caster, localStore, castId); - - target.removeBehaviorChangeListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDamageTakenListener.java deleted file mode 100644 index 19556478b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDamageTakenListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABDamageTakenListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveDamageTakenListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABDamageTakenListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removeDamageTakenListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDamageTakenModificationListener.java deleted file mode 100644 index c1d061acf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDamageTakenModificationListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABDamageTakenModificationListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveDamageTakenModificationListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABDamageTakenModificationListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removeDamageTakenModificationListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDeathReplacementEffect.java deleted file mode 100644 index f6a1dd2ad..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveDeathReplacementEffect.java +++ /dev/null @@ -1,23 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABDeathReplacementPriorityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABDeathReplacementCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveDeathReplacementEffect implements ABAction { - - private ABUnitCallback target; - private ABDeathReplacementPriorityCallback priority; - private ABDeathReplacementCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - target.callback(game, caster, localStore, castId).removeDeathReplacementEffect( - priority.callback(game, caster, localStore, castId), listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveEvasionListener.java deleted file mode 100644 index 379f35f05..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveEvasionListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABEvasionListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveEvasionListener implements ABAction { - - private ABUnitCallback targetUnit; - private ABEvasionListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - - target.removeEvasionListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveFinalDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveFinalDamageTakenModificationListener.java deleted file mode 100644 index 1befac130..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/ABActionRemoveFinalDamageTakenModificationListener.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.ABFinalDamageTakenModificationListenerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveFinalDamageTakenModificationListener implements ABAction { - - private ABUnitCallback target; - private ABFinalDamageTakenModificationListenerCallback listener; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit targetUnit = target.callback(game, caster, localStore, castId); - - targetUnit.removeFinalDamageTakenModificationListener(listener.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDamageTakenModificationMultiplyDamageMultiplier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDamageTakenModificationMultiplyDamageMultiplier.java deleted file mode 100644 index e12bfb2b7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDamageTakenModificationMultiplyDamageMultiplier.java +++ /dev/null @@ -1,21 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenModificationListenerDamageModResult; - -public class ABActionDamageTakenModificationMultiplyDamageMultiplier implements ABAction { - - private ABFloatCallback multiplier; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitAttackDamageTakenModificationListenerDamageModResult result = (CUnitAttackDamageTakenModificationListenerDamageModResult) localStore.get(ABLocalStoreKeys.DAMAGEMODRESULT+castId); - result.addDamageMultiplier(multiplier.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDamageTakenModificationSetDamageMultiplier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDamageTakenModificationSetDamageMultiplier.java deleted file mode 100644 index 024400226..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDamageTakenModificationSetDamageMultiplier.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenModificationListenerDamageModResult; - -public class ABActionDamageTakenModificationSetDamageMultiplier implements ABAction { - - private ABFloatCallback multiplier; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitAttackDamageTakenModificationListenerDamageModResult result = (CUnitAttackDamageTakenModificationListenerDamageModResult) localStore.get(ABLocalStoreKeys.DAMAGEMODRESULT+castId); - - result.setDamageMultiplier(multiplier.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementFinishReincarnating.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementFinishReincarnating.java deleted file mode 100644 index dec4b2ac4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementFinishReincarnating.java +++ /dev/null @@ -1,19 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionDeathReplacementFinishReincarnating implements ABAction { - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - caster.setFalseDeath(false); - game.getWorldCollision().addUnit(caster); - caster.getUnitAnimationListener().playAnimation(true, PrimaryTag.STAND, SequenceUtils.EMPTY, 1.0f, true); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementSetReincarnating.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementSetReincarnating.java deleted file mode 100644 index 588131988..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementSetReincarnating.java +++ /dev/null @@ -1,25 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementResult; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementStacking; - -public class ABActionDeathReplacementSetReincarnating implements ABAction { - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitDeathReplacementResult result = (CUnitDeathReplacementResult)localStore.get(ABLocalStoreKeys.DEATHRESULT+castId); - CUnitDeathReplacementStacking stacking = (CUnitDeathReplacementStacking)localStore.get(ABLocalStoreKeys.DEATHSTACKING+castId); - - stacking.setAllowStacking(false); - stacking.setAllowSamePriorityStacking(false); - result.setReincarnating(true); - caster.setFalseDeath(true); - game.getWorldCollision().removeUnit(caster); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementSetReviving.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementSetReviving.java deleted file mode 100644 index ac8f0e041..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionDeathReplacementSetReviving.java +++ /dev/null @@ -1,24 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementResult; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementStacking; - -public class ABActionDeathReplacementSetReviving implements ABAction { - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitDeathReplacementResult result = (CUnitDeathReplacementResult)localStore.get(ABLocalStoreKeys.DEATHRESULT+castId); - CUnitDeathReplacementStacking stacking = (CUnitDeathReplacementStacking)localStore.get(ABLocalStoreKeys.DEATHSTACKING+castId); - - stacking.setAllowStacking(false); - stacking.setAllowSamePriorityStacking(false); - result.setReviving(true); - caster.setFalseDeath(true); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerAddBonusDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerAddBonusDamage.java deleted file mode 100644 index ca67781b8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerAddBonusDamage.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; - -public class ABActionPreDamageListenerAddBonusDamage implements ABAction { - - private ABFloatCallback value; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitAttackPreDamageListenerDamageModResult result = (CUnitAttackPreDamageListenerDamageModResult) localStore - .get(ABLocalStoreKeys.PREDAMAGERESULT+castId); - result.addBonusDamage(value.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerAddDamageMultiplier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerAddDamageMultiplier.java deleted file mode 100644 index 47ced68d6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerAddDamageMultiplier.java +++ /dev/null @@ -1,22 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; - -public class ABActionPreDamageListenerAddDamageMultiplier implements ABAction { - - private ABFloatCallback value; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitAttackPreDamageListenerDamageModResult result = (CUnitAttackPreDamageListenerDamageModResult) localStore - .get(ABLocalStoreKeys.PREDAMAGERESULT+castId); - result.addDamageMultiplier(value.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerSetMiss.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerSetMiss.java deleted file mode 100644 index 9cf5703e5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionPreDamageListenerSetMiss.java +++ /dev/null @@ -1,26 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; - -public class ABActionPreDamageListenerSetMiss implements ABAction { - - private ABBooleanCallback miss; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitAttackPreDamageListenerDamageModResult result = (CUnitAttackPreDamageListenerDamageModResult) localStore - .get(ABLocalStoreKeys.PREDAMAGERESULT+castId); - if (miss != null) { - result.setMiss(miss.callback(game, caster, localStore, castId)); - } else { - result.setMiss(true); - } - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionReactionPreventHit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionReactionPreventHit.java deleted file mode 100644 index 2abfdf16a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionReactionPreventHit.java +++ /dev/null @@ -1,16 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionReactionPreventHit implements ABAction { - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - localStore.put(ABLocalStoreKeys.REACTIONALLOWHIT+castId, false); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionSetPreDamageStacking.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionSetPreDamageStacking.java deleted file mode 100644 index 9cf1766d4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionSetPreDamageStacking.java +++ /dev/null @@ -1,24 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackEffectListenerStacking; - -public class ABActionSetPreDamageStacking implements ABAction { - - private ABBooleanCallback allowStacking; - private ABBooleanCallback allowSamePriorityStacking; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnitAttackEffectListenerStacking stacking = (CUnitAttackEffectListenerStacking) localStore.get(ABLocalStoreKeys.PREDAMAGESTACKING+castId); - - stacking.setAllowStacking(allowStacking.callback(game, caster, localStore, castId)); - stacking.setAllowSamePriorityStacking(allowSamePriorityStacking.callback(game, caster, localStore, castId)); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionSubtractTotalDamageDealt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionSubtractTotalDamageDealt.java deleted file mode 100644 index 6d29c99c0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalActions/ABActionSubtractTotalDamageDealt.java +++ /dev/null @@ -1,21 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABActionSubtractTotalDamageDealt implements ABAction { - - private ABFloatCallback amount; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - float damage = (float) localStore.get(ABLocalStoreKeys.TOTALDAMAGEDEALT+castId); - damage-= amount.callback(game, caster, localStore, castId); - localStore.put(ABLocalStoreKeys.TOTALDAMAGEDEALT+castId, damage); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetNewBehaviorTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetNewBehaviorTarget.java deleted file mode 100644 index 150544836..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetNewBehaviorTarget.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.targetcallbacks.ABTargetCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; - -public class ABCallbackGetNewBehaviorTarget extends ABTargetCallback { - - @Override - public AbilityTarget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - CBehavior beh = (CBehavior) localStore.get(ABLocalStoreKeys.POSTCHANGEBEHAVIOR+castId); - AbilityTarget tar = beh.visit(BehaviorTargetVisitor.INSTANCE); - - return tar; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetReactionAttackProjectileAttackType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetReactionAttackProjectileAttackType.java deleted file mode 100644 index 7fc5fa7db..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetReactionAttackProjectileAttackType.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAttackTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; - -public class ABCallbackGetReactionAttackProjectileAttackType extends ABAttackTypeCallback { - - @Override - public CAttackType callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return ((CAttackProjectile) localStore.get(ABLocalStoreKeys.ATTACKPROJ+castId)).getUnitAttack().getAttackType(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetReactionAttackProjectileDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetReactionAttackProjectileDamage.java deleted file mode 100644 index 4c868d00b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetReactionAttackProjectileDamage.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; - -public class ABCallbackGetReactionAttackProjectileDamage extends ABFloatCallback { - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return ((CAttackProjectile) localStore.get(ABLocalStoreKeys.ATTACKPROJ+castId)).getDamage(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTotalDamageDealt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTotalDamageDealt.java deleted file mode 100644 index e8dbe6beb..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTotalDamageDealt.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetTotalDamageDealt extends ABFloatCallback { - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Float) localStore.get(ABLocalStoreKeys.TOTALDAMAGEDEALT+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTriggeringAttackType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTriggeringAttackType.java deleted file mode 100644 index 94f4e1bb7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTriggeringAttackType.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAttackTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; - -public class ABCallbackGetTriggeringAttackType extends ABAttackTypeCallback { - - @Override - public CAttackType callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CAttackType) localStore.get(ABLocalStoreKeys.ATTACKTYPE+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTriggeringDamageType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTriggeringDamageType.java deleted file mode 100644 index c73196b51..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackGetTriggeringDamageType.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABDamageTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABCallbackGetTriggeringDamageType extends ABDamageTypeCallback { - - @Override - public CDamageType callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CDamageType) localStore.get(ABLocalStoreKeys.DAMAGETYPE+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackIsTriggeringDamageAnAttack.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackIsTriggeringDamageAnAttack.java deleted file mode 100644 index 9ca3a15f0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackIsTriggeringDamageAnAttack.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackIsTriggeringDamageAnAttack extends ABBooleanCallback { - - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (boolean) localStore.get(ABLocalStoreKeys.DAMAGEISATTACK+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackIsTriggeringDamageRanged.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackIsTriggeringDamageRanged.java deleted file mode 100644 index e319eba16..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalCallbacks/ABCallbackIsTriggeringDamageRanged.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackIsTriggeringDamageRanged extends ABBooleanCallback { - - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (boolean) localStore.get(ABLocalStoreKeys.DAMAGEISRANGED+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalConditions/ABConditionIsNewBehaviorCategoryInList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalConditions/ABConditionIsNewBehaviorCategoryInList.java deleted file mode 100644 index 3ef14cc41..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitlisteners/internalConditions/ABConditionIsNewBehaviorCategoryInList.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalConditions; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; - -public class ABConditionIsNewBehaviorCategoryInList implements ABCondition { - - private List list; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, int castId) { - CBehavior beh = (CBehavior) localStore.get(ABLocalStoreKeys.POSTCHANGEBEHAVIOR+castId); - CBehaviorCategory cat = CBehaviorCategory.IDLE; - if (beh != null) { - cat = beh.getBehaviorCategory(); - } - return list.contains(cat); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionAddUnitToQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionAddUnitToQueue.java deleted file mode 100644 index 2f7b250f0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionAddUnitToQueue.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitqueue; - -import java.util.Map; -import java.util.Queue; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue.ABUnitQueueCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionAddUnitToQueue implements ABSingleAction { - - private ABUnitQueueCallback queue; - private ABUnitCallback unit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Queue groupQueue = this.queue.callback(game, caster, localStore, castId); - final CUnit rUnit = this.unit.callback(game, caster, localStore, castId); - groupQueue.add(rUnit); - localStore.put(ABLocalStoreKeys.LASTADDEDUNIT, rUnit); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GroupAddUnitAU(" + this.queue.generateJassEquivalent(jassTextGenerator) + ", " - + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionClearUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionClearUnitQueue.java deleted file mode 100644 index 2dbddc969..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionClearUnitQueue.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitqueue; - -import java.util.Map; -import java.util.Queue; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue.ABUnitQueueCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionClearUnitQueue implements ABSingleAction { - - private ABUnitQueueCallback queue; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Queue groupQueue = this.queue.callback(game, caster, localStore, castId); - groupQueue.clear(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GroupClear(" + this.queue.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionCreateUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionCreateUnitQueue.java deleted file mode 100644 index a5d5e9e0b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionCreateUnitQueue.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitqueue; - -import java.util.LinkedList; -import java.util.Map; -import java.util.Queue; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionCreateUnitQueue implements ABSingleAction { - - private String name; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Queue queue = new LinkedList<>(); - if (this.name != null) { - localStore.put("_unitqueue_" + this.name, queue); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDUNITQUEUE, queue); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.name != null) { - return "CreateNamedQueueAU(" + jassTextGenerator.getTriggerLocalStore() + ", \"" + this.name + "\")"; - } - return "CreateQueueAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionRemoveUnitFromQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionRemoveUnitFromQueue.java deleted file mode 100644 index 671e76181..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitqueue/ABActionRemoveUnitFromQueue.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitqueue; - -import java.util.Map; -import java.util.Queue; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue.ABUnitQueueCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; - -public class ABActionRemoveUnitFromQueue implements ABSingleAction { - - private ABUnitQueueCallback queue; - private ABUnitCallback unit; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Queue groupQueue = this.queue.callback(game, caster, localStore, castId); - final CUnit rUnit = this.unit.callback(game, caster, localStore, castId); - groupQueue.remove(rUnit); - localStore.put(ABLocalStoreKeys.LASTREMOVEDDUNIT, rUnit); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GroupRemoveUnitAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.queue.generateJassEquivalent(jassTextGenerator) + ", " - + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionAddStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionAddStateModBuff.java deleted file mode 100644 index 971c2a7ea..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionAddStateModBuff.java +++ /dev/null @@ -1,25 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitstate; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statemodcallbacks.ABStateModBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; - -public class ABActionAddStateModBuff implements ABAction { - - private ABUnitCallback targetUnit; - private ABStateModBuffCallback buff; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - StateModBuff theBuff = buff.callback(game, caster, localStore, castId); - - target.addStateModBuff(theBuff); - target.computeUnitState(game, theBuff.getBuffType()); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionCreateStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionCreateStateModBuff.java deleted file mode 100644 index f5af5fc08..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionCreateStateModBuff.java +++ /dev/null @@ -1,29 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitstate; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks.ABLongCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuffType; - -public class ABActionCreateStateModBuff implements ABAction { - - private StateModBuffType buffType; - private ABLongCallback value; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - StateModBuff buff = null; - if (value != null) { - buff = new StateModBuff(buffType, value.callback(game, caster, localStore, castId)); - } else { - buff = new StateModBuff(buffType, 1); - } - - localStore.put(ABLocalStoreKeys.LASTCREATEDSMB, buff); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionRemoveStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionRemoveStateModBuff.java deleted file mode 100644 index 3402453fd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionRemoveStateModBuff.java +++ /dev/null @@ -1,25 +0,0 @@ - -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitstate; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statemodcallbacks.ABStateModBuffCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; - -public class ABActionRemoveStateModBuff implements ABAction { - - private ABUnitCallback targetUnit; - private ABStateModBuffCallback buff; - - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, final int castId) { - CUnit target = targetUnit.callback(game, caster, localStore, castId); - StateModBuff theBuff = buff.callback(game, caster, localStore, castId); - - target.removeStateModBuff(theBuff); - target.computeUnitState(game, theBuff.getBuffType()); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionSetUnitFadeTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionSetUnitFadeTimer.java deleted file mode 100644 index f88cf80a8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unitstate/ABActionSetUnitFadeTimer.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitstate; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks.ABTimerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABActionSetUnitFadeTimer implements ABAction { - - private ABUnitCallback targetUnit; - private ABTimerCallback timer; - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final CUnit target = this.targetUnit.callback(game, caster, localStore, castId); - final CTimer theTimer = this.timer.callback(game, caster, localStore, castId); - - target.setFadeTimer(theTimer); - } -} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionCreateLocationVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionCreateLocationVisionModifier.java deleted file mode 100644 index e024c5885..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionCreateLocationVisionModifier.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.vision; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.ABPlayerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CCircleFogModifier; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CTimedCircleFogModifier; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CFogState; - -public class ABActionCreateLocationVisionModifier implements ABAction { - - private ABLocationCallback location; - private ABFloatCallback radius; - private ABFloatCallback duration; - private ABPlayerCallback player; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, int castId) { - CFogModifier vision; - final AbilityPointTarget loc = this.location.callback(game, caster, localStore, castId); - if (this.duration == null) { - vision = new CCircleFogModifier(CFogState.VISIBLE, this.radius.callback(game, caster, localStore, castId), - loc.getX(), loc.getY()); - } - else { - vision = new CTimedCircleFogModifier(CFogState.VISIBLE, - this.radius.callback(game, caster, localStore, castId), loc.getX(), loc.getY(), - this.duration.callback(game, caster, localStore, castId)); - } - if (this.player != null) { - this.player.callback(game, caster, localStore, castId).addFogModifer(game, vision, false); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDVISIONMODIFIER, vision); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionCreateUnitVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionCreateUnitVisionModifier.java deleted file mode 100644 index bd53b91d2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionCreateUnitVisionModifier.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.vision; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.ABPlayerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CUnitVisionFogModifier; - -public class ABActionCreateUnitVisionModifier implements ABAction { - - private ABUnitCallback unit; - private ABPlayerCallback player; - private ABBooleanCallback alwaysNightVision; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, int castId) { - boolean alwaysNight = false; - if (this.alwaysNightVision != null) { - alwaysNight = this.alwaysNightVision.callback(game, caster, localStore, castId); - } - - final CUnitVisionFogModifier vision = new CUnitVisionFogModifier( - this.unit.callback(game, caster, localStore, castId), alwaysNight); - if (this.player != null) { - this.player.callback(game, caster, localStore, castId).addFogModifer(game, vision, false); - } - localStore.put(ABLocalStoreKeys.LASTCREATEDVISIONMODIFIER, vision); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionRemoveVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionRemoveVisionModifier.java deleted file mode 100644 index df0caf181..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionRemoveVisionModifier.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.vision; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.ABPlayerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.visionmodifier.ABVisionModifierCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionRemoveVisionModifier implements ABAction { - - private ABVisionModifierCallback modifier; - private ABPlayerCallback player; - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, int castId) { - player.callback(game, caster, localStore, castId).removeFogModifer(game, modifier.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionSetBurrowPlaceholder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionSetBurrowPlaceholder.java deleted file mode 100644 index b35a3d382..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/vision/ABActionSetBurrowPlaceholder.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.vision; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionSetBurrowPlaceholder implements ABAction { - - @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, int castId) { - // TODO Auto-generated method stub - - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABAbilityCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABAbilityCallback.java deleted file mode 100644 index 203c1c91e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABAbilityCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABAbilityCallback implements ABCallback { - - abstract public CAbility callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetLastCreatedAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetLastCreatedAbility.java deleted file mode 100644 index 50625f51e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetLastCreatedAbility.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetLastCreatedAbility extends ABAbilityCallback { - - @Override - public CAbility callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CAbility) localStore.get(ABLocalStoreKeys.LASTCREATEDABILITY); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDABILITY", - JassTextGeneratorType.AbilityHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetPartnerAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetPartnerAbility.java deleted file mode 100644 index 5e5a4d663..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetPartnerAbility.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetPartnerAbility extends ABAbilityCallback { - - @Override - public CAbility callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CAbility) localStore.get(ABLocalStoreKeys.LASTPARTNERABILITY); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTPARTNERABILITY", - JassTextGeneratorType.AbilityHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetReactionAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetReactionAbility.java deleted file mode 100644 index 240b809ff..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetReactionAbility.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetReactionAbility extends ABAbilityCallback { - - @Override - public CAbility callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CAbility) localStore.get(ABLocalStoreKeys.REACTIONABILITY); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_REACTIONABILITY", - JassTextGeneratorType.AbilityHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetStoredAbilityByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetStoredAbilityByKey.java deleted file mode 100644 index 0651154f5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/abilitycallbacks/ABCallbackGetStoredAbilityByKey.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredAbilityByKey extends ABAbilityCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CAbility callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - return (CAbility) localStore.get(ABLocalStoreKeys - .combineUserInstanceKey(this.key.callback(game, caster, localStore, castId), castId)); - } - else { - return (CAbility) localStore - .get(ABLocalStoreKeys.combineUserKey(this.key.callback(game, caster, localStore, castId), castId)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.instanceValue == null) { - return "GetLocalStoreUserCastAbilityHandleAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; - } - return "GetStoredAbilityAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABBooleanCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABBooleanCallback.java deleted file mode 100644 index 0485e2504..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABBooleanCallback.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABBooleanCallback implements ABCallback { - - abstract public Boolean callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetAbilityDataAsBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetAbilityDataAsBoolean.java deleted file mode 100644 index d548fc3f4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetAbilityDataAsBoolean.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityDataAsBoolean extends ABBooleanCallback { - - private DataFieldLetter dataField; - - @SuppressWarnings("unchecked") - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - final String data = levelData.get(level - 1).getData().get(this.dataField.getIndex()); - if (data.equals("-")) { - return false; - } - return Integer.parseInt(data) == 1; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "GetAbilityDataAsFloatAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" - + this.dataField.name() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetParentAbilityDataAsBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetParentAbilityDataAsBoolean.java deleted file mode 100644 index 8b731440e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetParentAbilityDataAsBoolean.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetParentAbilityDataAsBoolean extends ABBooleanCallback { - - private ABIntegerCallback dataField; - - @SuppressWarnings("unchecked") - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.PARENTLEVELDATA); - final int parentLevel = (int) ((Map) localStore.get(ABLocalStoreKeys.PARENTLOCALSTORE)) - .get(ABLocalStoreKeys.CURRENTLEVEL); - - final String data = levelData.get(parentLevel - 1).getData() - .get(this.dataField.callback(game, caster, localStore, castId)); - final int parsedData = Integer.parseInt(data); - return parsedData == 1; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "GetAbilityDataAsBooleanAU(" + jassTextGenerator.getTriggerLocalStore() + ", ConvertDataFieldLetter(" - + this.dataField.generateJassEquivalent(jassTextGenerator) + "))"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetStoredBooleanByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetStoredBooleanByKey.java deleted file mode 100644 index 56ffbd12f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackGetStoredBooleanByKey.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredBooleanByKey extends ABBooleanCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - return (Boolean) localStore.get(ABLocalStoreKeys - .combineUserInstanceKey(this.key.callback(game, caster, localStore, castId), castId)); - } - else { - return (Boolean) localStore - .get(ABLocalStoreKeys.combineUserKey(this.key.callback(game, caster, localStore, castId), castId)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.instanceValue == null) { - return "GetLocalStoreUserCastBooleanAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; - } - return "GetStoredBooleanAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackIntegerToBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackIntegerToBoolean.java deleted file mode 100644 index c12d5bd41..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackIntegerToBoolean.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; - -public class ABCallbackIntegerToBoolean extends ABBooleanCallback { - - private ABIntegerCallback value; - - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return this.value.callback(game, caster, localStore, castId) != 0; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return this.value.generateJassEquivalent(jassTextGenerator) + " != 0"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackIsProjectileReflected.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackIsProjectileReflected.java deleted file mode 100644 index 4bcd190ac..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackIsProjectileReflected.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile.ABProjectileCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABCallbackIsProjectileReflected extends ABBooleanCallback { - - private ABProjectileCallback projectile; - - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CProjectile proj = this.projectile.callback(game, caster, localStore, castId); - return proj.isReflected(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "IsProjectileReflected(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackRawBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackRawBoolean.java deleted file mode 100644 index e1423a735..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackRawBoolean.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRawBoolean extends ABBooleanCallback { - - private Boolean value; - - @Override - public Boolean callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return this.value; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return this.value.toString(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackWasCastingInterrupted.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackWasCastingInterrupted.java deleted file mode 100644 index be620b98f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/booleancallbacks/ABCallbackWasCastingInterrupted.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackWasCastingInterrupted extends ABBooleanCallback { - - @Override - public Boolean callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Boolean) localStore.get(ABLocalStoreKeys.INTERRUPTED); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_INTERRUPTED", JassTextGeneratorType.Boolean); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABBuffCallback.java deleted file mode 100644 index f22148639..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABBuffCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABBuffCallback implements ABCallback { - - abstract public CBuff callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABCallbackGetLastCreatedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABCallbackGetLastCreatedBuff.java deleted file mode 100644 index beb430e0b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABCallbackGetLastCreatedBuff.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetLastCreatedBuff extends ABBuffCallback { - - @Override - public CBuff callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return (CBuff) localStore.get(ABLocalStoreKeys.LASTCREATEDBUFF); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDBUFF", JassTextGeneratorType.BuffHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABCallbackGetStoredBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABCallbackGetStoredBuffByKey.java deleted file mode 100644 index 77831022a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/buffcallbacks/ABCallbackGetStoredBuffByKey.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredBuffByKey extends ABBuffCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CBuff callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - return (CBuff) localStore.get(ABLocalStoreKeys - .combineUserInstanceKey(this.key.callback(game, caster, localStore, castId), castId)); - } - else { - return (CBuff) localStore - .get(ABLocalStoreKeys.combineUserKey(this.key.callback(game, caster, localStore, castId), castId)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.instanceValue == null) { - return "GetLocalStoreUserCastBuffHandleAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; - } - return "GetStoredBuffAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABCallbackGetEnumDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABCallbackGetEnumDestructable.java deleted file mode 100644 index e55f8f8f7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABCallbackGetEnumDestructable.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetEnumDestructable extends ABDestructableCallback { - - @Override - public CDestructable callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CDestructable) localStore.get(ABLocalStoreKeys.ENUMDESTRUCTABLE+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABCallbackGetProjectileHitDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABCallbackGetProjectileHitDestructable.java deleted file mode 100644 index e732b8e29..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABCallbackGetProjectileHitDestructable.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetProjectileHitDestructable extends ABDestructableCallback { - - @Override - public CDestructable callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CDestructable) localStore.get(ABLocalStoreKeys.PROJECTILEHITDEST+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABDestructableCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABDestructableCallback.java deleted file mode 100644 index 4ca32a3c6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructable/ABDestructableCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABDestructableCallback implements ABCallback { - - abstract public CDestructable callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABCallbackGetLastCreatedDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABCallbackGetLastCreatedDestructableBuff.java deleted file mode 100644 index dd30aac82..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABCallbackGetLastCreatedDestructableBuff.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructablebuff; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetLastCreatedDestructableBuff extends ABDestructableBuffCallback { - - @Override - public CDestructableBuff callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CDestructableBuff) localStore.get(ABLocalStoreKeys.LASTCREATEDDESTBUFF); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABCallbackGetStoredDestructableBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABCallbackGetStoredDestructableBuffByKey.java deleted file mode 100644 index 0325cffe8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABCallbackGetStoredDestructableBuffByKey.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructablebuff; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredDestructableBuffByKey extends ABDestructableBuffCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CDestructableBuff callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (CDestructableBuff) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (CDestructableBuff) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABDestructableBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABDestructableBuffCallback.java deleted file mode 100644 index 92a683539..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/destructablebuff/ABDestructableBuffCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructablebuff; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABDestructableBuffCallback implements ABCallback { - - abstract public CDestructableBuff callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAttackPreDamageListenerPriorityCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAttackPreDamageListenerPriorityCallback.java deleted file mode 100644 index 0ca870e21..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAttackPreDamageListenerPriorityCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerPriority; - -public abstract class ABAttackPreDamageListenerPriorityCallback implements ABCallback { - - abstract public CUnitAttackPreDamageListenerPriority callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAttackTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAttackTypeCallback.java deleted file mode 100644 index b96f85b73..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAttackTypeCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; - -public abstract class ABAttackTypeCallback implements ABCallback { - - abstract public CAttackType callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAutocastTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAutocastTypeCallback.java deleted file mode 100644 index 13fec532a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABAutocastTypeCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABAutocastTypeCallback implements ABCallback { - - abstract public AutocastType callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackConditionalAutocastType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackConditionalAutocastType.java deleted file mode 100644 index 886cffa71..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackConditionalAutocastType.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABCallbackConditionalAutocastType extends ABAutocastTypeCallback { - - private ABCondition condition; - private ABAutocastTypeCallback value1; - private ABAutocastTypeCallback value2; - - @Override - public AutocastType callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (condition.evaluate(game, caster, localStore, castId)) { - return value1.callback(game, caster, localStore, castId); - } - return value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetAttackTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetAttackTypeFromString.java deleted file mode 100644 index 4632db04e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetAttackTypeFromString.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; - -public class ABCallbackGetAttackTypeFromString extends ABAttackTypeCallback { - - private ABStringCallback id; - - @Override - public CAttackType callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return CAttackType.valueOf(id.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetAutocastTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetAutocastTypeFromString.java deleted file mode 100644 index fb305c0f3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetAutocastTypeFromString.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; - -public class ABCallbackGetAutocastTypeFromString extends ABAutocastTypeCallback { - - private ABStringCallback id; - - @Override - public AutocastType callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return AutocastType.valueOf(id.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetDamageTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetDamageTypeFromString.java deleted file mode 100644 index 2b44e9938..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetDamageTypeFromString.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABCallbackRawString; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABCallbackGetDamageTypeFromString extends ABDamageTypeCallback { - - private ABStringCallback id; - - @Override - public CDamageType callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return CDamageType.valueOf(this.id.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - if (this.id instanceof ABCallbackRawString) { - // if possible, convert it directly, no shenanigans - final String value = ((ABCallbackRawString) this.id).getValue(); - return "DAMAGE_TYPE_" + value; - } - return "String2DamageType(" + this.id.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetNonStackingStatBuffTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetNonStackingStatBuffTypeFromString.java deleted file mode 100644 index 3b7328cb1..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackGetNonStackingStatBuffTypeFromString.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABCallbackRawString; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; - -public class ABCallbackGetNonStackingStatBuffTypeFromString extends ABNonStackingStatBuffTypeCallback { - - private ABStringCallback id; - - @Override - public NonStackingStatBuffType callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId) { - return NonStackingStatBuffType.valueOf(this.id.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - if (this.id instanceof ABCallbackRawString) { - // if possible, convert it directly, no shenanigans - final String value = ((ABCallbackRawString) this.id).getValue(); - return "NON_STACKING_STAT_BUFF_TYPE_" + value; - } - return "String2NonStackingStatBuffType(" + this.id.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackRawDeathEffectPriority.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackRawDeathEffectPriority.java deleted file mode 100644 index 6303e42bc..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackRawDeathEffectPriority.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementEffectPriority; - -public class ABCallbackRawDeathEffectPriority extends ABDeathReplacementPriorityCallback { - - private CUnitDeathReplacementEffectPriority priority; - - @Override - public CUnitDeathReplacementEffectPriority callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return priority; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackRawPreDamageListenerPriority.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackRawPreDamageListenerPriority.java deleted file mode 100644 index 61734c9c1..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABCallbackRawPreDamageListenerPriority.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerPriority; - -public class ABCallbackRawPreDamageListenerPriority extends ABAttackPreDamageListenerPriorityCallback { - - private CUnitAttackPreDamageListenerPriority priority; - - @Override - public CUnitAttackPreDamageListenerPriority callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return priority; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABDamageTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABDamageTypeCallback.java deleted file mode 100644 index ab95bd34e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABDamageTypeCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public abstract class ABDamageTypeCallback implements ABCallback { - - abstract public CDamageType callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABDeathReplacementPriorityCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABDeathReplacementPriorityCallback.java deleted file mode 100644 index 00b8cacce..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABDeathReplacementPriorityCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementEffectPriority; - -public abstract class ABDeathReplacementPriorityCallback implements ABCallback { - - abstract public CUnitDeathReplacementEffectPriority callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABNonStackingStatBuffTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABNonStackingStatBuffTypeCallback.java deleted file mode 100644 index 24446dc1e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/enumcallbacks/ABNonStackingStatBuffTypeCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; - -public abstract class ABNonStackingStatBuffTypeCallback implements ABCallback { - - abstract public NonStackingStatBuffType callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABCallbackGetLastCreatedTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABCallbackGetLastCreatedTimeOfDayEvent.java deleted file mode 100644 index 326b441d5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABCallbackGetLastCreatedTimeOfDayEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.eventcallbacks.timeeventcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event.ABTimeOfDayEvent; - -public class ABCallbackGetLastCreatedTimeOfDayEvent extends ABTimeOfDayEventCallback { - - @Override - public ABTimeOfDayEvent callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABTimeOfDayEvent) localStore.get(ABLocalStoreKeys.LASTCREATEDTODEVENT); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABCallbackGetStoredTimeOfDayEventByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABCallbackGetStoredTimeOfDayEventByKey.java deleted file mode 100644 index 105dbe68a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABCallbackGetStoredTimeOfDayEventByKey.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.eventcallbacks.timeeventcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event.ABTimeOfDayEvent; - -public class ABCallbackGetStoredTimeOfDayEventByKey extends ABTimeOfDayEventCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABTimeOfDayEvent callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABTimeOfDayEvent) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABTimeOfDayEvent) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABTimeOfDayEventCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABTimeOfDayEventCallback.java deleted file mode 100644 index 7537c5cf2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/eventcallbacks/timeeventcallbacks/ABTimeOfDayEventCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.eventcallbacks.timeeventcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event.ABTimeOfDayEvent; - -public abstract class ABTimeOfDayEventCallback implements ABCallback { - - abstract public ABTimeOfDayEvent callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackAddFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackAddFloat.java deleted file mode 100644 index b3b85a5b8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackAddFloat.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackAddFloat extends ABFloatCallback { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) + value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackCeilFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackCeilFloat.java deleted file mode 100644 index 440231a79..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackCeilFloat.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackCeilFloat extends ABFloatCallback { - - private ABFloatCallback value; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (float) Math.ceil(value.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackCos.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackCos.java deleted file mode 100644 index 06370aff9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackCos.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackCos extends ABFloatCallback { - - private ABFloatCallback angle; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (float) StrictMath.cos(angle.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackDivideFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackDivideFloat.java deleted file mode 100644 index 5fadfa223..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackDivideFloat.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackDivideFloat extends ABFloatCallback { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return this.value1.callback(game, caster, localStore, castId) - / this.value2.callback(game, caster, localStore, castId); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return this.value1.generateJassEquivalent(jassTextGenerator) + " / " - + this.value2.generateJassEquivalent(jassTextGenerator); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackFMaxValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackFMaxValue.java deleted file mode 100644 index 1b1003781..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackFMaxValue.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackFMaxValue extends ABFloatCallback { - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return Float.MAX_VALUE; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackFloorFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackFloorFloat.java deleted file mode 100644 index 59ac487e2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackFloorFloat.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackFloorFloat extends ABFloatCallback { - - private ABFloatCallback value; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (float) Math.floor(value.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityArea.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityArea.java deleted file mode 100644 index d62c94574..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityArea.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.ABAbilityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityArea extends ABFloatCallback { - - private ABAbilityCallback ability; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (ability == null) { - AbilityBuilderAbility abil = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - return abil.getArea(); - } else { - CAbility abil = ability.callback(game, caster, localStore, castId); - if (abil instanceof AbilityBuilderAbility) { - return ((AbilityBuilderAbility)abil).getArea(); - } else { - return 0f; - } - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCastRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCastRange.java deleted file mode 100644 index a150352a0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCastRange.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.ABAbilityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityCastRange extends ABFloatCallback { - - private ABAbilityCallback ability; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (ability == null) { - AbilityBuilderAbility abil = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - return abil.getCastRange(); - } else { - CAbility abil = ability.callback(game, caster, localStore, castId); - if (abil instanceof AbilityBuilderAbility) { - return ((AbilityBuilderAbility)abil).getCastRange(); - } else { - return 0f; - } - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCastTime.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCastTime.java deleted file mode 100644 index 59e20d4a7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCastTime.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityCastTime extends ABFloatCallback { - - @SuppressWarnings("unchecked") - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - return levelData.get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getCastTime(); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "GetAbilityCastTimeAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCooldown.java deleted file mode 100644 index 1c10c3f2e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityCooldown.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.ABAbilityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityCooldown extends ABFloatCallback { - - private ABAbilityCallback ability; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (ability == null) { - AbilityBuilderAbility abil = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - return abil.getCooldown(); - } else { - CAbility abil = ability.callback(game, caster, localStore, castId); - if (abil instanceof AbilityBuilderAbility) { - return ((AbilityBuilderAbility)abil).getCooldown(); - } else { - return 0f; - } - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityDataAsFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityDataAsFloat.java deleted file mode 100644 index 12427c989..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityDataAsFloat.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityDataAsFloat extends ABFloatCallback { - - private DataFieldLetter dataField; - - @SuppressWarnings("unchecked") - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - final String data = levelData.get(level - 1).getData().get(this.dataField.getIndex()); - if (data.contains("-") || data.isEmpty()) { - return 0f; - } - - return Float.parseFloat(data); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "GetAbilityDataAsFloatAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" - + this.dataField.name() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityDuration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityDuration.java deleted file mode 100644 index e56020bb4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityDuration.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; - -public class ABCallbackGetAbilityDuration extends ABFloatCallback { - - private ABUnitCallback target; - - @SuppressWarnings("unchecked") - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - if (this.target != null) { - final CUnit tar = this.target.callback(game, caster, localStore, castId); - if (tar.isHero() || tar.isUnitType(CUnitTypeJass.RESISTANT)) { - return levelData.get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getDurationHero(); - } - } - return levelData.get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getDurationNormal(); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - if (this.target != null) { - return "GetAbilityDurationForTargetAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ")"; - } - return "GetAbilityDurationAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; - - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityHeroDuration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityHeroDuration.java deleted file mode 100644 index 84bd0f6db..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAbilityHeroDuration.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityHeroDuration extends ABFloatCallback { - - @SuppressWarnings("unchecked") - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - List levelData = (List) localStore.get(ABLocalStoreKeys.LEVELDATA); - return levelData.get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL))-1).getDurationHero(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAngleBetweenLocations.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAngleBetweenLocations.java deleted file mode 100644 index eb44d1a92..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetAngleBetweenLocations.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; - -public class ABCallbackGetAngleBetweenLocations extends ABFloatCallback { - - private ABLocationCallback origin; - private ABLocationCallback target; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - final AbilityPointTarget o = this.origin.callback(game, caster, localStore, castId); - final AbilityPointTarget t = this.target.callback(game, caster, localStore, castId); - - final double dx = t.getX() - o.getX(); - final double dy = t.getY() - o.getY(); - return (float) StrictMath.atan2(dy, dx); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "AngleBetweenPointsAU(" + this.origin.generateJassEquivalent(jassTextGenerator) + ", " - + this.target.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetDistanceBetweenLocations.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetDistanceBetweenLocations.java deleted file mode 100644 index fbb0d8fda..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetDistanceBetweenLocations.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; - -public class ABCallbackGetDistanceBetweenLocations extends ABFloatCallback { - - private ABLocationCallback origin; - private ABLocationCallback target; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - AbilityPointTarget o = origin.callback(game, caster, localStore, castId); - AbilityPointTarget t = target.callback(game, caster, localStore, castId); - - return o.dst(t); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetLocationX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetLocationX.java deleted file mode 100644 index 357eb985c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetLocationX.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; - -public class ABCallbackGetLocationX extends ABFloatCallback { - - private ABLocationCallback location; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return location.callback(game, caster, localStore, castId).getX(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetLocationY.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetLocationY.java deleted file mode 100644 index f121accdf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetLocationY.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; - -public class ABCallbackGetLocationY extends ABFloatCallback { - - private ABLocationCallback location; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return location.callback(game, caster, localStore, castId).getY(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetParentAbilityDataAsFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetParentAbilityDataAsFloat.java deleted file mode 100644 index f65feb881..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetParentAbilityDataAsFloat.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetParentAbilityDataAsFloat extends ABFloatCallback { - - private DataFieldLetter dataField; - - @SuppressWarnings("unchecked") - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - List levelData = (List) localStore.get(ABLocalStoreKeys.PARENTLEVELDATA); - int parentLevel = (int) ((Map)localStore.get(ABLocalStoreKeys.PARENTLOCALSTORE)).get(ABLocalStoreKeys.CURRENTLEVEL); - - String data = levelData.get(parentLevel-1).getData().get(dataField.getIndex()); - - return Float.parseFloat(data); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetStoredFloatByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetStoredFloatByKey.java deleted file mode 100644 index 0f0cdc0ce..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetStoredFloatByKey.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredFloatByKey extends ABFloatCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - return (Float) localStore.get(ABLocalStoreKeys - .combineUserInstanceKey(this.key.callback(game, caster, localStore, castId), castId)); - } - else { - return (Float) localStore - .get(ABLocalStoreKeys.combineUserKey(this.key.callback(game, caster, localStore, castId), castId)); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - if (this.instanceValue == null) { - return "GetLocalStoreUserCastRealAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; - } - return "GetStoredRealAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitAcquisitionRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitAcquisitionRange.java deleted file mode 100644 index f3250f2e0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitAcquisitionRange.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitAcquisitionRange extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit theUnit = unit.callback(game, caster, localStore, castId); - if (theUnit.getAcquisitionRange() > 0) { - return theUnit.getAcquisitionRange(); - } - return (float) theUnit.getUnitType().getSightRadiusDay(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCastPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCastPoint.java deleted file mode 100644 index 54e23f904..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCastPoint.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitCastPoint extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return unit.callback(game, caster, localStore, castId).getUnitType().getCastPoint(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCurrentHp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCurrentHp.java deleted file mode 100644 index f71cfa3fe..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCurrentHp.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitCurrentHp extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return this.unit.callback(game, caster, localStore, castId).getLife(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GetUnitState(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", UNIT_STATE_LIFE)"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCurrentMana.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCurrentMana.java deleted file mode 100644 index 07a9bb2d3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitCurrentMana.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitCurrentMana extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return unit.callback(game, caster, localStore, castId).getMana(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitFacing.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitFacing.java deleted file mode 100644 index 6728180a1..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitFacing.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitFacing extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return this.unit.callback(game, caster, localStore, castId).getFacing(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GetUnitFacing(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitInitialMana.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitInitialMana.java deleted file mode 100644 index d85b2d0ca..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitInitialMana.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitInitialMana extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (float) unit.callback(game, caster, localStore, castId).getUnitType().getManaInitial(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitLocationX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitLocationX.java deleted file mode 100644 index ef3b0fc0d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitLocationX.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitLocationX extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return unit.callback(game, caster, localStore, castId).getX(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitLocationY.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitLocationY.java deleted file mode 100644 index fdc1745db..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackGetUnitLocationY.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitLocationY extends ABFloatCallback { - - private ABUnitCallback unit; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return unit.callback(game, caster, localStore, castId).getY(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackIntToFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackIntToFloat.java deleted file mode 100644 index 7a60382f7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackIntToFloat.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; - -public class ABCallbackIntToFloat extends ABFloatCallback { - - private ABIntegerCallback value; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return this.value.callback(game, caster, localStore, castId).floatValue(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return this.value.generateJassEquivalent(jassTextGenerator); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMaxFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMaxFloat.java deleted file mode 100644 index 3e534303a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMaxFloat.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMaxFloat extends ABFloatCallback { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return Math.max(this.value1.callback(game, caster, localStore, castId), - this.value2.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RMaxBJ(" + this.value1.generateJassEquivalent(jassTextGenerator) + ", " - + this.value2.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMinFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMinFloat.java deleted file mode 100644 index ddc34e16d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMinFloat.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMinFloat extends ABFloatCallback { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return Math.min(this.value1.callback(game, caster, localStore, castId), - this.value2.callback(game, caster, localStore, castId)); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "RMinBJ(" + this.value1.generateJassEquivalent(jassTextGenerator) + ", " - + this.value2.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMultiplyFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMultiplyFloat.java deleted file mode 100644 index e7c1e3c9c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackMultiplyFloat.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMultiplyFloat extends ABFloatCallback { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) * value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackNegativeFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackNegativeFloat.java deleted file mode 100644 index 97fb186bd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackNegativeFloat.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackNegativeFloat extends ABFloatCallback { - - private ABFloatCallback value; - - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return -1 * this.value.callback(game, caster, localStore, castId); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "-(" + this.value.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackPi.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackPi.java deleted file mode 100644 index 9a674959a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackPi.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackPi extends ABFloatCallback { - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (float) StrictMath.PI; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRandomBoundedFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRandomBoundedFloat.java deleted file mode 100644 index 52e82be66..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRandomBoundedFloat.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRandomBoundedFloat extends ABFloatCallback { - - private ABFloatCallback bound; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getSeededRandom().nextFloat(bound.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRandomFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRandomFloat.java deleted file mode 100644 index 39bd66d20..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRandomFloat.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRandomFloat extends ABFloatCallback { - - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getSeededRandom().nextFloat(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRawFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRawFloat.java deleted file mode 100644 index 5e1ae758f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackRawFloat.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRawFloat extends ABFloatCallback { - - private Float value; - - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return this.value; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return this.value.toString(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackSin.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackSin.java deleted file mode 100644 index c8f243723..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackSin.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackSin extends ABFloatCallback { - - private ABFloatCallback angle; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (float) StrictMath.sin(angle.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackSubtractFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackSubtractFloat.java deleted file mode 100644 index 61342c2c6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackSubtractFloat.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackSubtractFloat extends ABFloatCallback { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public Float callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return this.value1.callback(game, caster, localStore, castId) - - this.value2.callback(game, caster, localStore, castId); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return this.value1.generateJassEquivalent(jassTextGenerator) + " - " - + this.value2.generateJassEquivalent(jassTextGenerator); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackTicksForDuration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackTicksForDuration.java deleted file mode 100644 index b36b6ea32..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABCallbackTicksForDuration.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackTicksForDuration extends ABFloatCallback { - - private ABFloatCallback duration; - - @Override - public Float callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return duration.callback(game, caster, localStore, castId) / WarsmashConstants.SIMULATION_STEP_TIME; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABFloatCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABFloatCallback.java deleted file mode 100644 index 863b4f947..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/floatcallbacks/ABFloatCallback.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABFloatCallback implements ABCallback { - - abstract public Float callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetLastCreatedLightningEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetLastCreatedLightningEffect.java deleted file mode 100644 index 04890439b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetLastCreatedLightningEffect.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; - -public class ABCallbackGetLastCreatedLightningEffect extends ABLightningCallback { - - @Override - public SimulationRenderComponentLightning callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (SimulationRenderComponentLightning) localStore.get(ABLocalStoreKeys.LASTCREATEDLIGHTNING); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetLastCreatedSpellEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetLastCreatedSpellEffect.java deleted file mode 100644 index 6b0691b8e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetLastCreatedSpellEffect.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABCallbackGetLastCreatedSpellEffect extends ABFXCallback { - - @Override - public SimulationRenderComponent callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (SimulationRenderComponent) localStore.get(ABLocalStoreKeys.LASTCREATEDFX); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetStoredFXByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetStoredFXByKey.java deleted file mode 100644 index 06ef5c1a5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetStoredFXByKey.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABCallbackGetStoredFXByKey extends ABFXCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public SimulationRenderComponent callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (SimulationRenderComponent) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (SimulationRenderComponent) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetStoredLightningByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetStoredLightningByKey.java deleted file mode 100644 index f132f1d81..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABCallbackGetStoredLightningByKey.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; - -public class ABCallbackGetStoredLightningByKey extends ABLightningCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public SimulationRenderComponentLightning callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (SimulationRenderComponentLightning) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (SimulationRenderComponentLightning) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABFXCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABFXCallback.java deleted file mode 100644 index 8d12b9a50..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABFXCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public abstract class ABFXCallback implements ABCallback { - - abstract public SimulationRenderComponent callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABLightningCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABLightningCallback.java deleted file mode 100644 index baff6e25e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/fxcallbacks/ABLightningCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; - -public abstract class ABLightningCallback implements ABCallback { - - abstract public SimulationRenderComponentLightning callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAbilityDataAsID.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAbilityDataAsID.java deleted file mode 100644 index 63aa90c53..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAbilityDataAsID.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityDataAsID extends ABIDCallback { - - private DataFieldLetter dataField; - - @SuppressWarnings("unchecked") - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - final String data = levelData.get(level - 1).getData().get(this.dataField.getIndex()); - if ((data == null) || "-".equals(data) || data.isBlank() || "_".equals(data)) { - return War3ID.NONE; - } - return War3ID.fromString(data); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "GetAbilityDataAsIDAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" - + this.dataField.name() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAbilityUnitId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAbilityUnitId.java deleted file mode 100644 index 9c40a5a65..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAbilityUnitId.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityUnitId extends ABIDCallback { - - @SuppressWarnings("unchecked") - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - List levelData = (List) localStore.get(ABLocalStoreKeys.LEVELDATA); - int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - War3ID unitId = levelData.get(level-1).getUnitId(); - if (unitId == null) { - return War3ID.NONE; - } - return unitId; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAlias.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAlias.java deleted file mode 100644 index 12ca40221..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetAlias.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAlias extends ABIDCallback { - - @Override - public War3ID callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return (War3ID) localStore.get(ABLocalStoreKeys.ALIAS); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ALIAS", JassTextGeneratorType.Integer); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetFirstBuffId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetFirstBuffId.java deleted file mode 100644 index 49da8617f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetFirstBuffId.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetFirstBuffId extends ABIDCallback { - - @SuppressWarnings("unchecked") - @Override - public War3ID callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final List buffs = ((List) localStore - .get(ABLocalStoreKeys.LEVELDATA)).get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1) - .getBuffs(); - if ((buffs != null) && !buffs.isEmpty()) { - return buffs.get(0); - } - return null; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "GetFirstBuffIdAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetFirstEffectId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetFirstEffectId.java deleted file mode 100644 index 3a132f119..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetFirstEffectId.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetFirstEffectId extends ABIDCallback { - - @SuppressWarnings("unchecked") - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - List effects = ((List) localStore.get(ABLocalStoreKeys.LEVELDATA)) - .get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getEffects(); - if (effects != null && !effects.isEmpty()) { - return effects.get(0); - } - return null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetNonCurrentTransformType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetNonCurrentTransformType.java deleted file mode 100644 index 4923e6c43..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetNonCurrentTransformType.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetNonCurrentTransformType extends ABIDCallback { - - private ABUnitCallback unit; - private ABIDCallback baseUnitId; - private ABIDCallback alternateUnitId; - - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit u1 = caster; - if (unit != null) { - u1 = unit.callback(game, caster, localStore, castId); - } - War3ID baseId = baseUnitId.callback(game, caster, localStore, castId); - War3ID altId = alternateUnitId.callback(game, caster, localStore, castId); - - if (altId == null || u1.getTypeId().equals(altId)) { - return baseId; - } else { - return altId; - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetParentAlias.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetParentAlias.java deleted file mode 100644 index c4530cb4d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetParentAlias.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetParentAlias extends ABIDCallback { - - @SuppressWarnings("unchecked") - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (War3ID) ((Map)localStore.get(ABLocalStoreKeys.PARENTLOCALSTORE)).get(ABLocalStoreKeys.ALIAS); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetSecondBuffId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetSecondBuffId.java deleted file mode 100644 index 83117eee0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetSecondBuffId.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetSecondBuffId extends ABIDCallback { - - @SuppressWarnings("unchecked") - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - List buffs = ((List) localStore.get(ABLocalStoreKeys.LEVELDATA)) - .get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getBuffs(); - - if (buffs != null && buffs.size()>1) { - return buffs.get(1); - } - return null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetStoredIDByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetStoredIDByKey.java deleted file mode 100644 index 287cbb7ee..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetStoredIDByKey.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredIDByKey extends ABIDCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (War3ID) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (War3ID) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetUnitType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetUnitType.java deleted file mode 100644 index 005bdd14f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetUnitType.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitType extends ABIDCallback { - - private ABUnitCallback unit; - - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (unit == null) { - return caster.getTypeId(); - } - return unit.callback(game, caster, localStore, castId).getTypeId(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetWar3IDFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetWar3IDFromString.java deleted file mode 100644 index 0d3a9f052..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackGetWar3IDFromString.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackGetWar3IDFromString extends ABIDCallback { - - private String id; - - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return War3ID.fromString(this.id); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "'" + this.id + "'"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackNullIfFalse.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackNullIfFalse.java deleted file mode 100644 index 2a7265e5c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABCallbackNullIfFalse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABCallbackNullIfFalse extends ABIDCallback { - - private ABCondition condition; - private ABIDCallback value; - - @Override - public War3ID callback(CSimulation game, CUnit caster, Map localStore, int castId) { - if (condition != null && condition.evaluate(game, caster, localStore, castId)) { - return value.callback(game, caster, localStore, castId); - } - return null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABIDCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABIDCallback.java deleted file mode 100644 index 259c15ddd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/idcallbacks/ABIDCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABIDCallback implements ABCallback { - - @Override - abstract public War3ID callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackAddInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackAddInteger.java deleted file mode 100644 index 1005e084f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackAddInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackAddInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) + value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackAndInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackAndInteger.java deleted file mode 100644 index 31d69a947..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackAndInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackAndInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) & value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackCountUnitsInRangeOfLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackCountUnitsInRangeOfLocation.java deleted file mode 100644 index 70839626b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackCountUnitsInRangeOfLocation.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.ABLocationCallback; - -public class ABCallbackCountUnitsInRangeOfLocation extends ABIntegerCallback { - - private static final Rectangle recycleRect = new Rectangle(); - private ABLocationCallback location; - private ABFloatCallback range; - - private int count = 0; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - AbilityPointTarget origin = location.callback(game, caster, localStore, castId); - Float rangeVal = range.callback(game, caster, localStore, castId); - - recycleRect.set(origin.getX() - rangeVal, origin.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - count = 0; - - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (enumUnit.canReach(origin, rangeVal)) { - count++; - } - return false; - } - }); - return count; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackCountUnitsInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackCountUnitsInRangeOfUnit.java deleted file mode 100644 index 12545a19a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackCountUnitsInRangeOfUnit.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackCountUnitsInRangeOfUnit extends ABIntegerCallback { - - private static final Rectangle recycleRect = new Rectangle(); - private ABUnitCallback unit; - private ABFloatCallback range; - - private int count = 0; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit originUnitTarget = unit.callback(game, caster, localStore, castId); - Float rangeVal = range.callback(game, caster, localStore, castId); - - recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - count = 0; - - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (originUnitTarget.canReach(enumUnit, rangeVal)) { - count++; - } - return false; - } - }); - return count; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackDetectionDropdownConversion.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackDetectionDropdownConversion.java deleted file mode 100644 index e12111478..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackDetectionDropdownConversion.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackDetectionDropdownConversion extends ABIntegerCallback { - - private ABIntegerCallback value; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - int val = value.callback(game, caster, localStore, castId); - switch(val) { - case 1: - return 1; - case 2: - return 2; - case 3: - return 127; - default: - - } - return 0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackDivideInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackDivideInteger.java deleted file mode 100644 index b2fc8bff0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackDivideInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackDivideInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) / value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityCastTimeAsInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityCastTimeAsInteger.java deleted file mode 100644 index f0def5514..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityCastTimeAsInteger.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityCastTimeAsInteger extends ABIntegerCallback { - - - @SuppressWarnings("unchecked") - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - List levelData = (List) localStore.get(ABLocalStoreKeys.LEVELDATA); - return (int) levelData.get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL))-1).getCastTime(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityDataAsInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityDataAsInteger.java deleted file mode 100644 index 26dae3bb3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityDataAsInteger.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityDataAsInteger extends ABIntegerCallback { - - private DataFieldLetter dataField; - - @SuppressWarnings("unchecked") - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - final String data = levelData.get(level - 1).getData().get(this.dataField.getIndex()); - if ("-".equals(data)) { - return 0; - } - return Integer.parseInt(data); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "GetAbilityDataAsIntegerAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" - + this.dataField.name() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityManaCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityManaCost.java deleted file mode 100644 index 6cdffe8ff..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityManaCost.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.ABAbilityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityManaCost extends ABIntegerCallback { - - private ABAbilityCallback ability; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (ability == null) { - AbilityBuilderActiveAbility abil = (AbilityBuilderActiveAbility) localStore.get(ABLocalStoreKeys.ABILITY); - return abil.getChargedManaCost(); - } else { - CAbility abil = ability.callback(game, caster, localStore, castId); - if (abil instanceof AbilityBuilderActiveAbility) { - return ((AbilityBuilderActiveAbility)abil).getChargedManaCost(); - } else { - return 0; - } - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityTargetAttachmentPoints.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityTargetAttachmentPoints.java deleted file mode 100644 index efb543c74..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetAbilityTargetAttachmentPoints.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.ABAbilityCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityTargetAttachmentPoints extends ABIntegerCallback { - - private ABAbilityCallback ability; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (ability == null) { - AbilityBuilderAbility abil = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - return abil.getAbilityIntField("Targetattachcount"); - } else { - CAbility abil = ability.callback(game, caster, localStore, castId); - if (abil instanceof AbilityBuilderAbility) { - return ((AbilityBuilderAbility)abil).getAbilityIntField("Targetattachcount"); - } else { - return 0; - } - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetPlayerId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetPlayerId.java deleted file mode 100644 index 2fce543f3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetPlayerId.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.ABPlayerCallback; - -public class ABCallbackGetPlayerId extends ABIntegerCallback { - - private ABPlayerCallback player; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return player.callback(game, caster, localStore, castId).getId(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetProjectileDestructableTargets.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetProjectileDestructableTargets.java deleted file mode 100644 index 7e872f126..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetProjectileDestructableTargets.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetProjectileDestructableTargets extends ABIntegerCallback { - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Integer) localStore.get(ABLocalStoreKeys.PROJECTILEDESTTARGETS + castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetProjectileUnitTargets.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetProjectileUnitTargets.java deleted file mode 100644 index 0a08e98d2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetProjectileUnitTargets.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetProjectileUnitTargets extends ABIntegerCallback { - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Integer) localStore.get(ABLocalStoreKeys.PROJECTILEUNITTARGETS + castId); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr( - "AB_LOCAL_STORE_KEY_PROJECTILEUNITTARGETS + I2S(" + jassTextGenerator.getCastId() + ")", - JassTextGeneratorType.Integer); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetSpellLevel.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetSpellLevel.java deleted file mode 100644 index a00d3b4e3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetSpellLevel.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetSpellLevel extends ABIntegerCallback { - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetStoredIntegerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetStoredIntegerByKey.java deleted file mode 100644 index b88184ce7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetStoredIntegerByKey.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredIntegerByKey extends ABIntegerCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - return (Integer) localStore.get(ABLocalStoreKeys - .combineUserInstanceKey(this.key.callback(game, caster, localStore, castId), castId)); - } - else { - return (Integer) localStore - .get(ABLocalStoreKeys.combineUserKey(this.key.callback(game, caster, localStore, castId), castId)); - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - if (this.instanceValue == null) { - return "GetLocalStoreUserCastIntegerAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; - } - return "GetStoredIntegerAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitGroupSize.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitGroupSize.java deleted file mode 100644 index 21a301039..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitGroupSize.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks.ABUnitGroupCallback; - -public class ABCallbackGetUnitGroupSize extends ABIntegerCallback { - - private ABUnitGroupCallback group; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return group.callback(game, caster, localStore, castId).size(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitQueueSize.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitQueueSize.java deleted file mode 100644 index ec6381f70..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitQueueSize.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue.ABUnitQueueCallback; - -public class ABCallbackGetUnitQueueSize extends ABIntegerCallback { - - private ABUnitQueueCallback queue; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return queue.callback(game, caster, localStore, castId).size(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeFoodCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeFoodCost.java deleted file mode 100644 index 2d1528b43..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeFoodCost.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; - -public class ABCallbackGetUnitTypeFoodCost extends ABIntegerCallback { - - private ABIDCallback id; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getUnitData().getUnitType(id.callback(game, caster, localStore, castId)).getFoodUsed(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeGoldCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeGoldCost.java deleted file mode 100644 index 4d8bc161a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeGoldCost.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; - -public class ABCallbackGetUnitTypeGoldCost extends ABIntegerCallback { - - private ABIDCallback id; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getUnitData().getUnitType(id.callback(game, caster, localStore, castId)).getGoldCost(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeLumberCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeLumberCost.java deleted file mode 100644 index 0b376e232..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackGetUnitTypeLumberCost.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; - -public class ABCallbackGetUnitTypeLumberCost extends ABIntegerCallback { - - private ABIDCallback id; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getUnitData().getUnitType(id.callback(game, caster, localStore, castId)).getLumberCost(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIntegerIf.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIntegerIf.java deleted file mode 100644 index e80fee070..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIntegerIf.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABCallbackIntegerIf extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - private ABCondition condition; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (condition == null || !condition.evaluate(game, caster, localStore, castId)) { - return value2.callback(game, caster, localStore, castId); - } - return value1.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIntegerZeroIfFalse.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIntegerZeroIfFalse.java deleted file mode 100644 index dc7fe0f22..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIntegerZeroIfFalse.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; - -public class ABCallbackIntegerZeroIfFalse extends ABIntegerCallback { - - private ABIntegerCallback value; - private ABBooleanCallback bool; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (bool == null || !bool.callback(game, caster, localStore, castId)) { - return 0; - } - return value.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIterator.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIterator.java deleted file mode 100644 index b10dce23e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackIterator.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackIterator extends ABIntegerCallback { - - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Integer) localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ITERATORCOUNT, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMaxInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMaxInteger.java deleted file mode 100644 index b6d7b0b74..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMaxInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMaxInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return Math.max(value1.callback(game, caster, localStore, castId), value2.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMinInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMinInteger.java deleted file mode 100644 index 9d989d5a4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMinInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMinInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return Math.min(value1.callback(game, caster, localStore, castId), value2.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMultiplyInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMultiplyInteger.java deleted file mode 100644 index 64a44d306..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackMultiplyInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMultiplyInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) * value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackOrInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackOrInteger.java deleted file mode 100644 index 257e00791..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackOrInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackOrInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) | value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackPlayerToStateModValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackPlayerToStateModValue.java deleted file mode 100644 index 7d3544a6c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackPlayerToStateModValue.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.ABPlayerCallback; - -public class ABCallbackPlayerToStateModValue extends ABIntegerCallback { - - private ABPlayerCallback player; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return 1 << player.callback(game, caster, localStore, castId).getId(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackRawInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackRawInteger.java deleted file mode 100644 index 9dee936e2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackRawInteger.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRawInteger extends ABIntegerCallback { - - private Integer value; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return this.value; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return this.value.toString(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackSubtractInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackSubtractInteger.java deleted file mode 100644 index 842e24db5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABCallbackSubtractInteger.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackSubtractInteger extends ABIntegerCallback { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) - value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABIntegerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABIntegerCallback.java deleted file mode 100644 index 811581c80..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/integercallbacks/ABIntegerCallback.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABIntegerCallback implements ABCallback { - - abstract public Integer callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/item/ABItemCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/item/ABItemCallback.java deleted file mode 100644 index b567a231b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/item/ABItemCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.item; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABItemCallback implements ABCallback { - - abstract public CItem callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAbilityEffectReactionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAbilityEffectReactionListenerCallback.java deleted file mode 100644 index c6777fd61..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAbilityEffectReactionListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityEffectReactionListener; - -public abstract class ABAbilityEffectReactionListenerCallback implements ABCallback { - - abstract public ABAbilityEffectReactionListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAbilityProjReactionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAbilityProjReactionListenerCallback.java deleted file mode 100644 index 2341f58cf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAbilityProjReactionListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityProjReactionListener; - -public abstract class ABAbilityProjReactionListenerCallback implements ABCallback { - - abstract public ABAbilityProjReactionListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackPostDamageListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackPostDamageListenerCallback.java deleted file mode 100644 index 15ba51199..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackPostDamageListenerCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPostDamageListener; - -public abstract class ABAttackPostDamageListenerCallback implements ABCallback { - - abstract public ABAttackPostDamageListener callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackPreDamageListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackPreDamageListenerCallback.java deleted file mode 100644 index 550befd35..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackPreDamageListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPreDamageListener; - -public abstract class ABAttackPreDamageListenerCallback implements ABCallback { - - abstract public ABAttackPreDamageListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackProjReactionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackProjReactionListenerCallback.java deleted file mode 100644 index 3772cd6cf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABAttackProjReactionListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackProjReactionListener; - -public abstract class ABAttackProjReactionListenerCallback implements ABCallback { - - abstract public ABAttackProjReactionListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABBehaviorChangeListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABBehaviorChangeListenerCallback.java deleted file mode 100644 index 571741aa7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABBehaviorChangeListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABBehaviorChangeListener; - -public abstract class ABBehaviorChangeListenerCallback implements ABCallback { - - abstract public ABBehaviorChangeListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAbilityEffectReactionListener.java deleted file mode 100644 index b6aaeab61..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAbilityEffectReactionListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityEffectReactionListener; - -public class ABCallbackGetLastCreatedAbilityEffectReactionListener extends ABAbilityEffectReactionListenerCallback { - - @Override - public ABAbilityEffectReactionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABAbilityEffectReactionListener) localStore.get(ABLocalStoreKeys.LASTCREATEDAbERL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAbilityProjReactionListener.java deleted file mode 100644 index eb3cc3941..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAbilityProjReactionListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityProjReactionListener; - -public class ABCallbackGetLastCreatedAbilityProjReactionListener extends ABAbilityProjReactionListenerCallback { - - @Override - public ABAbilityProjReactionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABAbilityProjReactionListener) localStore.get(ABLocalStoreKeys.LASTCREATEDAbPRL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackPostDamageListener.java deleted file mode 100644 index 449ec50ac..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackPostDamageListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPostDamageListener; - -public class ABCallbackGetLastCreatedAttackPostDamageListener extends ABAttackPostDamageListenerCallback { - - @Override - public ABAttackPostDamageListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABAttackPostDamageListener) localStore.get(ABLocalStoreKeys.LASTCREATEDAPoDL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackPreDamageListener.java deleted file mode 100644 index 0bbfbe256..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackPreDamageListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPreDamageListener; - -public class ABCallbackGetLastCreatedAttackPreDamageListener extends ABAttackPreDamageListenerCallback { - - @Override - public ABAttackPreDamageListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABAttackPreDamageListener) localStore.get(ABLocalStoreKeys.LASTCREATEDAPrDL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackProjReactionListener.java deleted file mode 100644 index d875ca9b2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedAttackProjReactionListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackProjReactionListener; - -public class ABCallbackGetLastCreatedAttackProjReactionListener extends ABAttackProjReactionListenerCallback { - - @Override - public ABAttackProjReactionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABAttackProjReactionListener) localStore.get(ABLocalStoreKeys.LASTCREATEDAtkPRL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedBehaviorChangeListener.java deleted file mode 100644 index 698cd4e6d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedBehaviorChangeListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABBehaviorChangeListener; - -public class ABCallbackGetLastCreatedBehaviorChangeListener extends ABBehaviorChangeListenerCallback { - - @Override - public ABBehaviorChangeListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABBehaviorChangeListener) localStore.get(ABLocalStoreKeys.LASTCREATEDBCL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDamageTakenListener.java deleted file mode 100644 index 539b9e5fb..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDamageTakenListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenListener; - -public class ABCallbackGetLastCreatedDamageTakenListener extends ABDamageTakenListenerCallback { - - @Override - public ABDamageTakenListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABDamageTakenListener) localStore.get(ABLocalStoreKeys.LASTCREATEDDTL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDamageTakenModificationListener.java deleted file mode 100644 index 564cc16e4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDamageTakenModificationListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenModificationListener; - -public class ABCallbackGetLastCreatedDamageTakenModificationListener extends ABDamageTakenModificationListenerCallback { - - @Override - public ABDamageTakenModificationListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABDamageTakenModificationListener) localStore.get(ABLocalStoreKeys.LASTCREATEDDTML); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDeathReplacement.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDeathReplacement.java deleted file mode 100644 index 23393ef16..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedDeathReplacement.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDeathReplacementEffect; - -public class ABCallbackGetLastCreatedDeathReplacement extends ABDeathReplacementCallback { - - @Override - public ABDeathReplacementEffect callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABDeathReplacementEffect) localStore.get(ABLocalStoreKeys.LASTCREATEDDRE); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedEvasionListener.java deleted file mode 100644 index 7746e2de3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedEvasionListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackEvasionListener; - -public class ABCallbackGetLastCreatedEvasionListener extends ABEvasionListenerCallback { - - @Override - public ABAttackEvasionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABAttackEvasionListener) localStore.get(ABLocalStoreKeys.LASTCREATEDAEL); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedFinalDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedFinalDamageTakenModificationListener.java deleted file mode 100644 index 9e2c0d03f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetLastCreatedFinalDamageTakenModificationListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABFinalDamageTakenModificationListener; - -public class ABCallbackGetLastCreatedFinalDamageTakenModificationListener extends ABFinalDamageTakenModificationListenerCallback { - - @Override - public ABFinalDamageTakenModificationListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (ABFinalDamageTakenModificationListener) localStore.get(ABLocalStoreKeys.LASTCREATEDFDTML); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAbilityEffectReactionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAbilityEffectReactionListenerByKey.java deleted file mode 100644 index 1a70f4144..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAbilityEffectReactionListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityEffectReactionListener; - -public class ABCallbackGetStoredAbilityEffectReactionListenerByKey extends ABAbilityEffectReactionListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABAbilityEffectReactionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABAbilityEffectReactionListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABAbilityEffectReactionListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAbilityProjReactionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAbilityProjReactionListenerByKey.java deleted file mode 100644 index cbe863e1d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAbilityProjReactionListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAbilityProjReactionListener; - -public class ABCallbackGetStoredAbilityProjReactionListenerByKey extends ABAbilityProjReactionListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABAbilityProjReactionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABAbilityProjReactionListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABAbilityProjReactionListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackPostDamageListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackPostDamageListenerByKey.java deleted file mode 100644 index b04bf19c5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackPostDamageListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPostDamageListener; - -public class ABCallbackGetStoredAttackPostDamageListenerByKey extends ABAttackPostDamageListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABAttackPostDamageListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABAttackPostDamageListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABAttackPostDamageListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackPreDamageListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackPreDamageListenerByKey.java deleted file mode 100644 index 0042162bc..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackPreDamageListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackPreDamageListener; - -public class ABCallbackGetStoredAttackPreDamageListenerByKey extends ABAttackPreDamageListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABAttackPreDamageListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABAttackPreDamageListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABAttackPreDamageListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackProjReactionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackProjReactionListenerByKey.java deleted file mode 100644 index 04b5862b0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredAttackProjReactionListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackProjReactionListener; - -public class ABCallbackGetStoredAttackProjReactionListenerByKey extends ABAttackProjReactionListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABAttackProjReactionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABAttackProjReactionListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABAttackProjReactionListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredBehaviorChangeListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredBehaviorChangeListenerByKey.java deleted file mode 100644 index bc4671755..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredBehaviorChangeListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABBehaviorChangeListener; - -public class ABCallbackGetStoredBehaviorChangeListenerByKey extends ABBehaviorChangeListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABBehaviorChangeListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABBehaviorChangeListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABBehaviorChangeListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDamageTakenListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDamageTakenListenerByKey.java deleted file mode 100644 index d0a8ef3b7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDamageTakenListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenListener; - -public class ABCallbackGetStoredDamageTakenListenerByKey extends ABDamageTakenListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABDamageTakenListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABDamageTakenListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABDamageTakenListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDamageTakenModificationListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDamageTakenModificationListenerByKey.java deleted file mode 100644 index 76603a934..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDamageTakenModificationListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenModificationListener; - -public class ABCallbackGetStoredDamageTakenModificationListenerByKey extends ABDamageTakenModificationListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABDamageTakenModificationListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABDamageTakenModificationListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABDamageTakenModificationListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDeathReplacementByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDeathReplacementByKey.java deleted file mode 100644 index d07f4db26..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredDeathReplacementByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDeathReplacementEffect; - -public class ABCallbackGetStoredDeathReplacementByKey extends ABDeathReplacementCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABDeathReplacementEffect callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABDeathReplacementEffect) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABDeathReplacementEffect) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredEvasionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredEvasionListenerByKey.java deleted file mode 100644 index 9bb07e8dd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredEvasionListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackEvasionListener; - -public class ABCallbackGetStoredEvasionListenerByKey extends ABEvasionListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABAttackEvasionListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABAttackEvasionListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABAttackEvasionListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredFinalDamageTakenModificationListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredFinalDamageTakenModificationListenerByKey.java deleted file mode 100644 index 731f503f3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABCallbackGetStoredFinalDamageTakenModificationListenerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABFinalDamageTakenModificationListener; - -public class ABCallbackGetStoredFinalDamageTakenModificationListenerByKey extends ABFinalDamageTakenModificationListenerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public ABFinalDamageTakenModificationListener callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (ABFinalDamageTakenModificationListener) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (ABFinalDamageTakenModificationListener) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDamageTakenListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDamageTakenListenerCallback.java deleted file mode 100644 index 233cef036..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDamageTakenListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenListener; - -public abstract class ABDamageTakenListenerCallback implements ABCallback { - - abstract public ABDamageTakenListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDamageTakenModificationListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDamageTakenModificationListenerCallback.java deleted file mode 100644 index 66b56ffed..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDamageTakenModificationListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDamageTakenModificationListener; - -public abstract class ABDamageTakenModificationListenerCallback implements ABCallback { - - abstract public ABDamageTakenModificationListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDeathReplacementCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDeathReplacementCallback.java deleted file mode 100644 index 5dbc7fdd1..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABDeathReplacementCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABDeathReplacementEffect; - -public abstract class ABDeathReplacementCallback implements ABCallback { - - abstract public ABDeathReplacementEffect callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABEvasionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABEvasionListenerCallback.java deleted file mode 100644 index 67aa1791c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABEvasionListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABAttackEvasionListener; - -public abstract class ABEvasionListenerCallback implements ABCallback { - - abstract public ABAttackEvasionListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABFinalDamageTakenModificationListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABFinalDamageTakenModificationListenerCallback.java deleted file mode 100644 index 404c61373..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/listenercallbacks/ABFinalDamageTakenModificationListenerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener.ABFinalDamageTakenModificationListener; - -public abstract class ABFinalDamageTakenModificationListenerCallback implements ABCallback { - - abstract public ABFinalDamageTakenModificationListener callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromOffset.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromOffset.java deleted file mode 100644 index d77bed263..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromOffset.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; - -public class ABCallbackCreateLocationFromOffset extends ABLocationCallback { - - private ABLocationCallback origin; - private ABFloatCallback dist; - private ABFloatCallback angle; - - @Override - public AbilityPointTarget callback(CSimulation game, CUnit caster, Map localStore, - final int castId) { - final AbilityPointTarget orig = this.origin.callback(game, caster, localStore, castId); - final float d = this.dist.callback(game, caster, localStore, castId); - final float a = this.angle.callback(game, caster, localStore, castId); - - return new AbilityPointTarget((float) (orig.x + (d * Math.cos(a))), (float) (orig.y + (d * Math.sin(a)))); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "PolarProjectionAU(" + this.origin.generateJassEquivalent(jassTextGenerator) + ", " - + this.dist.generateJassEquivalent(jassTextGenerator) + ", " - + this.angle.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromTarget.java deleted file mode 100644 index e49edabb0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromTarget.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.targetcallbacks.ABTargetCallback; - -public class ABCallbackCreateLocationFromTarget extends ABLocationCallback { - - private ABTargetCallback target; - - @Override - public AbilityPointTarget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - AbilityTarget tar = target.callback(game, caster, localStore, castId); - return new AbilityPointTarget(tar.getX(), tar.getY()); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromXY.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromXY.java deleted file mode 100644 index ff77068b7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackCreateLocationFromXY.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; - -public class ABCallbackCreateLocationFromXY extends ABLocationCallback { - - private ABFloatCallback x; - private ABFloatCallback y; - - @Override - public AbilityPointTarget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return new AbilityPointTarget(x.callback(game, caster, localStore, castId), y.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetProjectileCurrentLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetProjectileCurrentLocation.java deleted file mode 100644 index ba8dbfdda..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetProjectileCurrentLocation.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetProjectileCurrentLocation extends ABLocationCallback { - - @Override - public AbilityPointTarget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (AbilityPointTarget) localStore.get(ABLocalStoreKeys.PROJECTILECURRENTLOC+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetStoredLocationByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetStoredLocationByKey.java deleted file mode 100644 index e2f06504d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetStoredLocationByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredLocationByKey extends ABLocationCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public AbilityPointTarget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (AbilityPointTarget) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (AbilityPointTarget) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetTargetedLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetTargetedLocation.java deleted file mode 100644 index b706e6b8b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetTargetedLocation.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetTargetedLocation extends ABLocationCallback { - - @Override - public AbilityPointTarget callback(CSimulation game, CUnit caster, Map localStore, - final int castId) { - final AbilityPointTarget target = (AbilityPointTarget) localStore - .get(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + castId); - - return target; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr( - "AB_LOCAL_STORE_KEY_ABILITYTARGETEDLOCATION + I2S(" + jassTextGenerator.getCastId() + ")", - JassTextGeneratorType.LocationHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetUnitLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetUnitLocation.java deleted file mode 100644 index 678173251..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABCallbackGetUnitLocation.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitLocation extends ABLocationCallback { - - private ABUnitCallback unit; - - @Override - public AbilityPointTarget callback(CSimulation game, CUnit caster, Map localStore, - final int castId) { - final CUnit theUnit = this.unit.callback(game, caster, localStore, castId); - - return new AbilityPointTarget(theUnit.getX(), theUnit.getY()); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GetUnitLoc(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABLocationCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABLocationCallback.java deleted file mode 100644 index 35b659e7a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/locationcallbacks/ABLocationCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABLocationCallback implements ABCallback { - - abstract public AbilityPointTarget callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackAddLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackAddLong.java deleted file mode 100644 index 18510ad67..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackAddLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackAddLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) + value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackAndLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackAndLong.java deleted file mode 100644 index 6174f7386..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackAndLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackAndLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) & value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackCreateDetectedData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackCreateDetectedData.java deleted file mode 100644 index 961b465dd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackCreateDetectedData.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; - -public class ABCallbackCreateDetectedData extends ABLongCallback { - - private ABIntegerCallback detectionLevel; - private ABIntegerCallback player; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - long ply = player.callback(game, caster, localStore, castId); - byte val = detectionLevel.callback(game, caster, localStore, castId).byteValue(); - return val + (ply<<8); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackCreateDetectorData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackCreateDetectorData.java deleted file mode 100644 index 2d0d043d8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackCreateDetectorData.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; - -public class ABCallbackCreateDetectorData extends ABLongCallback { - - private ABIntegerCallback detectionLevel; - private ABFloatCallback range; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - long rng = Math.min(PathingGrid.getFogOfWarDistance(range.callback(game, caster, localStore, castId)), 8388607); - byte val = detectionLevel.callback(game, caster, localStore, castId).byteValue(); - return val + (rng<<8); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackDivideLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackDivideLong.java deleted file mode 100644 index 6c946c99b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackDivideLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackDivideLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) / value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackGetStoredLongByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackGetStoredLongByKey.java deleted file mode 100644 index 7f7477a9a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackGetStoredLongByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredLongByKey extends ABLongCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (Long) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (Long) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMaxLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMaxLong.java deleted file mode 100644 index 5be9dd0c8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMaxLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMaxLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return Math.max(value1.callback(game, caster, localStore, castId), value2.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMinLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMinLong.java deleted file mode 100644 index 009fe226d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMinLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMinLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return Math.min(value1.callback(game, caster, localStore, castId), value2.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMultiplyLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMultiplyLong.java deleted file mode 100644 index 8604b2ecf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackMultiplyLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackMultiplyLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) * value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackOrLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackOrLong.java deleted file mode 100644 index ed810c446..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackOrLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackOrLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) | value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackRawLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackRawLong.java deleted file mode 100644 index 0f05dde2f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackRawLong.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRawLong extends ABLongCallback { - - private Long value; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackSubtractLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackSubtractLong.java deleted file mode 100644 index 5ac646476..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABCallbackSubtractLong.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackSubtractLong extends ABLongCallback { - - private ABLongCallback value1; - private ABLongCallback value2; - - @Override - public Long callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value1.callback(game, caster, localStore, castId) - value2.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABLongCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABLongCallback.java deleted file mode 100644 index 18f86344e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/longcallbacks/ABLongCallback.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABLongCallback implements ABCallback { - - abstract public Long callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABCallbackIdString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABCallbackIdString.java deleted file mode 100644 index 77f06d56d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABCallbackIdString.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.orderid; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; - -public class ABCallbackIdString extends ABOrderIdCallback { - - private ABStringCallback idString; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return OrderIdUtils.getOrderId(idString.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABCallbackRawID.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABCallbackRawID.java deleted file mode 100644 index 049bac028..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABCallbackRawID.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.orderid; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRawID extends ABOrderIdCallback { - - private Integer id; - - @Override - public Integer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return id; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABOrderIdCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABOrderIdCallback.java deleted file mode 100644 index d7a51dc33..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/orderid/ABOrderIdCallback.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.orderid; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABOrderIdCallback implements ABCallback { - - abstract public Integer callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetOwnerOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetOwnerOfUnit.java deleted file mode 100644 index e51234389..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetOwnerOfUnit.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; - -public class ABCallbackGetOwnerOfUnit extends ABPlayerCallback { - - private ABUnitCallback unit; - - @Override - public CPlayer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getPlayer(unit.callback(game, caster, localStore, castId).getPlayerIndex()); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetPlayerById.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetPlayerById.java deleted file mode 100644 index c9ac77f5d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetPlayerById.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; - -public class ABCallbackGetPlayerById extends ABPlayerCallback { - - private ABIntegerCallback id; - - @Override - public CPlayer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getPlayer(id.callback(game, caster, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetStoredPlayerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetStoredPlayerByKey.java deleted file mode 100644 index 5f1f7b035..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABCallbackGetStoredPlayerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; - -public class ABCallbackGetStoredPlayerByKey extends ABPlayerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CPlayer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (CPlayer) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (CPlayer) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABPlayerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABPlayerCallback.java deleted file mode 100644 index a21eaf731..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/player/ABPlayerCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; - -public abstract class ABPlayerCallback implements ABCallback { - - abstract public CPlayer callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetLastCreatedProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetLastCreatedProjectile.java deleted file mode 100644 index 5df29d48b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetLastCreatedProjectile.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABCallbackGetLastCreatedProjectile extends ABProjectileCallback { - - @Override - public CProjectile callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CProjectile) localStore.get(ABLocalStoreKeys.LASTCREATEDPROJECTILE); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetReactionAbilityProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetReactionAbilityProjectile.java deleted file mode 100644 index 876450ead..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetReactionAbilityProjectile.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABCallbackGetReactionAbilityProjectile extends ABProjectileCallback { - - @Override - public CProjectile callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return (CProjectile) localStore.get(ABLocalStoreKeys.ABILITYPROJ); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITYPROJ", JassTextGeneratorType.ProjectileHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetReactionAttackProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetReactionAttackProjectile.java deleted file mode 100644 index 541370e83..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetReactionAttackProjectile.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABCallbackGetReactionAttackProjectile extends ABProjectileCallback { - - @Override - public CProjectile callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CProjectile) localStore.get(ABLocalStoreKeys.ATTACKPROJ+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetStoredProjectileByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetStoredProjectileByKey.java deleted file mode 100644 index 26aa50e8e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetStoredProjectileByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABCallbackGetStoredProjectileByKey extends ABProjectileCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CProjectile callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (CProjectile) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (CProjectile) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetThisProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetThisProjectile.java deleted file mode 100644 index edeee3449..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABCallbackGetThisProjectile.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABCallbackGetThisProjectile extends ABProjectileCallback { - - @Override - public CProjectile callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CProjectile) localStore.get(ABLocalStoreKeys.THISPROJECTILE); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABProjectileCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABProjectileCallback.java deleted file mode 100644 index 7dccb4446..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/projectile/ABProjectileCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public abstract class ABProjectileCallback implements ABCallback { - - abstract public CProjectile callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABCallbackGetLastCreatedNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABCallbackGetLastCreatedNonStackingStatBuff.java deleted file mode 100644 index 7fa3ef4d5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABCallbackGetLastCreatedNonStackingStatBuff.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statbuffcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; - -public class ABCallbackGetLastCreatedNonStackingStatBuff extends ABNonStackingStatBuffCallback { - - @Override - public NonStackingStatBuff callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId) { - return (NonStackingStatBuff) localStore.get(ABLocalStoreKeys.LASTCREATEDNSSB); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDNSSB", - JassTextGeneratorType.NonStackingStatBuffHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABCallbackGetStoredNonStackingStatBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABCallbackGetStoredNonStackingStatBuffByKey.java deleted file mode 100644 index df546501d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABCallbackGetStoredNonStackingStatBuffByKey.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statbuffcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; - -public class ABCallbackGetStoredNonStackingStatBuffByKey extends ABNonStackingStatBuffCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public NonStackingStatBuff callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId) { - if ((this.instanceValue == null) || this.instanceValue.callback(game, caster, localStore, castId)) { - return (NonStackingStatBuff) localStore.get(ABLocalStoreKeys - .combineUserInstanceKey(this.key.callback(game, caster, localStore, castId), castId)); - } - else { - return (NonStackingStatBuff) localStore - .get(ABLocalStoreKeys.combineUserKey(this.key.callback(game, caster, localStore, castId), castId)); - } - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - if (this.instanceValue == null) { - return "GetLocalStoreUserCastNonStackingStatBuffHandleAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; - } - return "GetStoredNonStackingStatBuffAU(" + jassTextGenerator.getTriggerLocalStore() + ", " - + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " - + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABNonStackingStatBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABNonStackingStatBuffCallback.java deleted file mode 100644 index 42207d5f0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statbuffcallbacks/ABNonStackingStatBuffCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statbuffcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; - -public abstract class ABNonStackingStatBuffCallback implements ABCallback { - - abstract public NonStackingStatBuff callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABCallbackGetLastCreatedStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABCallbackGetLastCreatedStateModBuff.java deleted file mode 100644 index a11b56e44..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABCallbackGetLastCreatedStateModBuff.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statemodcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; - -public class ABCallbackGetLastCreatedStateModBuff extends ABStateModBuffCallback { - - @Override - public StateModBuff callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (StateModBuff) localStore.get(ABLocalStoreKeys.LASTCREATEDSMB); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABCallbackGetStoredStateModBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABCallbackGetStoredStateModBuffByKey.java deleted file mode 100644 index aedb869b0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABCallbackGetStoredStateModBuffByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statemodcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; - -public class ABCallbackGetStoredStateModBuffByKey extends ABStateModBuffCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public StateModBuff callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (StateModBuff) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (StateModBuff) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABStateModBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABStateModBuffCallback.java deleted file mode 100644 index 9d1a26861..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/statemodcallbacks/ABStateModBuffCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statemodcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; - -public abstract class ABStateModBuffCallback implements ABCallback { - - abstract public StateModBuff callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackBooleanToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackBooleanToString.java deleted file mode 100644 index 661820ecc..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackBooleanToString.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; - -public class ABCallbackBooleanToString extends ABStringCallback { - - private ABBooleanCallback value; - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return "" + value.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackCatStrings.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackCatStrings.java deleted file mode 100644 index 1f9fe6f1f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackCatStrings.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackCatStrings extends ABStringCallback { - - private List stringList; - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - String output = ""; - for (ABStringCallback callB : stringList) { - output += callB.callback(game, caster, localStore, castId); - } - return output; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackFloatToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackFloatToString.java deleted file mode 100644 index 6ee69ebba..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackFloatToString.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; - -public class ABCallbackFloatToString extends ABStringCallback { - - private ABFloatCallback value; - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return "" + value.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAbilityDataAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAbilityDataAsString.java deleted file mode 100644 index b474a939c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAbilityDataAsString.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; - -public class ABCallbackGetAbilityDataAsString extends ABStringCallback { - - private DataFieldLetter dataField; - - @SuppressWarnings("unchecked") - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - List levelData = (List) localStore.get(ABLocalStoreKeys.LEVELDATA); - int level = (int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL); - - return levelData.get(level-1).getData().get(dataField.getIndex()); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAliasAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAliasAsString.java deleted file mode 100644 index afdd0361f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAliasAsString.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAliasAsString extends ABStringCallback { - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return ((War3ID) localStore.get(ABLocalStoreKeys.ALIAS)).asStringValue(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAllowStackingKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAllowStackingKey.java deleted file mode 100644 index 58a198f7d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetAllowStackingKey.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; - -public class ABCallbackGetAllowStackingKey extends ABStringCallback { - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return NonStackingStatBuff.ALLOW_STACKING_KEY; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "\"" + NonStackingStatBuff.ALLOW_STACKING_KEY + "\""; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetCodeAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetCodeAsString.java deleted file mode 100644 index 174cff4ce..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetCodeAsString.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetCodeAsString extends ABStringCallback { - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return ((War3ID) localStore.get(ABLocalStoreKeys.CODE)).asStringValue(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetUnitHandleAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetUnitHandleAsString.java deleted file mode 100644 index 48c913677..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackGetUnitHandleAsString.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackGetUnitHandleAsString extends ABStringCallback { - - private ABUnitCallback unit; - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return "" + unit.callback(game, caster, localStore, castId).getHandleId(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackIntegerToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackIntegerToString.java deleted file mode 100644 index 6ce1460df..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackIntegerToString.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; - -public class ABCallbackIntegerToString extends ABStringCallback { - - private ABIntegerCallback value; - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return "" + value.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackLongToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackLongToString.java deleted file mode 100644 index 04045f616..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackLongToString.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks.ABLongCallback; - -public class ABCallbackLongToString extends ABStringCallback { - - private ABLongCallback value; - - @Override - public String callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return "" + value.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackRawString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackRawString.java deleted file mode 100644 index 00674b646..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABCallbackRawString.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackRawString extends ABStringCallback { - - private String value; - - @Override - public String callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return this.value; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return "\"" + this.value + "\""; - } - - public String getValue() { - return this.value; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABStringCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABStringCallback.java deleted file mode 100644 index 614507c7b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/stringcallbacks/ABStringCallback.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABStringCallback implements ABCallback { - - abstract public String callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABCallbackGetAbilityTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABCallbackGetAbilityTarget.java deleted file mode 100644 index 354995a26..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABCallbackGetAbilityTarget.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.targetcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityTarget extends ABTargetCallback { - - @Override - public AbilityTarget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - AbilityPointTarget target = (AbilityPointTarget) localStore.get(ABLocalStoreKeys.ABILITYTARGETEDLOCATION+castId); - if (target != null) { - return target; - } - CUnit taru = (CUnit) localStore.get(ABLocalStoreKeys.ABILITYTARGETEDUNIT+castId); - if (taru != null) { - return taru; - } - return null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABCallbackGetStoredTargetByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABCallbackGetStoredTargetByKey.java deleted file mode 100644 index 154070a76..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABCallbackGetStoredTargetByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.targetcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredTargetByKey extends ABTargetCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public AbilityTarget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (AbilityTarget) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (AbilityTarget) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABTargetCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABTargetCallback.java deleted file mode 100644 index 968b074f4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/targetcallbacks/ABTargetCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.targetcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABTargetCallback implements ABCallback { - - abstract public AbilityTarget callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetFiringTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetFiringTimer.java deleted file mode 100644 index 0b7931ede..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetFiringTimer.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABCallbackGetFiringTimer extends ABTimerCallback { - - @Override - public CTimer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CTimer) localStore.get(ABLocalStoreKeys.FIRINGTIMER); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetLastCreatedTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetLastCreatedTimer.java deleted file mode 100644 index 00541eed3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetLastCreatedTimer.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABCallbackGetLastCreatedTimer extends ABTimerCallback { - - @Override - public CTimer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CTimer) localStore.get(ABLocalStoreKeys.LASTCREATEDTIMER); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetLastStartedTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetLastStartedTimer.java deleted file mode 100644 index 244e3366b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetLastStartedTimer.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABCallbackGetLastStartedTimer extends ABTimerCallback { - - @Override - public CTimer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CTimer) localStore.get(ABLocalStoreKeys.LASTSTARTEDTIMER); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetStoredTimerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetStoredTimerByKey.java deleted file mode 100644 index 916e02c01..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABCallbackGetStoredTimerByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABCallbackGetStoredTimerByKey extends ABTimerCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CTimer callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (CTimer) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (CTimer) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABTimerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABTimerCallback.java deleted file mode 100644 index 95b3cccc7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/timercallbacks/ABTimerCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public abstract class ABTimerCallback implements ABCallback { - - abstract public CTimer callback(final CSimulation game, final CUnit caster, - final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAbilityPairedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAbilityPairedUnit.java deleted file mode 100644 index a0e8bbd0f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAbilityPairedUnit.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityPairedUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.ABILITYPAIREDUNIT + castId); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr( - "AB_LOCAL_STORE_KEY_ABILITYPAIREDUNIT + I2S(" + jassTextGenerator.getCastId() + ")", - JassTextGeneratorType.UnitHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAbilityTargetedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAbilityTargetedUnit.java deleted file mode 100644 index 71b20ef4d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAbilityTargetedUnit.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAbilityTargetedUnit extends ABUnitCallback { - - @Override - public CUnit callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.ABILITYTARGETEDUNIT + castId); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr( - "AB_LOCAL_STORE_KEY_ABILITYTARGETEDUNIT + I2S(" + jassTextGenerator.getCastId() + ")", - JassTextGeneratorType.UnitHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAttackedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAttackedUnit.java deleted file mode 100644 index 2957ad0e9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAttackedUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAttackedUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.ATTACKEDUNIT+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAttackingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAttackingUnit.java deleted file mode 100644 index 81b28bbf3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetAttackingUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetAttackingUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.ATTACKINGUNIT+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetBuffCastingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetBuffCastingUnit.java deleted file mode 100644 index e3857278c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetBuffCastingUnit.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetBuffCastingUnit extends ABUnitCallback { - - @Override - public CUnit callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.BUFFCASTINGUNIT); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_BUFFCASTINGUNIT", JassTextGeneratorType.UnitHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetBuffedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetBuffedUnit.java deleted file mode 100644 index 7f342b8a9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetBuffedUnit.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackGetBuffedUnit extends ABUnitCallback { - - @Override - public CUnit callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return caster; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getCaster(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetCastingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetCastingUnit.java deleted file mode 100644 index 87035ccb0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetCastingUnit.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackGetCastingUnit extends ABUnitCallback { - - @Override - public CUnit callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return caster; - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getCaster(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetDyingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetDyingUnit.java deleted file mode 100644 index c87723587..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetDyingUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetDyingUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.DYINGUNIT+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetEnumUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetEnumUnit.java deleted file mode 100644 index 03a1a026e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetEnumUnit.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetEnumUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.ENUMUNIT + castId); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr( - "AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + ")", - JassTextGeneratorType.UnitHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetKillingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetKillingUnit.java deleted file mode 100644 index 8501afd15..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetKillingUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetKillingUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.KILLINGUNIT+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetLastCreatedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetLastCreatedUnit.java deleted file mode 100644 index a79ff3718..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetLastCreatedUnit.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetLastCreatedUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.LASTCREATEDUNIT); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDUNIT", - JassTextGeneratorType.UnitHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetListenerUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetListenerUnit.java deleted file mode 100644 index 0bef7734d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetListenerUnit.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackGetListenerUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return caster; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetMatchingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetMatchingUnit.java deleted file mode 100644 index c3ec53a62..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetMatchingUnit.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetMatchingUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.MATCHINGUNIT + castId); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr( - "AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + ")", - JassTextGeneratorType.UnitHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetNearestCorpseInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetNearestCorpseInRangeOfUnit.java deleted file mode 100644 index 2095c2734..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetNearestCorpseInRangeOfUnit.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.iterstructs.UnitAndRange; - -public class ABCallbackGetNearestCorpseInRangeOfUnit extends ABUnitCallback { - private static final Rectangle recycleRect = new Rectangle(); - - private ABUnitCallback originUnit; - private ABFloatCallback range; - private List conditions; - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit originUnitTarget = originUnit.callback(game, caster, localStore, castId); - Float rangeVal = range.callback(game, caster, localStore, castId); - - final UnitAndRange ur = new UnitAndRange(); - - recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - game.getWorldCollision().enumCorpsesInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (originUnitTarget.canReach(enumUnit, rangeVal)) { - double dist = originUnitTarget.distance(enumUnit); - if (ur.getUnit() == null || ur.getRange() > dist) { - if (conditions != null) { - boolean result = true; - localStore.put(ABLocalStoreKeys.MATCHINGUNIT+castId, enumUnit); - for (ABCondition condition : conditions) { - result = result && condition.evaluate(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.MATCHINGUNIT+castId); - if (result) { - ur.setRange(dist); - ur.setUnit(enumUnit); - } - } else { - ur.setRange(dist); - ur.setUnit(enumUnit); - } - } - } - return false; - } - }); - return ur.getUnit(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetNearestUnitInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetNearestUnitInRangeOfUnit.java deleted file mode 100644 index 8b5b1bb5e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetNearestUnitInRangeOfUnit.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.iterstructs.UnitAndRange; - -public class ABCallbackGetNearestUnitInRangeOfUnit extends ABUnitCallback { - private static final Rectangle recycleRect = new Rectangle(); - - private ABUnitCallback originUnit; - private ABFloatCallback range; - private List conditions; - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit originUnitTarget = originUnit.callback(game, caster, localStore, castId); - Float rangeVal = range.callback(game, caster, localStore, castId); - - final UnitAndRange ur = new UnitAndRange(); - - recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (originUnitTarget.canReach(enumUnit, rangeVal)) { - double dist = originUnitTarget.distance(enumUnit); - if (ur.getUnit() == null || ur.getRange() > dist) { - if (conditions != null) { - boolean result = true; - localStore.put(ABLocalStoreKeys.MATCHINGUNIT+castId, enumUnit); - for (ABCondition condition : conditions) { - result = result && condition.evaluate(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.MATCHINGUNIT+castId); - if (result) { - ur.setRange(dist); - ur.setUnit(enumUnit); - } - } else { - ur.setRange(dist); - ur.setUnit(enumUnit); - } - } - } - return false; - } - }); - return ur.getUnit(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetParentCastingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetParentCastingUnit.java deleted file mode 100644 index 58bd70516..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetParentCastingUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetParentCastingUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.PARENTCASTER); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetProjectileHitUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetProjectileHitUnit.java deleted file mode 100644 index bc0fed690..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetProjectileHitUnit.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetProjectileHitUnit extends ABUnitCallback { - - @Override - public CUnit callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.PROJECTILEHITUNIT + castId); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return jassTextGenerator.getUserDataExpr( - "AB_LOCAL_STORE_KEY_PROJECTILEHITUNIT + I2S(" + jassTextGenerator.getCastId() + ")", - JassTextGeneratorType.UnitHandle); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetReactionAbilityCastingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetReactionAbilityCastingUnit.java deleted file mode 100644 index f0e8a627e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetReactionAbilityCastingUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetReactionAbilityCastingUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CUnit) localStore.get(ABLocalStoreKeys.REACTIONABILITYCASTER+castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetReactionAbilityTargetUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetReactionAbilityTargetUnit.java deleted file mode 100644 index fa2991a10..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetReactionAbilityTargetUnit.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetReactionAbilityTargetUnit extends ABUnitCallback { - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - AbilityTarget tar = (AbilityTarget) localStore.get(ABLocalStoreKeys.REACTIONABILITYCASTER+castId); - return tar.visit(AbilityTargetVisitor.UNIT); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetStoredUnitByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetStoredUnitByKey.java deleted file mode 100644 index eeabe0d24..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackGetStoredUnitByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetStoredUnitByKey extends ABUnitCallback { - - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (CUnit) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (CUnit) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackPollUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackPollUnitQueue.java deleted file mode 100644 index b2c793ae8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABCallbackPollUnitQueue.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue.ABUnitQueueCallback; - -public class ABCallbackPollUnitQueue extends ABUnitCallback { - - private ABUnitQueueCallback queue; - - @Override - public CUnit callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return queue.callback(game, caster, localStore, castId).poll(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABUnitCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABUnitCallback.java deleted file mode 100644 index d50c3026b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitcallbacks/ABUnitCallback.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABUnitCallback implements ABCallback { - - @Override - abstract public CUnit callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABCallbackGetLastCreatedUnitGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABCallbackGetLastCreatedUnitGroup.java deleted file mode 100644 index 7af08a948..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABCallbackGetLastCreatedUnitGroup.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks; - -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetLastCreatedUnitGroup extends ABUnitGroupCallback { - - @SuppressWarnings("unchecked") - @Override - public Set callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Set) localStore.get(ABLocalStoreKeys.LASTCREATEDUNITGROUP); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABCallbackGetUnitGroupByName.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABCallbackGetUnitGroupByName.java deleted file mode 100644 index 07082ce51..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABCallbackGetUnitGroupByName.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks; - -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackGetUnitGroupByName extends ABUnitGroupCallback { - - private String name; - - @SuppressWarnings("unchecked") - @Override - public Set callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Set) localStore.get("_unitgroup_" + name); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABUnitGroupCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABUnitGroupCallback.java deleted file mode 100644 index 3d5a52c09..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitgroupcallbacks/ABUnitGroupCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks; - -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABUnitGroupCallback implements ABCallback { - - abstract public Set callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABCallbackGetLastCreatedUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABCallbackGetLastCreatedUnitQueue.java deleted file mode 100644 index a8078748b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABCallbackGetLastCreatedUnitQueue.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue; - -import java.util.Map; -import java.util.Queue; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetLastCreatedUnitQueue extends ABUnitQueueCallback { - - @SuppressWarnings("unchecked") - @Override - public Queue callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Queue) localStore.get(ABLocalStoreKeys.LASTCREATEDUNITQUEUE); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABCallbackGetUnitQueueByName.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABCallbackGetUnitQueueByName.java deleted file mode 100644 index 62c6c9d6e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABCallbackGetUnitQueueByName.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue; - -import java.util.Map; -import java.util.Queue; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABCallbackGetUnitQueueByName extends ABUnitQueueCallback { - - private String name; - - @SuppressWarnings("unchecked") - @Override - public Queue callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (Queue) localStore.get("_unitqueue_" + name); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABUnitQueueCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABUnitQueueCallback.java deleted file mode 100644 index f4d4bf160..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/unitqueue/ABUnitQueueCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue; - -import java.util.Map; -import java.util.Queue; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABUnitQueueCallback implements ABCallback { - - abstract public Queue callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABCallbackGetLastCreatedVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABCallbackGetLastCreatedVisionModifier.java deleted file mode 100644 index afe7382e3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABCallbackGetLastCreatedVisionModifier.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.visionmodifier; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; - -public class ABCallbackGetLastCreatedVisionModifier extends ABVisionModifierCallback { - - @Override - public CFogModifier callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (CFogModifier) localStore.get(ABLocalStoreKeys.LASTCREATEDVISIONMODIFIER); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABCallbackGetStoredVisionModifierByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABCallbackGetStoredVisionModifierByKey.java deleted file mode 100644 index 9081a659c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABCallbackGetStoredVisionModifierByKey.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.visionmodifier; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.ABStringCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; - -public class ABCallbackGetStoredVisionModifierByKey extends ABVisionModifierCallback { - private ABStringCallback key; - private ABBooleanCallback instanceValue; - - @Override - public CFogModifier callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (instanceValue == null || instanceValue.callback(game, caster, localStore, castId)) { - return (CFogModifier) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(game, caster, localStore, castId), castId)); - } else { - return (CFogModifier) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(game, caster, localStore, castId), castId)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABVisionModifierCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABVisionModifierCallback.java deleted file mode 100644 index 91a794b60..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/visionmodifier/ABVisionModifierCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.visionmodifier; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; - -public abstract class ABVisionModifierCallback implements ABCallback { - - abstract public CFogModifier callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABCallbackGetProjectileHitWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABCallbackGetProjectileHitWidget.java deleted file mode 100644 index e96931a59..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABCallbackGetProjectileHitWidget.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.widget; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABCallbackGetProjectileHitWidget extends ABWidgetCallback { - - @Override - public CWidget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CWidget unit = (CWidget) localStore.get(ABLocalStoreKeys.PROJECTILEHITUNIT + castId); - final CWidget dest = (CWidget) localStore.get(ABLocalStoreKeys.PROJECTILEHITDEST + castId); - if (unit != null) { - return unit; - } - else { - return dest; - } - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "GetProjectileHitWidgetAU()"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABCallbackUnitToWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABCallbackUnitToWidget.java deleted file mode 100644 index 506d4effc..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABCallbackUnitToWidget.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.widget; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; - -public class ABCallbackUnitToWidget extends ABWidgetCallback { - - private ABUnitCallback unit; - - @Override - public CWidget callback(CSimulation game, CUnit caster, Map localStore, final int castId) { - return unit.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABWidgetCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABWidgetCallback.java deleted file mode 100644 index 773f2d03f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/callback/widget/ABWidgetCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.widget; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; - -public abstract class ABWidgetCallback implements ABCallback { - - abstract public CWidget callback(final CSimulation game, final CUnit caster, final Map localStore, final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsDestructableValidTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsDestructableValidTarget.java deleted file mode 100644 index e453885bf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsDestructableValidTarget.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable.ABDestructableCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; - -public class ABConditionIsDestructableValidTarget implements ABCondition { - - private ABUnitCallback caster; - private ABDestructableCallback target; - - @SuppressWarnings("unchecked") - @Override - public boolean evaluate(CSimulation game, CUnit casterUnit, Map localStore, final int castId) { - CUnit theCaster = casterUnit; - - List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - EnumSet targetsAllowed = levelData.get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL))-1) - .getTargetsAllowed(); - - if (targetsAllowed.isEmpty()) { - return true; - } - if (caster != null) { - theCaster = caster.callback(game, casterUnit, localStore, castId); - } - - return target.callback(game, casterUnit, localStore, castId).canBeTargetedBy(game, theCaster, targetsAllowed); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsPassAllAbilityTargetChecks.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsPassAllAbilityTargetChecks.java deleted file mode 100644 index 3fd549d13..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsPassAllAbilityTargetChecks.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.widget.ABWidgetCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; - -public class ABConditionIsPassAllAbilityTargetChecks implements ABCondition { - - private ABUnitCallback caster; - private ABWidgetCallback target; - - @Override - public boolean evaluate(CSimulation game, CUnit casterUnit, Map localStore, final int castId) { - CUnit theCaster = casterUnit; - - if (caster != null) { - theCaster = caster.callback(game, casterUnit, localStore, castId); - } - - AbilityBuilderActiveAbility abil = (AbilityBuilderActiveAbility) localStore.get(ABLocalStoreKeys.ABILITY); - final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver - .getInstance().reset(); - - abil.checkCanTarget(game, theCaster, abil.getBaseOrderId(), target.callback(game, casterUnit, localStore, castId), booleanTargetReceiver); - - if (booleanTargetReceiver.isTargetable()) { - return true; - } - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitInGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitInGroup.java deleted file mode 100644 index 2306805a3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitInGroup.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.Map; -import java.util.Set; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks.ABUnitGroupCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitInGroup implements ABCondition { - - private ABUnitGroupCallback group; - private ABUnitCallback unit; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Set groupSet = group.callback(game, caster, localStore, castId); - CUnit rUnit = unit.callback(game, caster, localStore, castId); - return groupSet.contains(rUnit); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitInRangeOfUnit.java deleted file mode 100644 index 30769d69b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitInRangeOfUnit.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitInRangeOfUnit implements ABCondition { - - private ABUnitCallback caster; - private ABUnitCallback target; - private ABFloatCallback range; - - @Override - public boolean evaluate(CSimulation game, CUnit casterUnit, Map localStore, final int castId) { - return caster.callback(game, casterUnit, localStore, castId).canReach(target.callback(game, casterUnit, localStore, castId), - range.callback(game, casterUnit, localStore, castId)); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitPassAllAbilityTargetChecks.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitPassAllAbilityTargetChecks.java deleted file mode 100644 index 69af0e5d0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitPassAllAbilityTargetChecks.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; - -public class ABConditionIsUnitPassAllAbilityTargetChecks implements ABCondition { - - private ABUnitCallback caster; - private ABUnitCallback target; - - @Override - public boolean evaluate(CSimulation game, CUnit casterUnit, Map localStore, final int castId) { - CUnit theCaster = casterUnit; - - if (caster != null) { - theCaster = caster.callback(game, casterUnit, localStore, castId); - } - - AbilityBuilderActiveAbility abil = (AbilityBuilderActiveAbility) localStore.get(ABLocalStoreKeys.ABILITY); - final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver - .getInstance().reset(); - - abil.checkCanTarget(game, theCaster, abil.getBaseOrderId(), - target.callback(game, casterUnit, localStore, castId), booleanTargetReceiver); - - if (booleanTargetReceiver.isTargetable()) { - return true; - } - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitValidTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitValidTarget.java deleted file mode 100644 index 59112df4b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsUnitValidTarget.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; - -public class ABConditionIsUnitValidTarget implements ABCondition { - - private ABUnitCallback caster; - private ABUnitCallback target; - private ABBooleanCallback targetedEffect; - - @SuppressWarnings("unchecked") - @Override - public boolean evaluate(CSimulation game, CUnit casterUnit, Map localStore, final int castId) { - CUnit theCaster = casterUnit; - - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final EnumSet targetsAllowed = levelData - .get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getTargetsAllowed(); - if (targetsAllowed.isEmpty()) { - return true; - } - final CUnit theUnit = this.target.callback(game, casterUnit, localStore, castId); - boolean te = false; - if (this.caster != null) { - theCaster = this.caster.callback(game, casterUnit, localStore, castId); - } - if (this.targetedEffect != null) { - te = this.targetedEffect.callback(game, theCaster, localStore, castId); - } -// for (CTargetType tar : targetsAllowed) { -// System.err.println("Matches " + tar + "? " + theUnit.canBeTargetedBy(game, theCaster, EnumSet.of(tar))); -// } - - return theUnit.canBeTargetedBy(game, theCaster, te, targetsAllowed, - BooleanAbilityTargetCheckReceiver.getInstance().reset()); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String casterExpr; - if (this.caster == null) { - casterExpr = jassTextGenerator.getCaster(); - } - else { - casterExpr = this.caster.generateJassEquivalent(jassTextGenerator); - } - String targetedEffectExpr = "false"; - if (this.targetedEffect != null) { - targetedEffectExpr = this.targetedEffect.generateJassEquivalent(jassTextGenerator); - } - return "IsUnitValidTargetAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + casterExpr + ", " - + targetedEffectExpr + ", " + jassTextGenerator.getTriggerLocalStore() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsValidTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsValidTarget.java deleted file mode 100644 index 110565ec3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionIsValidTarget.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.widget.ABWidgetCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; - -public class ABConditionIsValidTarget implements ABCondition { - - private ABUnitCallback caster; - private ABWidgetCallback target; - - @SuppressWarnings("unchecked") - @Override - public boolean evaluate(CSimulation game, CUnit casterUnit, Map localStore, final int castId) { - CUnit theCaster = casterUnit; - - final List levelData = (List) localStore - .get(ABLocalStoreKeys.LEVELDATA); - final EnumSet targetsAllowed = levelData - .get(((int) localStore.get(ABLocalStoreKeys.CURRENTLEVEL)) - 1).getTargetsAllowed(); - - if (targetsAllowed.isEmpty()) { - return true; - } - if (this.caster != null) { - theCaster = this.caster.callback(game, casterUnit, localStore, castId); - } - -// CWidget theTarget = target.callback(game, theCaster, localStore, castId); -// for (CTargetType tar : targetsAllowed) { -// System.err.println("Matches " + tar + "? " + theTarget.canBeTargetedBy(game, theCaster, EnumSet.of(tar))); -// } - - return this.target.callback(game, casterUnit, localStore, castId).canBeTargetedBy(game, theCaster, - targetsAllowed); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String casterExpr; - if (this.caster == null) { - casterExpr = jassTextGenerator.getCaster(); - } - else { - casterExpr = this.caster.generateJassEquivalent(jassTextGenerator); - } - return "IsValidTargetAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + casterExpr + ", " - + jassTextGenerator.getTriggerLocalStore() + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionMatchingCorpseExistsInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionMatchingCorpseExistsInRangeOfUnit.java deleted file mode 100644 index f7d2bf815..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionMatchingCorpseExistsInRangeOfUnit.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.iterstructs.UnitAndRange; - -public class ABConditionMatchingCorpseExistsInRangeOfUnit implements ABCondition { - private static final Rectangle recycleRect = new Rectangle(); - - private ABUnitCallback originUnit; - private ABFloatCallback range; - private List conditions; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit originUnitTarget = originUnit.callback(game, caster, localStore, castId); - Float rangeVal = range.callback(game, caster, localStore, castId); - - final UnitAndRange ur = new UnitAndRange(); - - recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - game.getWorldCollision().enumCorpsesInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (originUnitTarget.canReach(enumUnit, rangeVal)) { - if (ur.getUnit() == null) { - if (conditions != null) { - boolean result = true; - localStore.put(ABLocalStoreKeys.MATCHINGUNIT+castId, enumUnit); - for (ABCondition condition : conditions) { - result = result && condition.evaluate(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.MATCHINGUNIT+castId); - if (result) { - ur.setUnit(enumUnit); - } - } else { - ur.setUnit(enumUnit); - } - } - } - return false; - } - }); - return ur.getUnit() != null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionMatchingUnitExistsInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionMatchingUnitExistsInRangeOfUnit.java deleted file mode 100644 index 9a2509fd9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionMatchingUnitExistsInRangeOfUnit.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.List; -import java.util.Map; - -import com.badlogic.gdx.math.Rectangle; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.iterstructs.UnitAndRange; - -public class ABConditionMatchingUnitExistsInRangeOfUnit implements ABCondition { - private static final Rectangle recycleRect = new Rectangle(); - - private ABUnitCallback originUnit; - private ABFloatCallback range; - private List conditions; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit originUnitTarget = originUnit.callback(game, caster, localStore, castId); - Float rangeVal = range.callback(game, caster, localStore, castId); - - final UnitAndRange ur = new UnitAndRange(); - - recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, - rangeVal * 2); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (originUnitTarget.canReach(enumUnit, rangeVal)) { - if (ur.getUnit() == null) { - if (conditions != null) { - boolean result = true; - localStore.put(ABLocalStoreKeys.MATCHINGUNIT+castId, enumUnit); - for (ABCondition condition : conditions) { - result = result && condition.evaluate(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.MATCHINGUNIT+castId); - if (result) { - ur.setUnit(enumUnit); - } - } else { - ur.setUnit(enumUnit); - } - } - } - return false; - } - }); - return ur.getUnit() != null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionSetCantUseReasonOnFailure.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionSetCantUseReasonOnFailure.java deleted file mode 100644 index ede10b861..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ABConditionSetCantUseReasonOnFailure.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeysEnum; - -public class ABConditionSetCantUseReasonOnFailure implements ABCondition { - - private ABCondition condition; - private CommandStringErrorKeysEnum reason; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - boolean result = condition.evaluate(game, caster, localStore, castId); - if (!result) { - localStore.put(ABLocalStoreKeys.CANTUSEREASON, reason.getKey()); - } - return result; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityNonPointTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityNonPointTarget.java deleted file mode 100644 index 8fffe15be..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityNonPointTarget.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTargetSimple; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsFlexAbilityNonPointTarget implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CAbilityAbilityBuilderActiveFlexTarget ability = (CAbilityAbilityBuilderActiveFlexTarget) localStore.get(ABLocalStoreKeys.FLEXABILITY); - - return !ability.isPointTarget(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityNonTargeted.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityNonTargeted.java deleted file mode 100644 index ba282bf3d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityNonTargeted.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTargetSimple; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsFlexAbilityNonTargeted implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CAbilityAbilityBuilderActiveFlexTarget ability = (CAbilityAbilityBuilderActiveFlexTarget) localStore.get(ABLocalStoreKeys.FLEXABILITY); - - return !ability.isTargetedSpell(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityPointTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityPointTarget.java deleted file mode 100644 index 96a94c532..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityPointTarget.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTargetSimple; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsFlexAbilityPointTarget implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CAbilityAbilityBuilderActiveFlexTarget ability = (CAbilityAbilityBuilderActiveFlexTarget) localStore.get(ABLocalStoreKeys.FLEXABILITY); - - return ability.isPointTarget(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityTargeted.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityTargeted.java deleted file mode 100644 index 1662a1918..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsFlexAbilityTargeted.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.CAbilityAbilityBuilderActiveFlexTargetSimple; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsFlexAbilityTargeted implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CAbilityAbilityBuilderActiveFlexTarget ability = (CAbilityAbilityBuilderActiveFlexTarget) localStore.get(ABLocalStoreKeys.FLEXABILITY); - - return ability.isTargetedSpell(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsOnCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsOnCooldown.java deleted file mode 100644 index f973888c6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsOnCooldown.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsOnCooldown implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - AbilityBuilderAbility ability = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - return ability.getCooldownRemainingTicks(game, caster) > 0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsToggleAbilityActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsToggleAbilityActive.java deleted file mode 100644 index df73e13ee..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsToggleAbilityActive.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsToggleAbilityActive implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - final AbilityBuilderActiveAbility ability = (AbilityBuilderActiveAbility) localStore - .get(ABLocalStoreKeys.ABILITY); - - return ability.isToggleOn(); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "IsToggleAbilityActive(" - + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) - + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsTransformingToAlternate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsTransformingToAlternate.java deleted file mode 100644 index 338a1b65e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/ability/ABConditionIsTransformingToAlternate.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsTransformingToAlternate implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return (boolean) localStore.get(ABLocalStoreKeys.TRANSFORMINGTOALT +castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsAttackTypeEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsAttackTypeEqual.java deleted file mode 100644 index bc92523ac..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsAttackTypeEqual.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.comparison; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAttackTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; - -public class ABConditionIsAttackTypeEqual implements ABCondition { - - private ABAttackTypeCallback attackType1; - private ABAttackTypeCallback attackType2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CAttackType lA = attackType1.callback(game, caster, localStore, castId); - CAttackType rA = attackType2.callback(game, caster, localStore, castId); - if (lA == null) { - if (rA == null) { - return true; - } - return false; - } - return lA.equals(rA); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsDamageTypeEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsDamageTypeEqual.java deleted file mode 100644 index fc11313b9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsDamageTypeEqual.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.comparison; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABDamageTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABConditionIsDamageTypeEqual implements ABCondition { - - private ABDamageTypeCallback damageType1; - private ABDamageTypeCallback damageType2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CDamageType lD = damageType1.callback(game, caster, localStore, castId); - CDamageType rD = damageType2.callback(game, caster, localStore, castId); - if (lD == null) { - if (rD == null) { - return true; - } - return false; - } - return lD.equals(rD); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsUnitEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsUnitEqual.java deleted file mode 100644 index 37503dbb9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/comparison/ABConditionIsUnitEqual.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.comparison; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitEqual implements ABCondition { - - private ABUnitCallback unit1; - private ABUnitCallback unit2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit lUnit = unit1.callback(game, caster, localStore, castId); - CUnit rUnit = unit2.callback(game, caster, localStore, castId); - if (lUnit == null) { - if (rUnit == null) { - return true; - } - return false; - } - return lUnit.equals(rUnit); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionGameplayConstantIsDefendCanDeflect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionGameplayConstantIsDefendCanDeflect.java deleted file mode 100644 index e6cb8dad4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionGameplayConstantIsDefendCanDeflect.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.game; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionGameplayConstantIsDefendCanDeflect implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getGameplayConstants().isDefendDeflection(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionGameplayConstantIsRelativeUpgradeCosts.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionGameplayConstantIsRelativeUpgradeCosts.java deleted file mode 100644 index 67a8fe5e5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionGameplayConstantIsRelativeUpgradeCosts.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.game; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionGameplayConstantIsRelativeUpgradeCosts implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return game.getGameplayConstants().isRelativeUpgradeCosts(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionIsTimeOfDayInRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionIsTimeOfDayInRange.java deleted file mode 100644 index 0dfbadbff..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/game/ABConditionIsTimeOfDayInRange.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.game; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsTimeOfDayInRange implements ABCondition { - - private ABFloatCallback startTime; - private ABFloatCallback endTime; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - float st = 0; - float et = Float.MAX_VALUE; - if (startTime != null) { - st = startTime.callback(game, caster, localStore, castId); - } - if (endTime != null) { - et = endTime.callback(game, caster, localStore, castId); - } - return st <= et ? game.getGameTimeOfDay() >= st && game.getGameTimeOfDay() < et - : game.getGameTimeOfDay() >= st || game.getGameTimeOfDay() < et; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/item/ABConditionIsItemAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/item/ABConditionIsItemAbility.java deleted file mode 100644 index fc5e5ccbf..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/item/ABConditionIsItemAbility.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.item; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionIsItemAbility implements ABCondition { - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - AbilityBuilderAbility ability = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - return ability.getItem() != null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/item/ABConditionItemHasCharges.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/item/ABConditionItemHasCharges.java deleted file mode 100644 index 9464ff0e5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/item/ABConditionItemHasCharges.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.item; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.item.ABItemCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABConditionItemHasCharges implements ABCondition { - - private ABItemCallback item; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - if (item == null) { - AbilityBuilderAbility ability = (AbilityBuilderAbility) localStore.get(ABLocalStoreKeys.ABILITY); - - return ability.getItem().getCharges() > 0; - } else { - return item.callback(game, caster, localStore, castId).getCharges() > 0; - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionAnd.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionAnd.java deleted file mode 100644 index 227643885..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionAnd.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.logical; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionAnd implements ABCondition { - - private ABCondition condition1; - private ABCondition condition2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return this.condition1.evaluate(game, caster, localStore, castId) - && this.condition2.evaluate(game, caster, localStore, castId); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return this.condition1.generateJassEquivalent(jassTextGenerator) + " and " - + this.condition2.generateJassEquivalent(jassTextGenerator); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionBool.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionBool.java deleted file mode 100644 index c56ea41b5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionBool.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.logical; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionBool implements ABCondition { - - private ABBooleanCallback bool; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return bool.callback(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionNot.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionNot.java deleted file mode 100644 index 484773f34..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionNot.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.logical; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionNot implements ABCondition { - - private ABCondition condition; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return !this.condition.evaluate(game, caster, localStore, castId); - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "not " + this.condition.generateJassEquivalent(jassTextGenerator); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionNotNull.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionNotNull.java deleted file mode 100644 index 6084374b2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionNotNull.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.logical; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionNotNull implements ABCondition { - - private ABCallback value; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return value.callback(game, caster, localStore, castId) != null; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionOr.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionOr.java deleted file mode 100644 index 86bd9ff74..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/logical/ABConditionOr.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.logical; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionOr implements ABCondition { - - private ABCondition condition1; - private ABCondition condition2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return condition1.evaluate(game, caster, localStore, castId) || condition2.evaluate(game, caster, localStore, castId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatEq0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatEq0.java deleted file mode 100644 index e5b0fde6b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatEq0.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionFloatEq0 implements ABCondition { - - private ABFloatCallback value; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Float v = value.callback(game, caster, localStore, castId); - - return v==0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatEqual.java deleted file mode 100644 index a465cb2b3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatEqual.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionFloatEqual implements ABCondition { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public boolean evaluate(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Float v1 = this.value1.callback(game, caster, localStore, castId); - final Float v2 = this.value2.callback(game, caster, localStore, castId); - - return v1.equals(v2); - } - - @Override - public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { - return this.value1.generateJassEquivalent(jassTextGenerator) + " == " - + this.value2.generateJassEquivalent(jassTextGenerator); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatGt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatGt.java deleted file mode 100644 index a9d80f0fb..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatGt.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionFloatGt implements ABCondition { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - final Float v1 = this.value1.callback(game, caster, localStore, castId); - final Float v2 = this.value2.callback(game, caster, localStore, castId); - - return v1 > v2; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return this.value1.generateJassEquivalent(jassTextGenerator) + " > " - + this.value2.generateJassEquivalent(jassTextGenerator); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatGte.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatGte.java deleted file mode 100644 index 84fbf332e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatGte.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionFloatGte implements ABCondition { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Float v1 = value1.callback(game, caster, localStore, castId); - Float v2 = value2.callback(game, caster, localStore, castId); - - return v1>=v2; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatLt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatLt.java deleted file mode 100644 index 9cbcf32d3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatLt.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionFloatLt implements ABCondition { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Float v1 = value1.callback(game, caster, localStore, castId); - Float v2 = value2.callback(game, caster, localStore, castId); - - return v1 localStore, final int castId) { - Float v1 = value1.callback(game, caster, localStore, castId); - Float v2 = value2.callback(game, caster, localStore, castId); - - return v1<=v2; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatNe.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatNe.java deleted file mode 100644 index e4aee0139..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatNe.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionFloatNe implements ABCondition { - - private ABFloatCallback value1; - private ABFloatCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Float v1 = value1.callback(game, caster, localStore, castId); - Float v2 = value2.callback(game, caster, localStore, castId); - - return !v1.equals(v2); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatNe0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatNe0.java deleted file mode 100644 index dad528589..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionFloatNe0.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionFloatNe0 implements ABCondition { - - private ABFloatCallback value; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Float v = value.callback(game, caster, localStore, castId); - - return v!=0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerEq.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerEq.java deleted file mode 100644 index 15cb48bea..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerEq.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerEq implements ABCondition { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value1.callback(game, caster, localStore, castId); - Integer v2 = value2.callback(game, caster, localStore, castId); - - return v1==v2; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerEq0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerEq0.java deleted file mode 100644 index b13d2433c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerEq0.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerEq0 implements ABCondition { - - private ABIntegerCallback value; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value.callback(game, caster, localStore, castId); - return v1 == 0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerGt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerGt.java deleted file mode 100644 index 47c7cf90b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerGt.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerGt implements ABCondition { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value1.callback(game, caster, localStore, castId); - Integer v2 = value2.callback(game, caster, localStore, castId); - return v1 > v2; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerGte.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerGte.java deleted file mode 100644 index 660b4c00b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerGte.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerGte implements ABCondition { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value1.callback(game, caster, localStore, castId); - Integer v2 = value2.callback(game, caster, localStore, castId); - return v1 >= v2; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerIsEven.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerIsEven.java deleted file mode 100644 index afcee0a93..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerIsEven.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerIsEven implements ABCondition { - - private ABIntegerCallback value; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value.callback(game, caster, localStore, castId); - - return (v1 % 2) == 0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerIsOdd.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerIsOdd.java deleted file mode 100644 index 201696de6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerIsOdd.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerIsOdd implements ABCondition { - - private ABIntegerCallback value; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value.callback(game, caster, localStore, castId); - - return (v1 % 2) == 1; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerLt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerLt.java deleted file mode 100644 index 7a22303ef..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerLt.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerLt implements ABCondition { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - final Integer v1 = this.value1.callback(game, caster, localStore, castId); - final Integer v2 = this.value2.callback(game, caster, localStore, castId); - return v1 < v2; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return this.value1.generateJassEquivalent(jassTextGenerator) + " < " - + this.value2.generateJassEquivalent(jassTextGenerator); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerLte.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerLte.java deleted file mode 100644 index a28d8674b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerLte.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerLte implements ABCondition { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value1.callback(game, caster, localStore, castId); - Integer v2 = value2.callback(game, caster, localStore, castId); - return v1 <= v2; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerNe.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerNe.java deleted file mode 100644 index 8b9388a5a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerNe.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerNe implements ABCondition { - - private ABIntegerCallback value1; - private ABIntegerCallback value2; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value1.callback(game, caster, localStore, castId); - Integer v2 = value2.callback(game, caster, localStore, castId); - return v1!=v2; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerNe0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerNe0.java deleted file mode 100644 index b3c0d045e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/numeric/ABConditionIntegerNe0.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIntegerNe0 implements ABCondition { - - private ABIntegerCallback value; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - Integer v1 = value.callback(game, caster, localStore, castId); - return v1 != 0; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/timer/ABConditionIsTimerActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/timer/ABConditionIsTimerActive.java deleted file mode 100644 index 5489324ce..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/timer/ABConditionIsTimerActive.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.timer; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks.ABTimerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsTimerActive implements ABCondition { - - private ABTimerCallback timer; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - return timer.callback(game, caster, localStore, castId).isRunning(); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionDoesUnitHaveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionDoesUnitHaveBuff.java deleted file mode 100644 index a7ad5056c..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionDoesUnitHaveBuff.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionDoesUnitHaveBuff implements ABCondition { - - private ABUnitCallback unit; - private ABIDCallback id; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit theUnit = unit.callback(game, caster, localStore, castId); - if (theUnit != null) { - for (CAbility ability : theUnit.getAbilities()) { - if (ability instanceof CBuff) { - if (((CBuff)ability).getAlias() == id.callback(game, caster, localStore, castId)) { - return true; - } - } - } - } - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitBuilding.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitBuilding.java deleted file mode 100644 index 5973f56a6..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitBuilding.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitBuilding implements ABCondition { - - private ABUnitCallback unit; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit theUnit = unit.callback(game, caster, localStore, castId); - if (theUnit != null) { - return theUnit.isBuilding(); - } - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitDead.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitDead.java deleted file mode 100644 index 596192cec..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitDead.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitDead implements ABCondition { - - private ABUnitCallback unit; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit theUnit = unit.callback(game, caster, localStore, castId); - if (theUnit != null) { - return theUnit.isDead(); - } - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitEnemy.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitEnemy.java deleted file mode 100644 index e4ecbf1d9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitEnemy.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; - -public class ABConditionIsUnitEnemy implements ABCondition { - - private ABUnitCallback caster; - private ABUnitCallback unit; - - @Override - public boolean evaluate(CSimulation game, CUnit casterUnit, Map localStore, final int castId) { - final CUnit theUnit = this.unit.callback(game, casterUnit, localStore, castId); - CUnit theCaster = casterUnit; - if (this.caster != null) { - theCaster = this.caster.callback(game, casterUnit, localStore, castId); - } - - if (theUnit != null) { - return !game.getPlayer(theUnit.getPlayerIndex()).hasAlliance(theCaster.getPlayerIndex(), - CAllianceType.PASSIVE); - } - return false; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - String casterExpr; - if (this.caster == null) { - casterExpr = jassTextGenerator.getCaster(); - } - else { - casterExpr = this.caster.generateJassEquivalent(jassTextGenerator); - } - return "IsUnitEnemy(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", GetOwningPlayer(" + casterExpr - + "))"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitMaxHp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitMaxHp.java deleted file mode 100644 index 31b75260a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitMaxHp.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitMaxHp implements ABCondition { - - private ABUnitCallback unit; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit theUnit = this.unit.callback(game, caster, localStore, castId); - if (theUnit != null) { - return theUnit.getLife() >= theUnit.getMaximumLife(); - } - return false; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "IsUnitMaxHpAU(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitMaxMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitMaxMp.java deleted file mode 100644 index 104c33cb2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitMaxMp.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitMaxMp implements ABCondition { - - private ABUnitCallback unit; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - final CUnit theUnit = this.unit.callback(game, caster, localStore, castId); - if (theUnit != null) { - return theUnit.getMana() >= theUnit.getMaximumMana(); - } - return false; - } - - @Override - public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { - return "IsUnitMaxMpAU(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitTraining.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitTraining.java deleted file mode 100644 index f0e941448..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/condition/unit/ABConditionIsUnitTraining.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit; - -import java.util.Map; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionIsUnitTraining implements ABCondition { - - private ABUnitCallback unit; - - @Override - public boolean evaluate(CSimulation game, CUnit caster, Map localStore, final int castId) { - CUnit theUnit = unit.callback(game, caster, localStore, castId); - if (theUnit != null) { - return theUnit.isBuildQueueActive(); - } - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABBuff.java deleted file mode 100644 index bce07cd43..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABBuff.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractCBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; - -public abstract class ABBuff extends AbstractCBuff { - - public ABBuff(int handleId, War3ID code, War3ID alias) { - super(handleId, code, alias); - } - - @Override - public void onCancelFromQueue(final CSimulation game, final CUnit unit, final int orderId) { - } - - @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) { - return null; - } - - @Override - public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, - final AbilityPointTarget point) { - return null; - } - - @Override - public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) { - return null; - } - - @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, - final AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - } - - @Override - public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - } - - @Override - public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, - final AbilityTargetCheckReceiver receiver) { - receiver.orderIdNotAccepted(); - } - - @Override - protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final int orderId, - final AbilityActivationReceiver receiver) { - receiver.notAnActiveAbility(); - } - - @Override - public T visit(final CAbilityVisitor visitor) { - return visitor.accept(this); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABDestructableBuff.java deleted file mode 100644 index 3e9795efe..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABDestructableBuff.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABDestructableBuff implements CDestructableBuff { - - private int handleId; - private War3ID alias; - private int level; - - protected Map localStore; - protected int castId = 0; - private CUnit caster; - - private List onAddActions; - private List onRemoveActions; - private List onDeathActions; - - public ABDestructableBuff(int handleId, War3ID alias, int level, Map localStore, List onAddActions, - List onRemoveActions, List onDeathActions, final int castId, CUnit caster) { - this.handleId = handleId; - this.alias = alias; - this.level = level; - this.castId = castId; - this.localStore = localStore; - this.onAddActions = onAddActions; - this.onRemoveActions = onRemoveActions; - this.onDeathActions = onDeathActions; - this.caster = caster; - } - - @Override - public int getHandleId() { - return this.handleId; - } - - @Override - public War3ID getAlias() { - return this.alias; - } - - @Override - public void onAdd(CSimulation game, CDestructable dest) { - localStore.put(ABLocalStoreKeys.BUFFEDDEST+castId, this); - if (onAddActions != null) { - for (ABAction action : onAddActions) { - action.runAction(game, this.caster, localStore, castId); - } - } - localStore.remove(ABLocalStoreKeys.BUFFEDDEST+castId); - } - - @Override - public void onRemove(CSimulation game, CDestructable dest) { - localStore.put(ABLocalStoreKeys.BUFFEDDEST+castId, this); - if (onRemoveActions != null) { - for (ABAction action : onRemoveActions) { - action.runAction(game, this.caster, localStore, castId); - } - } - localStore.remove(ABLocalStoreKeys.BUFFEDDEST+castId); - } - - @Override - public void onDeath(CSimulation game, CDestructable dest) { - localStore.put(ABLocalStoreKeys.BUFFEDDEST+castId, this); - if (onDeathActions != null) { - for (ABAction action : onDeathActions) { - action.runAction(game, this.caster, localStore, castId); - } - } - localStore.remove(ABLocalStoreKeys.BUFFEDDEST+castId); - } - - @Override - public int getLevel() { - return this.level; - } - - @Override - public void setLevel(int level) { - this.level = level; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericAuraBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericAuraBuff.java deleted file mode 100644 index 8c1f3d85b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericAuraBuff.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.HashMap; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; - -public class ABGenericAuraBuff extends ABBuff { - private Map fx; - - private CUnit caster; - - public ABGenericAuraBuff(int handleId, War3ID alias, CUnit caster) { - super(handleId, alias, alias); - this.caster = caster; - this.fx = new HashMap<>(); - } - - @Override - public void onAdd(final CSimulation game, final CUnit unit) { - if (unit != this.caster) { - this.fx.put(unit.getHandleId(), unit.addNonStackingFx(game, "aura", getAlias(), CEffectType.TARGET)); - } - } - - @Override - public void onRemove(final CSimulation game, final CUnit unit) { - NonStackingFx theFx = this.fx.get(unit.getHandleId()); - if (theFx != null) { - this.fx.remove(unit.getHandleId()); - unit.removeNonStackingFx(game, theFx); - } - } - - @Override - public float getDurationRemaining(CSimulation game, final CUnit unit) { - return 0; - } - - @Override - public float getDurationMax() { - return 0; - } - - @Override - public boolean isTimedLifeBar() { - return false; - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - } - - @Override - public void onDeath(CSimulation game, CUnit cUnit) { - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericPermanentBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericPermanentBuff.java deleted file mode 100644 index 52cdb7061..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericPermanentBuff.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public abstract class ABGenericPermanentBuff extends ABBuff { - - public ABGenericPermanentBuff(int handleId, War3ID alias, boolean showIcon) { - super(handleId, alias, alias); - this.setIconShowing(showIcon); - } - - public ABGenericPermanentBuff(int handleId, War3ID alias) { - super(handleId, alias, alias); - } - - protected abstract void onBuffAdd(CSimulation game, CUnit unit); - - @Override - public void onAdd(final CSimulation game, final CUnit unit) { - this.onBuffAdd(game, unit); - } - - protected abstract void onBuffRemove(CSimulation game, CUnit unit); - - @Override - public void onRemove(final CSimulation game, final CUnit unit) { - this.onBuffRemove(game, unit); - } - - @Override - public float getDurationRemaining(CSimulation game, final CUnit unit) { - return 0; - } - - @Override - public float getDurationMax() { - return 0; - } - - @Override - public boolean isTimedLifeBar() { - return false; - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - } - - @Override - public void onDeath(CSimulation game, CUnit cUnit) { - } - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericTimedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericTimedBuff.java deleted file mode 100644 index 52ffa1875..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericTimedBuff.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public abstract class ABGenericTimedBuff extends ABBuff { - private boolean showTimedLifeBar; - private final float duration; - private int currentTick = 0; - private int expireTick; - - public ABGenericTimedBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar) { - super(handleId, alias, alias); - this.showTimedLifeBar = showTimedLifeBar; - this.duration = duration; - } - - @Override - public boolean isTimedLifeBar() { - return showTimedLifeBar; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - this.onBuffAdd(game, unit); - if (this.duration == 0) { - expireTick = Integer.MAX_VALUE; - } else { - final int durationTicks = (int) (this.duration / WarsmashConstants.SIMULATION_STEP_TIME); - expireTick = durationTicks; - } - } - - protected abstract void onBuffAdd(CSimulation game, CUnit unit); - - @Override - public void onRemove(CSimulation game, CUnit unit) { - this.onBuffRemove(game, unit); - } - - protected abstract void onBuffRemove(CSimulation game, CUnit unit); - - protected abstract void onBuffExpire(CSimulation game, CUnit unit); - - @Override - public float getDurationMax() { - return this.duration; - } - - @Override - public float getDurationRemaining(final CSimulation game, final CUnit unit) { - final int remaining = Math.max(0, this.expireTick - this.currentTick); - return remaining * WarsmashConstants.SIMULATION_STEP_TIME; - } - - @Override - public void onTick(final CSimulation game, final CUnit caster) { - this.currentTick++; - if (this.currentTick > this.expireTick) { - this.onBuffExpire(game, caster); - caster.remove(game, this); - } - } - - @Override - public void onDeath(final CSimulation game, final CUnit cUnit) { - cUnit.remove(game, this); - } - - public void updateExpiration(final CSimulation game, final CUnit unit) { - final int durationTicks = (int) (this.duration / WarsmashConstants.SIMULATION_STEP_TIME); - expireTick = game.getGameTurnTick() + durationTicks; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABPermanentPassiveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABPermanentPassiveBuff.java deleted file mode 100644 index e5cc97059..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABPermanentPassiveBuff.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABPermanentPassiveBuff extends ABGenericPermanentBuff { - - protected Map localStore; - private List onAddActions; - private List onRemoveActions; - - private boolean showFx = true; - private boolean playSfx = false; - - private CEffectType artType = CEffectType.TARGET; - private NonStackingFx fx; - private SimulationRenderComponent sfx; - private SimulationRenderComponent lsfx; - - protected int castId = 0; - - public ABPermanentPassiveBuff(int handleId, War3ID alias, Map localStore, - List onAddActions, List onRemoveActions, boolean showIcon, final int castId) { - this(handleId, alias, localStore, onAddActions, onRemoveActions, castId); - this.setIconShowing(showIcon); - } - - public ABPermanentPassiveBuff(int handleId, War3ID alias, Map localStore, - List onAddActions, List onRemoveActions, final int castId) { - super(handleId, alias); - this.localStore = localStore; - this.onAddActions = onAddActions; - this.onRemoveActions = onRemoveActions; - this.castId = castId; - } - - public void setArtType(CEffectType artType) { - this.artType = artType; - } - - public void setShowFx(boolean showFx) { - this.showFx = showFx; - } - - public void setPlaySfx(boolean playSfx) { - this.playSfx = playSfx; - } - - @Override - protected void onBuffAdd(CSimulation game, CUnit unit) { - if(this.fx != null) { - unit.removeNonStackingFx(game, this.fx); - } - if (this.getAlias() != null) { - if (showFx) { - this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), artType); - } - if (playSfx) { - this.sfx = game.unitSoundEffectEvent(unit, getAlias()); - this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); - } - } - if (onAddActions != null) { - for (ABAction action : onAddActions) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - protected void onBuffRemove(CSimulation game, CUnit unit) { - if (this.fx != null) { - unit.removeNonStackingFx(game, this.fx); - } - if (this.sfx != null) { - this.sfx.remove(); - } - if (this.lsfx != null) { - this.lsfx.remove(); - } - if (onRemoveActions != null) { - for (ABAction action : onRemoveActions) { - action.runAction(game, unit, localStore, castId); - } - } - } - - - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTargetingBuff.java deleted file mode 100644 index 8bd3d103f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTargetingBuff.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABTargetingBuff extends ABBuff { - public ABTargetingBuff(int handleId, War3ID alias) { - super(handleId, alias, alias); - this.setIconShowing(false); - } - - @Override - public float getDurationRemaining(CSimulation game, CUnit unit) { - return 0; - } - - @Override - public float getDurationMax() { - return 0; - } - - @Override - public boolean isTimedLifeBar() { - return false; - } - - @Override - public void onAdd(CSimulation game, CUnit unit) { - } - - @Override - public void onRemove(CSimulation game, CUnit unit) { - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - } - - @Override - public void onDeath(CSimulation game, CUnit cUnit) { - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedArtBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedArtBuff.java deleted file mode 100644 index 77e1efd9f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedArtBuff.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABTimedArtBuff extends ABGenericTimedBuff { - private NonStackingFx fx; - private SimulationRenderComponent sfx; - private SimulationRenderComponent lsfx; - private CEffectType artType = CEffectType.TARGET; - - public ABTimedArtBuff(int handleId, War3ID alias, float duration, boolean showIcon) { - this(handleId, alias, duration); - this.setIconShowing(showIcon); - } - - public ABTimedArtBuff(int handleId, War3ID alias, float duration) { - super(handleId, alias, duration, false); - } - - public void setArtType(CEffectType artType) { - this.artType = artType; - } - - @Override - protected void onBuffAdd(CSimulation game, CUnit unit) { - if(this.fx != null) { - unit.removeNonStackingFx(game, this.fx); - this.fx = null; - } - if (this.getAlias() != null) { - this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), artType); - this.sfx = game.unitSoundEffectEvent(unit, getAlias()); - this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); - } - } - - @Override - protected void onBuffRemove(CSimulation game, CUnit unit) { - if (this.fx != null) { - unit.removeNonStackingFx(game, this.fx); - } - if (this.sfx != null) { - this.sfx.remove(); - } - if (this.lsfx != null) { - this.lsfx.remove(); - } - } - - @Override - protected void onBuffExpire(CSimulation game, CUnit unit) { - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedBuff.java deleted file mode 100644 index 2219c8876..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedBuff.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; - -public class ABTimedBuff extends ABGenericTimedBuff { - - protected Map localStore; - private List onAddActions; - private List onRemoveActions; - private List onExpireActions; - - private CEffectType artType = CEffectType.TARGET; - private NonStackingFx fx; - private SimulationRenderComponent sfx; - private SimulationRenderComponent lsfx; - - protected int castId = 0; - - public ABTimedBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, boolean showIcon, final int castId) { - this(handleId, alias, duration, showTimedLifeBar, localStore, onAddActions, onRemoveActions, onExpireActions, castId); - this.setIconShowing(showIcon); - } - - public ABTimedBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, final int castId) { - super(handleId, alias, duration, showTimedLifeBar); - this.localStore = localStore; - this.onAddActions = onAddActions; - this.onRemoveActions = onRemoveActions; - this.onExpireActions = onExpireActions; - this.castId = castId; - } - - public void setArtType(CEffectType artType) { - this.artType = artType; - } - - @Override - protected void onBuffAdd(CSimulation game, CUnit unit) { - if(this.fx != null) { - unit.removeNonStackingFx(game, this.fx); - } - if (this.getAlias() != null) { - if (artType != null) { - this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), artType); - } - this.sfx = game.unitSoundEffectEvent(unit, getAlias()); - this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); - } - if (onAddActions != null) { - for (ABAction action : onAddActions) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - protected void onBuffRemove(CSimulation game, CUnit unit) { - if (this.fx != null) { - unit.removeNonStackingFx(game, this.fx); - } - if (this.sfx != null) { - this.sfx.remove(); - } - if (this.lsfx != null) { - this.lsfx.remove(); - } - if (onRemoveActions != null) { - for (ABAction action : onRemoveActions) { - action.runAction(game, unit, localStore, castId); - } - } - } - - @Override - protected void onBuffExpire(CSimulation game, CUnit unit) { - if (onExpireActions != null) { - for (ABAction action : onExpireActions) { - action.runAction(game, unit, localStore, castId); - } - } - } - - - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedInstantTransformationBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedInstantTransformationBuff.java deleted file mode 100644 index 50736010a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedInstantTransformationBuff.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderPassiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.DelayInstantTransformationTimer; - -public class ABTimedInstantTransformationBuff extends ABGenericTimedBuff { - - private Map localStore; - private OnTransformationActions actions; - private AbilityBuilderPassiveAbility abil; - private CUnitType targetType; - private boolean addAlternateTagAfter; - private boolean perm; - private float dur; - private float transTime; - - public ABTimedInstantTransformationBuff(int handleId, Map localStore, OnTransformationActions actions, War3ID alias, float duration, AbilityBuilderPassiveAbility ability, - CUnitType newType, boolean addAlternateTagAfter, boolean permanent, float transformationDuration) { - super(handleId, alias, duration, true); - this.setIconShowing(false); - this.localStore = localStore; - this.actions = actions; - this.abil = ability; - this.targetType = newType; - this.addAlternateTagAfter = addAlternateTagAfter; - this.perm = permanent; - this.dur = transformationDuration; - } - - @Override - protected void onBuffAdd(CSimulation game, CUnit unit) { - } - - @Override - protected void onBuffRemove(CSimulation game, CUnit unit) { - } - - @Override - protected void onBuffExpire(CSimulation game, CUnit unit) { - if (dur > 0) { - TransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); - new DelayInstantTransformationTimer(game, localStore, unit, actions, addAlternateTagAfter, transTime, null, targetType, abil, - null, transTime, 0).start(game); - } else { - TransformationHandler.instantTransformation(game, localStore, unit, targetType, actions, abil, addAlternateTagAfter, perm, true); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTargetingBuff.java deleted file mode 100644 index 051ee90d8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTargetingBuff.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class ABTimedTargetingBuff extends ABGenericTimedBuff { - public ABTimedTargetingBuff(int handleId, War3ID alias, float duration) { - super(handleId, alias, duration, false); - this.setIconShowing(false); - } - - @Override - protected void onBuffAdd(CSimulation game, CUnit unit) { - } - - @Override - protected void onBuffRemove(CSimulation game, CUnit unit) { - } - - @Override - protected void onBuffExpire(CSimulation game, CUnit unit) { - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingBuff.java deleted file mode 100644 index 6a64244a9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingBuff.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABTimedTickingBuff extends ABTimedBuff { - - private List onTickActions; - - public ABTimedTickingBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, List onTickActions, boolean showIcon, final int castId) { - this(handleId, alias, duration, showTimedLifeBar, localStore, onAddActions, onRemoveActions, onExpireActions, onTickActions, castId); - this.setIconShowing(showIcon); - } - - public ABTimedTickingBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, List onTickActions, final int castId) { - super(handleId, alias, duration, showTimedLifeBar, localStore, onAddActions, onRemoveActions, onExpireActions, castId); - this.onTickActions = onTickActions; - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - if (onTickActions != null) { - for (ABAction action : onTickActions) { - action.runAction(game, unit, localStore, castId); - } - } - super.onTick(game, unit); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingPausedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingPausedBuff.java deleted file mode 100644 index 9e35b5e64..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingPausedBuff.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABTimedTickingPausedBuff extends ABTimedBuff { - - private List onTickActions; - - public ABTimedTickingPausedBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, List onTickActions, boolean showIcon, final int castId) { - this(handleId, alias, duration, showTimedLifeBar, localStore, onAddActions, onRemoveActions, onExpireActions, onTickActions, castId); - this.setIconShowing(showIcon); - } - - public ABTimedTickingPausedBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, List onTickActions, final int castId) { - super(handleId, alias, duration, showTimedLifeBar, localStore, onAddActions, onRemoveActions, onExpireActions, castId); - this.onTickActions = onTickActions; - } - - @Override - public void onTick(CSimulation game, CUnit unit) { - if (onTickActions != null) { - for (ABAction action : onTickActions) { - action.runAction(game, unit, localStore, castId); - } - } - if (!unit.isPaused()) { - super.onTick(game, unit); - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingPostDeathBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingPostDeathBuff.java deleted file mode 100644 index 08c4423b0..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTickingPostDeathBuff.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABTimedTickingPostDeathBuff extends ABTimedTickingBuff { - - public ABTimedTickingPostDeathBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, List onTickActions, boolean showIcon, final int castId) { - this(handleId, alias, duration, showTimedLifeBar, localStore, onAddActions, onRemoveActions, onExpireActions, onTickActions, castId); - this.setIconShowing(showIcon); - } - - public ABTimedTickingPostDeathBuff(int handleId, War3ID alias, float duration, boolean showTimedLifeBar, Map localStore, - List onAddActions, List onRemoveActions, List onExpireActions, List onTickActions, final int castId) { - super(handleId, alias, duration, showTimedLifeBar, localStore, onAddActions, onRemoveActions, onExpireActions, onTickActions, castId); - } - - @Override - public void onDeath(CSimulation game, CUnit unit) { - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTransformationBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTransformationBuff.java deleted file mode 100644 index 2ea3d79bd..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABTimedTransformationBuff.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorFinishTransformation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.COrderStartTransformation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.DelayInstantTransformationTimer; - -public class ABTimedTransformationBuff extends ABGenericTimedBuff { - - private Map localStore; - private OnTransformationActions actions; - private AbilityBuilderActiveAbility abil; - private CUnitType targetType; - private boolean addAlternateTagAfter; - private boolean perm; - private float dur; - private float transTime; - private float landTime; - private float atlAdDelay; - private float altAdTime; - private boolean imLand; - private boolean imTakeOff; - private boolean instantTransformation; - - public ABTimedTransformationBuff(int handleId, Map localStore, OnTransformationActions actions, War3ID alias, float duration, AbilityBuilderActiveAbility ability, - CUnitType newType, boolean addAlternateTagAfter, boolean permanent, float transformationDuration, - float transformationTime, float landingDelay, float altitudeAdjustmentDelay, - float altitudeAdjustmentDuration, boolean immediateLanding, boolean immediateTakeoff) { - super(handleId, alias, duration, true); - this.setIconShowing(false); - this.localStore = localStore; - this.actions = actions; - this.abil = ability; - this.targetType = newType; - this.addAlternateTagAfter = addAlternateTagAfter; - this.perm = permanent; - this.dur = transformationDuration; - this.transTime = transformationTime; - this.landTime = landingDelay; - this.atlAdDelay = altitudeAdjustmentDelay; - this.altAdTime = altitudeAdjustmentDuration; - this.imLand = immediateLanding; - this.imTakeOff = immediateTakeoff; - this.instantTransformation = false; - } - - public ABTimedTransformationBuff(int handleId, Map localStore, OnTransformationActions actions, War3ID alias, float duration, AbilityBuilderActiveAbility ability, - CUnitType newType, boolean addAlternateTagAfter, boolean permanent, float transformationDuration) { - super(handleId, alias, duration, true); - this.setIconShowing(false); - this.localStore = localStore; - this.actions = actions; - this.abil = ability; - this.targetType = newType; - this.addAlternateTagAfter = addAlternateTagAfter; - this.perm = permanent; - this.dur = transformationDuration; - this.instantTransformation = true; - } - - @Override - protected void onBuffAdd(CSimulation game, CUnit unit) { - } - - @Override - protected void onBuffRemove(CSimulation game, CUnit unit) { - } - - @Override - protected void onBuffExpire(CSimulation game, CUnit unit) { - if (abil.isToggleOn()) { - abil.deactivate(game, unit); - } - if (instantTransformation) { - if (dur > 0) { - TransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); - new DelayInstantTransformationTimer(game, localStore, unit, actions, addAlternateTagAfter, transTime, null, targetType, abil, - null, transTime, 0).start(game); - } else { - TransformationHandler.instantTransformation(game, localStore, unit, targetType, actions, abil, addAlternateTagAfter, perm, true); - } - } else { - unit.order(game, new COrderStartTransformation( - new CBehaviorFinishTransformation(localStore, unit, abil, targetType, actions, addAlternateTagAfter, - addAlternateTagAfter ? abil.getBaseOrderId() : abil.getOffOrderId(), perm, dur, transTime, - landTime, atlAdDelay, altAdTime, imLand, imTakeOff, this.getAlias(), targetType, instantTransformation), - abil.getBaseOrderId()), false); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABAction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABAction.java deleted file mode 100644 index d81f56134..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public interface ABAction extends JassTextGeneratorStmt { - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId); - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABCallback.java deleted file mode 100644 index 30c2bce97..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABCallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGeneratorExpr; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public interface ABCallback extends JassTextGeneratorExpr { - - public Object callback(final CSimulation game, final CUnit caster, final Map localStore, - final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABCondition.java deleted file mode 100644 index 737325b71..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABCondition.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core; - -import java.util.Map; - -import com.etheller.warsmash.parsers.jass.JassTextGeneratorExpr; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public interface ABCondition extends JassTextGeneratorExpr { - - public boolean evaluate(final CSimulation game, final CUnit caster, final Map localStore, - final int castId); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABLocalStoreKeys.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABLocalStoreKeys.java deleted file mode 100644 index d4f31fdc3..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABLocalStoreKeys.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core; - -public class ABLocalStoreKeys { - // Core values - public static final String ABILITYEDITORDATA = "_abilityEditorData"; - public static final String LEVELDATA = "_levelData"; - public static final String PARENTLEVELDATA = "_parentLevelData"; - public static final String PARENTCASTER = "_parentCaster"; - public static final String PARENTLOCALSTORE = "_parentLocalStore"; - public static final String ALIAS = "_alias"; - public static final String CODE = "_code"; - public static final String GAME = "_game"; - public static final String THISUNIT = "_thisUnit"; - public static final String ABILITY = "_ability"; - public static final String ITEM = "_item"; - public static final String ITEMSLOT = "_itemSlot"; - public static final String ITERATORCOUNT = "_i"; - public static final String BREAK = "_break"; - public static final String BUFFCASTINGUNIT = "_buffCastingUnit"; - - public static final String NEWBEHAVIOR = "_newBehavior"; - - public static final String FAILEDTOCAST = "_failedToCast#"; - public static final String TRANSFORMINGTOALT = "_transformingToAlt#"; - public static final String CHANNELING = "_channeling#"; - public static final String INTERRUPTED = "_interrupted#"; - public static final String PERIODICNEXTTICK = "_periodicNextTick#"; - - public static final String CANTUSEREASON = "_cantUseReason"; - - public static final String TOGGLEDABILITY = "_toggledAbility"; - public static final String FLEXABILITY = "_flexAbility"; - public static final String PAIRABILITY = "_pairAbility"; - - // Aura Template - public static final String AURAGROUP = "_auraGroup"; - - // FX names - public static final String LASTCREATEDFX = "_lastCreatedFx"; - public static final String LASTCREATEDLIGHTNING = "_lastCreatedLtng"; - - // Unit Names - public static final String ENUMUNIT = "_enumUnit#"; - public static final String MATCHINGUNIT = "_matchingUnit#"; - public static final String LASTCREATEDUNIT = "_lastCreatedUnit"; - public static final String LASTADDEDUNIT = "_lastAddedUnit"; - public static final String LASTREMOVEDDUNIT = "_lastRemovedUnit"; - - // Ability Names - public static final String LASTCREATEDABILITY = "_lastCreatedAbility"; - public static final String LASTCREATEDBUFF = "_lastCreatedBuff"; - public static final String LASTADDEDABILITY = "_lastAddedAbility"; - public static final String LASTADDEDBUFF = "_lastAddedBuff"; - public static final String CURRENTLEVEL = "_currentLevel"; - - public static final String LASTCREATEDUNITGROUP = "_lastCreatedUnitGroup"; - public static final String LASTCREATEDUNITQUEUE = "_lastCreatedUnitQueue"; - - public static final String LASTCREATEDDESTBUFF = "_lastCreatedDestBuff"; - - //Generic Targeting - public static final String ATTACKINGUNIT = "_attackingUnit#"; - public static final String ATTACKEDUNIT = "_attackedUnit#"; - public static final String ABILITYTARGETEDUNIT = "_abilityTargetedUnit#"; - public static final String ABILITYTARGETEDDESTRUCTABLE = "_abilityTargetedDestructable#"; - public static final String ABILITYTARGETEDITEM = "_abilityTargetedItem#"; - public static final String ABILITYTARGETEDLOCATION = "_abilityTargetedLocation#"; - - //Event Targeting - public static final String EVENTABILITY = "_eventAbility#"; - public static final String EVENTABILITYID = "_eventAbilityId#"; - public static final String EVENTCASTINGUNIT = "_eventCastingUnit#"; - public static final String EVENTTARGETEDUNIT = "_eventTargetedUnit#"; - public static final String EVENTTARGETEDDESTRUCTABLE = "_eventTargetedDestructable#"; - public static final String EVENTTARGETEDITEM = "_eventTargetedItem#"; - public static final String EVENTTARGETEDLOCATION = "_eventTargetedLocation#"; - - //Generic Attacks - public static final String BASEDAMAGEDEALT = "_baseDamageDealt#"; - public static final String BONUSDAMAGEDEALT = "_bonusDamageDealt#"; - public static final String TOTALDAMAGEDEALT = "_totalDamageDealt#"; - public static final String WEAPONTYPE = "_weaponType#"; - public static final String ATTACKTYPE = "_attackType#"; - public static final String DAMAGETYPE = "_damageType#"; - - //Timers - public static final String LASTCREATEDTIMER = "_lastCreatedTimer"; - public static final String LASTSTARTEDTIMER = "_lastStartedTimer"; - public static final String FIRINGTIMER = "_firingTimer"; - - //Events - public static final String LASTCREATEDTODEVENT = "_lastCreatedToDEvent"; - - - // Dest Names - public static final String BUFFEDDEST = "_buffedDest#"; - public static final String ENUMDESTRUCTABLE = "_enumDest#"; - - //Projectiles - public static final String LASTCREATEDPROJECTILE = "_lastCreatedProjectile"; - public static final String THISPROJECTILE = "_thisProjectile#"; - public static final String PROJECTILEUNITTARGETS = "_projUnitTargets#"; - public static final String PROJECTILEDESTTARGETS = "_projDestTargets#"; - public static final String PROJECTILECURRENTLOC = "_projCurrentLoc#"; - public static final String PROJECTILEHITUNIT = "_projHitUnit#"; - public static final String PROJECTILEHITDEST = "_projHitDest#"; - - //vision - public static final String LASTCREATEDVISIONMODIFIER = "_lastCreatedVisionMod"; - - - // Pairing - public static final String ABILITYPAIREDUNIT = "_abilityPairedUnit#"; - public static final String LASTPARTNERABILITY = "_lastPartnerAbility"; - - // Transforming - public static final String ACTIVE_ALTITUDE_ADJUSTMENT = "_activeAltAdj"; - public static final String WAITING_ANIMATION = "_morphTimer"; - - - - // NonStackingStatBuff Names - public static final String LASTCREATEDNSSB = "_lastCreatedNSSB"; - - // StateModBuff Names - public static final String LASTCREATEDSMB = "_lastCreatedSMB"; - - // AttackEvasionListener Names - public static final String LASTCREATEDAEL = "_lastCreatedAEL"; - public static final String DAMAGEISATTACK = "_damageIsAttack#"; - public static final String DAMAGEISRANGED = "_damageIsRanged#"; - - // AttackPostDamageListener Names - public static final String LASTCREATEDAPoDL = "_lastCreatedAPoDL"; - - // AttackPreDamageListener Names - public static final String LASTCREATEDAPrDL = "_lastCreatedAPrDL"; - public static final String PREDAMAGERESULT = "_preDamageResult#"; - public static final String PREDAMAGESTACKING = "_preDamageStacking#"; - - // DamageTakenListener Names - public static final String LASTCREATEDDTL = "_lastCreatedDTL"; - - // DamageTakenModificationListener Names - public static final String LASTCREATEDDTML = "_lastCreatedDTML"; - public static final String DAMAGEMODRESULT = "_damageModResult#"; - - // DamageTakenModificationListener Names - public static final String LASTCREATEDFDTML = "_lastCreatedFDTML"; - - // DeathReplacementEffect Names - public static final String LASTCREATEDDRE = "_lastCreatedDRE"; - public static final String KILLINGUNIT = "_killingUnit#"; - public static final String DYINGUNIT = "_dyingUnit#"; - public static final String DEATHRESULT = "_deathResult#"; - public static final String DEATHSTACKING = "_deathStacking#"; - - // Reaction Names - public static final String LASTCREATEDAtkPRL = "_lastCreatedAtkPRL"; - public static final String LASTCREATEDAbPRL = "_lastCreatedAbPRL"; - public static final String LASTCREATEDAbERL = "_lastCreatedAbERL"; - public static final String REACTIONALLOWHIT = "_reactionAllowHit#"; - public static final String ATTACKPROJ = "_attackProj#"; - public static final String ABILITYPROJ = "_abilityProj#"; - public static final String REACTIONABILITY = "_reactionAbility#"; - public static final String REACTIONABILITYCASTER = "_reactionAbilityCaster#"; - public static final String REACTIONABILITYTARGET = "_reactionAbilityTarget#"; - - // Behavior Change Names - public static final String LASTCREATEDBCL = "_lastCreatedBCL"; - public static final String PRECHANGEBEHAVIOR = "_preChangeBehavior#"; - public static final String POSTCHANGEBEHAVIOR = "_postChangeBehaviorj#"; - public static final String BEHAVIORONGOING = "_behaviorOngoing#"; - - public static String combineKey(String key, int castId) { - return key + castId; - } - - public static String combineUserKey(String key, int castId) { - return "__" + key; - } - - public static String combineUserInstanceKey(String key, int castId) { - return "__" + key + "#" + castId; - } - - public static String combineSubroutineKey(String key, int castId) { - return "_!" + key; - } - - public static String combineSubroutineInstanceKey(String key, int castId) { - return "_!" + key + "#" + castId; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABSingleAction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABSingleAction.java deleted file mode 100644 index ec5e1e46f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/ABSingleAction.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core; - -import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; - -public interface ABSingleAction extends ABAction, JassTextGeneratorCallStmt { - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/AbilityBuilderGsonBuilder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/AbilityBuilderGsonBuilder.java deleted file mode 100644 index 4961fa938..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/core/AbilityBuilderGsonBuilder.java +++ /dev/null @@ -1,1075 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.ability.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.buff.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.destructable.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.events.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.floatingtext.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.gamestate.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.item.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.player.ABActionGiveResourcesToPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.player.ABActionSetAbilityEnabledForPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.projectile.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.stats.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.timer.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.animation.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.art.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit.movement.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitgroup.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalActions.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalCallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitlisteners.internalConditions.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitqueue.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unitstate.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.vision.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.abilitycallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.buffcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructable.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.destructablebuff.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.eventcallbacks.timeeventcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.fxcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.listenercallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.locationcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.longcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.orderid.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.player.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statbuffcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.statemodcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.stringcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.targetcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.timercallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.visionmodifier.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.widget.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.ability.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.comparison.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.game.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.item.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.logical.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.numeric.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.timer.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.condition.unit.*; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.typeadapters.RuntimeTypeAdapterFactory; - -@SuppressWarnings({ "unchecked", "rawtypes" }) -public abstract class AbilityBuilderGsonBuilder { - - private static void registerAbilityCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetStoredAbilityByKey.class, "getStoredAbilityByKey") - .registerSubtype(ABCallbackGetPartnerAbility.class, "getPartnerAbility") - .registerSubtype(ABCallbackGetReactionAbility.class, "getReactionAbility") - .registerSubtype(ABCallbackGetLastCreatedAbility.class, "getLastCreatedAbility"); - } - - private static void registerAbilityEffectReactionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedAbilityEffectReactionListener.class, - "getLastCreatedAbilityEffectReactionListener") - .registerSubtype(ABCallbackGetStoredAbilityEffectReactionListenerByKey.class, - "getStoredAbilityEffectReactionListenerByKey"); - } - - private static void registerAbilityProjReactionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedAbilityProjReactionListener.class, - "getLastCreatedAbilityProjReactionListener") - .registerSubtype(ABCallbackGetStoredAbilityProjReactionListenerByKey.class, - "getStoredAbilityProjReactionListenerByKey"); - } - - private static void registerAttackProjReactionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedAttackProjReactionListener.class, - "getLastCreatedAttackProjReactionListener") - .registerSubtype(ABCallbackGetStoredAttackProjReactionListenerByKey.class, - "getStoredAttackProjReactionListenerByKey"); - } - - private static void registerAttackPostDamageListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedAttackPostDamageListener.class, - "getLastCreatedAttackPostDamageListener") - .registerSubtype(ABCallbackGetStoredAttackPostDamageListenerByKey.class, - "getStoredAttackPostDamageListenerByKey"); - } - - private static void registerAttackPreDamageListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedAttackPreDamageListener.class, - "getLastCreatedAttackPreDamageListener") - .registerSubtype(ABCallbackGetStoredAttackPreDamageListenerByKey.class, - "getStoredAttackPreDamageListenerByKey"); - } - - private static void registerBehaviorChangeListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedBehaviorChangeListener.class, - "getLastCreatedBehaviorChangeListener") - .registerSubtype(ABCallbackGetStoredBehaviorChangeListenerByKey.class, - "getStoredBehaviorChangeListenerByKey"); - } - - private static void registerBooleanCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackRawBoolean.class, "rawBoolean") - .registerSubtype(ABCallbackGetStoredBooleanByKey.class, "getStoredBooleanByKey") - .registerSubtype(ABCallbackGetAbilityDataAsBoolean.class, "getAbilityDataAsBoolean") - .registerSubtype(ABCallbackGetParentAbilityDataAsBoolean.class, "getParentAbilityDataAsBoolean") - .registerSubtype(ABCallbackWasCastingInterrupted.class, "wasCastingInterrupted") - .registerSubtype(ABCallbackIsTriggeringDamageAnAttack.class, "isTriggeringDamageAnAttack") - .registerSubtype(ABCallbackIsTriggeringDamageRanged.class, "isTriggeringDamageRanged") - - .registerSubtype(ABCallbackIsProjectileReflected.class, "isProjectileReflected") - - .registerSubtype(ABCallbackIntegerToBoolean.class, "i2b") - ; - } - - private static void registerBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetStoredBuffByKey.class, "getStoredBuffByKey") - .registerSubtype(ABCallbackGetLastCreatedBuff.class, "getLastCreatedBuff"); - } - - private static void registerDamageTakenListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedDamageTakenListener.class, "getLastCreatedDamageTakenListener") - .registerSubtype(ABCallbackGetStoredDamageTakenListenerByKey.class, - "getStoredDamageTakenListenerByKey"); - } - - private static void registerDamageTakenModificationListenerCallbacks( - RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedDamageTakenModificationListener.class, - "getLastCreatedDamageTakenModificationListener") - .registerSubtype(ABCallbackGetStoredDamageTakenModificationListenerByKey.class, - "getStoredDamageTakenModificationListenerByKey"); - } - - private static void registerDeathReplacementEffectCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedDeathReplacement.class, "getLastCreatedDeathReplacement") - .registerSubtype(ABCallbackGetStoredDeathReplacementByKey.class, "getStoredDeathReplacementByKey"); - } - - private static void registerDestructableCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetEnumDestructable.class, "getEnumDestructable") - .registerSubtype(ABCallbackGetProjectileHitDestructable.class, "getProjectileHitDestructable"); - } - - private static void registerDestructableBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedDestructableBuff.class, "getLastCreatedDestructableBuff") - .registerSubtype(ABCallbackGetStoredDestructableBuffByKey.class, "getStoredDestructableBuffByKey"); - } - - private static void registerEvasionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedEvasionListener.class, "getLastCreatedEvasionListener") - .registerSubtype(ABCallbackGetStoredEvasionListenerByKey.class, "getStoredEvasionListenerByKey"); - } - - private static void registerFinalDamageTakenModificationListenerCallbacks( - RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedFinalDamageTakenModificationListener.class, - "getLastCreatedFinalDamageTakenModificationListener") - .registerSubtype(ABCallbackGetStoredFinalDamageTakenModificationListenerByKey.class, - "getStoredFinalDamageTakenModificationListenerByKey"); - } - - private static void registerFloatCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetAbilityArea.class, "getAbilityArea") - .registerSubtype(ABCallbackGetAbilityDuration.class, "getAbilityDuration") - .registerSubtype(ABCallbackGetAbilityCastTime.class, "getAbilityCastTime") - .registerSubtype(ABCallbackGetAbilityCastRange.class, "getAbilityCastRange") - .registerSubtype(ABCallbackGetAbilityHeroDuration.class, "getAbilityHeroDuration") - .registerSubtype(ABCallbackGetAbilityCooldown.class, "getAbilityCooldown") - - .registerSubtype(ABCallbackRawFloat.class, "rawFloat") - .registerSubtype(ABCallbackIntToFloat.class, "i2f") - .registerSubtype(ABCallbackNegativeFloat.class, "negativeFloat") - .registerSubtype(ABCallbackPi.class, "pi").registerSubtype(ABCallbackCos.class, "cos") - .registerSubtype(ABCallbackSin.class, "sin") - - .registerSubtype(ABCallbackFMaxValue.class, "fMaxValue") - - .registerSubtype(ABCallbackGetStoredFloatByKey.class, "getStoredFloatByKey") - .registerSubtype(ABCallbackGetAbilityDataAsFloat.class, "getAbilityDataAsFloat") - .registerSubtype(ABCallbackGetParentAbilityDataAsFloat.class, "getParentAbilityDataAsFloat") - .registerSubtype(ABCallbackRandomFloat.class, "randomFloat") - .registerSubtype(ABCallbackRandomBoundedFloat.class, "randomBoundedFloat") - .registerSubtype(ABCallbackGetUnitLocationX.class, "getUnitLocationX") - .registerSubtype(ABCallbackGetUnitLocationY.class, "getUnitLocationY") - .registerSubtype(ABCallbackGetLocationX.class, "getLocationX") - .registerSubtype(ABCallbackGetLocationY.class, "getLocationY") - .registerSubtype(ABCallbackGetUnitFacing.class, "getUnitFacing") - .registerSubtype(ABCallbackGetUnitAcquisitionRange.class, "getUnitAcquisitionRange") - .registerSubtype(ABCallbackGetUnitCastPoint.class, "getUnitCastPoint") - .registerSubtype(ABCallbackGetUnitCurrentMana.class, "getUnitCurrentMana") - .registerSubtype(ABCallbackGetUnitInitialMana.class, "getUnitInitialMana") - .registerSubtype(ABCallbackGetUnitCurrentHp.class, "getUnitCurrentHp") - - .registerSubtype(ABCallbackGetAngleBetweenLocations.class, "getAngleBetweenLocations") - .registerSubtype(ABCallbackGetDistanceBetweenLocations.class, "getDistanceBetweenLocations") - .registerSubtype(ABCallbackTicksForDuration.class, "ticksForDuration") - - .registerSubtype(ABCallbackGetTotalDamageDealt.class, "getTotalDamageDealt") - .registerSubtype(ABCallbackGetReactionAttackProjectileDamage.class, "getReactionAttackProjectileDamage") - - ; - } - - private static void registerGenericFloatCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackAddFloat.class, "f+") - .registerSubtype(ABCallbackSubtractFloat.class, "f-") - .registerSubtype(ABCallbackMultiplyFloat.class, "f*") - .registerSubtype(ABCallbackDivideFloat.class, "f/") - .registerSubtype(ABCallbackMinFloat.class, "fMin") - .registerSubtype(ABCallbackMaxFloat.class, "fMax") - .registerSubtype(ABCallbackCeilFloat.class, "ceil") - .registerSubtype(ABCallbackFloorFloat.class, "floor"); - } - - private static void registerSpecialFloatCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackAddFloat.class, "f+") - .registerSubtype(ABCallbackSubtractFloat.class, "f-").registerSubtype(ABCallbackMultiplyFloat.class, "f*") - .registerSubtype(ABCallbackDivideFloat.class, "f/") - .registerSubtype(ABCallbackMinFloat.class, "fMin").registerSubtype(ABCallbackMaxFloat.class, "fMax") - .registerSubtype(ABCallbackCeilFloat.class, "ceil") - .registerSubtype(ABCallbackFloorFloat.class, "floor"); - } - - private static void registerFxCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedSpellEffect.class, "getLastCreatedSpellEffect") - .registerSubtype(ABCallbackGetStoredFXByKey.class, "getStoredFXByKey"); - } - - private static void registerIdCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetStoredIDByKey.class, "getStoredIDByKey") - .registerSubtype(ABCallbackGetAbilityDataAsID.class, "getAbilityDataAsID") - .registerSubtype(ABCallbackGetAbilityUnitId.class, "getAbilityUnitId") - .registerSubtype(ABCallbackGetWar3IDFromString.class, "getWar3IDFromString") - .registerSubtype(ABCallbackGetAlias.class, "getAlias") - .registerSubtype(ABCallbackGetParentAlias.class, "getParentAlias") - .registerSubtype(ABCallbackGetFirstBuffId.class, "getFirstBuffId") - .registerSubtype(ABCallbackGetSecondBuffId.class, "getSecondBuffId") - .registerSubtype(ABCallbackGetFirstEffectId.class, "getFirstEffectId") - - .registerSubtype(ABCallbackGetUnitType.class, "getUnitType") - .registerSubtype(ABCallbackGetNonCurrentTransformType.class, "getNonCurrentTransformType") - - .registerSubtype(ABCallbackNullIfFalse.class, "nullIfFalse"); - } - - private static void registerIntegerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackRawInteger.class, "rawInteger") - .registerSubtype(ABCallbackGetStoredIntegerByKey.class, "getStoredIntegerByKey") - .registerSubtype(ABCallbackIterator.class, "iterator") - - .registerSubtype(ABCallbackGetAbilityDataAsInteger.class, "getAbilityDataAsInteger") - .registerSubtype(ABCallbackGetAbilityManaCost.class, "getAbilityManaCost") - .registerSubtype(ABCallbackGetAbilityCastTimeAsInteger.class, "getAbilityCastTimeAsInteger") - .registerSubtype(ABCallbackGetAbilityTargetAttachmentPoints.class, "getAbilityTargetAttachmentPoints") - - .registerSubtype(ABCallbackCountUnitsInRangeOfUnit.class, "countUnitsInRangeOfUnit") - .registerSubtype(ABCallbackCountUnitsInRangeOfLocation.class, "countUnitsInRangeOfLocation") - .registerSubtype(ABCallbackGetSpellLevel.class, "getSpellLevel") - .registerSubtype(ABCallbackGetProjectileUnitTargets.class, "getProjectileUnitTargets") - .registerSubtype(ABCallbackGetProjectileDestructableTargets.class, "getProjectileDestructableTargets") - - .registerSubtype(ABCallbackGetUnitTypeGoldCost.class, "getUnitTypeGoldCost") - .registerSubtype(ABCallbackGetUnitTypeLumberCost.class, "getUnitTypeLumberCost") - .registerSubtype(ABCallbackGetUnitTypeFoodCost.class, "getUnitTypeFoodCost") - - .registerSubtype(ABCallbackAddInteger.class, "i+") - .registerSubtype(ABCallbackSubtractInteger.class, "i-") - .registerSubtype(ABCallbackMultiplyInteger.class, "i*") - .registerSubtype(ABCallbackDivideInteger.class, "i/") - .registerSubtype(ABCallbackAndInteger.class, "i&") - .registerSubtype(ABCallbackOrInteger.class, "i|") - .registerSubtype(ABCallbackMinInteger.class, "iMin") - .registerSubtype(ABCallbackMaxInteger.class, "iMax") - - .registerSubtype(ABCallbackIntegerIf.class, "iIf") - .registerSubtype(ABCallbackIntegerZeroIfFalse.class, "i0IfFalse") - - .registerSubtype(ABCallbackGetUnitGroupSize.class, "getUnitGroupSize") - .registerSubtype(ABCallbackGetUnitQueueSize.class, "getUnitQueueSize") - - .registerSubtype(ABCallbackGetPlayerId.class, "getPlayerId") - - .registerSubtype(ABCallbackPlayerToStateModValue.class, "playerToStateModValue") - .registerSubtype(ABCallbackDetectionDropdownConversion.class, "detectionDropdownConversion"); - } - - private static void registerLightningCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedLightningEffect.class, "getLastCreatedLightningEffect") - .registerSubtype(ABCallbackGetStoredLightningByKey.class, "getStoredLightningByKey"); - } - - private static void registerLocationCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackCreateLocationFromXY.class, "createLocationFromXY") - .registerSubtype(ABCallbackCreateLocationFromOffset.class, "createLocationFromOffset") - .registerSubtype(ABCallbackGetStoredLocationByKey.class, "getStoredLocationByKey") - .registerSubtype(ABCallbackGetTargetedLocation.class, "getTargetedLocation") - .registerSubtype(ABCallbackCreateLocationFromTarget.class, "createLocationFromTarget") - .registerSubtype(ABCallbackGetProjectileCurrentLocation.class, "getProjectileCurrentLocation") - .registerSubtype(ABCallbackGetUnitLocation.class, "getUnitLocation"); - } - - private static void registerLongCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackRawLong.class, "rawLong") - .registerSubtype(ABCallbackGetStoredLongByKey.class, "getStoredLongByKey") - - .registerSubtype(ABCallbackAddLong.class, "l+") - .registerSubtype(ABCallbackSubtractLong.class, "l-") - .registerSubtype(ABCallbackMultiplyLong.class, "l*") - .registerSubtype(ABCallbackDivideLong.class, "l/") - .registerSubtype(ABCallbackAndLong.class, "l&") - .registerSubtype(ABCallbackOrLong.class, "l|") - .registerSubtype(ABCallbackMinLong.class, "lMin") - .registerSubtype(ABCallbackMaxLong.class, "lMax") - - .registerSubtype(ABCallbackCreateDetectorData.class, "createDetectorData") - .registerSubtype(ABCallbackCreateDetectedData.class, "createDetectedData"); - } - - private static void registerOrderIdCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackRawID.class, "rawId") - .registerSubtype(ABCallbackIdString.class, "idString"); - } - - private static void registerPlayerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetPlayerById.class, "getPlayerById") - .registerSubtype(ABCallbackGetStoredPlayerByKey.class, "getStoredPlayerByKey") - .registerSubtype(ABCallbackGetOwnerOfUnit.class, "getOwnerOfUnit"); - } - - private static void registerProjectileCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedProjectile.class, "getLastCreatedProjectile") - .registerSubtype(ABCallbackGetStoredProjectileByKey.class, "getStoredProjectileByKey") - .registerSubtype(ABCallbackGetThisProjectile.class, "getThisProjectile") - - - .registerSubtype(ABCallbackGetReactionAttackProjectile.class, "getReactionAttackProjectile") - .registerSubtype(ABCallbackGetReactionAbilityProjectile.class, "getReactionAbilityProjectile") - - ; - } - - private static void registerStatBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedNonStackingStatBuff.class, "getLastCreatedNonStackingStatBuff") - .registerSubtype(ABCallbackGetStoredNonStackingStatBuffByKey.class, - "getStoredNonStackingStatBuffByKey"); - } - - private static void registerStateModBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetLastCreatedStateModBuff.class, "getLastCreatedStateModBuff") - .registerSubtype(ABCallbackGetStoredStateModBuffByKey.class, - "getStoredStateModBuffByKey"); - } - - private static void registerStringCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackRawString.class, "rawString") - .registerSubtype(ABCallbackGetAbilityDataAsString.class, "getAbilityDataAsString") - .registerSubtype(ABCallbackCatStrings.class, "catStrings") - .registerSubtype(ABCallbackGetAliasAsString.class, "getAliasAsString") - .registerSubtype(ABCallbackGetCodeAsString.class, "getCodeAsString") - .registerSubtype(ABCallbackGetUnitHandleAsString.class, "getUnitHandleAsString") - .registerSubtype(ABCallbackGetAllowStackingKey.class, "getAllowStackingKey") - - - - .registerSubtype(ABCallbackBooleanToString.class, "b2s") - .registerSubtype(ABCallbackFloatToString.class, "f2s") - .registerSubtype(ABCallbackIntegerToString.class, "i2s") - .registerSubtype(ABCallbackLongToString.class, "l2s") - ; - } - - private static void registerTargetCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetAbilityTarget.class, "getAbilityTarget") - .registerSubtype(ABCallbackGetNewBehaviorTarget.class, "getNewBehaviorTarget") - .registerSubtype(ABCallbackGetStoredTargetByKey.class, "getStoredTargetByKey"); - } - - private static void registerTimeOfDayEventCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedTimeOfDayEvent.class, "getLastCreatedTimeOfDayEvent") - .registerSubtype(ABCallbackGetStoredTimeOfDayEventByKey.class, "getStoredTimeOfDayEventByKey"); - } - - private static void registerTimerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedTimer.class, "getLastCreatedTimer") - .registerSubtype(ABCallbackGetLastStartedTimer.class, "getLastStartedTimer") - .registerSubtype(ABCallbackGetFiringTimer.class, "getFiringTimer") - .registerSubtype(ABCallbackGetStoredTimerByKey.class, "getStoredTimerByKey"); - } - - private static void registerUnitCallbacks(RuntimeTypeAdapterFactory unitCallbackTypeFactory) { - unitCallbackTypeFactory.registerSubtype(ABCallbackGetCastingUnit.class, "getCastingUnit") - .registerSubtype(ABCallbackGetBuffCastingUnit.class, "getBuffCastingUnit") - .registerSubtype(ABCallbackGetBuffedUnit.class, "getBuffedUnit") - .registerSubtype(ABCallbackGetListenerUnit.class, "getListenerUnit") - .registerSubtype(ABCallbackGetEnumUnit.class, "getEnumUnit") - .registerSubtype(ABCallbackGetMatchingUnit.class, "getMatchingUnit") - .registerSubtype(ABCallbackGetAttackedUnit.class, "getAttackedUnit") - .registerSubtype(ABCallbackGetAttackingUnit.class, "getAttackingUnit") - .registerSubtype(ABCallbackGetDyingUnit.class, "getDyingUnit") - .registerSubtype(ABCallbackGetKillingUnit.class, "getKillingUnit") - .registerSubtype(ABCallbackGetAbilityTargetedUnit.class, "getAbilityTargetedUnit") - .registerSubtype(ABCallbackGetAbilityPairedUnit.class, "getAbilityPairedUnit") - .registerSubtype(ABCallbackGetStoredUnitByKey.class, "getStoredUnitByKey") - .registerSubtype(ABCallbackGetParentCastingUnit.class, "getParentCastingUnit") - .registerSubtype(ABCallbackGetProjectileHitUnit.class, "getProjectileHitUnit") - .registerSubtype(ABCallbackGetLastCreatedUnit.class, "getLastCreatedUnit") - - .registerSubtype(ABCallbackGetReactionAbilityCastingUnit.class, "getReactionAbilityCastingUnit") - .registerSubtype(ABCallbackGetReactionAbilityTargetUnit.class, "getReactionAbilityTargetUnit") - - .registerSubtype(ABCallbackPollUnitQueue.class, "pollUnitQueue") - - .registerSubtype(ABCallbackGetNearestUnitInRangeOfUnit.class, "getNearestUnitInRangeOfUnit") - .registerSubtype(ABCallbackGetNearestCorpseInRangeOfUnit.class, "getNearestCorpseInRangeOfUnit"); - } - - private static void registerUnitGroupCallbacks(RuntimeTypeAdapterFactory unitGroupCallbackTypeFactory) { - unitGroupCallbackTypeFactory.registerSubtype(ABCallbackGetUnitGroupByName.class, "getUnitGroupByName") - .registerSubtype(ABCallbackGetLastCreatedUnitGroup.class, "getLastCreatedUnitGroup"); - } - - private static void registerUnitQueueCallbacks(RuntimeTypeAdapterFactory unitGroupCallbackTypeFactory) { - unitGroupCallbackTypeFactory.registerSubtype(ABCallbackGetUnitQueueByName.class, "getUnitQueueByName") - .registerSubtype(ABCallbackGetLastCreatedUnitQueue.class, "getLastCreatedUnitQueue"); - } - - private static void registerVisionModifierCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetStoredVisionModifierByKey.class, "getStoredVisionModifierByKey") - .registerSubtype(ABCallbackGetLastCreatedVisionModifier.class, "getLastCreatedVisionModifier") - ; - } - - private static void registerWidgetCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { - callbackTypeFactory - .registerSubtype(ABCallbackGetProjectileHitWidget.class, "getProjectileHitWidget") - .registerSubtype(ABCallbackUnitToWidget.class, "unitToWidget") - ; - } - - private static void registerConditions(RuntimeTypeAdapterFactory conditionTypeFactory) { - conditionTypeFactory.registerSubtype(ABConditionAnd.class, "and").registerSubtype(ABConditionOr.class, "or") - .registerSubtype(ABConditionNot.class, "not").registerSubtype(ABConditionBool.class, "bool") - .registerSubtype(ABConditionNotNull.class, "notNull") - - .registerSubtype(ABConditionFloatEqual.class, "f=") - .registerSubtype(ABConditionFloatEq0.class, "f=0") - .registerSubtype(ABConditionFloatGte.class, "f>=") - .registerSubtype(ABConditionFloatGt.class, "f>") - .registerSubtype(ABConditionFloatLte.class, "f<=") - .registerSubtype(ABConditionFloatLt.class, "f<") - .registerSubtype(ABConditionFloatNe.class, "f!=") - .registerSubtype(ABConditionFloatNe0.class, "f!=0") - - .registerSubtype(ABConditionIntegerEq.class, "i=") - .registerSubtype(ABConditionIntegerNe.class, "i!=") - .registerSubtype(ABConditionIntegerGt.class, "i>") - .registerSubtype(ABConditionIntegerGte.class, "i>=") - .registerSubtype(ABConditionIntegerLt.class, "i<") - .registerSubtype(ABConditionIntegerLte.class, "i<=") - .registerSubtype(ABConditionIntegerNe0.class, "i!=0") - .registerSubtype(ABConditionIntegerEq0.class, "i=0") - .registerSubtype(ABConditionIntegerIsOdd.class, "iOdd") - .registerSubtype(ABConditionIntegerIsEven.class, "iEven") - - .registerSubtype(ABConditionSetCantUseReasonOnFailure.class, "setCantUseReasonOnFailure") - - .registerSubtype(ABConditionIsValidTarget.class, "isValidTarget") - .registerSubtype(ABConditionIsUnitValidTarget.class, "isUnitValidTarget") - .registerSubtype(ABConditionIsPassAllAbilityTargetChecks.class, "isPassAllAbilityTargetChecks") - .registerSubtype(ABConditionIsUnitPassAllAbilityTargetChecks.class, "isUnitPassAllAbilityTargetChecks") - .registerSubtype(ABConditionIsDestructableValidTarget.class, "isDestructableValidTarget") - - .registerSubtype(ABConditionIsUnitInRangeOfUnit.class, "isUnitInRangeOfUnit") - .registerSubtype(ABConditionMatchingUnitExistsInRangeOfUnit.class, "matchingUnitExistsInRangeOfUnit") - .registerSubtype(ABConditionMatchingCorpseExistsInRangeOfUnit.class, "matchingCorpseExistsInRangeOfUnit") - - .registerSubtype(ABConditionIsUnitInGroup.class, "isUnitInGroup") - .registerSubtype(ABConditionIsUnitEqual.class, "isUnitEqual") - .registerSubtype(ABConditionIsAttackTypeEqual.class, "isAttackTypeEqual") - .registerSubtype(ABConditionIsDamageTypeEqual.class, "isDamageTypeEqual") - - .registerSubtype(ABConditionIsOnCooldown.class, "isOnCooldown") - .registerSubtype(ABConditionIsFlexAbilityTargeted.class, "isFlexAbilityTargeted") - .registerSubtype(ABConditionIsFlexAbilityNonTargeted.class, "isFlexAbilityNonTargeted") - .registerSubtype(ABConditionIsFlexAbilityPointTarget.class, "isFlexAbilityPointTarget") - .registerSubtype(ABConditionIsFlexAbilityNonPointTarget.class, "isFlexAbilityNonPointTarget") - .registerSubtype(ABConditionIsToggleAbilityActive.class, "isToggleAbilityActive") - .registerSubtype(ABConditionIsTransformingToAlternate.class, "isTransformingToAlternate") - - - .registerSubtype(ABConditionDoesUnitHaveBuff.class, "doesUnitHaveBuff") - .registerSubtype(ABConditionIsUnitMaxHp.class, "isUnitMaxHp") - .registerSubtype(ABConditionIsUnitMaxMp.class, "isUnitMaxMp") - .registerSubtype(ABConditionIsUnitBuilding.class, "isUnitBuilding") - .registerSubtype(ABConditionIsUnitEnemy.class, "isUnitEnemy") - .registerSubtype(ABConditionIsUnitDead.class, "isUnitDead") - .registerSubtype(ABConditionIsUnitTraining.class, "isUnitTraining") - - .registerSubtype(ABConditionIsItemAbility.class, "isItemAbility") - .registerSubtype(ABConditionItemHasCharges.class, "itemHasCharges") - - .registerSubtype(ABConditionIsTimerActive.class, "isTimerActive") - - - .registerSubtype(ABConditionIsTimeOfDayInRange.class, "isTimeOfDayInRange") - .registerSubtype(ABConditionGameplayConstantIsRelativeUpgradeCosts.class, "gameplayConstantIsRelativeUpgradeCosts") - .registerSubtype(ABConditionGameplayConstantIsDefendCanDeflect.class, "gameplayConstantIsDefendCanDeflect") - - - .registerSubtype(ABConditionIsNewBehaviorCategoryInList.class, "isNewBehaviorCategoryInList") - ; - } - - private static void registerActions(RuntimeTypeAdapterFactory factory) { - factory.registerSubtype(ABActionIf.class, "if") - .registerSubtype(ABActionWhile.class, "while") - .registerSubtype(ABActionFor.class, "for") - .registerSubtype(ABActionBreak.class, "break") - .registerSubtype(ABActionIterateUnitsInRangeOfUnit.class, "iterateUnitsInRangeOfUnit") - .registerSubtype(ABActionIterateUnitsInRangeOfUnitMatchingCondition.class, "iterateUnitsInRangeOfUnitMatchingCondition") - .registerSubtype(ABActionIterateUnitsInRangeOfLocation.class, "iterateUnitsInRangeOfLocation") - .registerSubtype(ABActionIterateUnitsInRangeOfLocationMatchingCondition.class, "iterateUnitsInRangeOfLocationMatchingCondition") - .registerSubtype(ABActionIterateUnitsInRect.class, "iterateUnitsInRect") - .registerSubtype(ABActionPeriodicExecute.class, "periodicExecute") - .registerSubtype(ABActionCleanUpCastInstance.class, "cleanUpCastInstance") - - .registerSubtype(ABActionCheckAbilityEffectReaction.class, "checkAbilityEffectReaction") - .registerSubtype(ABActionCheckAbilityProjReaction.class, "checkAbilityProjReaction") - - .registerSubtype(ABActionCreateSpellEffectOnUnit.class, "createSpellEffectOnUnit") - .registerSubtype(ABActionCreateTemporarySpellEffectOnUnit.class, "createTemporarySpellEffectOnUnit") - .registerSubtype(ABActionCreateSpellEffectAtLocation.class, "createSpellEffectAtLocation") - .registerSubtype(ABActionCreateTemporarySpellEffectAtLocation.class, - "createTemporarySpellEffectAtLocation") - .registerSubtype(ABActionCreateSpellEffectAtPoint.class, "createSpellEffectAtPoint") - .registerSubtype(ABActionCreateTemporarySpellEffectAtPoint.class, "createTemporarySpellEffectAtPoint") - .registerSubtype(ABActionCreateSoundEffectOnUnit.class, "createSoundEffectOnUnit") - .registerSubtype(ABActionCreateLoopingSoundEffectOnUnit.class, "createLoopingSoundEffectOnUnit") - .registerSubtype(ABActionCreateLightningEffect.class, "createLightningEffect") - .registerSubtype(ABActionRemoveLightningEffect.class, "removeLightningEffect") - - .registerSubtype(ABActionCreateUnitTargetedProjectile.class, "createUnitTargetedProjectile") - .registerSubtype(ABActionCreateLocationTargetedProjectile.class, "createLocationTargetedProjectile") - .registerSubtype(ABActionCreateUnitTargetedCollisionProjectile.class, "createUnitTargetedCollisionProjectile") - .registerSubtype(ABActionCreateLocationTargetedCollisionProjectile.class, "createLocationTargetedCollisionProjectile") - .registerSubtype(ABActionCreateUnitTargetedPseudoProjectile.class, "createUnitTargetedPseudoProjectile") - .registerSubtype(ABActionCreateLocationTargetedPseudoProjectile.class, "createLocationTargetedPseudoProjectile") - - .registerSubtype(ABActionSetProjectileDone.class, "setProjectileDone") - .registerSubtype(ABActionSetProjectileReflected.class, "setProjectileReflected") - .registerSubtype(ABActionSetProjectileTarget.class, "setProjectileTarget") - .registerSubtype(ABActionSetAttackProjectileDamage.class, "setAttackProjectileDamage") - - - .registerSubtype(ABActionAddAbility.class, "addAbility") - .registerSubtype(ABActionAddNewAbility.class, "addNewAbility") - .registerSubtype(ABActionRemoveAbility.class, "removeAbility") - .registerSubtype(ABActionStoreValueLocally.class, "storeValueLocally") - .registerSubtype(ABActionRemoveSpellEffect.class, "removeSpellEffect") - .registerSubtype(ABActionCreateAbilityFromId.class, "createAbilityFromId") - .registerSubtype(ABActionAddDefenseBonus.class, "addDefenseBonus") - .registerSubtype(ABActionRemoveDefenseBonus.class, "removeDefenseBonus") - .registerSubtype(ABActionAddRallyAbility.class, "addRallyAbility") - - .registerSubtype(ABActionCreateUnitGroup.class, "createUnitGroup") - .registerSubtype(ABActionIterateUnitsInGroup.class, "iterateUnitsInGroup") - .registerSubtype(ABActionAddUnitToGroup.class, "addUnitToGroup") - .registerSubtype(ABActionRemoveUnitFromGroup.class, "removeUnitFromGroup") - - .registerSubtype(ABActionCreateUnitQueue.class, "createUnitQueue") - .registerSubtype(ABActionIterateUnitsInQueue.class, "iterateUnitsInQueue") - .registerSubtype(ABActionAddUnitToQueue.class, "addUnitToQueue") - .registerSubtype(ABActionRemoveUnitFromQueue.class, "removeUnitFromQueue") - .registerSubtype(ABActionClearUnitQueue.class, "clearUnitQueue") - - .registerSubtype(ABActionCreateUnit.class, "createUnit") - .registerSubtype(ABActionDamageTarget.class, "damageTarget").registerSubtype(ABActionHeal.class, "heal") - .registerSubtype(ABActionSetHp.class, "setHp").registerSubtype(ABActionResurrect.class, "resurrect") - .registerSubtype(ABActionSetMp.class, "setMp") - .registerSubtype(ABActionAddMp.class, "addMp") - .registerSubtype(ABActionSubtractMp.class, "subtractMp") - .registerSubtype(ABActionAddStunBuff.class, "addStunBuff") - .registerSubtype(ABActionKillUnit.class, "killUnit") - .registerSubtype(ABActionRemoveUnit.class, "removeUnit") - .registerSubtype(ABActionHideUnit.class, "hideUnit") - .registerSubtype(ABActionUnhideUnit.class, "unhideUnit") - .registerSubtype(ABActionMergeUnits.class, "mergeUnits") - .registerSubtype(ABActionTransformUnit.class, "transformUnit") - .registerSubtype(ABActionTransformUnitInstant.class, "transformUnitInstant") - .registerSubtype(ABActionTransformedUnitAbilityAdd.class, "transformedUnitAbilityAdd") - .registerSubtype(ABActionTransformedUnitAbilityRemove.class, "transformedUnitAbilityRemove") - .registerSubtype(ABActionSetExplodesOnDeath.class, "setExplodesOnDeath") - .registerSubtype(ABActionIssueStopOrder.class, "issueStopOrder") - .registerSubtype(ABActionSendUnitBackToWork.class, "sendUnitBackToWork") - .registerSubtype(ABActionStartTrainingUnit.class, "startTrainingUnit") - .registerSubtype(ABActionStartSacrificingUnit.class, "startSacrificingUnit") - - .registerSubtype(ABActionSetUnitFlyHeight.class, "setUnitFlyHeight") - .registerSubtype(ABActionSetUnitMovementTypeNoCollision.class, "setUnitMovementTypeNoCollision") - - - .registerSubtype(ABActionPlayAnimation.class, "playAnimation") - .registerSubtype(ABActionAddSecondaryAnimationTag.class, "addSecondaryAnimationTag") - .registerSubtype(ABActionRemoveSecondaryAnimationTag.class, "removeSecondaryAnimationTag") - - .registerSubtype(ABActionSetUnitAlpha.class, "setUnitAlpha") - .registerSubtype(ABActionMultiplyUnitAlpha.class, "multiplyUnitAlpha") - .registerSubtype(ABActionDivideUnitAlpha.class, "divideUnitAlpha") - - .registerSubtype(ABActionInstantReturnResources.class, "instantReturnResources") - .registerSubtype(ABActionEnableWorkerAbilities.class, "enableWorkerAbilities") - .registerSubtype(ABActionDisableWorkerAbilities.class, "disableWorkerAbilities") - - - - .registerSubtype(ABActionStartCooldown.class, "startCooldown") - .registerSubtype(ABActionResetCooldown.class, "resetCooldown") - .registerSubtype(ABActionActivateToggledAbility.class, "activateToggledAbility") - .registerSubtype(ABActionDeactivateToggledAbility.class, "deactivateToggledAbility") - .registerSubtype(ABActionBeginChanneling.class, "beginChanneling") - .registerSubtype(ABActionFinishChanneling.class, "finishChanneling") - .registerSubtype(ABActionSetAbilityCastRange.class, "setAbilityCastRange") - .registerSubtype(ABActionAddTargetAllowed.class, "addTargetAllowed") - .registerSubtype(ABActionRemoveTargetAllowed.class, "removeTargetAllowed") - - - .registerSubtype(ABActionCreateTimer.class, "createTimer") - .registerSubtype(ABActionStartTimer.class, "startTimer") - .registerSubtype(ABActionUpdateTimerTimeout.class, "updateTimerTimeout") - .registerSubtype(ABActionRemoveTimer.class, "removeTimer") - - .registerSubtype(ABActionAddBuff.class, "addBuff") - .registerSubtype(ABActionAddNonStackingDisplayBuff.class, "addNonStackingDisplayBuff") - .registerSubtype(ABActionRemoveBuff.class, "removeBuff") - .registerSubtype(ABActionRemoveNonStackingDisplayBuff.class, "removeNonStackingDisplayBuff") - .registerSubtype(ABActionCreatePassiveBuff.class, "createPassiveBuff") - .registerSubtype(ABActionCreateTargetingBuff.class, "createTargetingBuff") - .registerSubtype(ABActionCreateTimedBuff.class, "createTimedBuff") - .registerSubtype(ABActionCreateTimedTargetingBuff.class, "createTimedTargetingBuff") - .registerSubtype(ABActionCreateTimedArtBuff.class, "createTimedArtBuff") - .registerSubtype(ABActionCreateTimedTickingBuff.class, "createTimedTickingBuff") - .registerSubtype(ABActionCreateTimedTickingPausedBuff.class, "createTimedTickingPausedBuff") - .registerSubtype(ABActionCreateTimedTickingPostDeathBuff.class, "createTimedTickingPostDeathBuff") - .registerSubtype(ABActionCreateTimedLifeBuff.class, "createTimedLifeBuff") - - .registerSubtype(ABActionCreateStateModBuff.class, "createStateModBuff") - .registerSubtype(ABActionAddStateModBuff.class, "addStateModBuff") - .registerSubtype(ABActionRemoveStateModBuff.class, "removeStateModBuff") - .registerSubtype(ABActionSetUnitFadeTimer.class, "setUnitFadeTimer") - - .registerSubtype(ABActionCreateNonStackingStatBuff.class, "createNonStackingStatBuff") - .registerSubtype(ABActionAddNonStackingStatBuff.class, "addNonStackingStatBuff") - .registerSubtype(ABActionRemoveNonStackingStatBuff.class, "removeNonStackingStatBuff") - .registerSubtype(ABActionUpdateNonStackingStatBuff.class, "updateNonStackingStatBuff") - .registerSubtype(ABActionRecomputeStatBuffsOnUnit.class, "recomputeStatBuffsOnUnit") - - .registerSubtype(ABActionCreateAttackPostDamageListener.class, "createAttackPostDamageListener") - .registerSubtype(ABActionAddAttackPostDamageListener.class, "addAttackPostDamageListener") - .registerSubtype(ABActionRemoveAttackPostDamageListener.class, "removeAttackPostDamageListener") - .registerSubtype(ABActionCreateAttackPreDamageListener.class, "createAttackPreDamageListener") - .registerSubtype(ABActionAddAttackPreDamageListener.class, "addAttackPreDamageListener") - .registerSubtype(ABActionRemoveAttackPreDamageListener.class, "removeAttackPreDamageListener") - .registerSubtype(ABActionCreateDamageTakenListener.class, "createDamageTakenListener") - .registerSubtype(ABActionAddDamageTakenListener.class, "addDamageTakenListener") - .registerSubtype(ABActionRemoveDamageTakenListener.class, "removeDamageTakenListener") - .registerSubtype(ABActionCreateDamageTakenModificationListener.class, - "createDamageTakenModificationListener") - .registerSubtype(ABActionAddDamageTakenModificationListener.class, "addDamageTakenModificationListener") - .registerSubtype(ABActionRemoveDamageTakenModificationListener.class, - "removeDamageTakenModificationListener") - .registerSubtype(ABActionCreateFinalDamageTakenModificationListener.class, - "createFinalDamageTakenModificationListener") - .registerSubtype(ABActionAddFinalDamageTakenModificationListener.class, "addFinalDamageTakenModificationListener") - .registerSubtype(ABActionRemoveFinalDamageTakenModificationListener.class, - "removeFinalDamageTakenModificationListener") - .registerSubtype(ABActionCreateEvasionListener.class, "createEvasionListener") - .registerSubtype(ABActionAddEvasionListener.class, "addEvasionListener") - .registerSubtype(ABActionRemoveEvasionListener.class, "removeEvasionListener") - .registerSubtype(ABActionCreateDeathReplacementEffect.class, "createDeathReplacementEffect") - .registerSubtype(ABActionAddDeathReplacementEffect.class, "addDeathReplacementEffect") - .registerSubtype(ABActionRemoveDeathReplacementEffect.class, "removeDeathReplacementEffect") - .registerSubtype(ABActionCreateBehaviorChangeListener.class, "createBehaviorChangeListener") - .registerSubtype(ABActionAddBehaviorChangeListener.class, "addBehaviorChangeListener") - .registerSubtype(ABActionRemoveBehaviorChangeListener.class, "removeBehaviorChangeListener") - - .registerSubtype(ABActionCreateAbilityEffectReactionListener.class, "createAbilityEffectReactionListener") - .registerSubtype(ABActionAddAbilityEffectReactionListener.class, "addAbilityEffectReactionListener") - .registerSubtype(ABActionRemoveAbilityEffectReactionListener.class, "removeAbilityEffectReactionListener") - .registerSubtype(ABActionCreateAbilityProjReactionListener.class, "createAbilityProjReactionListener") - .registerSubtype(ABActionAddAbilityProjReactionListener.class, "addAbilityProjReactionListener") - .registerSubtype(ABActionRemoveAbilityProjReactionListener.class, "removeAbilityProjReactionListener") - .registerSubtype(ABActionCreateAttackProjReactionListener.class, "createAttackProjReactionListener") - .registerSubtype(ABActionAddAttackProjReactionListener.class, "addAttackProjReactionListener") - .registerSubtype(ABActionRemoveAttackProjReactionListener.class, "removeAttackProjReactionListener") - - .registerSubtype(ABActionDamageTakenModificationSetDamageMultiplier.class, "setDamageTakenMultiplier") - .registerSubtype(ABActionDamageTakenModificationMultiplyDamageMultiplier.class, - "multiplyDamageTakenMultiplier") - .registerSubtype(ABActionPreDamageListenerAddDamageMultiplier.class, "addDamageDealtMultiplier") - .registerSubtype(ABActionPreDamageListenerAddBonusDamage.class, "addBonusDamageDealt") - .registerSubtype(ABActionPreDamageListenerSetMiss.class, "preDamageListenerSetMiss") - .registerSubtype(ABActionSetPreDamageStacking.class, "setStacking") - .registerSubtype(ABActionDeathReplacementSetReviving.class, "setReviving") - .registerSubtype(ABActionDeathReplacementSetReincarnating.class, "setReincarnating") - .registerSubtype(ABActionDeathReplacementFinishReincarnating.class, "finishReincarnating") - .registerSubtype(ABActionSubtractTotalDamageDealt.class, "subtractTotalDamageDealt") - .registerSubtype(ABActionReactionPreventHit.class, "reactionPreventHit") - - .registerSubtype(ABActionAddDestructableBuff.class, "addDestructableBuff") - .registerSubtype(ABActionCreateDestructableBuff.class, "createDestructableBuff") - .registerSubtype(ABActionRemoveDestructableBuff.class, "removeDestructableBuff") - .registerSubtype(ABActionIterateDestructablesInRangeOfLocation.class, "iterateDestructablesInRangeOfLocation") - .registerSubtype(ABActionDamageDestructable.class, "damageDestructable") - - .registerSubtype(ABActionCreateFloatingTextOnUnit.class, "createFloatingTextOnUnit") - .registerSubtype(ABActionCreateNumericFloatingTextOnUnit.class, "createNumericFloatingTextOnUnit") - - .registerSubtype(ABActionSetAutoTargetUnit.class, "setAutoTargetUnit") - .registerSubtype(ABActionSetAutoTargetDestructable.class, "setAutoTargetDestructable") - - - - .registerSubtype(ABActionChargeItem.class, "chargeItem") - - - - - .registerSubtype(ABActionGiveResourcesToPlayer.class, "giveResourcesToPlayer") - .registerSubtype(ABActionSetAbilityEnabledForPlayer.class, "setAbilityEnabledForPlayer") - - .registerSubtype(ABActionCreateUnitVisionModifier.class, "createUnitVisionModifier") - .registerSubtype(ABActionCreateLocationVisionModifier.class, "createLocationVisionModifier") - .registerSubtype(ABActionRemoveVisionModifier.class, "removeVisionModifier") - .registerSubtype(ABActionSetBurrowPlaceholder.class, "setBurrowPlaceholder") - - - - - .registerSubtype(ABActionCreateTimeOfDayEvent.class, "createTimeOfDayEvent") - .registerSubtype(ABActionRegisterTimeOfDayEvent.class, "registerTimeOfDayEvent") - .registerSubtype(ABActionRegisterUniqueTimeOfDayEvent.class, "registerUniqueTimeOfDayEvent") - .registerSubtype(ABActionUnregisterTimeOfDayEvent.class, "unregisterTimeOfDayEvent") - - - - .registerSubtype(ABActionCreateSubroutine.class, "createSubroutine") - .registerSubtype(ABActionRunSubroutine.class, "runSubroutine") - - .registerSubtype(ABActionSetFalseTimeOfDay.class, "setFalseTimeOfDay") - ; - } - - public static Gson create() { - GsonBuilder gsonBuilder = new GsonBuilder(); - - final RuntimeTypeAdapterFactory actionTypeFactory = RuntimeTypeAdapterFactory.of(ABAction.class, - "type"); - registerActions(actionTypeFactory); - gsonBuilder.registerTypeAdapterFactory(actionTypeFactory); - - final RuntimeTypeAdapterFactory callbackTypeFactory = RuntimeTypeAdapterFactory.of(ABCallback.class, - "type"); - registerAbilityCallbacks(callbackTypeFactory); - registerAbilityEffectReactionListenerCallbacks(callbackTypeFactory); - registerAbilityProjReactionListenerCallbacks(callbackTypeFactory); - registerAttackProjReactionListenerCallbacks(callbackTypeFactory); - registerAttackPostDamageListenerCallbacks(callbackTypeFactory); - registerAttackPreDamageListenerCallbacks(callbackTypeFactory); - registerBehaviorChangeListenerCallbacks(callbackTypeFactory); - registerBooleanCallbacks(callbackTypeFactory); - registerBuffCallbacks(callbackTypeFactory); - registerDamageTakenListenerCallbacks(callbackTypeFactory); - registerDamageTakenModificationListenerCallbacks(callbackTypeFactory); - registerDeathReplacementEffectCallbacks(callbackTypeFactory); - registerDestructableCallbacks(callbackTypeFactory); - registerDestructableBuffCallbacks(callbackTypeFactory); - registerEvasionListenerCallbacks(callbackTypeFactory); - registerFinalDamageTakenModificationListenerCallbacks(callbackTypeFactory); - registerFloatCallbacks(callbackTypeFactory); - registerGenericFloatCallbacks(callbackTypeFactory); - registerFxCallbacks(callbackTypeFactory); - registerIdCallbacks(callbackTypeFactory); - registerIntegerCallbacks(callbackTypeFactory); - registerLightningCallbacks(callbackTypeFactory); - registerLocationCallbacks(callbackTypeFactory); - registerLongCallbacks(callbackTypeFactory); - registerOrderIdCallbacks(callbackTypeFactory); - registerPlayerCallbacks(callbackTypeFactory); - registerProjectileCallbacks(callbackTypeFactory); - registerStatBuffCallbacks(callbackTypeFactory); - registerStateModBuffCallbacks(callbackTypeFactory); - registerStringCallbacks(callbackTypeFactory); - registerTargetCallbacks(callbackTypeFactory); - registerTimeOfDayEventCallbacks(callbackTypeFactory); - registerTimerCallbacks(callbackTypeFactory); - registerUnitCallbacks(callbackTypeFactory); - registerUnitGroupCallbacks(callbackTypeFactory); - registerUnitQueueCallbacks(callbackTypeFactory); - registerVisionModifierCallbacks(callbackTypeFactory); - registerWidgetCallbacks(callbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(callbackTypeFactory); - - final RuntimeTypeAdapterFactory abilityCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABAbilityCallback.class, "type"); - registerAbilityCallbacks(abilityCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(abilityCallbackTypeFactory); - - final RuntimeTypeAdapterFactory abilityEffectReactionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABAbilityEffectReactionListenerCallback.class, "type"); - registerAbilityEffectReactionListenerCallbacks(abilityEffectReactionListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(abilityEffectReactionListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory abilityProjReactionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABAbilityProjReactionListenerCallback.class, "type"); - registerAbilityProjReactionListenerCallbacks(abilityProjReactionListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(abilityProjReactionListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory attackProjReactionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABAttackProjReactionListenerCallback.class, "type"); - registerAttackProjReactionListenerCallbacks(attackProjReactionListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(attackProjReactionListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory attackPostDamageListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABAttackPostDamageListenerCallback.class, "type"); - registerAttackPostDamageListenerCallbacks(attackPostDamageListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(attackPostDamageListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory attackPreDamageListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABAttackPreDamageListenerCallback.class, "type"); - registerAttackPreDamageListenerCallbacks(attackPreDamageListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(attackPreDamageListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory behaviorChangeListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABBehaviorChangeListenerCallback.class, "type"); - registerBehaviorChangeListenerCallbacks(behaviorChangeListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(behaviorChangeListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory booleanCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABBooleanCallback.class, "type"); - registerBooleanCallbacks(booleanCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(booleanCallbackTypeFactory); - - final RuntimeTypeAdapterFactory buffCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABBuffCallback.class, "type"); - registerBuffCallbacks(buffCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(buffCallbackTypeFactory); - - final RuntimeTypeAdapterFactory damageTakenListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABDamageTakenListenerCallback.class, "type"); - registerDamageTakenListenerCallbacks(damageTakenListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(damageTakenListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory damageTakenModificationListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABDamageTakenModificationListenerCallback.class, "type"); - registerDamageTakenModificationListenerCallbacks(damageTakenModificationListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(damageTakenModificationListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory deathReplacementEffectCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABDeathReplacementCallback.class, "type"); - registerDeathReplacementEffectCallbacks(deathReplacementEffectCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(deathReplacementEffectCallbackTypeFactory); - - final RuntimeTypeAdapterFactory destructableCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABDestructableCallback.class, "type"); - registerDestructableCallbacks(destructableCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(destructableCallbackTypeFactory); - - final RuntimeTypeAdapterFactory destructableBuffCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABDestructableBuffCallback.class, "type"); - registerDestructableBuffCallbacks(destructableBuffCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(destructableBuffCallbackTypeFactory); - - final RuntimeTypeAdapterFactory evasionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABEvasionListenerCallback.class, "type"); - registerEvasionListenerCallbacks(evasionListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(evasionListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory finalDamageTakenModificationListenerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABFinalDamageTakenModificationListenerCallback.class, "type"); - registerFinalDamageTakenModificationListenerCallbacks(finalDamageTakenModificationListenerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(finalDamageTakenModificationListenerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory floatCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABFloatCallback.class, "type"); - registerFloatCallbacks(floatCallbackTypeFactory); - registerSpecialFloatCallbacks(floatCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(floatCallbackTypeFactory); - - final RuntimeTypeAdapterFactory fxCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABFXCallback.class, "type"); - registerFxCallbacks(fxCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(fxCallbackTypeFactory); - - final RuntimeTypeAdapterFactory idCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABIDCallback.class, "type"); - registerIdCallbacks(idCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(idCallbackTypeFactory); - - final RuntimeTypeAdapterFactory integerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABIntegerCallback.class, "type"); - registerIntegerCallbacks(integerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(integerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory lightningCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABLightningCallback.class, "type"); - registerLightningCallbacks(lightningCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(lightningCallbackTypeFactory); - - final RuntimeTypeAdapterFactory locationCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABLocationCallback.class, "type"); - registerLocationCallbacks(locationCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(locationCallbackTypeFactory); - - final RuntimeTypeAdapterFactory longCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABLongCallback.class, "type"); - registerLongCallbacks(longCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(longCallbackTypeFactory); - - final RuntimeTypeAdapterFactory orderIdCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABOrderIdCallback.class, "type"); - registerOrderIdCallbacks(orderIdCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(orderIdCallbackTypeFactory); - - - final RuntimeTypeAdapterFactory playerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABPlayerCallback.class, "type"); - registerPlayerCallbacks(playerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(playerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory projectileCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABProjectileCallback.class, "type"); - registerProjectileCallbacks(projectileCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(projectileCallbackTypeFactory); - - final RuntimeTypeAdapterFactory statBuffCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABNonStackingStatBuffCallback.class, "type"); - registerStatBuffCallbacks(statBuffCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(statBuffCallbackTypeFactory); - - final RuntimeTypeAdapterFactory stateModBuffCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABStateModBuffCallback.class, "type"); - registerStateModBuffCallbacks(stateModBuffCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(stateModBuffCallbackTypeFactory); - - final RuntimeTypeAdapterFactory stringCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABStringCallback.class, "type"); - registerStringCallbacks(stringCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(stringCallbackTypeFactory); - - final RuntimeTypeAdapterFactory targetCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABTargetCallback.class, "type"); - registerTargetCallbacks(targetCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(targetCallbackTypeFactory); - - final RuntimeTypeAdapterFactory timeOfDayEventCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABTimeOfDayEventCallback.class, "type"); - registerTimeOfDayEventCallbacks(timeOfDayEventCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(timeOfDayEventCallbackTypeFactory); - - final RuntimeTypeAdapterFactory timerCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABTimerCallback.class, "type"); - registerTimerCallbacks(timerCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(timerCallbackTypeFactory); - - final RuntimeTypeAdapterFactory unitCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABUnitCallback.class, "type"); - registerUnitCallbacks(unitCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(unitCallbackTypeFactory); - - final RuntimeTypeAdapterFactory unitGroupCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABUnitGroupCallback.class, "type"); - registerUnitGroupCallbacks(unitGroupCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(unitGroupCallbackTypeFactory); - - final RuntimeTypeAdapterFactory unitQueueCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABUnitQueueCallback.class, "type"); - registerUnitQueueCallbacks(unitQueueCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(unitQueueCallbackTypeFactory); - - final RuntimeTypeAdapterFactory visionModifierCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABVisionModifierCallback.class, "type"); - registerVisionModifierCallbacks(visionModifierCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(visionModifierCallbackTypeFactory); - - - final RuntimeTypeAdapterFactory widgetCallbackTypeFactory = RuntimeTypeAdapterFactory - .of(ABWidgetCallback.class, "type"); - registerWidgetCallbacks(widgetCallbackTypeFactory); - gsonBuilder.registerTypeAdapterFactory(widgetCallbackTypeFactory); - - final RuntimeTypeAdapterFactory conditionTypeFactory = RuntimeTypeAdapterFactory - .of(ABCondition.class, "type"); - registerConditions(conditionTypeFactory); - gsonBuilder.registerTypeAdapterFactory(conditionTypeFactory); - - // ENUM CALLBACKS - final RuntimeTypeAdapterFactory nssbtTypeFactory = RuntimeTypeAdapterFactory - .of(ABNonStackingStatBuffTypeCallback.class, "type"); - nssbtTypeFactory.registerSubtype(ABCallbackGetNonStackingStatBuffTypeFromString.class, - "getNonStackingStatBuffTypeFromString"); - gsonBuilder.registerTypeAdapterFactory(nssbtTypeFactory); - - final RuntimeTypeAdapterFactory atTypeFactory = RuntimeTypeAdapterFactory - .of(ABAttackTypeCallback.class, "type"); - atTypeFactory.registerSubtype(ABCallbackGetAttackTypeFromString.class, "getAttackTypeFromString") - .registerSubtype(ABCallbackGetTriggeringAttackType.class, "getTriggeringAttackType") - .registerSubtype(ABCallbackGetReactionAttackProjectileAttackType.class, "getReactionAttackProjectileAttackType"); - gsonBuilder.registerTypeAdapterFactory(atTypeFactory); - - final RuntimeTypeAdapterFactory dtTypeFactory = RuntimeTypeAdapterFactory - .of(ABDamageTypeCallback.class, "type"); - dtTypeFactory.registerSubtype(ABCallbackGetDamageTypeFromString.class, "getDamageTypeFromString") - .registerSubtype(ABCallbackGetTriggeringDamageType.class, "getTriggeringDamageType"); - gsonBuilder.registerTypeAdapterFactory(dtTypeFactory); - - final RuntimeTypeAdapterFactory pdlpTypeFactory = RuntimeTypeAdapterFactory - .of(ABAttackPreDamageListenerPriorityCallback.class, "type"); - pdlpTypeFactory.registerSubtype(ABCallbackRawPreDamageListenerPriority.class, "rawPriority"); - gsonBuilder.registerTypeAdapterFactory(pdlpTypeFactory); - - final RuntimeTypeAdapterFactory drepTypeFactory = RuntimeTypeAdapterFactory - .of(ABDeathReplacementPriorityCallback.class, "type"); - drepTypeFactory.registerSubtype(ABCallbackRawDeathEffectPriority.class, "rawPriority"); - gsonBuilder.registerTypeAdapterFactory(drepTypeFactory); - - final RuntimeTypeAdapterFactory autocastTypeFactory = RuntimeTypeAdapterFactory - .of(ABAutocastTypeCallback.class, "type"); - autocastTypeFactory.registerSubtype(ABCallbackConditionalAutocastType.class, - "conditionalAutocastType"); - autocastTypeFactory.registerSubtype(ABCallbackGetAutocastTypeFromString.class, - "getAutocastTypeFromString"); - gsonBuilder.registerTypeAdapterFactory(autocastTypeFactory); - - - return gsonBuilder.create(); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABGlobalWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABGlobalWidgetEvent.java deleted file mode 100644 index 52a6dea62..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABGlobalWidgetEvent.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event; - -import java.util.List; -import java.util.Map; - -import com.etheller.interpreter.ast.scope.TriggerExecutionScope; -import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CGlobalWidgetEvent; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; - -public class ABGlobalWidgetEvent extends CGlobalWidgetEvent { - - private CSimulation game; - private CUnit caster; - private Map localStore; - private int castId; - - private ABCondition condition; - private List actions; - - public ABGlobalWidgetEvent(CSimulation game, CUnit caster, Map localStore, int castId, - CWidget widget, JassGameEventsWar3 eventType, ABCondition condition, List actions) { - super(game, game.getGlobalScope(), null, eventType, null); - this.game = game; - this.caster = caster; - this.localStore = localStore; - this.castId = castId; - - this.condition = condition; - this.actions = actions; - } - - @Override - public void fire(final CWidget triggerWidget, final TriggerExecutionScope scope) { - if (condition == null || condition.evaluate(game, caster, localStore, castId)) { - if (scope instanceof CommonTriggerExecutionScope) { - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDUNIT + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetUnit()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDLOCATION + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetPoint()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDITEM + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetItem()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetDestructable()); - this.localStore.put(ABLocalStoreKeys.EVENTCASTINGUNIT + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbilityUnit()); - this.localStore.put(ABLocalStoreKeys.EVENTABILITYID + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbilityId()); - this.localStore.put(ABLocalStoreKeys.EVENTABILITY + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbility()); - } - if (actions != null) { - for (ABAction action : actions) { - action.runAction(game, caster, localStore, castId); - } - } - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDLOCATION + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDITEM + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTCASTINGUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTABILITYID + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTABILITY + castId); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABPlayerEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABPlayerEvent.java deleted file mode 100644 index 9fd35212e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABPlayerEvent.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event; - -import java.util.List; -import java.util.Map; - -import com.etheller.interpreter.ast.scope.TriggerExecutionScope; -import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayerEvent; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayerJass; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; - -public class ABPlayerEvent extends CPlayerEvent { - - private CSimulation game; - private CUnit caster; - private Map localStore; - private int castId; - - private ABCondition condition; - private List actions; - - public ABPlayerEvent(CSimulation game, CUnit caster, Map localStore, int castId, CPlayerJass player, - JassGameEventsWar3 eventType, ABCondition condition, List actions) { - super(game.getGlobalScope(), player, null, eventType, null); - this.game = game; - this.caster = caster; - this.localStore = localStore; - this.castId = castId; - - this.condition = condition; - this.actions = actions; - } - - public void fire(final CUnit hero, final TriggerExecutionScope scope) { - if (condition == null || condition.evaluate(game, caster, localStore, castId)) { - if (scope instanceof CommonTriggerExecutionScope) { - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDUNIT + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetUnit()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDLOCATION + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetPoint()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDITEM + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetItem()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetDestructable()); - this.localStore.put(ABLocalStoreKeys.EVENTCASTINGUNIT + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbilityUnit()); - this.localStore.put(ABLocalStoreKeys.EVENTABILITYID + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbilityId()); - this.localStore.put(ABLocalStoreKeys.EVENTABILITY + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbility()); - } - if (actions != null) { - for (ABAction action : actions) { - action.runAction(game, caster, localStore, castId); - } - } - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDLOCATION + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDITEM + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTCASTINGUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTABILITYID + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTABILITY + castId); - } - } - - public void fire(final CPlayer player, final TriggerExecutionScope scope) { - if (condition == null || condition.evaluate(game, caster, localStore, castId)) { - if (actions != null) { - for (ABAction action : actions) { - action.runAction(game, caster, localStore, castId); - } - } - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABWidgetEvent.java deleted file mode 100644 index bac842515..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABWidgetEvent.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event; - -import java.util.List; -import java.util.Map; - -import com.etheller.interpreter.ast.scope.TriggerExecutionScope; -import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CWidgetEvent; - -public class ABWidgetEvent extends CWidgetEvent { - - private CSimulation game; - private CUnit caster; - private Map localStore; - private int castId; - - private ABCondition condition; - private List actions; - - public ABWidgetEvent(CSimulation game, CUnit caster, Map localStore, int castId, CWidget widget, - JassGameEventsWar3 eventType, ABCondition condition, List actions) { - super(game.getGlobalScope(), widget, null, eventType, null); - this.game = game; - this.caster = caster; - this.localStore = localStore; - this.castId = castId; - - this.condition = condition; - this.actions = actions; - } - - @Override - public void fire(final CWidget triggerWidget, final TriggerExecutionScope scope) { - if (condition == null || condition.evaluate(game, caster, localStore, castId)) { - if (scope instanceof CommonTriggerExecutionScope) { - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDUNIT + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetUnit()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDLOCATION + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetPoint()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDITEM + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetItem()); - this.localStore.put(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE + castId, - ((CommonTriggerExecutionScope) scope).getSpellTargetDestructable()); - this.localStore.put(ABLocalStoreKeys.EVENTCASTINGUNIT + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbilityUnit()); - this.localStore.put(ABLocalStoreKeys.EVENTABILITYID + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbilityId()); - this.localStore.put(ABLocalStoreKeys.EVENTABILITY + castId, - ((CommonTriggerExecutionScope) scope).getSpellAbility()); - } - if (actions != null) { - for (ABAction action : actions) { - action.runAction(game, caster, localStore, castId); - } - } - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDLOCATION + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDITEM + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTCASTINGUNIT + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTABILITYID + castId); - this.localStore.remove(ABLocalStoreKeys.EVENTABILITY + castId); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/handler/TransformationHandler.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/handler/TransformationHandler.java deleted file mode 100644 index 2ef6b0858..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/handler/TransformationHandler.java +++ /dev/null @@ -1,269 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.GetInstantTransformationBuffVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff.ABTimedTransformationBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.AltitudeAdjustmentTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.DelayTimerTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer.TransformationMorphAnimationTimer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class TransformationHandler { - - public static void setUnitID(final CSimulation game, final Map localStore, final CUnit unit, - final CUnitType newType, final boolean addAlternateTagAfter, final OnTransformationActions actions, - final CAbility ability) { - setUnitID(game, localStore, unit, newType, addAlternateTagAfter, actions, ability, false); - } - - public static void setUnitID(final CSimulation game, final Map localStore, final CUnit unit, - final CUnitType newType, final boolean addAlternateTagAfter, final OnTransformationActions actions, - final CAbility ability, final boolean updateArt) { - final CPlayer pl = game.getPlayer(unit.getPlayerIndex()); - if (actions != null) { - pl.setGold(Math.max(pl.getGold() - actions.goldCost, 0)); - pl.setLumber(Math.max(pl.getLumber() - actions.lumberCost, 0)); - - if (!addAlternateTagAfter) { - if (actions.onUntransformActions != null) { - for (final ABAction action : actions.onUntransformActions) { - action.runAction(game, unit, localStore, 0); - } - } - } - } - - unit.setTypeId(game, newType.getTypeId(), updateArt); - pl.setUnitFoodUsed(unit, newType.getFoodUsed()); - pl.setUnitFoodMade(unit, newType.getFoodMade()); - if (addAlternateTagAfter) { - if (unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE)) { - unit.getUnitAnimationListener().forceResetCurrentAnimation(); - } - } - else { - if (unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE)) { - unit.getUnitAnimationListener().forceResetCurrentAnimation(); - } - } - game.unitSoundEffectEvent(unit, ability.getAlias()); - - if (addAlternateTagAfter && (actions != null)) { - if (actions.onTransformActions != null) { - for (final ABAction action : actions.onTransformActions) { - action.runAction(game, unit, localStore, 0); - } - } - } - } - - public static void playMorphAnimation(final CUnit unit, final boolean addAlternateTagAfter) { - if (addAlternateTagAfter) { - unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); - unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, SequenceUtils.EMPTY, 1.0f, true); - } - else { - unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, EnumSet.of(SecondaryTag.ALTERNATE), - 1.0f, true); - } - unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, - addAlternateTagAfter ? EnumSet.of(SecondaryTag.ALTERNATE) : SequenceUtils.EMPTY, true); - if (addAlternateTagAfter) { - unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE); - } - else { - unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); - } - } - - public static void setTags(final CUnit unit, final boolean addAlternateTagAfter) { - if (addAlternateTagAfter) { - unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE); - } - else { - unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); - } - unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, - addAlternateTagAfter ? EnumSet.of(SecondaryTag.ALTERNATE) : SequenceUtils.EMPTY, 1.0f, true); - } - - public static void beginTakingOff(final CSimulation game, final Map localStore, final CUnit unit, - final CUnitType newType, final OnTransformationActions actions, final CAbility ability, - final boolean addAlternateTagAfter, final boolean immediateTakeoff, final float altitudeAdjustmentDelay, - final float altitudeAdjustmentDuration) { - CTimer timer = (CTimer) localStore.get(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT); - if (timer != null) { - game.unregisterTimer(timer); - } - timer = (new DelayTimerTimer( - new AltitudeAdjustmentTimer(game, unit, newType.getDefaultFlyingHeight(), altitudeAdjustmentDuration), - localStore, altitudeAdjustmentDelay)); - timer.start(game); - localStore.put(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, timer); - TransformationHandler.setUnitID(game, localStore, unit, newType, addAlternateTagAfter, actions, ability); - if (immediateTakeoff) { - TransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); - } - else { - final CTimer t2 = new TransformationMorphAnimationTimer(game, unit, addAlternateTagAfter, - altitudeAdjustmentDelay); - t2.start(game); - localStore.put(ABLocalStoreKeys.WAITING_ANIMATION, t2); - } - } - - public static void beginLanding(final CSimulation game, final Map localStore, final CUnit unit, - final CUnitType newType, final boolean addAlternateTagAfter, final boolean immediateLanding, - final float landingDelay, final float altitudeAdjustmentDuration) { - unit.setFacing(225); - if (immediateLanding) { - TransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); - } - else { - final CTimer timer = new TransformationMorphAnimationTimer(game, unit, addAlternateTagAfter, landingDelay); - timer.start(game); - localStore.put(ABLocalStoreKeys.WAITING_ANIMATION, timer); - } - CTimer timer = (CTimer) localStore.get(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT); - if (timer != null) { - game.unregisterTimer(timer); - } - timer = new AltitudeAdjustmentTimer(game, unit, newType.getDefaultFlyingHeight(), altitudeAdjustmentDuration); - timer.start(game); - localStore.put(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, timer); - } - - public static void startSlowTransformation(final CSimulation game, final Map localStore, - final CUnit unit, final CUnitType newType, final OnTransformationActions actions, final CAbility ability, - final boolean addAlternateTagAfter, final boolean takingOff, final boolean landing, - final boolean immediateTakeoff, final boolean immediateLanding, final float altitudeAdjustmentDelay, - final float landingDelay, final float altitudeAdjustmentDuration) { - final CTimer timer = (CTimer) localStore.get(ABLocalStoreKeys.WAITING_ANIMATION); - if (timer != null) { - game.unregisterTimer(timer); - } - unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, - addAlternateTagAfter ? SequenceUtils.EMPTY : EnumSet.of(SecondaryTag.ALTERNATE), true); - if (takingOff || landing) { - - if (takingOff) { - TransformationHandler.beginTakingOff(game, localStore, unit, newType, actions, ability, - addAlternateTagAfter, immediateTakeoff, altitudeAdjustmentDelay, altitudeAdjustmentDuration); - } - - if (landing) { - TransformationHandler.beginLanding(game, localStore, unit, newType, addAlternateTagAfter, - immediateLanding, landingDelay, altitudeAdjustmentDuration); - } - } - else { - TransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); - } - } - - public static void finishSlowTransformation(final CSimulation game, final Map localStore, - final CUnit unit, final CUnitType newType, final OnTransformationActions actions, - final AbilityBuilderAbility ability, final boolean addAlternateTagAfter, final boolean permanent, - final boolean takingOff) { - if (!takingOff) { - TransformationHandler.setUnitID(game, localStore, unit, newType, addAlternateTagAfter, actions, ability); - } - if (permanent) { - unit.remove(game, ability); - } - } - - public static void instantTransformation(final CSimulation game, final Map localStore, - final CUnit unit, final CUnitType newType, final OnTransformationActions actions, - final AbilityBuilderAbility ability, final boolean addAlternateTagAfter, final boolean permanent, - final boolean playMorph) { - if (newType.getTypeId().equals(unit.getTypeId())) { - return; - } - System.err.println("setting " + newType.getTypeId() + " on " + unit.getTypeId()); - setUnitID(game, localStore, unit, newType, addAlternateTagAfter, actions, ability, false); - if (playMorph) { - TransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); - } - if (permanent) { - unit.remove(game, ability); - } - } - - public static void createSlowTransformBackBuff(final CSimulation game, final Map localStore, - final CUnit unit, final CUnitType newType, final OnTransformationActions actions, - final AbilityBuilderActiveAbility ability, final War3ID buffId, final boolean addAlternateTagAfter, - final float transformationTime, final float duration, final boolean permanent, final boolean takingOff, - final boolean landing, final boolean immediateTakeoff, final boolean immediateLanding, - final float altitudeAdjustmentDelay, final float landingDelay, final float altitudeAdjustmentDuration) { - if (addAlternateTagAfter && (duration > 0)) { - unit.add(game, - new ABTimedTransformationBuff(game.getHandleIdAllocator().createId(), localStore, actions, - buffId == null ? ability.getAlias() : buffId, duration, ability, newType, - !addAlternateTagAfter, permanent, duration, transformationTime, landingDelay, - altitudeAdjustmentDelay, altitudeAdjustmentDuration, immediateLanding, immediateTakeoff)); - } - } - - public static void createInstantTransformBackBuff(final CSimulation game, final Map localStore, - final CUnit unit, final CUnitType newType, final OnTransformationActions actions, - final AbilityBuilderAbility ability, final War3ID buffId, final boolean addAlternateTagAfter, - final float transformationTime, final float duration, final boolean permanent) { - if (addAlternateTagAfter && (duration > 0)) { - final ABBuff thebuff = ability - .visit(GetInstantTransformationBuffVisitor.getInstance().reset(game, localStore, newType, actions, - buffId, addAlternateTagAfter, transformationTime, duration, permanent)); - if (thebuff != null) { - unit.add(game, thebuff); - } - } - } - - public static class OnTransformationActions { - private int goldCost; - private int lumberCost; - private Integer foodCost; - private List onTransformActions; - private List onUntransformActions; - - public OnTransformationActions(final List onUntransformActions) { - this.onUntransformActions = onUntransformActions; - } - - public OnTransformationActions(final int goldCost, final int lumberCost, final Integer foodCost, - final List onTransformActions, final List onUntransformActions) { - this.goldCost = goldCost; - this.lumberCost = lumberCost; - this.foodCost = foodCost; - this.onTransformActions = onTransformActions; - this.onUntransformActions = onUntransformActions; - } - - public OnTransformationActions createUntransformActions() { - return new OnTransformationActions(-this.goldCost, -this.lumberCost, - this.foodCost != null ? -this.foodCost : null, null, this.onUntransformActions); - } - - public void setOnUntransformActions(final List onUntransformActions) { - this.onUntransformActions = onUntransformActions; - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/iterstructs/UnitAndRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/iterstructs/UnitAndRange.java deleted file mode 100644 index fdef0c325..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/iterstructs/UnitAndRange.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.iterstructs; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; - -public class UnitAndRange { - private CUnit unit; - private double range; - - public CUnit getUnit() { - return unit; - } - public void setUnit(CUnit unit) { - this.unit = unit; - } - public double getRange() { - return range; - } - public void setRange(double range) { - this.range = range; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/jass/ABActionJass.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/jass/ABActionJass.java deleted file mode 100644 index e9a9abd70..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/jass/ABActionJass.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.jass; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import com.etheller.interpreter.ast.execution.JassThread; -import com.etheller.interpreter.ast.scope.GlobalScope; -import com.etheller.interpreter.ast.value.CodeJassValue; -import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; - -public class ABActionJass implements ABAction { - private final CodeJassValue jassFunction; - - public ABActionJass(final CodeJassValue jassFunction) { - this.jassFunction = jassFunction; - } - - @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final GlobalScope globalScope = game.getGlobalScope(); - final JassThread thread = globalScope.createThread(this.jassFunction, - CommonTriggerExecutionScope.abilityBuilder(caster, localStore, castId)); - globalScope.runThreadUntilCompletion(thread); - } - - @Override - public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { - throw new UnsupportedOperationException(); - } - - public static List wrap(final CodeJassValue jassFunction) { - if (jassFunction == null) { - return Collections.emptyList(); - } - else { - return Arrays.asList(new ABActionJass(jassFunction)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/jass/ABConditionJass.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/jass/ABConditionJass.java deleted file mode 100644 index 649fe5fca..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/jass/ABConditionJass.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.jass; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import com.etheller.interpreter.ast.scope.trigger.TriggerBooleanExpression; -import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; - -public class ABConditionJass implements ABCondition { - private final TriggerBooleanExpression boolExpr; - - public ABConditionJass(final TriggerBooleanExpression boolExpr) { - this.boolExpr = boolExpr; - } - - @Override - public boolean evaluate(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - return this.boolExpr.evaluate(game.getGlobalScope(), - CommonTriggerExecutionScope.abilityBuilder(caster, localStore, castId)); - } - - public static List wrap(final TriggerBooleanExpression jassFunction) { - if (jassFunction == null) { - return Collections.emptyList(); - } - else { - return Arrays.asList(new ABConditionJass(jassFunction)); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAbilityEffectReactionListener.java deleted file mode 100644 index 0431a81ea..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAbilityEffectReactionListener.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.listeners.CUnitAbilityEffectReactionListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; - -public class ABAbilityEffectReactionListener implements CUnitAbilityEffectReactionListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABAbilityEffectReactionListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public boolean onHit(final CSimulation simulation, CUnit source, CUnit target, CAbility ability) { - if (!this.useCastId) { - this.triggerId++; - } - localStore.put(ABLocalStoreKeys.REACTIONALLOWHIT+triggerId, true); - localStore.put(ABLocalStoreKeys.REACTIONABILITYCASTER+triggerId, source); - localStore.put(ABLocalStoreKeys.REACTIONABILITYTARGET+triggerId, target); - localStore.put(ABLocalStoreKeys.REACTIONABILITY+triggerId, ability); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, target, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.REACTIONABILITYCASTER+triggerId); - localStore.remove(ABLocalStoreKeys.REACTIONABILITYTARGET+triggerId); - localStore.remove(ABLocalStoreKeys.REACTIONABILITY+triggerId); - return (boolean) localStore.remove(ABLocalStoreKeys.REACTIONALLOWHIT+triggerId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAbilityProjReactionListener.java deleted file mode 100644 index 1a240262b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAbilityProjReactionListener.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.listeners.CUnitAbilityProjReactionListener; - -public class ABAbilityProjReactionListener implements CUnitAbilityProjReactionListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABAbilityProjReactionListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public boolean onHit(final CSimulation simulation, CUnit source, CUnit target, CProjectile projectile) { - if (!this.useCastId) { - this.triggerId++; - } - localStore.put(ABLocalStoreKeys.REACTIONALLOWHIT+triggerId, true); - localStore.put(ABLocalStoreKeys.REACTIONABILITYCASTER+triggerId, source); - localStore.put(ABLocalStoreKeys.REACTIONABILITYTARGET+triggerId, target); - localStore.put(ABLocalStoreKeys.ABILITYPROJ+triggerId, projectile); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, target, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.REACTIONABILITYCASTER+triggerId); - localStore.remove(ABLocalStoreKeys.REACTIONABILITYTARGET+triggerId); - localStore.remove(ABLocalStoreKeys.ABILITYPROJ+triggerId); - return (boolean) localStore.remove(ABLocalStoreKeys.REACTIONALLOWHIT+triggerId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackEvasionListener.java deleted file mode 100644 index cec7b8dce..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackEvasionListener.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackEvasionListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABAttackEvasionListener implements CUnitAttackEvasionListener { - - private Map localStore; - private List conditions; - - private int triggerId = 0; - private boolean useCastId; - - public ABAttackEvasionListener(Map localStore, List conditions, int castId, boolean useCastId) { - this.localStore = localStore; - this.conditions = conditions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public boolean onAttack(CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, - CDamageType damageType) { - boolean evade = false; - localStore.put(ABLocalStoreKeys.ATTACKINGUNIT+triggerId, attacker); - localStore.put(ABLocalStoreKeys.ATTACKEDUNIT+triggerId, target); - localStore.put(ABLocalStoreKeys.DAMAGEISATTACK+triggerId, isAttack); - localStore.put(ABLocalStoreKeys.DAMAGEISRANGED+triggerId, isRanged); - localStore.put(ABLocalStoreKeys.DAMAGETYPE+triggerId, damageType); - if (conditions != null) { - for (ABCondition condition : conditions) { - evade = evade || condition.evaluate(simulation, target, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKEDUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISATTACK+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISRANGED+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGETYPE+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - return evade; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackPostDamageListener.java deleted file mode 100644 index 14201f393..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackPostDamageListener.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPostDamageListener; - -public class ABAttackPostDamageListener implements CUnitAttackPostDamageListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABAttackPostDamageListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public void onHit(CSimulation simulation, CUnit attacker, AbilityTarget target, float damage) { - localStore.put(ABLocalStoreKeys.ATTACKINGUNIT+triggerId, attacker); - localStore.put(ABLocalStoreKeys.ATTACKEDUNIT+triggerId, target); - localStore.put(ABLocalStoreKeys.TOTALDAMAGEDEALT+triggerId, damage); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, attacker, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKEDUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.TOTALDAMAGEDEALT+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackPreDamageListener.java deleted file mode 100644 index fc243dc66..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackPreDamageListener.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackEffectListenerStacking; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABAttackPreDamageListener implements CUnitAttackPreDamageListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABAttackPreDamageListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public CUnitAttackEffectListenerStacking onAttack(CSimulation simulation, CUnit attacker, AbilityTarget target, - CWeaponType weaponType, CAttackType attackType, CDamageType damageType, - CUnitAttackPreDamageListenerDamageModResult damageResult) { - localStore.put(ABLocalStoreKeys.ATTACKINGUNIT+triggerId, attacker); - localStore.put(ABLocalStoreKeys.ATTACKEDUNIT+triggerId, target); - localStore.put(ABLocalStoreKeys.WEAPONTYPE+triggerId, weaponType); - localStore.put(ABLocalStoreKeys.ATTACKTYPE+triggerId, attackType); - localStore.put(ABLocalStoreKeys.DAMAGETYPE+triggerId, damageType); - localStore.put(ABLocalStoreKeys.BASEDAMAGEDEALT+triggerId, damageResult.getBaseDamage()); - localStore.put(ABLocalStoreKeys.BONUSDAMAGEDEALT+triggerId, damageResult.getBonusDamage()); - localStore.put(ABLocalStoreKeys.PREDAMAGERESULT+triggerId, damageResult); - CUnitAttackEffectListenerStacking stacking = new CUnitAttackEffectListenerStacking(); - localStore.put(ABLocalStoreKeys.PREDAMAGESTACKING+triggerId, stacking); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, attacker, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKEDUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.WEAPONTYPE+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKTYPE+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGETYPE+triggerId); - localStore.remove(ABLocalStoreKeys.BASEDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.BONUSDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.PREDAMAGERESULT+triggerId); - localStore.remove(ABLocalStoreKeys.PREDAMAGESTACKING+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - return stacking; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackProjReactionListener.java deleted file mode 100644 index 7feee21a8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABAttackProjReactionListener.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.listeners.CUnitAttackProjReactionListener; - -public class ABAttackProjReactionListener implements CUnitAttackProjReactionListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABAttackProjReactionListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public boolean onHit(final CSimulation simulation, CUnit source, CUnit target, CAttackProjectile projectile) { - if (!this.useCastId) { - this.triggerId++; - } - localStore.put(ABLocalStoreKeys.REACTIONALLOWHIT+triggerId, true); - localStore.put(ABLocalStoreKeys.ATTACKINGUNIT+triggerId, source); - localStore.put(ABLocalStoreKeys.ATTACKEDUNIT+triggerId, target); - localStore.put(ABLocalStoreKeys.ATTACKPROJ+triggerId, projectile); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, target, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKEDUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKPROJ+triggerId); - return (boolean) localStore.remove(ABLocalStoreKeys.REACTIONALLOWHIT+triggerId); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABBehaviorChangeListener.java deleted file mode 100644 index d9a8af57a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABBehaviorChangeListener.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitBehaviorChangeListener; - -public class ABBehaviorChangeListener implements CUnitBehaviorChangeListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABBehaviorChangeListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public void onChange(CSimulation game, CUnit unit, CBehavior previousBehavior, CBehavior newBehavior, boolean ongoing) { - localStore.put(ABLocalStoreKeys.PRECHANGEBEHAVIOR+triggerId, previousBehavior); - localStore.put(ABLocalStoreKeys.POSTCHANGEBEHAVIOR+triggerId, newBehavior); - localStore.put(ABLocalStoreKeys.BEHAVIORONGOING+triggerId, ongoing); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(game, unit, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.PRECHANGEBEHAVIOR+triggerId); - localStore.remove(ABLocalStoreKeys.POSTCHANGEBEHAVIOR+triggerId); - localStore.remove(ABLocalStoreKeys.BEHAVIORONGOING+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDamageTakenListener.java deleted file mode 100644 index acf0359c4..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDamageTakenListener.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABDamageTakenListener implements CUnitAttackDamageTakenListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABDamageTakenListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public void onDamage(CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, - CDamageType damageType, float damage, float bonusDamage, float trueDamage) { - localStore.put(ABLocalStoreKeys.ATTACKINGUNIT+triggerId, attacker); - localStore.put(ABLocalStoreKeys.ATTACKEDUNIT+triggerId, target); - localStore.put(ABLocalStoreKeys.DAMAGEISATTACK+triggerId, isAttack); - localStore.put(ABLocalStoreKeys.DAMAGEISRANGED+triggerId, isRanged); - localStore.put(ABLocalStoreKeys.DAMAGETYPE+triggerId, damageType); - localStore.put(ABLocalStoreKeys.BASEDAMAGEDEALT+triggerId, damage); - localStore.put(ABLocalStoreKeys.BONUSDAMAGEDEALT+triggerId, bonusDamage); - localStore.put(ABLocalStoreKeys.TOTALDAMAGEDEALT+triggerId, trueDamage); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, target, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKEDUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISATTACK+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISRANGED+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGETYPE+triggerId); - localStore.remove(ABLocalStoreKeys.BASEDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.BONUSDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.TOTALDAMAGEDEALT+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDamageTakenModificationListener.java deleted file mode 100644 index 7cba193e8..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDamageTakenModificationListener.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenModificationListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenModificationListenerDamageModResult; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABDamageTakenModificationListener implements CUnitAttackDamageTakenModificationListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABDamageTakenModificationListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public CUnitAttackDamageTakenModificationListenerDamageModResult onDamage(CSimulation simulation, CUnit attacker, - CUnit target, boolean isAttack, boolean isRanged, CAttackType attackType, CDamageType damageType, - CUnitAttackDamageTakenModificationListenerDamageModResult previousDamage) { - localStore.put(ABLocalStoreKeys.ATTACKINGUNIT+triggerId, attacker); - localStore.put(ABLocalStoreKeys.ATTACKEDUNIT+triggerId, target); - localStore.put(ABLocalStoreKeys.DAMAGEISATTACK+triggerId, isAttack); - localStore.put(ABLocalStoreKeys.DAMAGEISRANGED+triggerId, isRanged); - localStore.put(ABLocalStoreKeys.ATTACKTYPE+triggerId, attackType); - localStore.put(ABLocalStoreKeys.DAMAGETYPE+triggerId, damageType); - localStore.put(ABLocalStoreKeys.BASEDAMAGEDEALT+triggerId, previousDamage.getBaseDamage()); - localStore.put(ABLocalStoreKeys.BONUSDAMAGEDEALT+triggerId, previousDamage.getBonusDamage()); - localStore.put(ABLocalStoreKeys.DAMAGEMODRESULT+triggerId, previousDamage); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, target, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKEDUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISATTACK+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISRANGED+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKTYPE+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGETYPE+triggerId); - localStore.remove(ABLocalStoreKeys.BASEDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.BONUSDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEMODRESULT+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - return previousDamage; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDeathReplacementEffect.java deleted file mode 100644 index 5e898bb0e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABDeathReplacementEffect.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementEffect; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementResult; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementStacking; - -public class ABDeathReplacementEffect implements CUnitDeathReplacementEffect { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABDeathReplacementEffect(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public CUnitDeathReplacementStacking onDeath(CSimulation simulation, CUnit unit, CUnit killer, - CUnitDeathReplacementResult result) { - localStore.put(ABLocalStoreKeys.KILLINGUNIT+triggerId, killer); - localStore.put(ABLocalStoreKeys.DYINGUNIT+triggerId, unit); - localStore.put(ABLocalStoreKeys.DEATHRESULT+triggerId, result); - CUnitDeathReplacementStacking stacking = new CUnitDeathReplacementStacking(); - localStore.put(ABLocalStoreKeys.DEATHSTACKING+triggerId, stacking); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, unit, localStore, triggerId); - } - } - localStore.remove(ABLocalStoreKeys.KILLINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.DYINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.DEATHRESULT+triggerId); - localStore.remove(ABLocalStoreKeys.DEATHSTACKING+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - return stacking; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABFinalDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABFinalDamageTakenModificationListener.java deleted file mode 100644 index 77e07d512..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/listener/ABFinalDamageTakenModificationListener.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.listener; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackFinalDamageTakenModificationListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class ABFinalDamageTakenModificationListener implements CUnitAttackFinalDamageTakenModificationListener { - - private Map localStore; - private List actions; - - private int triggerId = 0; - private boolean useCastId; - - public ABFinalDamageTakenModificationListener(Map localStore, List actions, int castId, boolean useCastId) { - this.localStore = localStore; - this.actions = actions; - this.useCastId = useCastId; - if (useCastId) { - this.triggerId = castId; - } - } - - @Override - public float onDamage(CSimulation simulation, CUnit attacker, - CUnit target, boolean isAttack, boolean isRanged, CAttackType attackType, CDamageType damageType, - float previousDamage) { - localStore.put(ABLocalStoreKeys.ATTACKINGUNIT+triggerId, attacker); - localStore.put(ABLocalStoreKeys.ATTACKEDUNIT+triggerId, target); - localStore.put(ABLocalStoreKeys.DAMAGEISATTACK+triggerId, isAttack); - localStore.put(ABLocalStoreKeys.DAMAGEISRANGED+triggerId, isRanged); - localStore.put(ABLocalStoreKeys.ATTACKTYPE+triggerId, attackType); - localStore.put(ABLocalStoreKeys.DAMAGETYPE+triggerId, damageType); - localStore.put(ABLocalStoreKeys.TOTALDAMAGEDEALT+triggerId, previousDamage); - localStore.put(ABLocalStoreKeys.DAMAGEMODRESULT+triggerId, previousDamage); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, target, localStore, triggerId); - } - } - float finalDamage = (float) localStore.get(ABLocalStoreKeys.TOTALDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKEDUNIT+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISATTACK+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEISRANGED+triggerId); - localStore.remove(ABLocalStoreKeys.ATTACKTYPE+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGETYPE+triggerId); - localStore.remove(ABLocalStoreKeys.TOTALDAMAGEDEALT+triggerId); - localStore.remove(ABLocalStoreKeys.DAMAGEMODRESULT+triggerId); - if (!this.useCastId) { - this.triggerId++; - } - return finalDamage; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderConfiguration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderConfiguration.java deleted file mode 100644 index 86bbdee5a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderConfiguration.java +++ /dev/null @@ -1,334 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import java.util.List; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.definitions.impl.CAbilityTypeDefinitionAbilityBuilder; - -public class AbilityBuilderConfiguration { - private String id; - - private String castId; - private String uncastId; - private String autoCastOnId; - private String autoCastOffId; - private AutocastType autoCastType; - - private AbilityBuilderType type; - private AbilityBuilderSpecialDisplayFields displayFields; - private AbilityBuilderSpecialConfigFields specialFields; - private AbilityBuilderOverrideFields overrideFields; - - private List extraTargetConditions; - private List extraAutoTargetConditions; - private List extraAutoNoTargetConditions; - private List extraCastConditions; - - private List onAddAbility; - private List onAddDisabledAbility; - private List onRemoveAbility; - private List onRemoveDisabledAbility; - - private List onDeathPreCast; - private List onCancelPreCast; - private List onOrderIssued; - private List onActivate; - private List onDeactivate; - - private List onLevelChange; - - private List onBeginCasting; - private List onEndCasting; - private List onChannelTick; - private List onEndChannel; - - public AbilityBuilderConfiguration(AbilityBuilderParser parser, AbilityBuilderDupe dupe) { - this.id = dupe.getId(); - this.castId = dupe.getCastId(); - this.uncastId = dupe.getUncastId(); - this.autoCastOnId = dupe.getAutoCastOnId(); - this.autoCastOffId = dupe.getAutoCastOffId(); - this.autoCastType = dupe.getAutoCastType(); - this.type = parser.getType(); - this.displayFields = parser.getDisplayFields(); - this.specialFields = parser.getSpecialFields(); - this.overrideFields = parser.getOverrideFields(); - - this.extraTargetConditions = parser.getExtraTargetConditions(); - this.extraAutoTargetConditions = parser.getExtraAutoTargetConditions(); - this.extraCastConditions = parser.getExtraCastConditions(); - this.extraAutoNoTargetConditions = parser.getExtraAutoNoTargetConditions(); - - this.onAddAbility = parser.getOnAddAbility(); - this.onAddDisabledAbility = parser.getOnAddDisabledAbility(); - this.onRemoveAbility = parser.getOnRemoveAbility(); - this.onRemoveDisabledAbility = parser.getOnRemoveDisabledAbility(); - this.onDeathPreCast = parser.getOnDeathPreCast(); - this.onCancelPreCast = parser.getOnCancelPreCast(); - this.onOrderIssued = parser.getOnOrderIssued(); - this.onActivate = parser.getOnActivate(); - this.onDeactivate = parser.getOnDeactivate(); - - this.onLevelChange = parser.getOnLevelChange(); - - this.onBeginCasting = parser.getOnBeginCasting(); - this.onEndCasting = parser.getOnEndCasting(); - this.onChannelTick = parser.getOnChannelTick(); - this.onEndChannel = parser.getOnEndChannel(); - } - - public CAbilityTypeDefinitionAbilityBuilder createDefinition() { - return new CAbilityTypeDefinitionAbilityBuilder(this); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCastId() { - return castId; - } - - public void setCastId(String castId) { - this.castId = castId; - } - - public String getUncastId() { - return uncastId; - } - - public void setUncastId(String uncastId) { - this.uncastId = uncastId; - } - - public String getAutoCastOnId() { - return autoCastOnId; - } - - public void setAutoCastOnId(String autoCastOnId) { - this.autoCastOnId = autoCastOnId; - } - - public String getAutoCastOffId() { - return autoCastOffId; - } - - public void setAutoCastOffId(String autoCastOffId) { - this.autoCastOffId = autoCastOffId; - } - - /** - * @return the autoCastType - */ - public AutocastType getAutoCastType() { - return autoCastType; - } - - /** - * @param autoCastType the autoCastType to set - */ - public void setAutoCastType(AutocastType autoCastType) { - this.autoCastType = autoCastType; - } - - public AbilityBuilderType getType() { - return type; - } - - public void setType(AbilityBuilderType type) { - this.type = type; - } - - public AbilityBuilderSpecialDisplayFields getDisplayFields() { - return displayFields; - } - - public void setDisplayFields(AbilityBuilderSpecialDisplayFields displayFields) { - this.displayFields = displayFields; - } - - public AbilityBuilderSpecialConfigFields getSpecialFields() { - return specialFields; - } - - public void setSpecialFields(AbilityBuilderSpecialConfigFields specialFields) { - this.specialFields = specialFields; - } - - public AbilityBuilderOverrideFields getOverrideFields() { - return overrideFields; - } - - public void setOverrideFields(AbilityBuilderOverrideFields overrideFields) { - this.overrideFields = overrideFields; - } - - public List getExtraTargetConditions() { - return extraTargetConditions; - } - - public void setExtraTargetConditions(List extraTargetConditions) { - this.extraTargetConditions = extraTargetConditions; - } - - /** - * @return the extraAutoTargetConditions - */ - public List getExtraAutoTargetConditions() { - return extraAutoTargetConditions; - } - - /** - * @param extraAutoTargetConditions the extraAutoTargetConditions to set - */ - public void setExtraAutoTargetConditions(List extraAutoTargetConditions) { - this.extraAutoTargetConditions = extraAutoTargetConditions; - } - - public List getExtraAutoNoTargetConditions() { - return extraAutoNoTargetConditions; - } - - public void setExtraAutoNoTargetConditions(List extraAutoNoTargetConditions) { - this.extraAutoNoTargetConditions = extraAutoNoTargetConditions; - } - - public List getExtraCastConditions() { - return extraCastConditions; - } - - public void setExtraCastConditions(List extraCastConditions) { - this.extraCastConditions = extraCastConditions; - } - - public List getOnAddAbility() { - return onAddAbility; - } - - public void setOnAddAbility(List onAddAbility) { - this.onAddAbility = onAddAbility; - } - - /** - * @return the onAddDisabledAbility - */ - public List getOnAddDisabledAbility() { - return onAddDisabledAbility; - } - - /** - * @param onAddDisabledAbility the onAddDisabledAbility to set - */ - public void setOnAddDisabledAbility(List onAddDisabledAbility) { - this.onAddDisabledAbility = onAddDisabledAbility; - } - - public List getOnRemoveAbility() { - return onRemoveAbility; - } - - public void setOnRemoveAbility(List onRemoveAbility) { - this.onRemoveAbility = onRemoveAbility; - } - - /** - * @return the onRemoveDisabledAbility - */ - public List getOnRemoveDisabledAbility() { - return onRemoveDisabledAbility; - } - - /** - * @param onRemoveDisabledAbility the onRemoveDisabledAbility to set - */ - public void setOnRemoveDisabledAbility(List onRemoveDisabledAbility) { - this.onRemoveDisabledAbility = onRemoveDisabledAbility; - } - - public List getOnDeathPreCast() { - return onDeathPreCast; - } - - public void setOnDeathPreCast(List onDeathPreCast) { - this.onDeathPreCast = onDeathPreCast; - } - - public List getOnCancelPreCast() { - return onCancelPreCast; - } - - public void setOnCancelPreCast(List onCancelPreCast) { - this.onCancelPreCast = onCancelPreCast; - } - - public List getOnOrderIssued() { - return onOrderIssued; - } - - public void setOnOrderIssued(List onOrderIssued) { - this.onOrderIssued = onOrderIssued; - } - - public List getOnActivate() { - return onActivate; - } - - public void setOnActivate(List onActivate) { - this.onActivate = onActivate; - } - - public List getOnDeactivate() { - return onDeactivate; - } - - public void setOnDeactivate(List onDeactivate) { - this.onDeactivate = onDeactivate; - } - - public List getOnLevelChange() { - return onLevelChange; - } - - public void setOnLevelChange(List onLevelChange) { - this.onLevelChange = onLevelChange; - } - - public List getOnBeginCasting() { - return onBeginCasting; - } - - public void setOnBeginCasting(List onBeginCasting) { - this.onBeginCasting = onBeginCasting; - } - - public List getOnEndCasting() { - return onEndCasting; - } - - public void setOnEndCasting(List onEndCasting) { - this.onEndCasting = onEndCasting; - } - - public List getOnChannelTick() { - return onChannelTick; - } - - public void setOnChannelTick(List onChannelTick) { - this.onChannelTick = onChannelTick; - } - - public List getOnEndChannel() { - return onEndChannel; - } - - public void setOnEndChannel(List onEndChannel) { - this.onEndChannel = onEndChannel; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderDupe.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderDupe.java deleted file mode 100644 index 0113a8381..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderDupe.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; - -public class AbilityBuilderDupe { - private String id; - - private String castId; - private String uncastId; - private String autoCastOnId; - private String autoCastOffId; - private AutocastType autoCastType; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCastId() { - return castId; - } - - public void setCastId(String castId) { - this.castId = castId; - } - - public String getUncastId() { - return uncastId; - } - - public void setUncastId(String uncastId) { - this.uncastId = uncastId; - } - - public String getAutoCastOnId() { - return autoCastOnId; - } - - public void setAutoCastOnId(String autoCastOnId) { - this.autoCastOnId = autoCastOnId; - } - - public String getAutoCastOffId() { - return autoCastOffId; - } - - public void setAutoCastOffId(String autoCastOffId) { - this.autoCastOffId = autoCastOffId; - } - - /** - * @return the autoCastType - */ - public AutocastType getAutoCastType() { - return autoCastType; - } - - /** - * @param autoCastType the autoCastType to set - */ - public void setAutoCastType(AutocastType autoCastType) { - this.autoCastType = autoCastType; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderFile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderFile.java deleted file mode 100644 index 887c18d6b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderFile.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import java.util.List; - -public class AbilityBuilderFile { - List abilityList; - - public List getAbilityList() { - return abilityList; - } - - public void setAbilityList(List abilityList) { - this.abilityList = abilityList; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderOverrideFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderOverrideFields.java deleted file mode 100644 index b03fab75d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderOverrideFields.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.enumcallbacks.ABAutocastTypeCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; - -public class AbilityBuilderOverrideFields { - - private ABFloatCallback areaOverride; - private ABFloatCallback rangeOverride; - private ABFloatCallback cooldownOverride; - private ABIntegerCallback manaCostOverride; - - private ABAutocastTypeCallback autocastTypeOverride; - - private ABIDCallback onTooltipOverride; - private ABIDCallback offTooltipOverride; - - private ABBooleanCallback physicalSpell; - private ABBooleanCallback universalSpell; - - public ABFloatCallback getAreaOverride() { - return areaOverride; - } - public void setAreaOverride(ABFloatCallback areaOverride) { - this.areaOverride = areaOverride; - } - public ABFloatCallback getRangeOverride() { - return rangeOverride; - } - public void setRangeOverride(ABFloatCallback rangeOverride) { - this.rangeOverride = rangeOverride; - } - public ABFloatCallback getCooldownOverride() { - return cooldownOverride; - } - public void setCooldownOverride(ABFloatCallback cooldownOverride) { - this.cooldownOverride = cooldownOverride; - } - public ABIntegerCallback getManaCostOverride() { - return manaCostOverride; - } - public void setManaCostOverride(ABIntegerCallback manaCostOverride) { - this.manaCostOverride = manaCostOverride; - } - public ABAutocastTypeCallback getAutocastTypeOverride() { - return autocastTypeOverride; - } - public void setAutocastTypeOverride(ABAutocastTypeCallback autocastTypeOverride) { - this.autocastTypeOverride = autocastTypeOverride; - } - public ABIDCallback getOnTooltipOverride() { - return onTooltipOverride; - } - public void setOnTooltipOverride(ABIDCallback onTooltipOverride) { - this.onTooltipOverride = onTooltipOverride; - } - public ABIDCallback getOffTooltipOverride() { - return offTooltipOverride; - } - public void setOffTooltipOverride(ABIDCallback offTooltipOverride) { - this.offTooltipOverride = offTooltipOverride; - } - public ABBooleanCallback getPhysicalSpell() { - return physicalSpell; - } - public void setPhysicalSpell(ABBooleanCallback physicalSpell) { - this.physicalSpell = physicalSpell; - } - public ABBooleanCallback getUniversalSpell() { - return universalSpell; - } - public void setUniversalSpell(ABBooleanCallback universalSpell) { - this.universalSpell = universalSpell; - } - - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParser.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParser.java deleted file mode 100644 index 1138690d9..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParser.java +++ /dev/null @@ -1,311 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.MeleeRangeTargetOverride; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.StatBuffFromDataField; - -public class AbilityBuilderParser { - - private List ids; - - private AbilityBuilderType type; - private AbilityBuilderSpecialDisplayFields displayFields; - private AbilityBuilderSpecialConfigFields specialFields; - private AbilityBuilderOverrideFields overrideFields; - - private List extraTargetConditions; - private List extraAutoTargetConditions; - private List extraAutoNoTargetConditions; - private List extraCastConditions; - - private List onAddAbility; - private List onAddDisabledAbility; - private List onRemoveAbility; - private List onRemoveDisabledAbility; - private List onDeathPreCast; - private List onCancelPreCast; - private List onOrderIssued; - private List onActivate; - private List onDeactivate; - - private List onLevelChange; - - private List onBeginCasting; - private List onEndCasting; - private List onChannelTick; - private List onEndChannel; - - //Template only - private AbilityBuilderParserTemplateFields templateFields; - - public List getIds() { - return ids; - } - - public void setIds(List ids) { - this.ids = ids; - } - - public AbilityBuilderType getType() { - return type; - } - - public void setType(AbilityBuilderType type) { - this.type = type; - } - - public AbilityBuilderSpecialDisplayFields getDisplayFields() { - return displayFields; - } - - public void setDisplayFields(AbilityBuilderSpecialDisplayFields displayFields) { - this.displayFields = displayFields; - } - - public AbilityBuilderSpecialConfigFields getSpecialFields() { - return specialFields; - } - - public void setSpecialFields(AbilityBuilderSpecialConfigFields specialFields) { - this.specialFields = specialFields; - } - - public AbilityBuilderOverrideFields getOverrideFields() { - return overrideFields; - } - - public void setOverrideFields(AbilityBuilderOverrideFields overrideFields) { - this.overrideFields = overrideFields; - } - - public List getExtraTargetConditions() { - return extraTargetConditions; - } - - public void setExtraTargetConditions(List extraTargetConditions) { - this.extraTargetConditions = extraTargetConditions; - } - - /** - * @return the extraAutoTargetConditions - */ - public List getExtraAutoTargetConditions() { - return extraAutoTargetConditions; - } - - /** - * @param extraAutoTargetConditions the extraAutoTargetConditions to set - */ - public void setExtraAutoTargetConditions(List extraAutoTargetConditions) { - this.extraAutoTargetConditions = extraAutoTargetConditions; - } - - public List getExtraAutoNoTargetConditions() { - return extraAutoNoTargetConditions; - } - - public void setExtraAutoNoTargetConditions(List extraAutoNoTargetConditions) { - this.extraAutoNoTargetConditions = extraAutoNoTargetConditions; - } - - public List getExtraCastConditions() { - return extraCastConditions; - } - - public void setExtraCastConditions(List extraCastConditions) { - this.extraCastConditions = extraCastConditions; - } - - public List getOnAddAbility() { - return onAddAbility; - } - - public void setOnAddAbility(List onAddAbility) { - this.onAddAbility = onAddAbility; - } - - /** - * @return the onAddDisabledAbility - */ - public List getOnAddDisabledAbility() { - return onAddDisabledAbility; - } - - /** - * @param onAddDisabledAbility the onAddDisabledAbility to set - */ - public void setOnAddDisabledAbility(List onAddDisabledAbility) { - this.onAddDisabledAbility = onAddDisabledAbility; - } - - public List getOnRemoveAbility() { - return onRemoveAbility; - } - - public void setOnRemoveAbility(List onRemoveAbility) { - this.onRemoveAbility = onRemoveAbility; - } - - /** - * @return the onRemoveDisabledAbility - */ - public List getOnRemoveDisabledAbility() { - return onRemoveDisabledAbility; - } - - /** - * @param onRemoveDisabledAbility the onRemoveDisabledAbility to set - */ - public void setOnRemoveDisabledAbility(List onRemoveDisabledAbility) { - this.onRemoveDisabledAbility = onRemoveDisabledAbility; - } - - public List getOnDeathPreCast() { - return onDeathPreCast; - } - - public void setOnDeathPreCast(List onDeathPreCast) { - this.onDeathPreCast = onDeathPreCast; - } - - public List getOnCancelPreCast() { - return onCancelPreCast; - } - - public void setOnCancelPreCast(List onCancelPreCast) { - this.onCancelPreCast = onCancelPreCast; - } - - public List getOnOrderIssued() { - return onOrderIssued; - } - - public void setOnOrderIssued(List onOrderIssued) { - this.onOrderIssued = onOrderIssued; - } - - public List getOnActivate() { - return onActivate; - } - - public void setOnActivate(List onActivate) { - this.onActivate = onActivate; - } - - public List getOnDeactivate() { - return onDeactivate; - } - - public void setOnDeactivate(List onDeactivate) { - this.onDeactivate = onDeactivate; - } - - public List getOnBeginCasting() { - return onBeginCasting; - } - - public void setOnBeginCasting(List onBeginCasting) { - this.onBeginCasting = onBeginCasting; - } - - public List getOnLevelChange() { - return onLevelChange; - } - - public void setOnLevelChange(List onLevelChange) { - this.onLevelChange = onLevelChange; - } - - public List getOnEndCasting() { - return onEndCasting; - } - - public void setOnEndCasting(List onEndCasting) { - this.onEndCasting = onEndCasting; - } - - public List getOnChannelTick() { - return onChannelTick; - } - - public void setOnChannelTick(List onChannelTick) { - this.onChannelTick = onChannelTick; - } - - public List getOnEndChannel() { - return onEndChannel; - } - - public void setOnEndChannel(List onEndChannel) { - this.onEndChannel = onEndChannel; - } - - public AbilityBuilderTemplateType getTemplateType() { - return templateFields.getTemplateType(); - } - - public void setTemplateType(AbilityBuilderTemplateType templateType) { - this.templateFields.setTemplateType(templateType); - } - - public List getAddToAuraActions() { - return templateFields.getAddToAuraActions(); - } - - public void setAddToAuraActions(List addToAuraActions) { - this.templateFields.setAddToAuraActions(addToAuraActions); - } - - public List getUpdateAuraLevelActions() { - return templateFields.getUpdateAuraLevelActions(); - } - - public void setUpdateAuraLevelActions(List updateAuraLevelActions) { - this.templateFields.setUpdateAuraLevelActions(updateAuraLevelActions); - } - - public List getRemoveFromAuraActions() { - return templateFields.getRemoveFromAuraActions(); - } - - public void setRemoveFromAuraActions(List removeFromAuraActions) { - this.templateFields.setRemoveFromAuraActions(removeFromAuraActions); - } - - public Map> getAbilityIdsToAddPerLevel() { - return templateFields.getAbilityIdsToAddPerLevel(); - } - - public void setAbilityIdsToAddPerLevel(Map> abilityIdsToAddPerLevel) { - this.setAbilityIdsToAddPerLevel(abilityIdsToAddPerLevel); - } - - public List getLevellingAbilityIdsToAdd() { - return templateFields.getLevellingAbilityIdsToAdd(); - } - - public void setLevellingAbilityIdsToAdd(List levellingAbilityIdsToAdd) { - this.templateFields.setLevellingAbilityIdsToAdd(levellingAbilityIdsToAdd); - } - - public List getStatBuffsFromDataFields() { - return templateFields.getStatBuffsFromDataFields(); - } - - public void setStatBuffsFromDataFields(List statBuffsFromDataFields) { - this.templateFields.setStatBuffsFromDataFields(statBuffsFromDataFields); - } - - public MeleeRangeTargetOverride getMeleeRangeTargetOverride() { - return templateFields.getMeleeRangeTargetOverride(); - } - - public void setMeleeRangeTargetOverride(MeleeRangeTargetOverride meleeRangeTargetOverride) { - this.templateFields.setMeleeRangeTargetOverride(meleeRangeTargetOverride); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParserTemplateFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParserTemplateFields.java deleted file mode 100644 index b299781e2..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParserTemplateFields.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.MeleeRangeTargetOverride; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.StatBuffFromDataField; - -public class AbilityBuilderParserTemplateFields { - //Template only - private AbilityBuilderTemplateType templateType; - //Aura template - private List addToAuraActions; - private List updateAuraLevelActions; - private List removeFromAuraActions; - //Simple Aura Template - private Map> abilityIdsToAddPerLevel; - private List levellingAbilityIdsToAdd; - //StatList - private List statBuffsFromDataFields; - private MeleeRangeTargetOverride meleeRangeTargetOverride; - - public AbilityBuilderTemplateType getTemplateType() { - return templateType; - } - - public void setTemplateType(AbilityBuilderTemplateType templateType) { - this.templateType = templateType; - } - - public List getAddToAuraActions() { - return addToAuraActions; - } - - public void setAddToAuraActions(List addToAuraActions) { - this.addToAuraActions = addToAuraActions; - } - - public List getUpdateAuraLevelActions() { - return updateAuraLevelActions; - } - - public void setUpdateAuraLevelActions(List updateAuraLevelActions) { - this.updateAuraLevelActions = updateAuraLevelActions; - } - - public List getRemoveFromAuraActions() { - return removeFromAuraActions; - } - - public void setRemoveFromAuraActions(List removeFromAuraActions) { - this.removeFromAuraActions = removeFromAuraActions; - } - - public Map> getAbilityIdsToAddPerLevel() { - return abilityIdsToAddPerLevel; - } - - public void setAbilityIdsToAddPerLevel(Map> abilityIdsToAddPerLevel) { - this.abilityIdsToAddPerLevel = abilityIdsToAddPerLevel; - } - - public List getLevellingAbilityIdsToAdd() { - return levellingAbilityIdsToAdd; - } - - public void setLevellingAbilityIdsToAdd(List levellingAbilityIdsToAdd) { - this.levellingAbilityIdsToAdd = levellingAbilityIdsToAdd; - } - - public List getStatBuffsFromDataFields() { - return statBuffsFromDataFields; - } - - public void setStatBuffsFromDataFields(List statBuffsFromDataFields) { - this.statBuffsFromDataFields = statBuffsFromDataFields; - } - - public MeleeRangeTargetOverride getMeleeRangeTargetOverride() { - return meleeRangeTargetOverride; - } - - public void setMeleeRangeTargetOverride(MeleeRangeTargetOverride meleeRangeTargetOverride) { - this.meleeRangeTargetOverride = meleeRangeTargetOverride; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParserUtil.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParserUtil.java deleted file mode 100644 index a71a3fe79..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderParserUtil.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.AbilityBuilderGsonBuilder; -import com.google.gson.Gson; -import com.google.gson.JsonParseException; - -public class AbilityBuilderParserUtil { - public static void loadAbilityBuilderFiles(final AbilityBuilderFileListener listener) { - final Gson gson = AbilityBuilderGsonBuilder.create(); - try { - final File abilityBehaviorsDir = new File("abilityBehaviors"); - final File[] abilityBehaviorFiles = abilityBehaviorsDir.listFiles(); - if (abilityBehaviorFiles != null) { - for (final File abilityBehaviorFile : abilityBehaviorFiles) { - loadAbilityBuilderFile(gson, abilityBehaviorFile, listener); - } - } - } - catch (final Exception e) { - e.printStackTrace(); - } - } - - public static void loadAbilityBuilderFile(final Gson gson, final File abilityBehaviorFile, - final AbilityBuilderFileListener listener) throws FileNotFoundException { - if (abilityBehaviorFile.isDirectory()) { - final File[] abilityBehaviorFiles = abilityBehaviorFile.listFiles(); - if (abilityBehaviorFiles != null) { - for (final File subAbilityBehaviorFile : abilityBehaviorFiles) { - loadAbilityBuilderFile(gson, subAbilityBehaviorFile, listener); - } - } - } - try { - final AbilityBuilderFile behaviors = gson.fromJson(new FileReader(abilityBehaviorFile), - AbilityBuilderFile.class); - for (final AbilityBuilderParser behavior : behaviors.getAbilityList()) { - listener.callback(behavior); - } - } - catch (final JsonParseException e) { - System.err.println("Failed to load Ability Builder config file: " + abilityBehaviorFile.getName()); - e.printStackTrace(); - } - catch (final IllegalArgumentException e) { - System.err.println("Failed to load Ability Builder config file: " + abilityBehaviorFile.getName()); - e.printStackTrace(); - } - } - - public static interface AbilityBuilderFileListener { - void callback(AbilityBuilderParser behavior); - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderSpecialConfigFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderSpecialConfigFields.java deleted file mode 100644 index ada9d5b73..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderSpecialConfigFields.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import java.util.List; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.floatcallbacks.ABFloatCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.orderid.ABOrderIdCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeysEnum; - -public class AbilityBuilderSpecialConfigFields { - private ABIntegerCallback bufferManaRequired; - private ABIntegerCallback manaDrainedPerSecond; - - private List pointTargeted; - private List targetedSpell; - - private List autoAquireTarget; - - private ABIDCallback pairAbilityId; - private ABIDCallback pairUnitId; - private CommandStringErrorKeysEnum pairUnitTypeError; - private CommandStringErrorKeysEnum cantTargetError; - private CommandStringErrorKeysEnum cantPairError; - private CommandStringErrorKeysEnum cantPairOffError; - private ABFloatCallback pairSearchRadius; - private ABBooleanCallback autoTargetPartner; - private ABIntegerCallback maxPartners; - private ABOrderIdCallback pairingOrderId; - private ABOrderIdCallback pairingOffOrderId; - private ABBooleanCallback orderPairedUnit; - private ABOrderIdCallback orderPairedUnitOrderId; - private ABOrderIdCallback orderPairedUnitOffOrderId; - - private CBehaviorCategory behaviorCategory; - - public ABIntegerCallback getBufferManaRequired() { - return bufferManaRequired; - } - - public void setBufferManaRequired(ABIntegerCallback bufferManaRequired) { - this.bufferManaRequired = bufferManaRequired; - } - - public ABIntegerCallback getManaDrainedPerSecond() { - return manaDrainedPerSecond; - } - - public void setManaDrainedPerSecond(ABIntegerCallback manaDrainedPerSecond) { - this.manaDrainedPerSecond = manaDrainedPerSecond; - } - - public List getPointTargeted() { - return pointTargeted; - } - - public void setPointTargeted(List pointTargeted) { - this.pointTargeted = pointTargeted; - } - - public List getTargetedSpell() { - return targetedSpell; - } - - public void setTargetedSpell(List targetedSpell) { - this.targetedSpell = targetedSpell; - } - - public List getAutoAquireTarget() { - return autoAquireTarget; - } - - public void setAutoAquireTarget(List autoAquireTarget) { - this.autoAquireTarget = autoAquireTarget; - } - - public ABIDCallback getPairAbilityId() { - return pairAbilityId; - } - - public void setPairAbilityId(ABIDCallback pairAbilityId) { - this.pairAbilityId = pairAbilityId; - } - - public ABIDCallback getPairUnitId() { - return pairUnitId; - } - - public void setPairUnitId(ABIDCallback pairUnitId) { - this.pairUnitId = pairUnitId; - } - - public CommandStringErrorKeysEnum getPairUnitTypeError() { - return pairUnitTypeError; - } - - public void setPairUnitTypeError(CommandStringErrorKeysEnum pairUnitTypeError) { - this.pairUnitTypeError = pairUnitTypeError; - } - - public CommandStringErrorKeysEnum getCantTargetError() { - return cantTargetError; - } - - public void setCantTargetError(CommandStringErrorKeysEnum cantTargetError) { - this.cantTargetError = cantTargetError; - } - - public CommandStringErrorKeysEnum getCantPairError() { - return cantPairError; - } - - public void setCantPairError(CommandStringErrorKeysEnum cantPairError) { - this.cantPairError = cantPairError; - } - - public CommandStringErrorKeysEnum getCantPairOffError() { - return cantPairOffError; - } - - public void setCantPairOffError(CommandStringErrorKeysEnum cantPairOffError) { - this.cantPairOffError = cantPairOffError; - } - - public ABFloatCallback getPairSearchRadius() { - return pairSearchRadius; - } - - public void setPairSearchRadius(ABFloatCallback pairSearchRadius) { - this.pairSearchRadius = pairSearchRadius; - } - - public ABBooleanCallback getAutoTargetPartner() { - return autoTargetPartner; - } - - public void setAutoTargetPartner(ABBooleanCallback autoTargetPartner) { - this.autoTargetPartner = autoTargetPartner; - } - - public ABIntegerCallback getMaxPartners() { - return maxPartners; - } - - public void setMaxPartners(ABIntegerCallback maxPartners) { - this.maxPartners = maxPartners; - } - - public ABOrderIdCallback getPairingOrderId() { - return pairingOrderId; - } - - public void setPairingOrderId(ABOrderIdCallback pairingOrderId) { - this.pairingOrderId = pairingOrderId; - } - - public ABOrderIdCallback getPairingOffOrderId() { - return pairingOffOrderId; - } - - public void setPairingOffOrderId(ABOrderIdCallback pairingOffOrderId) { - this.pairingOffOrderId = pairingOffOrderId; - } - - public ABBooleanCallback getOrderPairedUnit() { - return orderPairedUnit; - } - - public void setOrderPairedUnit(ABBooleanCallback orderPairedUnit) { - this.orderPairedUnit = orderPairedUnit; - } - - public ABOrderIdCallback getOrderPairedUnitOrderId() { - return orderPairedUnitOrderId; - } - - public void setOrderPairedUnitOrderId(ABOrderIdCallback orderPairedUnitOrderId) { - this.orderPairedUnitOrderId = orderPairedUnitOrderId; - } - - public ABOrderIdCallback getOrderPairedUnitOffOrderId() { - return orderPairedUnitOffOrderId; - } - - public void setOrderPairedUnitOffOrderId(ABOrderIdCallback orderPairedUnitOffOrderId) { - this.orderPairedUnitOffOrderId = orderPairedUnitOffOrderId; - } - - public CBehaviorCategory getBehaviorCategory() { - return behaviorCategory; - } - - public void setBehaviorCategory(CBehaviorCategory behaviorCategory) { - this.behaviorCategory = behaviorCategory; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderSpecialDisplayFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderSpecialDisplayFields.java deleted file mode 100644 index 635c5c934..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderSpecialDisplayFields.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.booleancallbacks.ABBooleanCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.idcallbacks.ABIDCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.integercallbacks.ABIntegerCallback; - -public class AbilityBuilderSpecialDisplayFields { - - private ABBooleanCallback showOnAndOffIcons; - - private ABIntegerCallback foodCost; - private ABIntegerCallback goldCost; - private ABIntegerCallback lumberCost; - - private ABBooleanCallback hideAreaCursor; - private ABBooleanCallback instantCast; - private ABBooleanCallback castlessNoTarget; - - private ABBooleanCallback toggleable; - private ABBooleanCallback castToggleOff; - private ABBooleanCallback separateOnAndOff; - private ABIDCallback alternateUnitId; - - public ABBooleanCallback getShowOnAndOffIcons() { - return showOnAndOffIcons; - } - public void setShowOnAndOffIcons(ABBooleanCallback showOnAndOffIcons) { - this.showOnAndOffIcons = showOnAndOffIcons; - } - public ABIntegerCallback getFoodCost() { - return foodCost; - } - public void setFoodCost(ABIntegerCallback foodCost) { - this.foodCost = foodCost; - } - public ABIntegerCallback getGoldCost() { - return goldCost; - } - public void setGoldCost(ABIntegerCallback goldCost) { - this.goldCost = goldCost; - } - public ABIntegerCallback getLumberCost() { - return lumberCost; - } - public void setLumberCost(ABIntegerCallback lumberCost) { - this.lumberCost = lumberCost; - } - public ABBooleanCallback getHideAreaCursor() { - return hideAreaCursor; - } - public void setHideAreaCursor(ABBooleanCallback hideAreaCursor) { - this.hideAreaCursor = hideAreaCursor; - } - public ABBooleanCallback getInstantCast() { - return instantCast; - } - public void setInstantCast(ABBooleanCallback instantCast) { - this.instantCast = instantCast; - } - public ABBooleanCallback getCastlessNoTarget() { - return castlessNoTarget; - } - public void setCastlessNoTarget(ABBooleanCallback castlessNoTarget) { - this.castlessNoTarget = castlessNoTarget; - } - public ABBooleanCallback getToggleable() { - return toggleable; - } - public void setToggleable(ABBooleanCallback toggleable) { - this.toggleable = toggleable; - } - public ABBooleanCallback getCastToggleOff() { - return castToggleOff; - } - public void setCastToggleOff(ABBooleanCallback castToggleOff) { - this.castToggleOff = castToggleOff; - } - public ABBooleanCallback getSeparateOnAndOff() { - return separateOnAndOff; - } - public void setSeparateOnAndOff(ABBooleanCallback separateOnAndOff) { - this.separateOnAndOff = separateOnAndOff; - } - public ABIDCallback getAlternateUnitId() { - return alternateUnitId; - } - public void setAlternateUnitId(ABIDCallback alternateUnitId) { - this.alternateUnitId = alternateUnitId; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderTemplateType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderTemplateType.java deleted file mode 100644 index 72f516608..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderTemplateType.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -public enum AbilityBuilderTemplateType { - AURA, - AURA_SIMPLE, - AURA_STATS, - PASSIVE_STATS; -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderType.java deleted file mode 100644 index b32cc879f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/AbilityBuilderType.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser; - -import com.etheller.interpreter.ast.util.CHandle; - -public enum AbilityBuilderType implements CHandle { - NORMAL_AUTOTARGET, - NORMAL_PAIRING, - NORMAL_FLEXTARGET_SIMPLE, - NORMAL_UNITTARGET_SIMPLE, - NORMAL_POINTTARGET_SIMPLE, - NORMAL_NOTARGET_SIMPLE, - NORMAL_FLEXTARGET, - NORMAL_UNITTARGET, - NORMAL_POINTTARGET, - NORMAL_NOTARGET, - TOGGLE, - SMART, - PASSIVE, - TEMPLATE, - HIDDEN; - - @Override - public int getHandleId() { - return ordinal(); - } - - public static final AbilityBuilderType[] VALUES = values(); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/DataFieldLetter.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/DataFieldLetter.java deleted file mode 100644 index 67bc84309..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/DataFieldLetter.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template; - -import com.etheller.interpreter.ast.util.CHandle; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; - -public enum DataFieldLetter implements CHandle { - A(0), - B(1), - C(2), - D(3), - E(4), - F(5), - G(6), - H(7), - I(8), - J(9); - - private int index; - - DataFieldLetter(int index) { - this.index = index; - } - - public int getIndex() { - return index; - } - - @Override - public int getHandleId() { - return ordinal(); - } - - public static final DataFieldLetter[] VALUES = values(); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/MeleeRangeTargetOverride.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/MeleeRangeTargetOverride.java deleted file mode 100644 index a7f076005..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/MeleeRangeTargetOverride.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template; - -public class MeleeRangeTargetOverride { - private boolean targetMelee; - private boolean targetRange; - public boolean isTargetMelee() { - return targetMelee; - } - public void setTargetMelee(boolean targetMelee) { - this.targetMelee = targetMelee; - } - public boolean isTargetRange() { - return targetRange; - } - public void setTargetRange(boolean targetRange) { - this.targetRange = targetRange; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/StatBuffFromDataField.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/StatBuffFromDataField.java deleted file mode 100644 index 09e6261a5..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/StatBuffFromDataField.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; - -public class StatBuffFromDataField { - private StatBuffType type; - private DataFieldLetter percentageBooleanField; - private DataFieldLetter flatBooleanField; - private DataFieldLetter dataField; - private Boolean percentageOverride; - private DataFieldLetter targetMeleeField; - private DataFieldLetter targetRangeField; - - private transient NonStackingStatBuff buff; - private transient NonStackingStatBuff secondAtkBuff; - - public StatBuffFromDataField(StatBuffFromDataField statBuff) { - this.type = statBuff.getType(); - this.percentageBooleanField = statBuff.getPercentageBooleanField(); - this.flatBooleanField = statBuff.getFlatBooleanField(); - this.dataField = statBuff.getDataField(); - this.percentageOverride = statBuff.isPercentageOverride(); - this.targetMeleeField = statBuff.getTargetMeleeField(); - this.targetRangeField = statBuff.getTargetRangeField(); - } - public StatBuffType getType() { - return type; - } - public void setType(StatBuffType type) { - this.type = type; - } - public DataFieldLetter getPercentageBooleanField() { - return percentageBooleanField; - } - public void setPercentageBooleanField(DataFieldLetter percentageBooleanField) { - this.percentageBooleanField = percentageBooleanField; - } - public DataFieldLetter getFlatBooleanField() { - return flatBooleanField; - } - public void setFlatBooleanField(DataFieldLetter flatBooleanField) { - this.flatBooleanField = flatBooleanField; - } - public DataFieldLetter getDataField() { - return dataField; - } - public void setDataField(DataFieldLetter dataField) { - this.dataField = dataField; - } - public Boolean isPercentageOverride() { - return percentageOverride; - } - public void setPercentageOverride(Boolean percentageOverride) { - this.percentageOverride = percentageOverride; - } - public DataFieldLetter getTargetMeleeField() { - return targetMeleeField; - } - public void setTargetMeleeField(DataFieldLetter targetMeleeField) { - this.targetMeleeField = targetMeleeField; - } - public DataFieldLetter getTargetRangeField() { - return targetRangeField; - } - public void setTargetRangeField(DataFieldLetter targetRangeField) { - this.targetRangeField = targetRangeField; - } - public NonStackingStatBuff getBuff() { - return buff; - } - public void setBuff(NonStackingStatBuff buff) { - this.buff = buff; - } - public NonStackingStatBuff getSecondAtkBuff() { - return secondAtkBuff; - } - public void setSecondAtkBuff(NonStackingStatBuff secondAtkBuff) { - this.secondAtkBuff = secondAtkBuff; - } - - public NonStackingStatBuffType convertToNonStackingType(CAbilityTypeAbilityBuilderLevelData abilityData) { - boolean percentage = false; - if (this.isPercentageOverride() != null) { - percentage = this.isPercentageOverride(); - } else { - if (this.getPercentageBooleanField() != null) { - try { - percentage = Integer.parseInt(abilityData.getData() - .get(this.getPercentageBooleanField().getIndex())) == 1; - } catch (NumberFormatException exc) { - percentage = false; - } - } else if (this.getFlatBooleanField() != null) { - try { - percentage = !(Integer.parseInt( - abilityData.getData().get(this.getFlatBooleanField().getIndex())) == 1); - } catch (NumberFormatException exc) { - percentage = true; - } - } - } - if (this.getType() == StatBuffType.ATK) { - boolean targetMelee = false; - boolean targetRange = false; - if (this.getTargetMeleeField() != null) { - targetMelee = Integer.parseInt( - abilityData.getData().get(this.getTargetMeleeField().getIndex())) == 1; - } - if (this.getTargetRangeField() != null) { - targetRange = Integer.parseInt( - abilityData.getData().get(this.getTargetRangeField().getIndex())) == 1; - } - - return this.getType().toAtkNonStackingStatBuffType(percentage, targetMelee, targetRange); - } else { - return this.getType().toNonStackingStatBuffType(percentage); - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/StatBuffType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/StatBuffType.java deleted file mode 100644 index d3aec8360..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/parser/template/StatBuffType.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; - -public enum StatBuffType { - ATK, - ATKSPD, - DEF, - HPGEN, - MAXHPGEN, - MPGEN, - MAXMPGEN, - MVSPD, - HPSTEAL, - THORNS, - MAXHP, - MAXMP; - - - public NonStackingStatBuffType toNonStackingStatBuffType(boolean percentage) { - switch(this) { - case DEF: - if (percentage) { - return NonStackingStatBuffType.DEFPCT; - } else { - return NonStackingStatBuffType.DEF; - } - case HPGEN: - if (percentage) { - return NonStackingStatBuffType.HPGENPCT; - } else { - return NonStackingStatBuffType.HPGEN; - } - case MAXHPGEN: - if (percentage) { - return NonStackingStatBuffType.MAXHPGENPCT; - } else { - return NonStackingStatBuffType.HPGEN; - } - case MAXMPGEN: - if (percentage) { - return NonStackingStatBuffType.MAXMPGENPCT; - } else { - return NonStackingStatBuffType.MPGEN; - } - case MPGEN: - if (percentage) { - return NonStackingStatBuffType.MPGENPCT; - } else { - return NonStackingStatBuffType.MPGEN; - } - case MAXHP: - if (percentage) { - return NonStackingStatBuffType.MAXHPPCT; - } else { - return NonStackingStatBuffType.MAXHP; - } - case MAXMP: - if (percentage) { - return NonStackingStatBuffType.MAXMPPCT; - } else { - return NonStackingStatBuffType.MAXMP; - } - case MVSPD: - if (percentage) { - return NonStackingStatBuffType.MVSPDPCT; - } else { - return NonStackingStatBuffType.MVSPD; - } - case THORNS: - if (percentage) { - return NonStackingStatBuffType.THORNSPCT; - } else { - return NonStackingStatBuffType.THORNS; - } - case ATKSPD: - return NonStackingStatBuffType.ATKSPD; - case HPSTEAL: - return NonStackingStatBuffType.HPSTEAL; - case ATK: - default: - System.err.println("ERROR: Tried to convert Attack buff type with wrong function"); - return null; - } - } - - public NonStackingStatBuffType toAtkNonStackingStatBuffType(boolean percentage, boolean melee, boolean range) { - switch(this) { - case ATK: - if (percentage) { - if (melee && range) { - return NonStackingStatBuffType.ALLATKPCT; - } else if (melee) { - return NonStackingStatBuffType.MELEEATKPCT; - } else if (range) { - return NonStackingStatBuffType.RNGDATKPCT; - } - } else { - if (melee && range) { - return NonStackingStatBuffType.ALLATK; - } else if (melee) { - return NonStackingStatBuffType.MELEEATK; - } else if (range) { - return NonStackingStatBuffType.RNGDATK; - } - } - System.err.println("ERROR: Tried to convert Attack buff with both melee and range set to false"); - return null; - default: - System.err.println("ERROR: Tried to convert non-Attack buff type with wrong function"); - return null; - } - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/projectile/ABCollisionProjectileListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/projectile/ABCollisionProjectileListener.java deleted file mode 100644 index 0c1d927ef..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/projectile/ABCollisionProjectileListener.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityCollisionProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABCollisionProjectileListener implements CAbilityCollisionProjectileListener { - - private List onLaunch; - private List onPreHits; - private List canHitTarget; - private List onHit; - - private CUnit caster; - private Map localStore; - private int castId; - - public ABCollisionProjectileListener(List onLaunch, List onPreHits, List canHitTarget, List onHit, CUnit caster, - Map localStore, int castId) { - super(); - this.onLaunch = onLaunch; - this.onPreHits = onPreHits; - this.canHitTarget = canHitTarget; - this.onHit = onHit; - this.caster = caster; - this.localStore = localStore; - this.castId = castId; - } - - @Override - public void onLaunch(CSimulation game, CProjectile projectile, AbilityTarget target) { - if (onLaunch != null) { - localStore.put(ABLocalStoreKeys.THISPROJECTILE+castId, projectile); - for (ABAction action : onLaunch) { - action.runAction(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.THISPROJECTILE+castId); - } - } - - @Override - public void onPreHits(CSimulation game, CProjectile projectile, AbilityPointTarget loc) { - if (onPreHits != null) { - localStore.put(ABLocalStoreKeys.THISPROJECTILE+castId, projectile); - for (ABAction action : onPreHits) { - action.runAction(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.THISPROJECTILE+castId); - } - } - - @Override - public boolean canHitTarget(CSimulation game, CWidget target) { - boolean result = true; - if (canHitTarget != null) { - CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); - localStore.put(ABLocalStoreKeys.PROJECTILEHITUNIT+castId, targetUnit); - localStore.put(ABLocalStoreKeys.PROJECTILEHITDEST+castId, targetDest); - for (ABCondition condition : canHitTarget) { - result = result && condition.evaluate(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.PROJECTILEHITUNIT+castId); - localStore.remove(ABLocalStoreKeys.PROJECTILEHITDEST+castId); - } - return result; - } - - @Override - public void onHit(CSimulation game, CProjectile projectile, AbilityTarget target) { - if (onHit != null) { - CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); - localStore.put(ABLocalStoreKeys.THISPROJECTILE+castId, projectile); - localStore.put(ABLocalStoreKeys.PROJECTILEHITUNIT+castId, targetUnit); - localStore.put(ABLocalStoreKeys.PROJECTILEHITDEST+castId, targetDest); - for (ABAction action : onHit) { - action.runAction(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.PROJECTILEHITUNIT+castId); - localStore.remove(ABLocalStoreKeys.PROJECTILEHITDEST+castId); - localStore.remove(ABLocalStoreKeys.THISPROJECTILE+castId); - } - } - - @Override - public void setUnitTargets(int units) { - localStore.put(ABLocalStoreKeys.PROJECTILEUNITTARGETS+castId, units); - } - - @Override - public void setDestructableTargets(int dests) { - localStore.put(ABLocalStoreKeys.PROJECTILEDESTTARGETS+castId, dests); - } - - @Override - public void setCurrentLocation(AbilityPointTarget loc) { - localStore.put(ABLocalStoreKeys.PROJECTILECURRENTLOC+castId, loc); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/projectile/ABProjectileListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/projectile/ABProjectileListener.java deleted file mode 100644 index 0099d6a55..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/projectile/ABProjectileListener.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.projectile; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; - -public class ABProjectileListener implements CAbilityProjectileListener { - - private List onLaunch; - private List onHit; - - private CUnit caster; - private Map localStore; - private int castId; - - public ABProjectileListener(List onLaunch, List onHit, CUnit caster, - Map localStore, int castId) { - super(); - this.onLaunch = onLaunch; - this.onHit = onHit; - this.caster = caster; - this.localStore = localStore; - this.castId = castId; - } - - @Override - public void onLaunch(CSimulation game, CProjectile projectile, AbilityTarget target) { - if (onLaunch != null) { - localStore.put(ABLocalStoreKeys.THISPROJECTILE+castId, projectile); - for (ABAction action : onLaunch) { - action.runAction(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.THISPROJECTILE+castId); - } - } - - @Override - public void onHit(CSimulation game, CProjectile projectile, AbilityTarget target) { - if (onHit != null) { - CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); - CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); - localStore.put(ABLocalStoreKeys.THISPROJECTILE+castId, projectile); - localStore.put(ABLocalStoreKeys.PROJECTILEHITUNIT+castId, targetUnit); - localStore.put(ABLocalStoreKeys.PROJECTILEHITDEST+castId, targetDest); - for (ABAction action : onHit) { - action.runAction(game, caster, localStore, castId); - } - localStore.remove(ABLocalStoreKeys.PROJECTILEHITUNIT+castId); - localStore.remove(ABLocalStoreKeys.PROJECTILEHITDEST+castId); - localStore.remove(ABLocalStoreKeys.THISPROJECTILE+castId); - } - } - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/ABTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/ABTimer.java deleted file mode 100644 index c735a8568..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/ABTimer.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer; - -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ABTimer extends CTimer { - private CUnit caster; - private Map localStore; - private List actions; - - private int castId = 0; - - public ABTimer(CUnit caster, Map localStore, List actions, final int castId) { - super(); - this.caster = caster; - this.localStore = localStore; - this.actions = actions; - this.castId = castId; - } - - - public void onFire(CSimulation simulation) { - localStore.put(ABLocalStoreKeys.FIRINGTIMER, this); - if (actions != null) { - for (ABAction action : actions) { - action.runAction(simulation, caster, localStore, castId); - } - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/AltitudeAdjustmentTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/AltitudeAdjustmentTimer.java deleted file mode 100644 index 2a84e5ef1..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/AltitudeAdjustmentTimer.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer; - -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class AltitudeAdjustmentTimer extends CTimer { - private CUnit unit; - private float heightInc; - private int durTicks; - private int endTick = 0; - - public AltitudeAdjustmentTimer(CSimulation game, CUnit unit, float targetHeight, float duration) { - super(); - this.unit = unit; - durTicks = Math.round(duration / WarsmashConstants.SIMULATION_STEP_TIME); - if (durTicks == 0) { - durTicks = 1; - } - this.heightInc = (targetHeight - unit.getFlyHeight()) / durTicks; - if (durTicks > 1) { - this.setRepeats(true); - } - this.setTimeoutTime(0f); - } - - @Override - public void start(CSimulation game) { - if (endTick == 0) { - this.endTick = game.getGameTurnTick() + durTicks - 1; - } - super.start(game); - } - - public void onFire(CSimulation game) { - if (this.unit.isDead()) { - this.setRepeats(false); - return; - } - this.unit.setFlyHeight(this.unit.getFlyHeight() + this.heightInc); - if(game.getGameTurnTick() >= endTick) { - this.setRepeats(false); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/DelayInstantTransformationTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/DelayInstantTransformationTimer.java deleted file mode 100644 index a87108724..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/DelayInstantTransformationTimer.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer; - -import java.util.Map; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.handler.TransformationHandler.OnTransformationActions; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class DelayInstantTransformationTimer extends CTimer { - private Map localStore; - private OnTransformationActions actions; - private CUnit unit; - private boolean addAlternateTagAfter; - private CUnitType baseType; - private CUnitType targetType; - private AbilityBuilderAbility abil; - private boolean perm; - private War3ID theBuffId; - private float transTime; - private float dur; - - public DelayInstantTransformationTimer(CSimulation game, Map localStore, CUnit unit, - OnTransformationActions actions, boolean addAlternateTagAfter, float delay, CUnitType baseType, - CUnitType targetType, AbilityBuilderAbility ability, War3ID buffId, float transformationTime, - float duration) { - super(); - this.localStore = localStore; - this.unit = unit; - this.actions = actions; - this.addAlternateTagAfter = addAlternateTagAfter; - this.baseType = baseType; - this.targetType = targetType; - this.abil = ability; - this.theBuffId = buffId; - this.transTime = transformationTime; - this.dur = duration; - this.setRepeats(false); - this.setTimeoutTime(delay); - } - - public void onFire(CSimulation game) { - TransformationHandler.instantTransformation(game, localStore, unit, targetType, actions, abil, - addAlternateTagAfter, perm, false); - if (dur > 0) { - TransformationHandler.createInstantTransformBackBuff(game, localStore, unit, baseType, - actions.createUntransformActions(), abil, theBuffId, - addAlternateTagAfter, transTime, dur, perm); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/DelayTimerTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/DelayTimerTimer.java deleted file mode 100644 index 310823b5b..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/DelayTimerTimer.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer; - -import java.util.Map; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class DelayTimerTimer extends CTimer { - - private CTimer timer; - Map localStore; - - public DelayTimerTimer(CTimer timer, Map localStore, float delay) { - super(); - this.timer = timer; - this.localStore = localStore; - this.setRepeats(false); - this.setTimeoutTime(delay); - } - - public void onFire(CSimulation game) { - localStore.put(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, timer); - timer.start(game); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/ManaDepletedCheckTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/ManaDepletedCheckTimer.java deleted file mode 100644 index 866147444..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/ManaDepletedCheckTimer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class ManaDepletedCheckTimer extends CTimer { - private CUnit caster; - private AbilityBuilderActiveAbility ability; - - public ManaDepletedCheckTimer(CUnit caster, AbilityBuilderActiveAbility ability) { - super(); - this.caster = caster; - this.ability = ability; - this.setRepeats(true); - this.setTimeoutTime(0f); - } - - public void onFire(CSimulation game) { - if(caster.getMana() <= 0) { - ability.deactivate(game, caster); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/TransformationMorphAnimationTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/TransformationMorphAnimationTimer.java deleted file mode 100644 index 8647769db..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/timer/TransformationMorphAnimationTimer.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.timer; - -import java.util.EnumSet; - -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; -import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; - -public class TransformationMorphAnimationTimer extends CTimer { - private final CUnit unit; - private final boolean addAlternateTagAfter; - - public TransformationMorphAnimationTimer(final CSimulation game, final CUnit unit, - final boolean addAlternateTagAfter, final float delay) { - super(); - this.unit = unit; - this.addAlternateTagAfter = addAlternateTagAfter; - this.setRepeats(false); - this.setTimeoutTime(delay); - } - - @Override - public void onFire(final CSimulation game) { - if (this.addAlternateTagAfter) { - this.unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); - this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, SequenceUtils.EMPTY, 1.0f, - true); - } - else { - this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, - EnumSet.of(SecondaryTag.ALTERNATE), 1.0f, true); - } - this.unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, - this.addAlternateTagAfter ? EnumSet.of(SecondaryTag.ALTERNATE) : SequenceUtils.EMPTY, true); - if (this.addAlternateTagAfter) { - this.unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE); - } - else { - this.unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/definitions/impl/CAbilityTypeDefinitionAbilityBuilder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/definitions/impl/CAbilityTypeDefinitionAbilityBuilder.java deleted file mode 100644 index c70585255..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/definitions/impl/CAbilityTypeDefinitionAbilityBuilder.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.definitions.impl; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.CAbilityTypeDefinition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilder; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.data.CUnitData; - -public class CAbilityTypeDefinitionAbilityBuilder - extends AbstractCAbilityTypeDefinition implements CAbilityTypeDefinition { - - private AbilityBuilderConfiguration parser; - - public CAbilityTypeDefinitionAbilityBuilder(AbilityBuilderConfiguration abilityBuilderParser) { - super(); - this.parser = abilityBuilderParser; - } - - @Override - public CAbilityType createAbilityType(final War3ID alias, final GameObject abilityEditorData) { - if (abilityEditorData != null) { - final int levels = abilityEditorData.getFieldAsInteger(LEVELS, 0); - final List levelData = new ArrayList<>(); - for (int level = 1; level <= levels; level++) { - levelData.add(createLevelData(abilityEditorData, level)); - } - return innerCreateAbilityType(alias, abilityEditorData, levelData); - } else { - return innerCreateAbilityType(alias, null, null); - } - } - - @Override - protected CAbilityTypeAbilityBuilderLevelData createLevelData(final GameObject abilityEditorData, - final int level) { - final String targetsAllowedAtLevelString = abilityEditorData.readSLKTag(TARGETS_ALLOWED+level); - final float area = abilityEditorData.readSLKTagFloat(AREA+level); - final float castRange = abilityEditorData.readSLKTagFloat(CAST_RANGE+level); - final float castTime = abilityEditorData.readSLKTagFloat(CASTING_TIME+level); - final float cooldown = abilityEditorData.readSLKTagFloat(COOLDOWN+level); - final float durationHero = abilityEditorData.readSLKTagFloat(HERO_DURATION+level); - final float durationNormal = abilityEditorData.readSLKTagFloat(DURATION+level); - final String[] buffStrings = abilityEditorData.readSLKTag(BUFF+level).split(","); - final String[] effectStrings = abilityEditorData.readSLKTag(EFFECT+level).split(","); - final String unitIdStr = abilityEditorData.readSLKTag(UNIT_ID+level); - War3ID unitId = War3ID.NONE; - if (unitIdStr != null && !unitIdStr.isEmpty() && unitIdStr.length() == 4) { - unitId = War3ID.fromString(unitIdStr); - } - - final List data = new ArrayList<>(); - List buffs = new ArrayList<>(); - List effects = new ArrayList<>(); - for (String buff : buffStrings) { - if (buff != null && !buff.isEmpty()) { - buffs.add(War3ID.fromString(buff)); - } - } - for (String effect : effectStrings) { - if (effect != null && !effect.isEmpty()) { - effects.add(War3ID.fromString(effect)); - } - } - String[] letters = { "A", "B", "C", "D", "E", "F", "G", "H", "I" }; - for (String letter : letters) { - data.add(abilityEditorData.readSLKTag("Data" + letter + level)); - } - final int manaCost = abilityEditorData.readSLKTagInt(MANA_COST+level); - final EnumSet targetsAllowedAtLevel = CTargetType.parseTargetTypeSet(targetsAllowedAtLevelString); - - int checkDeps = abilityEditorData.readSLKTagInt(CHECK_DEPENDENCIES); - List requirements = null; - if (checkDeps > 0) { - final List requirementsString = abilityEditorData.getFieldAsList(REQUIREMENTS); - final List requirementsLevelsString = abilityEditorData.getFieldAsList(REQUIREMENT_LEVELS); - requirements = CUnitData.parseRequirements(requirementsString, - requirementsLevelsString); - } - - return new CAbilityTypeAbilityBuilderLevelData(targetsAllowedAtLevel, area, castRange, castTime, cooldown, - durationHero, durationNormal, buffs, effects, manaCost, data, unitId, requirements); - } - - @Override - protected CAbilityType innerCreateAbilityType(final War3ID alias, final GameObject abilityEditorData, - final List levelData) { - if (abilityEditorData != null) { - return new CAbilityTypeAbilityBuilder(alias, abilityEditorData.getFieldAsWar3ID(CODE, -1), abilityEditorData, levelData, parser); - } else { - return new CAbilityTypeAbilityBuilder(alias, alias, null, null, parser); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/definitions/impl/CAbilityTypeDefinitionAbilityTemplateBuilder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/definitions/impl/CAbilityTypeDefinitionAbilityTemplateBuilder.java deleted file mode 100644 index d0ac8f69f..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/definitions/impl/CAbilityTypeDefinitionAbilityTemplateBuilder.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.definitions.impl; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.CAbilityTypeDefinition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParser; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityBuilderLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl.CAbilityTypeAbilityTemplateBuilder; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.data.CUnitData; - -public class CAbilityTypeDefinitionAbilityTemplateBuilder - extends AbstractCAbilityTypeDefinition implements CAbilityTypeDefinition { - - private AbilityBuilderParser parser; - - public CAbilityTypeDefinitionAbilityTemplateBuilder(AbilityBuilderParser abilityBuilderParser) { - super(); - this.parser = abilityBuilderParser; - } - - @Override - public CAbilityType createAbilityType(final War3ID alias, final GameObject abilityEditorData) { - if (abilityEditorData != null) { - final int levels = abilityEditorData.getFieldAsInteger(LEVELS, 0); - final List levelData = new ArrayList<>(); - for (int level = 1; level <= levels; level++) { - levelData.add(createLevelData(abilityEditorData, level)); - } - return innerCreateAbilityType(alias, abilityEditorData, levelData); - } else { - return innerCreateAbilityType(alias, null, null); - } - } - - @Override - protected CAbilityTypeAbilityBuilderLevelData createLevelData(final GameObject abilityEditorData, - final int level) { - final String targetsAllowedAtLevelString = abilityEditorData.readSLKTag(TARGETS_ALLOWED+level); - final float area = abilityEditorData.readSLKTagFloat(AREA+level); - final float castRange = abilityEditorData.readSLKTagFloat(CAST_RANGE+level); - final float castTime = abilityEditorData.readSLKTagFloat(CASTING_TIME+level); - final float cooldown = abilityEditorData.readSLKTagFloat(COOLDOWN+level); - final float durationHero = abilityEditorData.readSLKTagFloat(HERO_DURATION+level); - final float durationNormal = abilityEditorData.readSLKTagFloat(DURATION+level); - final String[] buffStrings = abilityEditorData.readSLKTag(BUFF+level).split(","); - final String[] effectStrings = abilityEditorData.readSLKTag(EFFECT+level).split(","); - final String unitIdStr = abilityEditorData.readSLKTag(UNIT_ID+level); - War3ID unitId = War3ID.NONE; - if (unitIdStr != null && !unitIdStr.isEmpty()) { - unitId = War3ID.fromString(unitIdStr); - } - - final List data = new ArrayList<>(); - List buffs = new ArrayList<>(); - List effects = new ArrayList<>(); - for (String buff : buffStrings) { - if (buff != null && !buff.isEmpty()) { - buffs.add(War3ID.fromString(buff)); - } - } - for (String effect : effectStrings) { - if (effect != null && !effect.isEmpty()) { - effects.add(War3ID.fromString(effect)); - } - } - String[] letters = { "A", "B", "C", "D", "E", "F", "G", "H", "I" }; - for (String letter : letters) { - data.add(abilityEditorData.readSLKTag("Data" + letter + level)); - } - final int manaCost = abilityEditorData.readSLKTagInt(MANA_COST+level); - final EnumSet targetsAllowedAtLevel = CTargetType.parseTargetTypeSet(targetsAllowedAtLevelString); - - int checkDeps = abilityEditorData.readSLKTagInt(CHECK_DEPENDENCIES); - List requirements = null; - if (checkDeps > 0) { - final List requirementsString = abilityEditorData.getFieldAsList(REQUIREMENTS); - final List requirementsLevelsString = abilityEditorData.getFieldAsList(REQUIREMENT_LEVELS); - requirements = CUnitData.parseRequirements(requirementsString, - requirementsLevelsString); - } - - return new CAbilityTypeAbilityBuilderLevelData(targetsAllowedAtLevel, area, castRange, castTime, cooldown, - durationHero, durationNormal, buffs, effects, manaCost, data, unitId, requirements); - } - - @Override - protected CAbilityType innerCreateAbilityType(final War3ID alias, final GameObject abilityEditorData, - final List levelData) { - if (abilityEditorData != null) { - return new CAbilityTypeAbilityTemplateBuilder(alias, abilityEditorData.getFieldAsWar3ID(CODE, -1), abilityEditorData, levelData, parser); - } else { - return new CAbilityTypeAbilityTemplateBuilder(alias, alias, null, null, parser); - } - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityBuilder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityBuilder.java deleted file mode 100644 index 268c1880a..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityBuilder.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.CAbilitySpell; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.*; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; - -public class CAbilityTypeAbilityBuilder extends CAbilityType { - - private AbilityBuilderConfiguration parser; - private GameObject abilityEditorData; - - public CAbilityTypeAbilityBuilder(War3ID alias, War3ID code, GameObject abilityEditorData, List levelData, AbilityBuilderConfiguration parser) { - super(alias, code, levelData); - this.parser = parser; - this.abilityEditorData = abilityEditorData; - } - - @Override - public CAbility createAbility(int handleId) { - Map localStore = new HashMap<>(); - localStore.put(ABLocalStoreKeys.ABILITYEDITORDATA, this.abilityEditorData); - localStore.put(ABLocalStoreKeys.LEVELDATA, getLevelData()); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, 1); - localStore.put(ABLocalStoreKeys.ALIAS, getAlias()); - localStore.put(ABLocalStoreKeys.CODE, getCode()); - CAbilitySpell ability; - - switch (parser.getType()) { - case PASSIVE: - return new CAbilityAbilityBuilderPassive(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case HIDDEN: - return new CAbilityAbilityBuilderNoIcon(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case TOGGLE: - return new CAbilityAbilityBuilderActiveToggle(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case NORMAL_NOTARGET_SIMPLE: - ability = new CAbilityAbilityBuilderActiveNoTargetSimple(handleId, getAlias(), getLevelData(), parser, localStore); - ability.populate(this.abilityEditorData, 1); - return ability; - case NORMAL_POINTTARGET_SIMPLE: - ability = new CAbilityAbilityBuilderActivePointTargetSimple(handleId, getAlias(), getLevelData(), parser, localStore); - ability.populate(this.abilityEditorData, 1); - return ability; - case NORMAL_UNITTARGET_SIMPLE: - ability = new CAbilityAbilityBuilderActiveUnitTargetSimple(handleId, getAlias(), getLevelData(), parser, localStore); - ability.populate(this.abilityEditorData, 1); - return ability; - case NORMAL_FLEXTARGET_SIMPLE: - ability = new CAbilityAbilityBuilderActiveFlexTargetSimple(handleId, getAlias(), getLevelData(), parser, localStore); - ability.populate(this.abilityEditorData, 1); - return ability; - case NORMAL_FLEXTARGET: - return new CAbilityAbilityBuilderActiveFlexTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case NORMAL_PAIRING: - return new CAbilityAbilityBuilderActivePairing(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case NORMAL_AUTOTARGET: - return new CAbilityAbilityBuilderActiveAutoTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case NORMAL_NOTARGET: - return new CAbilityAbilityBuilderActiveNoTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case NORMAL_POINTTARGET: - return new CAbilityAbilityBuilderActivePointTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - case NORMAL_UNITTARGET: - default: - return new CAbilityAbilityBuilderActiveUnitTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); - } - } - - public void setLevel(CSimulation game, CUnit unit, CAbilitySpell existingAbility, int level) { - existingAbility.setLevel(game, unit, level); - existingAbility.populate(abilityEditorData, level); - } - - @Override - public void setLevel(CSimulation game, CUnit unit, CLevelingAbility existingAbility, int level) { - existingAbility.setLevel(game, unit, level); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityBuilderLevelData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityBuilderLevelData.java deleted file mode 100644 index 00b42137e..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityBuilderLevelData.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl; - -import java.util.EnumSet; -import java.util.List; - -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityTypeLevelData; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; - -public class CAbilityTypeAbilityBuilderLevelData extends CAbilityTypeLevelData { - private final float area; - private final float castRange; - private final float castTime; - private final float cooldown; - private final float durationHero; - private final float durationNormal; - private final List buffs; - private final List effects; - private final int manaCost; - private final List data; - private final War3ID unitId; - private List requirements; - - public CAbilityTypeAbilityBuilderLevelData(EnumSet targetsAllowed, float area, float castRange, - float castTime, float cooldown, float durationHero, float durationNormal, List buffs, - List effects, int manaCost, List data, War3ID unitId, List requirements) { - super(targetsAllowed); - this.area = area; - this.castRange = castRange; - this.castTime = castTime; - this.cooldown = cooldown; - this.durationHero = durationHero; - this.durationNormal = durationNormal; - this.buffs = buffs; - this.effects = effects; - this.manaCost = manaCost; - this.data = data; - this.unitId = unitId; - this.requirements = requirements; - } - - public float getArea() { - return area; - } - - public float getCastRange() { - return castRange; - } - - public float getCastTime() { - return castTime; - } - - public float getCooldown() { - return cooldown; - } - - public float getDurationHero() { - return durationHero; - } - - public float getDurationNormal() { - return durationNormal; - } - - public List getBuffs() { - return buffs; - } - - public List getEffects() { - return effects; - } - - public int getManaCost() { - return manaCost; - } - - public List getData() { - return data; - } - - public War3ID getUnitId() { - return unitId; - } - - /** - * @return the requirements - */ - public List getRequirements() { - return requirements; - } - - /** - * @param requirements the requirements to set - */ - public void setRequirements(List requirements) { - this.requirements = requirements; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityTemplateBuilder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityTemplateBuilder.java deleted file mode 100644 index f5eedbca7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/types/impl/CAbilityTypeAbilityTemplateBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.etheller.warsmash.units.GameObject; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template.CAbilityAbilityBuilderAuraTemplate; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template.CAbilityAbilityBuilderSimpleAuraTemplate; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template.CAbilityAbilityBuilderStatAuraTemplate; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.template.CAbilityAbilityBuilderStatPassiveTemplate; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParser; - -public class CAbilityTypeAbilityTemplateBuilder extends CAbilityType { - - private AbilityBuilderParser parser; - private GameObject abilityEditorData; - - public CAbilityTypeAbilityTemplateBuilder(War3ID alias, War3ID code, GameObject abilityEditorData, List levelData, AbilityBuilderParser parser) { - super(alias, code, levelData); - this.parser = parser; - this.abilityEditorData = abilityEditorData; - } - - @Override - public CAbility createAbility(int handleId) { - Map localStore = new HashMap<>(); - localStore.put(ABLocalStoreKeys.ABILITYEDITORDATA, this.abilityEditorData); - localStore.put(ABLocalStoreKeys.LEVELDATA, getLevelData()); - localStore.put(ABLocalStoreKeys.CURRENTLEVEL, 1); - localStore.put(ABLocalStoreKeys.ALIAS, getAlias()); - - switch (parser.getTemplateType()) { - case PASSIVE_STATS: - return new CAbilityAbilityBuilderStatPassiveTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getStatBuffsFromDataFields()); - case AURA_STATS: - return new CAbilityAbilityBuilderStatAuraTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getStatBuffsFromDataFields(), parser.getMeleeRangeTargetOverride()); - case AURA_SIMPLE: - return new CAbilityAbilityBuilderSimpleAuraTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getAbilityIdsToAddPerLevel(), parser.getLevellingAbilityIdsToAdd()); - case AURA: - default: - return new CAbilityAbilityBuilderAuraTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getAddToAuraActions(), parser.getUpdateAuraLevelActions(), parser.getRemoveFromAuraActions()); - } - } - - @Override - public void setLevel(CSimulation game, CUnit unit, CLevelingAbility existingAbility, int level) { - existingAbility.setLevel(game, unit, level); - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderAbility.java new file mode 100644 index 000000000..1a25e9e7b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderAbility.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.Aliased; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public interface ABAbilityBuilderAbility extends CLevelingAbility, Aliased { + public List getLevelData(); + + public ABAbilityBuilderConfiguration getConfig(); + + public ABLocalDataStore getLocalStore(); + + public float getArea(); + + public float getCooldown(); + + public float getCastRange(); + + public float getCastTime(); + + public void startCooldown(CSimulation game, CUnit unit); + + public void resetCooldown(CSimulation game, CUnit unit); + + public float getCooldownRemainingTicks(CSimulation game, CUnit unit); + + War3ID getOnTooltipOverride(); + + public int getAbilityIntField(String field); + public float getAbilityFloatField(String field); + public String getAbilityStringField(String field); + public boolean getAbilityBooleanField(String field); + + boolean hasUniqueFlag(String flag); + void addUniqueFlag(String flag); + void removeUniqueFlag(String flag); + + public int getIconVisibleMenuId(); + void setIconVisibleMenuId(int menu); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveAbility.java new file mode 100644 index 000000000..fe5a736c5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveAbility.java @@ -0,0 +1,81 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.CAutocastAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.GenericSingleIconActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; + +public interface ABAbilityBuilderActiveAbility extends ABAbilityBuilderAbility, CAutocastAbility, GenericSingleIconActiveAbility { + public List getLevelData(); + + public ABAbilityBuilderConfiguration getConfig(); + + public ABLocalDataStore getLocalStore(); + + public int getChargedManaCost(); + public void setCastRange(float castRange); + public boolean ignoreCastTime(); + + public EnumSet getTargetsAllowed(); + + public int getOffOrderId(); + + public PrimaryTag getCastingPrimaryTag(); + + public EnumSet getCastingSecondaryTags(); + + public void activate(final CSimulation game, final CUnit caster); + + public void deactivate(final CSimulation game, final CUnit caster); + + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver); + + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, + boolean autoOrder, final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver); + + public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, + boolean autoOrder, final AbilityTargetCheckReceiver receiver); + + public void internalBegin(CSimulation game, CUnit theCaster, int orderId, boolean b, AbilityTarget theTarget); + + public void runOnOrderIssuedActions(CSimulation game, CUnit caster, int orderId); + + public void runBeginCastingActions(CSimulation game, CUnit caster, int orderId); + + public void runEndCastingActions(CSimulation game, CUnit caster, int orderId); + + public void runChannelTickActions(CSimulation game, CUnit caster, int orderId); + + public void runEndChannelActions(CSimulation game, CUnit caster, int orderId); + + public void runCancelPreCastActions(CSimulation game, CUnit caster, int orderId); + + public boolean isSeparateOnAndOff(); + + War3ID getOnTooltipOverride(); + + War3ID getOffTooltipOverride(); + + boolean isActive(); + + public void cleanupInputs(); + public void cleanupInputs(int castId); + + public boolean isMenuAbility(); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveAutoTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveAutoTarget.java new file mode 100644 index 000000000..dde52bf09 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveAutoTarget.java @@ -0,0 +1,153 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; + +public class ABAbilityBuilderActiveAutoTarget extends ABAbilityBuilderGenericActive { + private ABBehavior behavior; + + public ABAbilityBuilderActiveAutoTarget(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, code, alias, levelData, config, localStore); + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + this.behavior = this.createRangedBehavior(unit); + super.onAdd(game, unit); + } + + @Override + protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver) { + return true; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + return true; + } + + @Override + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + CWidget target = autoTarget(game, caster); + if (target != null) { + this.runOnOrderIssuedActions(game, caster, orderId); + this.behavior.setCastId(castId); + return this.behavior.reset(game, target, orderId, autoOrder); + } else { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId)); + return null; + } + } + + @Override + public void internalBegin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget noTarget) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, caster.getCurrentBehavior()); + CWidget target = autoTarget(game, caster); + if (target != null) { + this.runOnOrderIssuedActions(game, caster, orderId); + } else { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId)); + } + } + + public CWidget autoTarget(CSimulation game, CUnit caster) { + CWidget target = null; + + if (this.config.getSpecialFields() != null && this.config.getSpecialFields().getAutoAquireTarget() != null) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId)); + + for (ABAction action : this.config.getSpecialFields().getAutoAquireTarget()) { + action.runAction(caster, this.localStore, castId); + } + + target = this.localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), + CWidget.class); + if (target == null) { + target = this.localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId), + CWidget.class); + if (target == null) { + target = this.localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId), CWidget.class); + } + } + } + return target; + } + + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver) { + CWidget prevTarget = null; + prevTarget = this.localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, ABConstants.NO_CAST_ID), + CWidget.class); + if (prevTarget == null) { + prevTarget = this.localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, ABConstants.NO_CAST_ID), + CWidget.class); + if (prevTarget == null) { + prevTarget = this.localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, ABConstants.NO_CAST_ID), + CWidget.class); + } + } + if (target == prevTarget) { + return true; + } else { + receiver.orderIdNotAccepted(); + return false; + } + } + + // Unused + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { + return null; + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { + return null; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveFlexTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveFlexTarget.java new file mode 100644 index 000000000..6e54167cd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveFlexTarget.java @@ -0,0 +1,252 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderBase; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderNoTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; + +public class ABAbilityBuilderActiveFlexTarget extends ABAbilityBuilderGenericActive { + private ABBehavior behavior; + + private boolean targetedSpell = false; + private boolean pointTarget = false; + private boolean castless; + + public ABAbilityBuilderActiveFlexTarget(int handleId, War3ID alias, War3ID code, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, alias, code, levelData, config, localStore); + } + + private void setTargeted(CSimulation game, CUnit unit) { + if (config.getSpecialFields() != null && config.getSpecialFields().getTargetedSpell() != null) { + boolean result = true; + for (ABBooleanCallback condition : config.getSpecialFields().getTargetedSpell()) { + result = result && condition.callback(unit, localStore, ABConstants.NO_CAST_ID); + } + this.targetedSpell = result; + } + } + + private void setPointTarget(CSimulation game, CUnit unit) { + if (config.getSpecialFields() != null && config.getSpecialFields().getPointTargeted() != null) { + boolean result = true; + for (ABBooleanCallback condition : config.getSpecialFields().getPointTargeted()) { + result = result && condition.callback(unit, localStore, ABConstants.NO_CAST_ID); + } + this.pointTarget = result; + } + } + + protected void determineCastless(CUnit unit) { + if (this.item != null || this.config.getDisplayFields() != null + && this.config.getDisplayFields().getCastlessNoTarget() != null && this.config.getDisplayFields() + .getCastlessNoTarget().callback(unit, localStore, ABConstants.NO_CAST_ID)) { + this.castless = true; + this.behavior = null; + } else { + this.castless = false; + if (this.behavior == null || !(this.behavior instanceof ABBehaviorAbilityBuilderNoTarget)) { + this.behavior = this.createNoTargetBehavior(unit); + } + } + } + + private void setBehavior(final CUnit unit) { + if (this.targetedSpell) { + if (this.behavior == null || !(this.behavior instanceof ABBehaviorAbilityBuilderBase)) { + this.behavior = this.createRangedBehavior(unit); + } + } else { + this.determineCastless(unit); + } + } + + public boolean isTargetedSpell() { + return this.targetedSpell; + } + + public boolean isPointTarget() { + return this.pointTarget; + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + this.setTargeted(game, unit); + this.setPointTarget(game, unit); + this.setBehavior(unit); + + } + + @Override + public void onAddDisabled(CSimulation game, CUnit unit) { + localStore.put(ABLocalStoreKeys.ISFLEXABILITY, this); + super.onAddDisabled(game, unit); + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + this.behavior = new ABBehaviorAbilityBuilderBase(unit, localStore, this); + this.setTargeted(game, unit); + this.setPointTarget(game, unit); + this.setBehavior(unit); + super.onAdd(game, unit); + } + + @Override + public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, + final AbilityTarget target) { + this.localStore.put(ABLocalStoreKeys.ISAUTOCASTTARGETING, autoOrder); + if (!this.isTargetedSpell() && castless && orderId == this.getBaseOrderId()) { + this.runBeginCastingActions(game, caster, orderId); + this.runEndCastingActions(game, caster, orderId); + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + return false; + } + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { + if (this.isTargetedSpell() && !this.isPointTarget()) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), + this.getLevel()); + this.behavior.setCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), + target.visit(AbilityTargetVisitor.UNIT)); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId), + target.visit(AbilityTargetVisitor.ITEM)); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId), + target.visit(AbilityTargetVisitor.DESTRUCTABLE)); + this.runOnOrderIssuedActions(game, caster, orderId); + return this.behavior.reset(game, target, orderId, autoOrder); + } else { + return null; + } + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { + if (this.isTargetedSpell() && this.isPointTarget()) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), + this.getLevel()); + this.behavior.setCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + this.castId, point); + this.runOnOrderIssuedActions(game, caster, orderId); + return this.behavior.reset(game, point, orderId, autoOrder); + } else { + return null; + } + } + + @Override + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { + if (!this.isTargetedSpell()) { + if (castless) { + return null; + } else { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), + this.getLevel()); + this.behavior.setCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + this.runOnOrderIssuedActions(game, caster, orderId); + return this.behavior.reset(orderId, autoOrder); + } + } else { + return null; + } + } + + @Override + public void internalBegin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget target) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, caster.getCurrentBehavior()); + if (this.isTargetedSpell()) { + if (this.isPointTarget()) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + this.castId, + target.visit(AbilityTargetVisitor.POINT)); + this.runOnOrderIssuedActions(game, caster, orderId); + } else { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), + target.visit(AbilityTargetVisitor.UNIT)); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId), + target.visit(AbilityTargetVisitor.ITEM)); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId), + target.visit(AbilityTargetVisitor.DESTRUCTABLE)); + this.runOnOrderIssuedActions(game, caster, orderId); + } + } else { + if (!castless) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + this.runOnOrderIssuedActions(game, caster, orderId); + } + } + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver) { + if (this.isTargetedSpell() && !this.isPointTarget()) { + return true; + } else { + receiver.orderIdNotAccepted(); + return false; + } + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + if (this.isTargetedSpell() && this.isPointTarget()) { + return true; + } else { + receiver.orderIdNotAccepted(); + return false; + } + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + if (!this.isTargetedSpell()) { + return true; + } else { + receiver.orderIdNotAccepted(); + return false; + } + } + + @Override + protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver) { + return true; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveNoTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveNoTarget.java new file mode 100644 index 000000000..71df030aa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveNoTarget.java @@ -0,0 +1,151 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; + +public class ABAbilityBuilderActiveNoTarget extends ABAbilityBuilderGenericActive { + + private ABBehavior behavior; + private boolean castless; + + public ABAbilityBuilderActiveNoTarget(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, code, alias, levelData, config, localStore); + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + super.onAdd(game, unit); + determineCastless(unit); + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + determineCastless(unit); + } + + protected void determineCastless(CUnit unit) { + if (this.item != null || this.config.getDisplayFields() != null + && this.config.getDisplayFields().getCastlessNoTarget() != null && this.config.getDisplayFields() + .getCastlessNoTarget().callback(unit, localStore, ABConstants.NO_CAST_ID)) { + this.castless = true; + this.behavior = null; + } else { + this.castless = false; + this.behavior = this.createNoTargetBehavior(unit); + } + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { + return null; + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { + return null; + } + + @Override + public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, + final AbilityTarget target) { + this.localStore.put(ABLocalStoreKeys.ISAUTOCASTTARGETING, autoOrder); + +// System.err.println("Checking queue notarg level: " + active + " orderID : " + orderId + " offID: " + this.getOffOrderId()); + if (castless && orderId == this.getBaseOrderId()) { +// System.err.println("Castless"); + if (!caster.chargeMana(this.getChargedManaCost())) { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), + CommandStringErrorKeys.NOT_ENOUGH_MANA); +// System.err.println("NoMana"); + return false; + } +// System.err.println("Had mana?"); + this.startCooldown(game, caster); + this.runBeginCastingActions(game, caster, orderId); + this.runEndCastingActions(game, caster, orderId); + caster.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CHANNEL, this, null); + caster.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this, null); + caster.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, this, null); + caster.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this, null); + caster.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this, null); + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + return false; + } + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); + } + + @Override + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { + this.internalBegin(game, caster, orderId, autoOrder, null); + if (castless) { + return null; + } else { + this.behavior.setCastId(castId); + return this.behavior.reset(orderId, autoOrder); + } + } + + @Override + public void internalBegin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget target) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + if (!castless) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, caster.getCurrentBehavior()); + this.runOnOrderIssuedActions(game, caster, orderId); + } + } + + @Override + public void cleanupInputs(int theCastId) { + this.localStore.remove(ABLocalStoreKeys.PREVIOUSBEHAVIOR); + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + return true; + } + + @Override + protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver) { + return true; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActivePairing.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActivePairing.java new file mode 100644 index 000000000..5e8018a0b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActivePairing.java @@ -0,0 +1,489 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CPairingAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorSendOrder; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitAndRangeComparator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeysEnum; + +public class ABAbilityBuilderActivePairing extends ABAbilityBuilderGenericActive implements CPairingAbility { + private ABBehavior behavior; + + private War3ID pairUnitId = null; + private War3ID pairAbilityId = null; + + private boolean autoTargetPartner = false; + private float pairSearchRadius = 0; + + private int internalOrderId = -1; + private int maxPartners = 1; + + private boolean orderPairedUnit = false; + private int orderPairedUnitOrderId = -1; + + private int internalOffOrderId = -1; + private int orderPairedUnitOffOrderId = -1; + + public ABAbilityBuilderActivePairing(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, code, alias, levelData, config, localStore); + + if (this.castingPrimaryTag == null) { + this.castingPrimaryTag = PrimaryTag.STAND; + } + + this.allowCastlessDeactivate = false; + } + + private void setPairingValues(CSimulation game, CUnit unit) { + + if (this.config.getSpecialFields() != null) { + if (this.config.getSpecialFields().getPairAbilityId() != null) { + this.pairAbilityId = this.config.getSpecialFields().getPairAbilityId().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getSpecialFields().getPairUnitId() != null) { + this.pairUnitId = this.config.getSpecialFields().getPairUnitId().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + + if (this.config.getSpecialFields().getAutoTargetPartner() != null) { + this.autoTargetPartner = this.config.getSpecialFields().getAutoTargetPartner().callback(unit, + localStore, ABConstants.NO_CAST_ID); + } + if (this.config.getSpecialFields().getPairSearchRadius() != null) { + this.pairSearchRadius = this.config.getSpecialFields().getPairSearchRadius().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + + if (this.config.getSpecialFields().getPairingOrderId() != null) { + this.internalOrderId = this.config.getSpecialFields().getPairingOrderId().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + + if (this.config.getSpecialFields().getPairingOffOrderId() != null) { + this.internalOffOrderId = this.config.getSpecialFields().getPairingOffOrderId().callback(unit, + localStore, ABConstants.NO_CAST_ID); + } + if (this.config.getSpecialFields().getMaxPartners() != null) { + this.maxPartners = this.config.getSpecialFields().getMaxPartners().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getSpecialFields().getOrderPairedUnit() != null) { + this.orderPairedUnit = this.config.getSpecialFields().getOrderPairedUnit().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getSpecialFields().getOrderPairedUnitOrderId() != null) { + this.orderPairedUnitOrderId = this.config.getSpecialFields().getOrderPairedUnitOrderId().callback(unit, + localStore, ABConstants.NO_CAST_ID); + } + if (this.config.getSpecialFields().getOrderPairedUnitOffOrderId() != null) { + this.orderPairedUnitOffOrderId = this.config.getSpecialFields().getOrderPairedUnitOffOrderId() + .callback(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + localStore.put(ABLocalStoreKeys.ISPAIRABILITY, this); + this.behavior = this.createRangedBehavior(unit); + this.behavior.setInstant(true); + super.onAdd(game, unit); + this.setPairingValues(game, unit); + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + this.setPairingValues(game, unit); + } + + protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver) { +// System.err.println(unit.getUnitType().getName() + " Checking can use order: " + orderId + " (Base: " +// + this.getBaseOrderId() + ", Internal: " + this.getPairOrderId(game, unit) + ")"); + if (checkNoTargetOrderId(game, unit, orderId)) { + Set partners = this.findPairUnits(game, unit); + if (partners == null || partners.isEmpty()) { + boolean isOffId = orderId == this.getOffOrderId() || orderId == this.getPairOffOrderId(game, unit); + if (!isOffId && this.config.getSpecialFields().getCantPairError() != null) { +// System.out.println("Use check failed: no parter, special message"); + receiver.activationCheckFailed(this.config.getSpecialFields().getCantPairError().getKey()); + return false; + } else if (isOffId && this.config.getSpecialFields().getCantPairOffError() != null) { +// System.out.println("Use check failed: no parter, special message"); + receiver.activationCheckFailed(this.config.getSpecialFields().getCantPairOffError().getKey()); + return false; + } else { +// System.out.println("Use check failed: no parter"); + receiver.activationCheckFailed(CommandStringErrorKeysEnum.UNABLE_TO_FIND_COUPLE_TARGET.getKey()); + return false; + } + } +// System.err.println("Check use: Partner found"); + } + return true; + } + + @Override + protected boolean innerCheckCastOrderId(final CSimulation game, final CUnit unit, final int orderId) { + return orderId == getBaseOrderId() || orderId == this.getPairOrderId(game, unit) || offOrderId(orderId) + || orderId == this.getPairOffOrderId(game, unit); + } + + private boolean checkNoTargetOrderId(final CSimulation game, final CUnit unit, final int orderId) { + return this.autoTargetParter(game, unit) && (onOrderId(orderId) || offOrderId(orderId)); + } + + private boolean checkTargetPrimeOrderId(final CSimulation game, final CUnit unit, final int orderId) { + return !this.autoTargetParter(game, unit) && (onOrderId(orderId) || offOrderId(orderId)); + } + + private boolean checkTargetInternalOrderId(final CSimulation game, final CUnit unit, final int orderId) { + return (((!this.active || this.separateOnAndOff) && orderId == this.getPairOrderId(game, unit)) + || ((this.toggleable && this.active) || this.separateOnAndOff) + && orderId == this.getPairOffOrderId(game, unit)); + } + + private boolean onOrderId(final int orderId) { + return (!this.active || this.separateOnAndOff) && orderId == this.getBaseOrderId(); + } + + private boolean offOrderId(final int orderId) { + return ((this.toggleable && this.active) || this.separateOnAndOff) && orderId == this.getOffOrderId(); + } + + @Override + public void internalBegin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget noTarget) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + // Just don't do this + } + + // ---- + // Non-Targeted + @Override + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { + if (checkNoTargetOrderId(game, caster, orderId)) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + +// System.err.println(caster.getUnitType().getName() + " Beginning NoTarget: " + orderId); + boolean isOffId = orderId == this.getOffOrderId(); + Set partners = this.findPairUnits(game, caster); + CUnit finalPartner = null; + if (partners != null) { +// System.err.println(caster.getUnitType().getName() + " Found Partners"); + int sendOrderId = isOffId ? this.orderPairedUnitOffOrderId(game, caster) + : this.orderPairedUnitOrderId(game, caster); +// System.err.println(caster.getUnitType().getName() + " isOffId = " + isOffId + " so picking between " + this.orderPairedUnitOrderId(game, caster) + " and " + this.orderPairedUnitOffOrderId(game, caster)); + boolean ordered = sendOrderId < 0; + for (CUnit partner : partners) { + if (sendOrderId >= 0) { + ordered |= partner.order(game, sendOrderId, caster); +// System.err.println(caster.getUnitType().getName() + " Sending order to " + partner.getUnitType().getName() + " (" + sendOrderId + ")"); + } + if ((isOffId ? this.getPairOffOrderId(game, caster) : this.getPairOrderId(game, caster)) >= 0) { +// System.err.println(caster.getUnitType().getName() + " Saved last partner for self-order: " +// + partner.getUnitType().getName()); + finalPartner = partner; + } + } + if (!ordered) { + // Failed to order any partners despite wanting to +// System.err.println( +// caster.getUnitType().getName() + " Attempted to order parter(s) but failed to order any: " +// + (isOffId ? this.orderPairedUnitOffOrderId(game, caster) +// : this.orderPairedUnitOrderId(game, caster))); + if (!isOffId && this.config.getSpecialFields().getCantPairError() != null) { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), + this.config.getSpecialFields().getCantPairError().getKey()); + } else if (isOffId && this.config.getSpecialFields().getCantPairOffError() != null) { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), + this.config.getSpecialFields().getCantPairOffError().getKey()); + } else { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), + CommandStringErrorKeysEnum.UNABLE_TO_FIND_COUPLE_TARGET.getKey()); + } + return null; + } + } + if (finalPartner != null + && (isOffId ? this.getPairOffOrderId(game, caster) : this.getPairOrderId(game, caster)) >= 0) { +// System.err.println(caster.getUnitType().getName() + " Have final partner, issuing self order behavior"); + if (isOffId) { + return new ABBehaviorSendOrder(caster, this, this.getPairOffOrderId(game, caster), + this.getBaseOrderId(), finalPartner); + } + return new ABBehaviorSendOrder(caster, this, this.getPairOrderId(game, caster), this.getBaseOrderId(), + finalPartner); + } else { + return null; + } + } + return null; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + if (checkNoTargetOrderId(game, unit, orderId)) { + return true; + } else { + receiver.orderIdNotAccepted(); + return false; + } + } + + // ---- + // Targeted + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); +// System.err.println(caster.getUnitType().getName() + " Received pair target order: " + orderId + " (Base: " +// + this.getBaseOrderId() + ", Internal: " + this.getPairOrderId(game, caster) + ")"); + if (checkTargetPrimeOrderId(game, caster, orderId)) { + final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + if (this.orderPairedUnit(game, caster) && this.orderPairedUnitOrderId(game, caster) != null) { +// System.err.println(caster.getUnitType().getName() + " Sending internal order to paired unit"); + boolean ordered = targetUnit.order(game, this.orderPairedUnitOrderId(game, caster), caster); + if (!ordered) { + if (this.config.getSpecialFields() != null + && this.config.getSpecialFields().getCantPairError() != null) { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), + this.config.getSpecialFields().getCantPairError().getKey()); + } else { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), + CommandStringErrorKeysEnum.UNABLE_TO_MERGE_WITH_THAT_UNIT.getKey()); + } + return caster.pollNextOrderBehavior(game); + } + } + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), targetUnit); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYPAIREDUNIT, castId), targetUnit); + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, caster.getCurrentBehavior()); +// System.out.println("Starting targeted behavior"); + + this.runOnOrderIssuedActions(game, caster, orderId); + this.behavior.setCastId(castId); + return this.behavior.reset(game, target, autoOrder); + } else if (checkTargetInternalOrderId(game, caster, orderId)) { +// System.err.println(caster.getUnitType().getName() + " Got internal order"); + final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), targetUnit); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYPAIREDUNIT, castId), targetUnit); + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, caster.getCurrentBehavior()); +// System.out.println("Starting internal targeted behavior with target: " + targetUnit); + + this.runOnOrderIssuedActions(game, caster, orderId); + this.behavior.setCastId(castId); + return this.behavior.reset(game, target, orderId, autoOrder); + } else { + return null; + } + } + + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver) { +// System.err.println(unit.getUnitType().getName() + " Checking can pair target order: " + orderId + " (Base: " +// + this.getBaseOrderId() + ", Internal: " + this.getPairOrderId(game, unit) + ")"); + if (checkTargetPrimeOrderId(game, unit, orderId) || checkTargetInternalOrderId(game, unit, orderId)) { + final CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + + if (targetUnit != null && unit.getPlayerIndex() != targetUnit.getPlayerIndex()) { + receiver.targetCheckFailed(CommandStringErrorKeys.MUST_TARGET_ONE_OF_YOUR_OWN_UNITS); + return false; + } + + if (this.config.getSpecialFields() != null + && this.config.getSpecialFields().getPairUnitTypeError() != null) { + if (getPairUnitID(game, unit) != null && !targetUnit.getTypeId().equals(getPairUnitID(game, unit))) { + receiver.targetCheckFailed(this.config.getSpecialFields().getPairUnitTypeError().getKey()); + return false; + } + } + if (!this.canPairWith(game, unit, targetUnit)) { + if (this.config.getSpecialFields() != null + && this.config.getSpecialFields().getCantTargetError() != null) { + receiver.targetCheckFailed(this.config.getSpecialFields().getCantTargetError().getKey()); + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_MERGE_WITH_THAT_UNIT); + } + return false; + } + return true; + } else { + receiver.orderIdNotAccepted(); + return false; + } + } + + // Method to search out partner unit + private boolean canPairWith(CSimulation game, CUnit caster, CUnit target) { + if (caster.isPaused() || target.isPaused() || caster.getPlayerIndex() != target.getPlayerIndex()) { +// System.err.println( +// caster.getUnitType().getName() + " Couldn't pair: unit is owned by different player, or is paused"); + return false; + } + if (getPairUnitID(game, caster) != null && !target.getTypeId().equals(getPairUnitID(game, caster))) { +// System.err.println(caster.getUnitType().getName() + " Couldn't pair: wrong unit id (Want:" +// + getPairUnitID(game, caster) + ", Got:" + target.getTypeId() + ")"); + return false; + } + if (getPairAbilityCode(game, caster) != null) { + for (CAbility ability : target.getAbilities()) { + if (this.getPairAbilityCode(game, caster).equals(ability.getCode())) { + localStore.put(ABLocalStoreKeys.LASTPARTNERABILITY, ability); + return true; + } + } +// System.err.println(caster.getUnitType().getName() + " Couldn't pair: No matching ability (Want:" +// + getPairAbilityCode(game, caster) + ")"); + } + return false; + } + + @Override + public Set findPairUnits(CSimulation game, CUnit caster) { + if (this.getPairAbilityCode(game, caster) != null || this.getPairUnitID(game, caster) != null) { + final Set retSet = new HashSet<>(); + if (this.maxPartners(game, caster) != 1) { + game.getWorldCollision().enumUnitsInRange(caster.getX(), caster.getY(), + this.getPairSearchRadius(game, caster), (enumUnit) -> { + if ((enumUnit != caster) && canPairWith(game, caster, enumUnit)) { + retSet.add(enumUnit); + } + return maxPartners(game, caster) != 0 && retSet.size() >= maxPartners(game, caster); + }); + } else { + final ABUnitAndRangeComparator ur = new ABUnitAndRangeComparator(); + Rectangle rect = new Rectangle(); + float rangeVal = this.getPairSearchRadius(game, caster); + + rect.set(caster.getX() - rangeVal, caster.getY() - rangeVal, rangeVal * 2, rangeVal * 2); + game.getWorldCollision().enumUnitsInRect(rect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (caster.canReach(enumUnit, rangeVal)) { + double dist = caster.distance(enumUnit); + if (ur.getUnit() == null || ur.getRange() > dist) { + if ((enumUnit != caster) && canPairWith(game, caster, enumUnit)) { + ur.setRange(dist); + ur.setUnit(enumUnit); + } + } + } + return false; + } + }); + if (ur.getUnit() != null) { + retSet.add(ur.getUnit()); + } + } + if (retSet.size() > 0) { + return retSet; + } + } + return null; + } + + // Methods to identify partner unit(s) + @Override + public War3ID getPairAbilityCode(CSimulation game, CUnit caster) { + return this.pairAbilityId; + } + + @Override + public War3ID getPairUnitID(CSimulation game, CUnit caster) { + return this.pairUnitId; + } + + @Override + public float getPairSearchRadius(CSimulation game, CUnit caster) { + if (this.pairSearchRadius == 0) { + return Float.MAX_VALUE; + } + return this.pairSearchRadius; + } + + // Methods to determine how targeting works + @Override + public boolean autoTargetParter(CSimulation game, CUnit caster) { + return this.autoTargetPartner; + } + + @Override + public int maxPartners(CSimulation game, CUnit caster) { + return this.maxPartners; + } // should only be one if autoTargetParter is false + + // Internal order to give to casting unit (generally used if auto targeting a + // partner. Not always needed) + @Override + public Integer getPairOrderId(CSimulation game, CUnit caster) { + return this.internalOrderId; + } + + @Override + public Integer getPairOffOrderId(CSimulation game, CUnit caster) { + return this.internalOffOrderId; + } + + // Optional order to send to paired unit + @Override + public boolean orderPairedUnit(CSimulation game, CUnit caster) { + return this.orderPairedUnit; + } + + @Override + public Integer orderPairedUnitOrderId(CSimulation game, CUnit caster) { + return this.orderPairedUnitOrderId; + } + + @Override + public Integer orderPairedUnitOffOrderId(CSimulation game, CUnit caster) { + return this.orderPairedUnitOffOrderId; + } + + // Not Used + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { + return null; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActivePointTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActivePointTarget.java new file mode 100644 index 000000000..d398b40c0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActivePointTarget.java @@ -0,0 +1,97 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; + +public class ABAbilityBuilderActivePointTarget extends ABAbilityBuilderGenericActive { + + private ABBehavior behavior; + + public ABAbilityBuilderActivePointTarget(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, code, alias, levelData, config, localStore); + } + + @Override + public boolean isToggleOn() { + return false; + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + this.behavior = this.createRangedBehavior(unit); + super.onAdd(game, unit); + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { + return null; + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { + this.internalBegin(game, caster, orderId, autoOrder, point); + this.behavior.setCastId(castId); + return this.behavior.reset(game, point, orderId, autoOrder); + } + + @Override + public void internalBegin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget theTarget) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + localStore.put(ABLocalStoreKeys.ABILITYTARGETEDLOCATION + this.castId, + theTarget.visit(AbilityTargetVisitor.POINT)); + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, caster.getCurrentBehavior()); + this.runOnOrderIssuedActions(game, caster, orderId); + } + + @Override + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { + return null; + } + + @Override + protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver) { + return true; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + return true; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveUnitTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveUnitTarget.java new file mode 100644 index 000000000..c267faf14 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderActiveUnitTarget.java @@ -0,0 +1,96 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; + +public class ABAbilityBuilderActiveUnitTarget extends ABAbilityBuilderGenericActive { + + private ABBehavior behavior; + + public ABAbilityBuilderActiveUnitTarget(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, code, alias, levelData, config, localStore); + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + this.behavior = this.createRangedBehavior(unit); + super.onAdd(game, unit); + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { + this.internalBegin(game, caster, orderId, autoOrder, target); + this.behavior.setCastId(castId); + return this.behavior.reset(game, target, orderId, autoOrder); + } + + @Override + public void internalBegin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityTarget target) { + this.castId = ABConstants.incrementCastId(this.castId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), this.getLevel()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), autoOrder); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), + target.visit(AbilityTargetVisitor.UNIT)); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId), + target.visit(AbilityTargetVisitor.ITEM)); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId), + target.visit(AbilityTargetVisitor.DESTRUCTABLE)); + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, caster.getCurrentBehavior()); + this.runOnOrderIssuedActions(game, caster, orderId); + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { + return null; + } + + @Override + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { + return null; + } + + @Override + protected boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver) { + return true; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver) { + return true; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + + @Override + protected boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderGenericActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderGenericActive.java new file mode 100644 index 000000000..29ae2ae58 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderGenericActive.java @@ -0,0 +1,1335 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.mdx.Sequence; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractGenericSingleIconNoSmartActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderBase; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderNoTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABTargetTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABManaDepletedCheckTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.MeleeUIAbilityActivationReceiver; + +public abstract class ABAbilityBuilderGenericActive extends AbstractGenericSingleIconNoSmartActiveAbility + implements ABAbilityBuilderActiveAbility { + protected List levelData; + protected ABAbilityBuilderConfiguration config; + protected ABLocalDataStore localStore; + protected int orderId; + protected int unorderId = 0; + protected int autoCastOnId = 0; + protected int autoCastOffId = 0; + protected boolean autocasting = false; + protected AutocastType autocastType = AutocastType.NONE; + protected boolean toggleable = false; + protected boolean separateOnAndOff = false; + protected boolean active = false; + protected boolean allowCastlessDeactivate = true; + protected PrimaryTag castingPrimaryTag; + protected EnumSet castingSecondaryTags; + + protected byte clickDisabled = 0; + + protected CItem item = null; + + protected float cooldown = 0; + protected int manaCost = 0; + protected float area = 0; + protected float range = 0; + protected float castTime = 0; + private boolean ignoreCastTime = false; + + protected boolean hideAreaCursor = false; + private Float areaCursorOverride; + + protected int bufferMana = 0; + private ABManaDepletedCheckTimer timer; + private NonStackingStatBuff manaDrain; + + protected int castId = ABConstants.STARTING_CAST_ID; + private War3ID onTooltipOverride = null; + private War3ID offTooltipOverride = null; + private EnumSet targetsAllowed; + private boolean dispel = false; + private boolean physical = false; + private boolean magic = true; + private boolean universal = false; + + protected Set uniqueFlags = null; + + private boolean isMenu = false; + private int visibleMenuId = 0; + + public ABAbilityBuilderGenericActive(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, code, alias); + this.levelData = levelData; + this.config = config; + this.localStore = localStore; + localStore.originAbility = this; + + if (config.getCastId() != null) { + orderId = OrderIdUtils.getOrderId(config.getCastId()); + } else { + orderId = 0; + } + if (config.getUncastId() != null) { + unorderId = OrderIdUtils.getOrderId(config.getUncastId()); + } + if (config.getAutoCastOnId() != null) { + autoCastOnId = OrderIdUtils.getOrderId(config.getAutoCastOnId()); + } + if (config.getAutoCastOffId() != null) { + autoCastOffId = OrderIdUtils.getOrderId(config.getAutoCastOffId()); + } + if (config.getAutoCastType() != null) { + autocastType = config.getAutoCastType(); + } + + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + final String animNames = editorData.getField(AbilityFields.ANIM_NAMES); + final EnumSet primaryTags = EnumSet.noneOf(AnimationTokens.PrimaryTag.class); + this.castingSecondaryTags = EnumSet.noneOf(AnimationTokens.SecondaryTag.class); + Sequence.populateTags(primaryTags, this.castingSecondaryTags, animNames); + if (primaryTags.isEmpty()) { + this.castingPrimaryTag = null; + } else { + this.castingPrimaryTag = primaryTags.iterator().next(); + } + if (this.castingSecondaryTags.isEmpty()) { + this.castingSecondaryTags = SequenceUtils.SPELL; + } + final int levels = editorData.getFieldAsInteger(AbilityFields.LEVELS, 0); + localStore.put(ABLocalStoreKeys.ISABILITYLEVELED, levels > 1); + } + + @Override + public int getAbilityIntField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldValue(field); + } + + @Override + public float getAbilityFloatField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldFloatValue(field); + } + + @Override + public String getAbilityStringField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getField(field); + } + + @Override + public boolean getAbilityBooleanField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldValue(field) != 0; + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + setSpellFields(game, unit); + determineToggleableFields(game, unit); + if (config.getOnLevelChange() != null) { + for (ABAction action : config.getOnLevelChange()) { + action.runAction(unit, this.localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + setSpellFields(game, unit); + determineToggleableFields(game, unit); + if (config.getOnAddAbility() != null) { + for (ABAction action : config.getOnAddAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onAddDisabled(CSimulation game, CUnit unit) { + localStore.game = game; + localStore.originUnit = unit; + localStore.originPlayer = game.getPlayer(unit.getPlayerIndex()); + addInitialUniqueFlags(game, unit); + setSpellFields(game, unit); + determineToggleableFields(game, unit); + if (config.getOnAddDisabledAbility() != null) { + for (ABAction action : config.getOnAddDisabledAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onRemoveDisabled(CSimulation game, CUnit unit) { + if (config.getOnRemoveDisabledAbility() != null) { + for (ABAction action : config.getOnRemoveDisabledAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + private void addInitialUniqueFlags(CSimulation game, CUnit unit) { + if (this.config.getInitialUniqueFlags() != null && !this.config.getInitialUniqueFlags().isEmpty()) { + this.uniqueFlags = new HashSet<>(); + for (ABStringCallback flag : this.config.getInitialUniqueFlags()) { + this.uniqueFlags.add(flag.callback(unit, localStore, ABConstants.NO_CAST_ID)); + } + } + } + + private void determineToggleableFields(CSimulation game, CUnit unit) { + if (config.getDisplayFields() != null && config.getDisplayFields().getSeparateOnAndOff() != null) { + this.separateOnAndOff = config.getDisplayFields().getSeparateOnAndOff().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (config.getDisplayFields() != null && config.getDisplayFields().getToggleable() != null) { + this.toggleable = config.getDisplayFields().getToggleable().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (config.getDisplayFields() != null && config.getDisplayFields().getCastToggleOff() != null) { + this.allowCastlessDeactivate = !config.getDisplayFields().getCastToggleOff().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (config.getDisplayFields() != null && config.getDisplayFields().getAlternateUnitId() != null) { + if (unit.getTypeId().equals(config.getDisplayFields().getAlternateUnitId().callback(unit, localStore, + ABConstants.NO_CAST_ID))) { + this.active = true; + } + } + if (config.getSpecialFields() != null && config.getSpecialFields().getBufferManaRequired() != null) { + this.bufferMana = config.getSpecialFields().getBufferManaRequired().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.toggleable) { + localStore.put(ABLocalStoreKeys.ISTOGGLEDABILITY, this); + int manaPerSec = 0; + if (config.getSpecialFields() != null && config.getSpecialFields().getManaDrainedPerSecond() != null) { + manaPerSec = config.getSpecialFields().getManaDrainedPerSecond().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (manaPerSec != 0) { + if (manaDrain == null) { + manaDrain = new NonStackingStatBuff(NonStackingStatBuffType.MPGEN, + NonStackingStatBuff.ALLOW_STACKING_KEY, (-1 * manaPerSec)); + } else { + manaDrain.setValue((-1 * manaPerSec)); + } + if (this.timer == null) { + timer = new ABManaDepletedCheckTimer(unit, this); + } + } else { + this.manaDrain = null; + this.timer = null; + } + + if (config.getDisplayFields() != null && config.getDisplayFields().getAlternateUnitId() != null) { + if (unit.getTypeId().equals(config.getDisplayFields().getAlternateUnitId().callback(unit, localStore, + ABConstants.NO_CAST_ID))) { + this.active = true; + } + } + } + } + + protected void setSpellFields(CSimulation game, CUnit unit) { + ABAbilityBuilderAbilityTypeLevelData levelDataLevel = this.levelData.get(this.getLevel() - 1); + this.manaCost = levelDataLevel.getManaCost(); + this.cooldown = levelDataLevel.getCooldown(); + this.range = levelDataLevel.getCastRange(); + this.area = levelDataLevel.getArea(); + this.castTime = levelDataLevel.getCastTime(); + if (this.config.getOverrideFields() != null) { + if (this.config.getOverrideFields().getAreaOverride() != null) { + this.area = this.config.getOverrideFields().getAreaOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getRangeOverride() != null) { + this.range = this.config.getOverrideFields().getRangeOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getCastTimeOverride() != null) { + this.castTime = this.config.getOverrideFields().getCastTimeOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getIgnoreCastTime() != null) { + this.ignoreCastTime = this.config.getOverrideFields().getIgnoreCastTime().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getCooldownOverride() != null) { + this.cooldown = this.config.getOverrideFields().getCooldownOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getManaCostOverride() != null) { + this.manaCost = this.config.getOverrideFields().getManaCostOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getAutocastTypeOverride() != null) { + this.autocastType = this.config.getOverrideFields().getAutocastTypeOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + + if (this.config.getOverrideFields().getOnTooltipOverride() != null) { + this.onTooltipOverride = this.config.getOverrideFields().getOnTooltipOverride().callback(unit, + localStore, ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getOffTooltipOverride() != null) { + this.offTooltipOverride = this.config.getOverrideFields().getOffTooltipOverride().callback(unit, + localStore, ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getPhysicalSpell() != null) { + this.physical = this.config.getOverrideFields().getPhysicalSpell().callback(unit, localStore, + ABConstants.NO_CAST_ID); + this.magic = this.physical ? false : this.magic; // Spells that just declare physical:true default to + // magic:false + } + if (this.config.getOverrideFields().getMagicSpell() != null) { + this.magic = this.config.getOverrideFields().getMagicSpell().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getDispel() != null) { + this.dispel = this.config.getOverrideFields().getDispel().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getUniversalSpell() != null) { + this.universal = this.config.getOverrideFields().getUniversalSpell().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + } + + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + final int requiredLevel = editorData.getFieldAsInteger(AbilityFields.REQUIRED_LEVEL, 0); + this.targetsAllowed = levelDataLevel.getTargetsAllowed(); + if ((requiredLevel < 6 || game.getGameplayConstants().isMagicImmuneResistsUltimates()) && !isPhysical() + && !isUniversal()) { + this.targetsAllowed.add(CTargetType.NON_MAGIC_IMMUNE); + if (isDispel()) { + this.targetsAllowed.add(CTargetType.LIMITED_MAGIC_IMMUNE); + } + } + if (isPhysical() && !isUniversal()) { + this.targetsAllowed.add(CTargetType.NON_ETHEREAL); + } + + if (this.config.getOverrideFields() != null + && this.config.getOverrideFields().getExtraTargetsAllowed() != null) { + for (ABTargetTypeCallback target : this.config.getOverrideFields().getExtraTargetsAllowed()) { + this.targetsAllowed.add(target.callback(unit, localStore, requiredLevel)); + } + } + if (this.config.getOverrideFields() != null + && this.config.getOverrideFields().getExcludedTargetsAllowed() != null) { + for (ABTargetTypeCallback target : this.config.getOverrideFields().getExcludedTargetsAllowed()) { + this.targetsAllowed.remove(target.callback(unit, localStore, requiredLevel)); + } + } + + if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getHideAreaCursor() != null) { + this.hideAreaCursor = this.config.getDisplayFields().getHideAreaCursor().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getAreaCursorOverride() != null) { + this.areaCursorOverride = this.config.getDisplayFields().getAreaCursorOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getIsMenu() != null) { + this.isMenu = this.config.getDisplayFields().getIsMenu().callback(unit, localStore, this.getLevel()); + if (this.isMenu) { + if (this.config.getDisplayFields().getMenuId() != null) { + this.orderId = this.config.getDisplayFields().getMenuId().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } else { + if (this.orderId == 0) { + this.orderId = this.getHandleId(); + } + } + } + } + } + + @Override + public void startCooldown(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + unit.beginCooldown(game, cdID, this.cooldown); + } + } + + @Override + public float getCooldownRemainingTicks(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + return unit.getCooldownRemainingTicks(game, cdID); + } + return unit.getCooldownRemainingTicks(game, this.getCode()); + } + + @Override + public void resetCooldown(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + unit.beginCooldown(game, cdID, 0); + } + } + + private War3ID getCooldownId() { + if (this.item != null) { + if (item.getItemType().isIgnoreCooldown()) { + return War3ID.NONE; + } else { + if (item.getItemType().getCooldownGroup() != null) { + return item.getItemType().getCooldownGroup(); + } + } + } + return getCode(); + } + + @Override + public void setItemAbility(final CItem item, int slot) { + this.item = item; + this.localStore.originItem = item; + this.localStore.put(ABLocalStoreKeys.ITEMSLOT, slot); + } + + @Override + public CItem getItem() { + return this.item; + } + + @Override + public int getBaseOrderId() { + return this.orderId; + } + + @Override + public int getOffOrderId() { + return this.unorderId; + } + + public PrimaryTag getCastingPrimaryTag() { + return this.castingPrimaryTag; + } + + public EnumSet getCastingSecondaryTags() { + return this.castingSecondaryTags; + } + + public List getLevelData() { + return this.levelData; + } + + public ABAbilityBuilderConfiguration getConfig() { + return this.config; + } + + public ABLocalDataStore getLocalStore() { + return this.localStore; + } + + @Override + public boolean hasUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + return this.uniqueFlags.contains(flag); + } + return false; + } + + public void addUniqueFlag(String flag) { + if (this.uniqueFlags == null) { + this.uniqueFlags = new HashSet<>(); + } + this.uniqueFlags.add(flag); + } + + public void removeUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + this.uniqueFlags.remove(flag); + } + } + + @SuppressWarnings("unchecked") + @Override + public T getUniqueValue(String key, Class cls) { + Object o = this.localStore.get(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + if (o != null && o.getClass() == cls) { + return (T) o; + } + return null; + } + + public void addUniqueValue(Object item, String key) { + this.localStore.put(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId()), item); + } + + public void removeUniqueValue(String key) { + this.localStore.remove(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + } + + @Override + public War3ID getOnTooltipOverride() { + return onTooltipOverride; + } + + @Override + public War3ID getOffTooltipOverride() { + return offTooltipOverride; + } + + @Override + public int getUIManaCost() { + return (this.toggleable && this.active && this.allowCastlessDeactivate) ? 0 : this.manaCost + this.bufferMana; + } + + @Override + public int getChargedManaCost() { + return this.manaCost; + } + + @Override + public float getUIAreaOfEffect() { + return ((this.area == 0 && (this.areaCursorOverride == null || this.areaCursorOverride == 0)) + || this.hideAreaCursor) ? Float.NaN + : (this.areaCursorOverride == null ? this.area : this.areaCursorOverride); + } + + public float getCooldown() { + return cooldown; + } + + public float getArea() { + return area; + } + + public float getCastRange() { + return range; + } + + public void setCastRange(float range) { + this.range = range; + } + + public float getCastTime() { + return castTime; + } + + public void setCastTime(float castTime) { + this.castTime = castTime; + } + + public boolean ignoreCastTime() { + return this.ignoreCastTime; + } + + public EnumSet getTargetsAllowed() { + return targetsAllowed; + } + + @Override + public boolean isSeparateOnAndOff() { + return separateOnAndOff; + } + + @Override + public boolean isToggleOn() { + return this.toggleable && this.active; + } + + @Override + public boolean isActive() { + return this.active; + } + + @Override + public boolean isClickDisabled() { + return this.clickDisabled != 0; + } + + @Override + public final void setClickDisabled(final boolean disabled, final CAbilityDisableType type) { + if (disabled) { + this.clickDisabled |= type.getMask(); + } else { + this.clickDisabled &= ~type.getMask(); + } + } + + @Override + public int getAutoCastOnOrderId() { + return this.autoCastOnId; + } + + @Override + public int getAutoCastOffOrderId() { + return this.autoCastOffId; + } + + @Override + public boolean isAutoCastOn() { + return this.autocasting; + } + + @Override + public void setAutoCastOn(final CSimulation simulation, final CUnit caster, final boolean autoCastOn, + final boolean notify) { + this.localStore.put(ABLocalStoreKeys.WASAUTOCASTON, this.autocasting); + this.autocasting = autoCastOn; + if (notify) { + caster.setAutocastAbility(simulation, autoCastOn ? this : null); + } + this.localStore.put(ABLocalStoreKeys.ISAUTOCASTON, autoCastOn); + if (this.config.getOnChangeAutoCast() != null) { + for (ABAction action : this.config.getOnChangeAutoCast()) { + action.runAction(caster, localStore, ABConstants.NO_CAST_ID); + } + } + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTON); + this.localStore.remove(ABLocalStoreKeys.WASAUTOCASTON); + } + + @Override + public AutocastType getAutocastType() { + return autocastType; + } + + protected ABBehavior createNoTargetBehavior(CUnit unit) { + ABBehavior beh = new ABBehaviorAbilityBuilderNoTarget(unit, localStore, this); + if (this.item != null || (this.config.getDisplayFields() != null + && this.config.getDisplayFields().getInstantCast() != null && this.config.getDisplayFields() + .getInstantCast().callback(unit, localStore, ABConstants.NO_CAST_ID))) { + beh.setInstant(true); + } + if (this.config.getSpecialFields() != null && this.config.getSpecialFields().getBehaviorCategory() != null) { + beh.setBehaviorCategory(this.config.getSpecialFields().getBehaviorCategory()); + } + return beh; + } + + protected ABBehavior createRangedBehavior(CUnit unit) { + ABBehavior beh = new ABBehaviorAbilityBuilderBase(unit, localStore, this); + if (this.item != null || (this.config.getDisplayFields() != null + && this.config.getDisplayFields().getInstantCast() != null && this.config.getDisplayFields() + .getInstantCast().callback(unit, localStore, ABConstants.NO_CAST_ID))) { + beh.setInstant(true); + } + if (this.config.getSpecialFields() != null && this.config.getSpecialFields().getBehaviorCategory() != null) { + beh.setBehaviorCategory(this.config.getSpecialFields().getBehaviorCategory()); + } + return beh; + } + + protected void innerCheckCooldownDisabled(final CSimulation game, final CUnit unit, final int orderId, + final AbilityActivationReceiver receiver) { + final int cooldownRemaining = unit.getCooldownRemainingTicks(game, getCooldownId()); + if (this.toggleable && this.active && this.allowCastlessDeactivate) { + if (cooldownRemaining > 0 && !(receiver instanceof MeleeUIAbilityActivationReceiver)) { + float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) + * WarsmashConstants.SIMULATION_STEP_TIME; + receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, + cooldownLengthDisplay); + } + } else { + if (cooldownRemaining > 0) { + float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) + * WarsmashConstants.SIMULATION_STEP_TIME; + receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, + cooldownLengthDisplay); + } + } + } + + @Override + protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final int orderId, + final AbilityActivationReceiver receiver) { + if ((orderId != 0) && ((orderId == getAutoCastOffOrderId()) || (orderId == getAutoCastOnOrderId()))) { + receiver.useOk(); + return; + } + final int cooldownRemaining = unit.getCooldownRemainingTicks(game, getCooldownId()); + + if (this.toggleable && this.active && this.allowCastlessDeactivate) { + if (cooldownRemaining > 0 && !(receiver instanceof MeleeUIAbilityActivationReceiver)) { + float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) + * WarsmashConstants.SIMULATION_STEP_TIME; + receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, + cooldownLengthDisplay); + } + receiver.useOk(); + } else { + if (cooldownRemaining > 0) { + float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) + * WarsmashConstants.SIMULATION_STEP_TIME; + receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, + cooldownLengthDisplay); + } else if (unit.getMana() < (this.manaCost + this.bufferMana)) { + receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_MANA); + } else { + CPlayer p = game.getPlayer(unit.getPlayerIndex()); + if (this.getUIGoldCost() > p.getGold()) { + receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_GOLD); + } else if (this.getUILumberCost() > p.getLumber()) { + receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_LUMBER); + } else if (this.getUIFoodCost() > 0 && this.getUIFoodCost() > p.getFoodCap() - p.getFoodUsed()) { + receiver.activationCheckFailed(CommandStringErrorKeys.NOT_ENOUGH_FOOD); + } else { + innerCheckExtraCastConditions(game, unit, orderId, receiver); + } + } + } + } + + protected void innerCheckExtraCastConditions(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver) { + if (innerCheckCanUseSpell(game, unit, orderId, receiver)) { + if (config.getExtraCastConditions() != null) { + boolean result = true; + for (ABBooleanCallback condition : config.getExtraCastConditions()) { + result = result && condition.callback(unit, localStore, ABConstants.NO_CAST_ID); + } + String failReason = (String) localStore.remove(ABLocalStoreKeys.CANTUSEREASON); + if (result) { + receiver.useOk(); + } else { + if (failReason != null) { + receiver.activationCheckFailed(failReason); + } else { + receiver.unknownReasonUseNotOk(); + } + } + } else { + receiver.useOk(); + } + } + } + + protected abstract boolean innerCheckCanUseSpell(CSimulation game, CUnit unit, int orderId, + AbilityActivationReceiver receiver); + + @Override + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { + this.localStore.put(ABLocalStoreKeys.ISAUTOCASTTARGETING, autoOrder); + if (innerCheckCastOrderId(game, unit, orderId)) { + innerCheckCanTarget(game, unit, orderId, target, receiver); + } else if (orderId == OrderIds.smart) { + innerCheckCanSmartTarget(game, unit, orderId, target, receiver); + } else { + receiver.orderIdNotAccepted(); + } + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + } + + @Override + public void checkCanAutoTarget(final CSimulation game, final CUnit unit, final int orderId, final CWidget target, + final AbilityTargetCheckReceiver receiver) { + if (orderId == getBaseOrderId()) { + this.localStore.put( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, ABConstants.NO_CAST_ID), + target.visit(AbilityTargetVisitor.UNIT)); + this.localStore.put( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, ABConstants.NO_CAST_ID), + target.visit(AbilityTargetVisitor.ITEM)); + this.localStore.put( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, ABConstants.NO_CAST_ID), + target.visit(AbilityTargetVisitor.DESTRUCTABLE)); + if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { + if (innerCheckTargetTargetable(game, unit, target, receiver)) { + if (innerCheckTargetInRange(unit, target)) { + String extraFailReason = innerCheckExtraAutoTargetConditions(game, unit, orderId); + if (extraFailReason != null) { + if (!extraFailReason.equals("unknown")) { + receiver.targetCheckFailed(extraFailReason); + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); + } + } else { + receiver.targetOk(target); + } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); + } + } + } + this.localStore + .remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, ABConstants.NO_CAST_ID)); + this.localStore + .remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, ABConstants.NO_CAST_ID)); + this.localStore.remove( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, ABConstants.NO_CAST_ID)); + } else { + receiver.orderIdNotAccepted(); + } + } + + @Override + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + this.localStore.put(ABLocalStoreKeys.ISAUTOCASTTARGETING, autoOrder); + if (innerCheckCastOrderId(game, unit, orderId)) { + innerCheckCanTarget(game, unit, orderId, target, receiver); + } else if (orderId == OrderIds.smart) { + innerCheckCanSmartTarget(game, unit, orderId, target, receiver); + } else { + receiver.orderIdNotAccepted(); + } + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + } + + @Override + public void checkCanAutoTarget(final CSimulation game, final CUnit unit, final int orderId, + final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + if (orderId == getBaseOrderId()) { + if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { + if (innerCheckTargetInRange(unit, target)) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, + ABConstants.NO_CAST_ID), target); + String extraFailReason = innerCheckExtraAutoTargetConditions(game, unit, orderId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, + ABConstants.NO_CAST_ID)); + if (extraFailReason != null) { + if (!extraFailReason.equals("unknown")) { + receiver.targetCheckFailed(extraFailReason); + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THERE); + } + } else { + receiver.targetOk(target); + } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); + } + } + } else { + receiver.orderIdNotAccepted(); + } + } + + @Override + public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final AbilityTargetCheckReceiver receiver) { + this.localStore.put(ABLocalStoreKeys.ISAUTOCASTTARGETING, autoOrder); + if ((orderId != 0) && ((orderId == getAutoCastOffOrderId()) || (orderId == getAutoCastOnOrderId()))) { + receiver.targetOk(null); + } else if (innerCheckCastOrderId(game, unit, orderId)) { + innerCheckCanTargetNoTarget(game, unit, orderId, receiver); + } else { + receiver.orderIdNotAccepted(); + } + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + } + + @Override + public void checkCanAutoTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, + final AbilityTargetCheckReceiver receiver) { + if (orderId == getBaseOrderId()) { + if (innerCheckCanTargetSpell(game, unit, orderId, receiver)) { + String extraFailReason = innerCheckExtraAutoNoTargetConditions(game, unit, orderId, receiver); + if (extraFailReason != null) { + if (!extraFailReason.equals("unknown")) { + receiver.targetCheckFailed(extraFailReason); + } else { + receiver.orderIdNotAccepted(); + } + } else { + receiver.targetOk(null); + } + } + } else { + receiver.orderIdNotAccepted(); + } + } + + @Override + protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { + if (innerCheckTargetInRange(unit, target)) { + localStore.put( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, ABConstants.NO_CAST_ID), + target); + String extraFailReason = innerCheckExtraTargetConditions(game, unit, orderId); + localStore.remove( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, ABConstants.NO_CAST_ID)); + if (extraFailReason != null) { + if (!extraFailReason.equals("unknown")) { + receiver.targetCheckFailed(extraFailReason); + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THERE); + } + } else { + receiver.targetOk(target); + } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); + } + } + } + + @Override + protected void innerCheckCanTarget(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, ABConstants.NO_CAST_ID), + target.visit(AbilityTargetVisitor.UNIT)); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, ABConstants.NO_CAST_ID), + target.visit(AbilityTargetVisitor.ITEM)); + this.localStore.put( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, ABConstants.NO_CAST_ID), + target.visit(AbilityTargetVisitor.DESTRUCTABLE)); + if (innerCheckCanTargetSpell(game, unit, orderId, target, receiver)) { + if (innerCheckTargetTargetable(game, unit, target, receiver)) { + if (innerCheckTargetInRange(unit, target)) { + String extraFailReason = innerCheckExtraTargetConditions(game, unit, orderId); + if (extraFailReason != null) { + if (!extraFailReason.equals("unknown")) { + receiver.targetCheckFailed(extraFailReason); + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.UNABLE_TO_TARGET_THIS_UNIT); + } + } else { + receiver.targetOk(target); + } + } else { + receiver.targetCheckFailed(CommandStringErrorKeys.TARGET_IS_OUTSIDE_RANGE); + } + } + } + this.localStore + .remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, ABConstants.NO_CAST_ID)); + this.localStore + .remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, ABConstants.NO_CAST_ID)); + this.localStore.remove( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, ABConstants.NO_CAST_ID)); + } + + @Override + protected void innerCheckCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + if (innerCheckCanTargetSpell(game, unit, orderId, receiver)) { + receiver.targetOk(null); + } + } + + protected boolean innerCheckCastOrderId(final CSimulation game, final CUnit unit, final int orderId) { + return ((!this.active || !this.toggleable) && orderId == getBaseOrderId()) + || ((this.active || this.separateOnAndOff) && orderId == getOffOrderId()); + } + + protected boolean innerCheckTargetTargetable(CSimulation game, CUnit unit, CWidget target, + final AbilityTargetCheckReceiver receiver) { + return target.canBeTargetedBy(game, unit, targetsAllowed, receiver); + } + + protected boolean innerCheckTargetInRange(CUnit unit, AbilityTarget target) { + return !unit.isMovementDisabled() || unit.canReach(target, this.getCastRange()); + } + + protected String innerCheckExtraTargetConditions(CSimulation game, CUnit unit, int orderId) { + if (config.getExtraTargetConditions() != null) { + boolean result = true; + for (ABBooleanCallback condition : config.getExtraTargetConditions()) { + result = result && condition.callback(unit, localStore, ABConstants.NO_CAST_ID); + } + String failReason = (String) localStore.remove(ABLocalStoreKeys.CANTUSEREASON); + if (result) { + return null; + } else { + if (failReason != null) { + return failReason; + } else { + return "unknown"; + } + } + } else { + return null; + } + } + + protected String innerCheckExtraAutoTargetConditions(CSimulation game, CUnit unit, int orderId) { + if (config.getExtraTargetConditions() != null || config.getExtraAutoTargetConditions() != null) { + boolean result = true; + if (config.getExtraTargetConditions() != null) { + for (ABBooleanCallback condition : config.getExtraTargetConditions()) { + result = result && condition.callback(unit, localStore, ABConstants.NO_CAST_ID); + } + } + if (config.getExtraAutoTargetConditions() != null) { + for (ABBooleanCallback condition : config.getExtraAutoTargetConditions()) { + result = result && condition.callback(unit, localStore, ABConstants.NO_CAST_ID); + } + } + String failReason = (String) localStore.remove(ABLocalStoreKeys.CANTUSEREASON); + if (result) { + return null; + } else { + if (failReason != null) { + return failReason; + } else { + return "unknown"; + } + } + } else { + return null; + } + } + + protected String innerCheckExtraAutoNoTargetConditions(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver) { + if (config.getExtraAutoNoTargetConditions() != null) { + boolean result = true; + if (config.getExtraAutoNoTargetConditions() != null) { + for (ABBooleanCallback condition : config.getExtraAutoNoTargetConditions()) { + result = result && condition.callback(unit, localStore, ABConstants.NO_CAST_ID); + } + } + String failReason = (String) localStore.remove(ABLocalStoreKeys.CANTUSEREASON); + if (result) { + return null; + } else { + if (failReason != null) { + return failReason; + } else { + return "unknown"; + } + } + } else { + return null; + } + } + + protected abstract boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, CWidget target, + AbilityTargetCheckReceiver receiver); + + protected abstract boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityPointTarget target, AbilityTargetCheckReceiver receiver); + + protected abstract boolean innerCheckCanTargetSpell(CSimulation game, CUnit unit, int orderId, + AbilityTargetCheckReceiver receiver); + + @Override + public int getUIFoodCost() { + if (this.toggleable && this.active && this.allowCastlessDeactivate) { + return 0; + } + if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getFoodCost() != null) { + return this.config.getDisplayFields().getFoodCost().callback(this.localStore.originUnit, localStore, + ABConstants.NO_CAST_ID); + } + return 0; + } + + @Override + public int getUIGoldCost() { + if (this.toggleable && this.active && this.allowCastlessDeactivate) { + return 0; + } + if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getGoldCost() != null) { + return this.config.getDisplayFields().getGoldCost().callback(this.localStore.originUnit, localStore, + ABConstants.NO_CAST_ID); + } + return 0; + } + + @Override + public int getUILumberCost() { + if (this.toggleable && this.active && this.allowCastlessDeactivate) { + return 0; + } + if (this.config.getDisplayFields() != null && this.config.getDisplayFields().getLumberCost() != null) { + return this.config.getDisplayFields().getLumberCost().callback(this.localStore.originUnit, localStore, + ABConstants.NO_CAST_ID); + } + return 0; + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + if (this.toggleable && this.active) { + deactivate(game, unit); + } + if (config.getOnRemoveAbility() != null) { + for (ABAction action : config.getOnRemoveAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + if (this.toggleable && this.active) { + deactivate(game, unit); + } + if (config.getOnDeathPreCast() != null) { + for (ABAction action : config.getOnDeathPreCast()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void runOnOrderIssuedActions(final CSimulation game, final CUnit caster, int orderId) { + if (config.getOnOrderIssued() != null) { + for (ABAction action : config.getOnOrderIssued()) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void runBeginCastingActions(final CSimulation game, final CUnit caster, int orderId) { + if (config.getOnBeginCasting() != null) { + for (ABAction action : config.getOnBeginCasting()) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void runEndCastingActions(final CSimulation game, final CUnit caster, int orderId) { + if (config.getOnEndCasting() != null) { + for (ABAction action : config.getOnEndCasting()) { + action.runAction(caster, localStore, castId); + } + } + if (this.toggleable) { + if (orderId == this.getBaseOrderId()) { + this.activate(game, caster); + } + if (orderId == this.getOffOrderId()) { + this.deactivate(game, caster); + } + } + } + + @Override + public void runChannelTickActions(final CSimulation game, final CUnit caster, int orderId) { + if (config.getOnChannelTick() != null) { + for (ABAction action : config.getOnChannelTick()) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void runEndChannelActions(final CSimulation game, final CUnit caster, int orderId) { + if (config.getOnEndChannel() != null) { + for (ABAction action : config.getOnEndChannel()) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void runCancelPreCastActions(final CSimulation game, final CUnit caster, int orderId) { + if (config.getOnCancelPreCast() != null) { + for (ABAction action : config.getOnCancelPreCast()) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void activate(final CSimulation game, final CUnit caster) { + Boolean failed = this.localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), + Boolean.class); + if (failed != null && failed) { + System.err.println("Failed to cast!"); + return; + } +// System.err.println("Activating!"); + this.active = true; + if (this.manaDrain != null) { + this.timer.start(game); + caster.addNonStackingStatBuff(game, manaDrain); + } + if (config.getOnActivate() != null) { + for (ABAction action : config.getOnActivate()) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void deactivate(final CSimulation game, final CUnit caster) { + Boolean failed = this.localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), + Boolean.class); + if (failed != null && failed) { + System.err.println("Failed to cast!"); + return; + } +// System.err.println("Deactivating!"); + this.active = false; + if (this.manaDrain != null) { + timer.pause(game); + caster.removeNonStackingStatBuff(game, manaDrain); + } + if (config.getOnDeactivate() != null) { + for (ABAction action : config.getOnDeactivate()) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public boolean checkBeforeQueue(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, + final AbilityTarget target) { + this.localStore.put(ABLocalStoreKeys.ISAUTOCASTTARGETING, autoOrder); +// System.err.println("Checking queue top level: " + active + " orderID : " + orderId + " offID: " + this.getOffOrderId()); + if (this.allowCastlessDeactivate && this.toggleable && this.active && orderId == this.getOffOrderId()) { + this.deactivate(game, caster); + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + return false; + } + this.localStore.remove(ABLocalStoreKeys.ISAUTOCASTTARGETING); + return super.checkBeforeQueue(game, caster, orderId, autoOrder, target); + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + + } + + @Override + public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) { + + } + + @Override + public T visit(final CAbilityVisitor visitor) { + return visitor.accept(this); + } + + @Override + public void checkRequirementsMet(CSimulation game, CUnit unit, AbilityActivationReceiver receiver) { + List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); + CPlayer player = game.getPlayer(unit.getPlayerIndex()); + if (reqs != null) { + for (final CUnitTypeRequirement requirement : reqs) { +// System.err.println("Checking reqs for " + this.getAlias() + ": looking for " +// + requirement.getRequirement() + " at amount " + requirement.getRequiredLevel() + " and found " +// + player.getTechtreeUnlocked(requirement.getRequirement())); + if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { + receiver.missingRequirement(requirement.getRequirement(), requirement.getRequiredLevel()); + } + } + } + } + + @Override + public boolean isRequirementsMet(CSimulation game, CUnit unit) { + List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); + CPlayer player = game.getPlayer(unit.getPlayerIndex()); + boolean requirementsMet = player.isTechtreeAllowedByMax(this.getAlias()); + if (reqs != null) { + for (final CUnitTypeRequirement requirement : reqs) { +// System.err.println("Checking reqs for " + this.getAlias() + ": looking for " +// + requirement.getRequirement() + " at amount " + requirement.getRequiredLevel() + " and found " +// + player.getTechtreeUnlocked(requirement.getRequirement())); + if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { + requirementsMet = false; + } + } + } +// System.err.println("Returning "+requirementsMet+" for " + this.getAlias()); + return requirementsMet; + } + + public boolean isDispel() { + return dispel; + } + + @Override + public boolean isPhysical() { + return physical; + } + + @Override + public boolean isMagic() { + return magic; + } + + @Override + public boolean isUniversal() { + return universal; + } + + @Override + public CAbilityCategory getAbilityCategory() { + return CAbilityCategory.SPELL; + } + + @Override + public void cleanupInputs() { + this.cleanupInputs(castId); + } + + @Override + public void cleanupInputs(int theCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, theCastId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, theCastId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, theCastId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, theCastId)); + this.localStore.remove(ABLocalStoreKeys.PREVIOUSBEHAVIOR); + } + + @Override + public int getIconVisibleMenuId() { + return this.visibleMenuId; + } + + @Override + public void setIconVisibleMenuId(int menu) { + this.visibleMenuId = menu; + } + + @Override + public boolean isMenuAbility() { + return this.isMenu; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderNoIcon.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderNoIcon.java new file mode 100644 index 000000000..29355b0b0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderNoIcon.java @@ -0,0 +1,399 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractGenericNoIconAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; + +public class ABAbilityBuilderNoIcon extends AbstractGenericNoIconAbility implements ABAbilityBuilderPassiveAbility { + + protected List levelData; + protected ABAbilityBuilderConfiguration config; + protected ABLocalDataStore localStore; + + protected CItem item = null; + + protected float cooldown = 0; + protected float area = 0; + protected float range = 0; + protected float castTime = 0; + + protected Set uniqueFlags = null; + + private int visibleMenuId = 0; + + public ABAbilityBuilderNoIcon(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(handleId, code, alias); + this.levelData = levelData; + this.config = config; + this.localStore = localStore; + localStore.originAbility = this; + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + final int levels = editorData.getFieldAsInteger(AbilityFields.LEVELS, 0); + localStore.put(ABLocalStoreKeys.ISABILITYLEVELED, levels > 1); + } + + private void addInitialUniqueFlags(CSimulation game, CUnit unit) { + if (this.config.getInitialUniqueFlags() != null && !this.config.getInitialUniqueFlags().isEmpty()) { + this.uniqueFlags = new HashSet<>(); + for (ABStringCallback flag : this.config.getInitialUniqueFlags()) { + this.uniqueFlags.add(flag.callback(unit, localStore, ABConstants.NO_CAST_ID)); + } + } + } + + protected void setSpellFields(CSimulation game, CUnit unit) { + ABAbilityBuilderAbilityTypeLevelData levelDataLevel = this.levelData.get(this.getLevel() - 1); + this.cooldown = levelDataLevel.getCooldown(); + this.area = levelDataLevel.getArea(); + this.range = levelDataLevel.getCastRange(); + if (this.config.getOverrideFields() != null) { + if (this.config.getOverrideFields().getAreaOverride() != null) { + this.area = this.config.getOverrideFields().getAreaOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getRangeOverride() != null) { + this.range = this.config.getOverrideFields().getRangeOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getCastTimeOverride() != null) { + this.castTime = this.config.getOverrideFields().getCastTimeOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getCooldownOverride() != null) { + this.cooldown = this.config.getOverrideFields().getCooldownOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + } + } + + @Override + public int getAbilityIntField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldValue(field); + } + + @Override + public float getAbilityFloatField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldFloatValue(field); + } + + @Override + public String getAbilityStringField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getField(field); + } + + @Override + public boolean getAbilityBooleanField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldValue(field) != 0; + } + + @Override + public List getLevelData() { + return this.levelData; + } + + @Override + public ABAbilityBuilderConfiguration getConfig() { + return this.config; + } + + @Override + public ABLocalDataStore getLocalStore() { + return this.localStore; + } + + @Override + public float getArea() { + return area; + } + + @Override + public float getCastRange() { + return range; + } + + public float getCastTime() { + return castTime; + } + + @Override + public float getCooldown() { + return cooldown; + } + + @Override + public void startCooldown(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + unit.beginCooldown(game, cdID, this.cooldown); + } + } + + @Override + public float getCooldownRemainingTicks(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + return unit.getCooldownRemainingTicks(game, cdID); + } + return unit.getCooldownRemainingTicks(game, this.getCode()); + } + + @Override + public void resetCooldown(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + unit.beginCooldown(game, cdID, 0); + } + } + + private War3ID getCooldownId() { + if (this.item != null) { + if (item.getItemType().isIgnoreCooldown()) { + return War3ID.NONE; + } else { + if (item.getItemType().getCooldownGroup() != null) { + return item.getItemType().getCooldownGroup(); + } + } + } + return getCode(); + } + + @Override + public void setItemAbility(final CItem item, int slot) { + this.item = item; + this.localStore.originItem = item; + this.localStore.put(ABLocalStoreKeys.ITEMSLOT, slot); + } + + @Override + public CItem getItem() { + return this.item; + } + + @Override + public boolean hasUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + return this.uniqueFlags.contains(flag); + } + return false; + } + + public void addUniqueFlag(String flag) { + if (this.uniqueFlags == null) { + this.uniqueFlags = new HashSet<>(); + } + this.uniqueFlags.add(flag); + } + + public void removeUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + this.uniqueFlags.remove(flag); + } + } + + @SuppressWarnings("unchecked") + @Override + public T getUniqueValue(String key, Class cls) { + Object o = this.localStore.get(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + if (o != null && o.getClass() == cls) { + return (T) o; + } + return null; + } + + public void addUniqueValue(Object item, String key) { + this.localStore.put(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId()), item); + } + + public void removeUniqueValue(String key) { + this.localStore.remove(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + setSpellFields(game, unit); + if (config.getOnLevelChange() != null) { + for (ABAction action : config.getOnLevelChange()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + localStore.game = game; + localStore.originUnit = unit; + localStore.originPlayer = game.getPlayer(unit.getPlayerIndex()); + if (config.getOnAddAbility() != null) { + for (ABAction action : config.getOnAddAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onAddDisabled(CSimulation game, CUnit unit) { + localStore.game = game; + localStore.originUnit = unit; + localStore.originPlayer = game.getPlayer(unit.getPlayerIndex()); + addInitialUniqueFlags(game, unit); + setSpellFields(game, unit); + if (config.getOnAddDisabledAbility() != null) { + for (ABAction action : config.getOnAddDisabledAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + if (config.getOnRemoveAbility() != null) { + for (ABAction action : config.getOnRemoveAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onRemoveDisabled(CSimulation game, CUnit unit) { + if (config.getOnRemoveDisabledAbility() != null) { + for (ABAction action : config.getOnRemoveDisabledAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + if (config.getOnDeathPreCast() != null) { + for (ABAction action : config.getOnDeathPreCast()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public T visit(final CAbilityVisitor visitor) { + return visitor.accept(this); + } + + @Override + public void checkRequirementsMet(CSimulation game, CUnit unit, AbilityActivationReceiver receiver) { + List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); + CPlayer player = game.getPlayer(unit.getPlayerIndex()); + if (reqs != null) { + for (final CUnitTypeRequirement requirement : reqs) { + if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { + receiver.missingRequirement(requirement.getRequirement(), requirement.getRequiredLevel()); + } + } + } + } + + @Override + public boolean isRequirementsMet(CSimulation game, CUnit unit) { + List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); + CPlayer player = game.getPlayer(unit.getPlayerIndex()); + boolean requirementsMet = player.isTechtreeAllowedByMax(this.getAlias()); + if (reqs != null) { + for (final CUnitTypeRequirement requirement : reqs) { + if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { + requirementsMet = false; + } + } + } + return requirementsMet; + } + + @Override + public int getIconVisibleMenuId() { + return this.visibleMenuId; + } + + @Override + public void setIconVisibleMenuId(int menu) { + this.visibleMenuId = menu; + } + + // Unneeded Methods + @Override + public void onCancelFromQueue(CSimulation game, CUnit unit, int orderId) { + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, CWidget target) { + return null; + } + + @Override + public CBehavior begin(CSimulation game, CUnit caster, int orderId, boolean autoOrder, AbilityPointTarget point) { + return null; + } + + @Override + public CBehavior beginNoTarget(CSimulation game, CUnit caster, int orderId, boolean autoOrder) { + return null; + } + + @Override + protected void innerCheckCanUse(CSimulation game, CUnit unit, int orderId, AbilityActivationReceiver receiver) { + receiver.notAnActiveAbility(); + } + + @Override + public void checkCanTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, CWidget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + } + + @Override + public void checkCanTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, AbilityPointTarget target, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + } + + @Override + public void checkCanTargetNoTarget(CSimulation game, CUnit unit, int orderId, boolean autoOrder, + AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + } + + @Override + public War3ID getOnTooltipOverride() { + return null; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderPassive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderPassive.java new file mode 100644 index 000000000..94ce84582 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderPassive.java @@ -0,0 +1,383 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; + +public class ABAbilityBuilderPassive extends AbilityGenericSingleIconPassiveAbility + implements ABAbilityBuilderPassiveAbility { + + protected List levelData; + protected ABAbilityBuilderConfiguration config; + protected ABLocalDataStore localStore; + + protected CItem item = null; + + protected float cooldown = 0; + protected float area = 0; + protected float range = 0; + private float castTime = 0; + + private War3ID onTooltipOverride = null; + + protected Set uniqueFlags = null; + + private int visibleMenuId = 0; + + public ABAbilityBuilderPassive(int handleId, War3ID code, War3ID alias, + List levelData, ABAbilityBuilderConfiguration config, + ABLocalDataStore localStore) { + super(code, alias, handleId); + this.levelData = levelData; + this.config = config; + this.localStore = localStore; + localStore.originAbility = this; + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + final int levels = editorData.getFieldAsInteger(AbilityFields.LEVELS, 0); + localStore.put(ABLocalStoreKeys.ISABILITYLEVELED, levels > 1); + } + + private void addInitialUniqueFlags(CSimulation game, CUnit unit) { + if (this.config.getInitialUniqueFlags() != null && !this.config.getInitialUniqueFlags().isEmpty()) { + this.uniqueFlags = new HashSet<>(); + for (ABStringCallback flag : this.config.getInitialUniqueFlags()) { + this.uniqueFlags.add(flag.callback(unit, localStore, ABConstants.NO_CAST_ID)); + } + } + } + + protected void setSpellFields(CSimulation game, CUnit unit) { + if (this.levelData.size() > 0) { + ABAbilityBuilderAbilityTypeLevelData levelDataLevel = this.levelData.get(this.getLevel() - 1); + this.cooldown = levelDataLevel.getCooldown(); + this.area = levelDataLevel.getArea(); + this.range = levelDataLevel.getCastRange(); + } + if (this.config.getOverrideFields() != null) { + if (this.config.getOverrideFields().getAreaOverride() != null) { + this.area = this.config.getOverrideFields().getAreaOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getRangeOverride() != null) { + this.range = this.config.getOverrideFields().getRangeOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getCastTimeOverride() != null) { + this.castTime = this.config.getOverrideFields().getCastTimeOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getCooldownOverride() != null) { + this.cooldown = this.config.getOverrideFields().getCooldownOverride().callback(unit, localStore, + ABConstants.NO_CAST_ID); + } + if (this.config.getOverrideFields().getOnTooltipOverride() != null) { + this.onTooltipOverride = this.config.getOverrideFields().getOnTooltipOverride().callback(unit, + localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public int getAbilityIntField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldValue(field); + } + + @Override + public float getAbilityFloatField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldFloatValue(field); + } + + @Override + public String getAbilityStringField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getField(field); + } + + @Override + public boolean getAbilityBooleanField(String field) { + GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldValue(field) != 0; + } + + @Override + public List getLevelData() { + return this.levelData; + } + + @Override + public ABAbilityBuilderConfiguration getConfig() { + return this.config; + } + + @Override + public ABLocalDataStore getLocalStore() { + return this.localStore; + } + + @Override + public float getArea() { + return area; + } + + @Override + public float getCastRange() { + return range; + } + + public float getCastTime() { + return castTime; + } + + @Override + public float getCooldown() { + return cooldown; + } + + @Override + public void startCooldown(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + unit.beginCooldown(game, cdID, this.cooldown); + } + } + + @Override + public float getCooldownRemainingTicks(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + return unit.getCooldownRemainingTicks(game, cdID); + } + return unit.getCooldownRemainingTicks(game, this.getCode()); + } + + @Override + public void resetCooldown(CSimulation game, CUnit unit) { + War3ID cdID = getCooldownId(); + if (cdID != War3ID.NONE) { + unit.beginCooldown(game, cdID, 0); + } + } + + private War3ID getCooldownId() { + if (this.item != null) { + if (item.getItemType().isIgnoreCooldown()) { + return War3ID.NONE; + } else { + if (item.getItemType().getCooldownGroup() != null) { + return item.getItemType().getCooldownGroup(); + } + } + } + return getCode(); + } + + @Override + public void setItemAbility(final CItem item, int slot) { + this.item = item; + this.localStore.originItem = item; + this.localStore.put(ABLocalStoreKeys.ITEMSLOT, slot); + } + + @Override + public CItem getItem() { + return this.item; + } + + @Override + public boolean hasUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + return this.uniqueFlags.contains(flag); + } + return false; + } + + public void addUniqueFlag(String flag) { + if (this.uniqueFlags == null) { + this.uniqueFlags = new HashSet<>(); + } + this.uniqueFlags.add(flag); + } + + public void removeUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + this.uniqueFlags.remove(flag); + } + } + + @SuppressWarnings("unchecked") + @Override + public T getUniqueValue(String key, Class cls) { + Object o = this.localStore.get(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + if (o != null && o.getClass() == cls) { + return (T) o; + } + return null; + } + + public void addUniqueValue(Object item, String key) { + this.localStore.put(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId()), item); + } + + public void removeUniqueValue(String key) { + this.localStore.remove(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + } + + @Override + public War3ID getOnTooltipOverride() { + return onTooltipOverride; + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + setSpellFields(game, unit); + if (config.getOnLevelChange() != null) { + for (ABAction action : config.getOnLevelChange()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + localStore.game = game; + localStore.originUnit = unit; + localStore.originPlayer = game.getPlayer(unit.getPlayerIndex()); + if (config.getOnAddAbility() != null) { + for (ABAction action : config.getOnAddAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onAddDisabled(CSimulation game, CUnit unit) { + localStore.game = game; + localStore.originUnit = unit; + localStore.originPlayer = game.getPlayer(unit.getPlayerIndex()); + addInitialUniqueFlags(game, unit); + setSpellFields(game, unit); + if (config.getOnAddDisabledAbility() != null) { + for (ABAction action : config.getOnAddDisabledAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + if (config.getOnRemoveAbility() != null) { + for (ABAction action : config.getOnRemoveAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onRemoveDisabled(CSimulation game, CUnit unit) { + if (config.getOnRemoveDisabledAbility() != null) { + for (ABAction action : config.getOnRemoveDisabledAbility()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + if (config.getOnDeathPreCast() != null) { + for (ABAction action : config.getOnDeathPreCast()) { + action.runAction(unit, localStore, ABConstants.NO_CAST_ID); + } + } + } + + @Override + public T visit(final CAbilityVisitor visitor) { + return visitor.accept(this); + } + + @Override + public void checkRequirementsMet(CSimulation game, CUnit unit, AbilityActivationReceiver receiver) { + if (this.levelData.size() > 0) { + List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); + CPlayer player = game.getPlayer(unit.getPlayerIndex()); + if (reqs != null) { + for (final CUnitTypeRequirement requirement : reqs) { + if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { + receiver.missingRequirement(requirement.getRequirement(), requirement.getRequiredLevel()); + } + } + } + } + } + + @Override + public boolean isRequirementsMet(CSimulation game, CUnit unit) { + if (this.levelData.size() > 0) { + List reqs = this.levelData.get(this.getLevel() - 1).getRequirements(); + CPlayer player = game.getPlayer(unit.getPlayerIndex()); + boolean requirementsMet = player.isTechtreeAllowedByMax(this.getAlias()); + if (reqs != null) { + for (final CUnitTypeRequirement requirement : reqs) { + if (player.getTechtreeUnlocked(requirement.getRequirement()) < requirement.getRequiredLevel()) { + requirementsMet = false; + } + } + } + return requirementsMet; + } + return true; + } + + @Override + protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final int orderId, + final AbilityActivationReceiver receiver) { + final int cooldownRemaining = unit.getCooldownRemainingTicks(game, getCooldownId()); + + if (cooldownRemaining > 0) { + float cooldownLengthDisplay = unit.getCooldownLengthDisplayTicks(game, getCooldownId()) + * WarsmashConstants.SIMULATION_STEP_TIME; + receiver.cooldownNotYetReady(cooldownRemaining * WarsmashConstants.SIMULATION_STEP_TIME, + cooldownLengthDisplay); + } + + super.innerCheckCanUse(game, unit, orderId, receiver); + } + + @Override + public int getIconVisibleMenuId() { + return this.visibleMenuId; + } + + @Override + public void setIconVisibleMenuId(int menu) { + this.visibleMenuId = menu; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderPassiveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderPassiveAbility.java new file mode 100644 index 000000000..dc14a0866 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/ABAbilityBuilderPassiveAbility.java @@ -0,0 +1,5 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability; + +public interface ABAbilityBuilderPassiveAbility extends ABAbilityBuilderAbility { + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderAuraTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderAuraTemplate.java new file mode 100644 index 000000000..c2b31e272 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderAuraTemplate.java @@ -0,0 +1,160 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABAbilityBuilderAuraTemplate extends AbilityGenericSingleIconPassiveAbility { + + private List levelData; + private ABLocalDataStore localStore; + + private Set auraGroup; + private int lastSeenLevel = 0; + private int loopTick = 0; + + private static final Rectangle recycleRect = new Rectangle(); + private EnumSet targetsAllowed = null; + private float range = 0; + + private CBuff buff; + + private List addToAuraActions; + private List updateAuraLevelActions; + private List removeFromAuraActions; + + private final int LEAVE_GROUP_TICKS = (int) (3 / WarsmashConstants.SIMULATION_STEP_TIME); + private final int ENTER_GROUP_TICKS = (int) (0.4 / WarsmashConstants.SIMULATION_STEP_TIME); + private final int RESET_GROUP_TICKS = LEAVE_GROUP_TICKS * 2; + + public ABAbilityBuilderAuraTemplate(int handleId, War3ID code, War3ID alias, + List levelData, ABLocalDataStore localStore, + List addToAuraActions, List updateAuraLevelActions, + List removeFromAuraActions) { + super(code, alias, handleId); + this.levelData = levelData; + this.localStore = localStore; + this.addToAuraActions = addToAuraActions; + this.updateAuraLevelActions = updateAuraLevelActions; + this.removeFromAuraActions = removeFromAuraActions; + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + targetsAllowed = levelData.get(getLevel()).getTargetsAllowed(); + range = levelData.get(getLevel()).getCastRange(); + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + auraGroup = new HashSet<>(); + localStore.put(ABLocalStoreKeys.AURAGROUP, auraGroup); + lastSeenLevel = getLevel(); + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + emptyAura(game, unit); + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + if (loopTick % LEAVE_GROUP_TICKS == 0) { + List unitList; + if (lastSeenLevel != getLevel()) { + unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { + updateLevelOfAura(game, iter, lastSeenLevel, getLevel()); + } + } + lastSeenLevel = getLevel(); + } + unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { + removeUnitFromAura(game, iter); + } + } + } + if (loopTick % ENTER_GROUP_TICKS == 0) { + recycleRect.set(unit.getX() - range, unit.getY() - range, range * 2, range * 2); + game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (unit.canReach(enumUnit, range) && enumUnit.canBeTargetedBy(game, unit, targetsAllowed) + && !auraGroup.contains(enumUnit)) { + addUnitToAura(game, enumUnit); + } + return false; + } + }); + } + loopTick++; + loopTick = loopTick % (RESET_GROUP_TICKS); + + } + + public void emptyAura(CSimulation game, CUnit unit) { + List unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + removeUnitFromAura(game, iter); + } + } + + public void addUnitToAura(CSimulation game, CUnit unit) { + auraGroup.add(unit); + if (addToAuraActions != null) { + for (ABAction action : addToAuraActions) { + action.runAction(unit, localStore, 0); + } + } + unit.add(game, buff); + } + + public void updateLevelOfAura(CSimulation game, CUnit unit, int prevLevel, int curLevel) { + if (updateAuraLevelActions != null) { + for (ABAction action : updateAuraLevelActions) { + action.runAction(unit, localStore, 0); + } + } + } + + public void removeUnitFromAura(CSimulation game, CUnit unit) { + unit.remove(game, buff); + if (removeFromAuraActions != null) { + for (ABAction action : removeFromAuraActions) { + action.runAction(unit, localStore, 0); + } + } + auraGroup.remove(unit); + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + emptyAura(game, unit); + } + + @Override + public boolean isUniversal() { + return true; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderSimpleAuraTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderSimpleAuraTemplate.java new file mode 100644 index 000000000..c40a41bc6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderSimpleAuraTemplate.java @@ -0,0 +1,207 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABAbilityBuilderSimpleAuraTemplate extends AbilityGenericSingleIconPassiveAbility { + + private List levelData; + private ABLocalDataStore localStore; + + private Set auraGroup; + private int lastSeenLevel = 0; + private int loopTick = 0; + + private static final Rectangle recycleRect = new Rectangle(); + private EnumSet targetsAllowed = null; + private float range = 0; + + private CBuff buff; + + private Map> abilityIdsToAddPerLevel; + private List levellingAbilityIdsToAdd; + + private Map> abilitiesToAddPerLevel; + private List levellingAbilitiesToAdd; + + private final int LEAVE_GROUP_TICKS = (int) (3 / WarsmashConstants.SIMULATION_STEP_TIME); + private final int ENTER_GROUP_TICKS = (int) (0.4 / WarsmashConstants.SIMULATION_STEP_TIME); + private final int RESET_GROUP_TICKS = LEAVE_GROUP_TICKS * 2; + + public ABAbilityBuilderSimpleAuraTemplate(int handleId, War3ID code, War3ID alias, + List levelData, ABLocalDataStore localStore, + Map> abilityIdsToAddPerLevel, List levellingAbilityIdsToAdd) { + super(code, alias, handleId); + this.levelData = levelData; + this.localStore = localStore; + this.abilityIdsToAddPerLevel = abilityIdsToAddPerLevel; + this.levellingAbilityIdsToAdd = levellingAbilityIdsToAdd; + + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + targetsAllowed = levelData.get(getLevel()).getTargetsAllowed(); + range = levelData.get(getLevel()).getCastRange(); + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + game.getAbilityData().createAbility(getAlias(), game.getHandleIdAllocator().createId()); + auraGroup = new HashSet<>(); + localStore.put(ABLocalStoreKeys.AURAGROUP, auraGroup); + lastSeenLevel = getLevel(); + this.abilitiesToAddPerLevel = new HashMap<>(); + this.levellingAbilitiesToAdd = new ArrayList<>(); + if (abilityIdsToAddPerLevel != null) { + for (Integer i : abilityIdsToAddPerLevel.keySet()) { + List list = new ArrayList<>(); + abilitiesToAddPerLevel.put(i, list); + for (War3ID abilityId : abilityIdsToAddPerLevel.get(i)) { + list.add(game.getAbilityData().getAbilityType(abilityId) + .createAbility(game.getHandleIdAllocator().createId())); + } + } + } + if (levellingAbilityIdsToAdd != null) { + for (War3ID abilityId : levellingAbilityIdsToAdd) { + CAbility abil = game.getAbilityData().getAbilityType(abilityId) + .createAbility(game.getHandleIdAllocator().createId()); + if (abil instanceof CLevelingAbility) { + levellingAbilitiesToAdd.add((CLevelingAbility) abil); + } + } + } + + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + emptyAura(game, unit); + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + if (loopTick % LEAVE_GROUP_TICKS == 0) { + List unitList; + if (lastSeenLevel != getLevel()) { + unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { + updateLevelOfAura(game, iter, lastSeenLevel, getLevel()); + } + } + lastSeenLevel = getLevel(); + } + unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { + removeUnitFromAura(game, iter); + } + } + } + if (loopTick % ENTER_GROUP_TICKS == 0) { + recycleRect.set(unit.getX() - range, unit.getY() - range, range * 2, range * 2); + game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (unit.canReach(enumUnit, range) && enumUnit.canBeTargetedBy(game, unit, targetsAllowed) + && !auraGroup.contains(enumUnit)) { + addUnitToAura(game, enumUnit); + } + return false; + } + }); + } + loopTick++; + loopTick = loopTick % (RESET_GROUP_TICKS); + + } + + public void emptyAura(CSimulation game, CUnit unit) { + List unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + removeUnitFromAura(game, iter); + } + } + + public void addUnitToAura(CSimulation game, CUnit unit) { + auraGroup.add(unit); + if (abilitiesToAddPerLevel != null) { + for (CAbility ability : abilitiesToAddPerLevel.get(getLevel())) { + unit.add(game, ability); + } + } + if (levellingAbilitiesToAdd != null) { + for (CAbility ability : levellingAbilitiesToAdd) { + unit.add(game, ability); + } + } + unit.add(game, buff); + } + + public void updateLevelOfAura(CSimulation game, CUnit unit, int prevLevel, int curLevel) { + if (abilitiesToAddPerLevel != null) { + for (CAbility ability : abilitiesToAddPerLevel.get(prevLevel)) { + unit.remove(game, ability); + } + } + if (abilitiesToAddPerLevel != null) { + for (CAbility ability : abilitiesToAddPerLevel.get(curLevel)) { + unit.add(game, ability); + } + } + if (levellingAbilitiesToAdd != null) { + for (CLevelingAbility ability : levellingAbilitiesToAdd) { + ability.setLevel(game, unit, curLevel); + } + } + } + + public void removeUnitFromAura(CSimulation game, CUnit unit) { + unit.remove(game, buff); + if (abilitiesToAddPerLevel != null) { + for (CAbility ability : abilitiesToAddPerLevel.get(getLevel())) { + unit.remove(game, ability); + } + } + if (levellingAbilitiesToAdd != null) { + for (CAbility ability : levellingAbilitiesToAdd) { + unit.remove(game, ability); + } + } + auraGroup.remove(unit); + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + emptyAura(game, unit); + } + + @Override + public boolean isUniversal() { + return true; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderStatAuraTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderStatAuraTemplate.java new file mode 100644 index 000000000..ff2e4432d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderStatAuraTemplate.java @@ -0,0 +1,338 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABGenericAuraBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABMeleeRangeTargetOverride; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABStatBuffFromDataField; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABAbilityBuilderStatAuraTemplate extends AbilityGenericSingleIconPassiveAbility { + + private List levelData; + private ABLocalDataStore localStore; + + private Set auraGroup; + private int loopTick = 0; + + private static final Rectangle recycleRect = new Rectangle(); + private EnumSet targetsAllowed = null; + private float range = 0; + + private War3ID buffId; + private CBuff buff; + + private SimulationRenderComponent fx; + + private boolean targetMelee = false; + private boolean targetRange = false; + private ABMeleeRangeTargetOverride rangeOverride; + + private String auraStackingKey; + + private List statBuffDataFields; + + private final int LEAVE_GROUP_TICKS = (int) (3 / WarsmashConstants.SIMULATION_STEP_TIME); + private final int ENTER_GROUP_TICKS = (int) (0.4 / WarsmashConstants.SIMULATION_STEP_TIME); + private final int RESET_GROUP_TICKS = LEAVE_GROUP_TICKS * 2; + private boolean leveled; + + public ABAbilityBuilderStatAuraTemplate(int handleId, War3ID code, War3ID alias, + List levelData, ABLocalDataStore localStore, + List statBuffDataFields, ABMeleeRangeTargetOverride meleeRangeTargetOverride) { + super(code, alias, handleId); + this.levelData = levelData; + this.localStore = localStore; + this.rangeOverride = meleeRangeTargetOverride; + this.targetsAllowed = levelData.get(getLevel() - 1).getTargetsAllowed(); + this.range = levelData.get(getLevel() - 1).getArea(); + this.auraStackingKey = ""; + + this.statBuffDataFields = new ArrayList<>(); + for (ABStatBuffFromDataField statBuff : statBuffDataFields) { + this.statBuffDataFields.add(new ABStatBuffFromDataField(statBuff)); + } + + if (!this.levelData.get(getLevel() - 1).getBuffs().isEmpty()) { + buffId = this.levelData.get(getLevel() - 1).getBuffs().get(0); + this.auraStackingKey = buffId.asStringValue(); + } + + for (ABStatBuffFromDataField statBuff : this.statBuffDataFields) { + createNewBuffs(statBuff); + } + + if (this.rangeOverride != null) { + this.targetMelee = this.rangeOverride.isTargetMelee(); + this.targetRange = this.rangeOverride.isTargetRange(); + } + + this.leveled = levelData.size() > 1; + } + + private void removeExistingBuffs(CSimulation game, ABStatBuffFromDataField statBuff) { + for (CUnit unit : auraGroup) { + unit.removeNonStackingStatBuff(game, statBuff.getBuff()); + if (statBuff.getSecondAtkBuff() != null) { + unit.removeNonStackingStatBuff(game, statBuff.getSecondAtkBuff()); + } + } + } + + private void addNewBuffs(CSimulation game, ABStatBuffFromDataField statBuff) { + for (CUnit unit : auraGroup) { + unit.addNonStackingStatBuff(game, statBuff.getBuff()); + if (statBuff.getSecondAtkBuff() != null) { + unit.addNonStackingStatBuff(game, statBuff.getSecondAtkBuff()); + } + } + } + + private void createNewBuffs(ABStatBuffFromDataField parsedBuff) { + NonStackingStatBuffType type = parsedBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); + NonStackingStatBuff newBuff = null; + switch (type) { + case RNGDATK: + case RNGDATKPCT: + newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + targetRange = true; + break; + case MELEEATK: + case MELEEATKPCT: + newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + targetMelee = true; + break; + case ALLATK: + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATK, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATK, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setSecondAtkBuff(newBuff); + targetMelee = true; + targetRange = true; + break; + case ALLATKPCT: + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATKPCT, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATKPCT, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setSecondAtkBuff(newBuff); + targetMelee = true; + targetRange = true; + break; + default: + newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + targetMelee = true; + targetRange = true; + } + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + this.buff.setLevel(game, unit, level); + targetsAllowed = levelData.get(getLevel() - 1).getTargetsAllowed(); + range = levelData.get(getLevel() - 1).getArea(); + this.targetMelee = false; + this.targetRange = false; + for (ABStatBuffFromDataField statBuff : this.statBuffDataFields) { + NonStackingStatBuffType type = statBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); + if (type == null) { + continue; + } + switch (type) { + case ALLATK: + if (statBuff.getSecondAtkBuff() == null) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + addNewBuffs(game, statBuff); + } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATK) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + addNewBuffs(game, statBuff); + } else { + statBuff.getBuff().setValue(Float.parseFloat( + levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); + targetMelee = true; + targetRange = true; + } + break; + case ALLATKPCT: + if (statBuff.getSecondAtkBuff() == null) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + addNewBuffs(game, statBuff); + } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATKPCT) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + addNewBuffs(game, statBuff); + } else { + statBuff.getBuff().setValue(Float.parseFloat( + levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); + targetMelee = true; + targetRange = true; + } + break; + default: + if (statBuff.getSecondAtkBuff() != null) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + addNewBuffs(game, statBuff); + } else if (type != statBuff.getBuff().getBuffType()) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + addNewBuffs(game, statBuff); + } else { + float parsedFloat; + try { + parsedFloat = Float.parseFloat( + levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex())); + } catch (NumberFormatException exc) { + parsedFloat = 0; + } + statBuff.getBuff().setValue(parsedFloat); + if (type == NonStackingStatBuffType.MELEEATK || type == NonStackingStatBuffType.MELEEATKPCT) { + targetMelee = true; + } else if (type == NonStackingStatBuffType.RNGDATK || type == NonStackingStatBuffType.RNGDATKPCT) { + targetRange = true; + } else { + targetMelee = true; + targetRange = true; + } + } + } + for (CUnit unitA : auraGroup) { + if (statBuff.getBuff().getBuffType().isHeroStat()) { + unitA.computeDerivedHeroFields(game, statBuff.getBuff().getBuffType()); + } else { + unitA.computeDerivedFields(statBuff.getBuff().getBuffType()); + } + } + } + if (this.rangeOverride != null) { + this.targetMelee = this.rangeOverride.isTargetMelee(); + this.targetRange = this.rangeOverride.isTargetRange(); + } + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + if (this.buffId != null) { + this.buff = new ABGenericAuraBuff(game.getHandleIdAllocator().createId(), this.buffId, + localStore, this, unit, + this.leveled, true); + } + game.getAbilityData().createAbility(getAlias(), game.getHandleIdAllocator().createId()); + auraGroup = new HashSet<>(); + localStore.put(ABLocalStoreKeys.AURAGROUP, auraGroup); + this.fx = game.createPersistentSpellEffectOnUnit(unit, this.getAlias(), CEffectType.TARGET); + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + emptyAura(game, unit); + this.fx.remove(); + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + if (loopTick % LEAVE_GROUP_TICKS == 0) { + List unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + if (!(iter.canBeTargetedBy(game, unit, targetsAllowed) && unit.canReach(iter, range))) { + removeUnitFromAura(game, iter); + } + } + } + if (loopTick % ENTER_GROUP_TICKS == 0) { + recycleRect.set(unit.getX() - range, unit.getY() - range, range * 2, range * 2); + game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (unit.canReach(enumUnit, range) && enumUnit.canBeTargetedBy(game, unit, targetsAllowed) + && !auraGroup.contains(enumUnit) + && ((targetMelee && enumUnit.isUnitType(CUnitTypeJass.MELEE_ATTACKER) + || (targetRange && enumUnit.isUnitType(CUnitTypeJass.RANGED_ATTACKER))))) { + addUnitToAura(game, enumUnit); + } + return false; + } + }); + } + loopTick++; + loopTick = loopTick % (RESET_GROUP_TICKS); + + } + + public void emptyAura(CSimulation game, CUnit unit) { + List unitList = new ArrayList<>(auraGroup); + for (CUnit iter : unitList) { + removeUnitFromAura(game, iter); + } + } + + public void addUnitToAura(CSimulation game, CUnit unit) { + for (ABStatBuffFromDataField statBuff : this.statBuffDataFields) { + unit.addNonStackingStatBuff(game, statBuff.getBuff()); + if (statBuff.getSecondAtkBuff() != null) { + unit.addNonStackingStatBuff(game, statBuff.getSecondAtkBuff()); + } + } + if (buff != null) { + unit.addNonStackingDisplayBuff(game, auraStackingKey, buff); + } + auraGroup.add(unit); + } + + public void removeUnitFromAura(CSimulation game, CUnit unit) { + if (buff != null) { + unit.removeNonStackingDisplayBuff(game, auraStackingKey, buff); + } + for (ABStatBuffFromDataField statBuff : this.statBuffDataFields) { + unit.removeNonStackingStatBuff(game, statBuff.getBuff()); + if (statBuff.getSecondAtkBuff() != null) { + unit.removeNonStackingStatBuff(game, statBuff.getSecondAtkBuff()); + } + } + auraGroup.remove(unit); + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + emptyAura(game, unit); + } + + @Override + public boolean isUniversal() { + return true; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderStatPassiveTemplate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderStatPassiveTemplate.java new file mode 100644 index 000000000..e185a50e8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/ability/template/ABAbilityBuilderStatPassiveTemplate.java @@ -0,0 +1,190 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template; + +import java.util.List; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbilityGenericSingleIconPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABPermanentPassiveBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABStatBuffFromDataField; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; + +public class ABAbilityBuilderStatPassiveTemplate extends AbilityGenericSingleIconPassiveAbility { + + private List levelData; + private ABLocalDataStore localStore; + + private War3ID buffId; + private CBuff buff; + + private CUnit caster; + + private String auraStackingKey; + + private List statBuffDataFields; + + public ABAbilityBuilderStatPassiveTemplate(int handleId, War3ID code, War3ID alias, + List levelData, ABLocalDataStore localStore, + List statBuffDataFields) { + super(code, alias, handleId); + this.levelData = levelData; + this.localStore = localStore; + this.statBuffDataFields = statBuffDataFields; + this.auraStackingKey = ""; + + if (!this.levelData.get(getLevel() - 1).getBuffs().isEmpty()) { + buffId = this.levelData.get(getLevel() - 1).getBuffs().get(0); + this.auraStackingKey = buffId.asStringValue(); + } + + for (ABStatBuffFromDataField statBuff : statBuffDataFields) { + createNewBuffs(statBuff); + } + } + + private void removeExistingBuffs(CSimulation game, ABStatBuffFromDataField statBuff) { + this.caster.removeNonStackingStatBuff(game, statBuff.getBuff()); + if (statBuff.getSecondAtkBuff() != null) { + this.caster.removeNonStackingStatBuff(game, statBuff.getSecondAtkBuff()); + } + } + + private void createNewBuffs(ABStatBuffFromDataField parsedBuff) { + NonStackingStatBuffType type = parsedBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); + NonStackingStatBuff newBuff = null; + switch (type) { + case RNGDATK: + case RNGDATKPCT: + newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + break; + case MELEEATK: + case MELEEATKPCT: + newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + break; + case ALLATK: + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATK, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATK, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setSecondAtkBuff(newBuff); + break; + case ALLATKPCT: + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.MELEEATKPCT, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + newBuff = new NonStackingStatBuff(NonStackingStatBuffType.RNGDATKPCT, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setSecondAtkBuff(newBuff); + break; + default: + newBuff = new NonStackingStatBuff(type, this.auraStackingKey, Float + .parseFloat(levelData.get(getLevel() - 1).getData().get(parsedBuff.getDataField().getIndex()))); + parsedBuff.setBuff(newBuff); + } + } + + @Override + public void setLevel(CSimulation game, CUnit unit, int level) { + super.setLevel(game, unit, level); + for (ABStatBuffFromDataField statBuff : this.statBuffDataFields) { + NonStackingStatBuffType type = statBuff.convertToNonStackingType(levelData.get(getLevel() - 1)); + if (type == null) { + continue; + } + switch (type) { + case ALLATK: + if (statBuff.getSecondAtkBuff() == null) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATK) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + } else { + statBuff.getBuff().setValue(Float.parseFloat( + levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); + } + break; + case ALLATKPCT: + if (statBuff.getSecondAtkBuff() == null) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + } else if (statBuff.getBuff().getBuffType() != NonStackingStatBuffType.MELEEATKPCT) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + } else { + statBuff.getBuff().setValue(Float.parseFloat( + levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); + } + break; + default: + if (statBuff.getSecondAtkBuff() != null) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + } else if (type != statBuff.getBuff().getBuffType()) { + removeExistingBuffs(game, statBuff); + createNewBuffs(statBuff); + } else { + statBuff.getBuff().setValue(Float.parseFloat( + levelData.get(getLevel() - 1).getData().get(statBuff.getDataField().getIndex()))); + } + } + if (statBuff.getBuff().getBuffType().isHeroStat()) { + caster.computeDerivedHeroFields(game, statBuff.getBuff().getBuffType()); + } else { + caster.computeDerivedFields(statBuff.getBuff().getBuffType()); + } + } + if (this.buff != null) { + this.buff.setLevel(game, unit, level); + } + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + if (this.buffId != null) { + this.buff = new ABPermanentPassiveBuff(game.getHandleIdAllocator().createId(), this.buffId, this, unit, + localStore, null, null, 0, false, true); + unit.addNonStackingDisplayBuff(game, auraStackingKey, buff); + } + this.caster = unit; + game.getAbilityData().createAbility(getAlias(), game.getHandleIdAllocator().createId()); + + for (ABStatBuffFromDataField statBuff : this.statBuffDataFields) { + unit.addNonStackingStatBuff(game, statBuff.getBuff()); + } + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + removeBuffFromUnit(game, unit); + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + } + + public void removeBuffFromUnit(CSimulation game, CUnit unit) { + if (this.buff != null) { + unit.removeNonStackingDisplayBuff(game, auraStackingKey, buff); + } + for (ABStatBuffFromDataField statBuff : this.statBuffDataFields) { + unit.removeNonStackingStatBuff(game, statBuff.getBuff()); + } + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + removeBuffFromUnit(game, unit); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehavior.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehavior.java new file mode 100644 index 000000000..cf28a948f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehavior.java @@ -0,0 +1,31 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; + +public interface ABBehavior extends CBehavior { + public CBehavior reset(final CSimulation game, final CWidget target, final boolean autoOrder); + + public CBehavior reset(final CSimulation game, final CWidget target, int orderId, final boolean autoOrder); + + public CBehavior reset(final CSimulation game, final AbilityPointTarget target, final boolean autoOrder); + + public CBehavior reset(final CSimulation game, final AbilityPointTarget target, int orderId, + final boolean autoOrder); + + public CBehavior reset(final boolean autoOrder); + + public CBehavior reset(int orderId, final boolean autoOrder); + + public void setCastId(int castId); + + public void setInstant(boolean instant); + + public void setBehaviorCategory(CBehaviorCategory behaviorCategory); + + public CAbility getAbility(); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorAbilityBuilderBase.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorAbilityBuilderBase.java new file mode 100644 index 000000000..a632d36f2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorAbilityBuilderBase.java @@ -0,0 +1,461 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior; + +import java.util.EnumSet; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABAbilityTargetStillTargetableVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CAbstractRangedBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityActivationReceiver; + +public class ABBehaviorAbilityBuilderBase extends CAbstractRangedBehavior implements ABBehavior { + private ABLocalDataStore localStore; + private ABAbilityBuilderActiveAbility ability; + private ABAbilityTargetStillTargetableVisitor preCastTargetableVisitor; + + private int castBehaviorNotifyTick = 0; + + private int castStartTick = 0; + private int castTimeEndTick = 0; + private int castPointTicks = 0; + private int backswingTicks = 0; + private boolean doneCastTime = false; + private boolean doneEffect = false; + private boolean channeling = false; + private boolean preventReInterrupt = false; + + private int castId = 0; + private int orderId; + private boolean autoOrder; + + private boolean instant = false; + private CBehaviorCategory behaviorCategory = null; + private EnumSet channelTags; + private boolean firstAnimation; + + public ABBehaviorAbilityBuilderBase(final CUnit unit, final ABLocalDataStore localStore, + ABAbilityBuilderActiveAbility ability) { + super(unit); + this.localStore = localStore; + this.ability = ability; + this.preCastTargetableVisitor = new ABAbilityTargetStillTargetableVisitor(); + + } + + public void setInstant(boolean instant) { + this.instant = instant; + } + + public void setBehaviorCategory(CBehaviorCategory behaviorCategory) { + this.behaviorCategory = behaviorCategory; + } + + public CBehavior reset(final CSimulation game, final CWidget target, final boolean autoOrder) { + this.doneCastTime = false; + this.doneEffect = false; + this.castStartTick = 0; + this.castTimeEndTick = this.ability.ignoreCastTime() ? 0 + : (int) (this.ability.getCastTime() / WarsmashConstants.SIMULATION_STEP_TIME); + this.castPointTicks = this.castTimeEndTick + + (int) (this.unit.getUnitType().getCastPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.backswingTicks = this.castPointTicks + + (int) (this.unit.getUnitType().getCastBackswingPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + this.orderId = this.ability.getBaseOrderId(); + this.preventReInterrupt = false; + this.firstAnimation = true; + this.autoOrder = autoOrder; + + this.channelTags = this.ability.getCastingSecondaryTags().clone(); + this.channelTags.add(SecondaryTag.CHANNEL); + return innerReset(game, target, false); + } + + public CBehavior reset(final CSimulation game, final CWidget target, int orderId, final boolean autoOrder) { + this.doneCastTime = false; + this.doneEffect = false; + this.castStartTick = 0; + this.castTimeEndTick = this.ability.ignoreCastTime() ? 0 + : (int) (this.ability.getCastTime() / WarsmashConstants.SIMULATION_STEP_TIME); + this.castPointTicks = this.castTimeEndTick + + (int) (this.unit.getUnitType().getCastPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.backswingTicks = this.castPointTicks + + (int) (this.unit.getUnitType().getCastBackswingPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + this.orderId = orderId; + this.preventReInterrupt = false; + this.firstAnimation = true; + this.autoOrder = autoOrder; + + this.channelTags = this.ability.getCastingSecondaryTags().clone(); + this.channelTags.add(SecondaryTag.CHANNEL); + return innerReset(game, target, false); + } + + public CBehavior reset(final CSimulation game, final AbilityPointTarget target, final boolean autoOrder) { + this.doneCastTime = false; + this.doneEffect = false; + this.castStartTick = 0; + this.castTimeEndTick = this.ability.ignoreCastTime() ? 0 + : (int) (this.ability.getCastTime() / WarsmashConstants.SIMULATION_STEP_TIME); + this.castPointTicks = this.castTimeEndTick + + (int) (this.unit.getUnitType().getCastPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.backswingTicks = this.castPointTicks + + (int) (this.unit.getUnitType().getCastBackswingPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + this.orderId = this.ability.getBaseOrderId(); + this.preventReInterrupt = false; + this.firstAnimation = true; + this.autoOrder = autoOrder; + + this.channelTags = this.ability.getCastingSecondaryTags().clone(); + this.channelTags.add(SecondaryTag.CHANNEL); + return innerReset(game, target, false); + } + + public CBehavior reset(final CSimulation game, final AbilityPointTarget target, int orderId, + final boolean autoOrder) { + this.doneCastTime = false; + this.doneEffect = false; + this.castStartTick = 0; + this.castTimeEndTick = this.ability.ignoreCastTime() ? 0 + : (int) (this.ability.getCastTime() / WarsmashConstants.SIMULATION_STEP_TIME); + this.castPointTicks = this.castTimeEndTick + + (int) (this.unit.getUnitType().getCastPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.backswingTicks = this.castPointTicks + + (int) (this.unit.getUnitType().getCastBackswingPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + this.orderId = orderId; + this.preventReInterrupt = false; + this.firstAnimation = true; + this.autoOrder = autoOrder; + + this.channelTags = this.ability.getCastingSecondaryTags().clone(); + this.channelTags.add(SecondaryTag.CHANNEL); + return innerReset(game, target, false); + } + + public ABBehavior reset(final boolean autoOrder) { + return null; + } + + public ABBehavior reset(int orderId, final boolean autoOrder) { + return null; + } + + @Override + public CBehavior update(final CSimulation game, boolean withinFacingWindow) { + boolean wasChanneling = this.channeling; + if (this.castStartTick == 0) { + CBehavior prevBeh = this.unit.getCurrentBehavior(); + + this.castStartTick = game.getGameTurnTick(); + this.castBehaviorNotifyTick = (int) (this.castStartTick + 0.5 / WarsmashConstants.SIMULATION_STEP_TIME); + + if (!this.target.visit( + this.preCastTargetableVisitor.reset(game, this.unit, ability, this.autoOrder, false, orderId))) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + + this.ability.checkCanUse(game, unit, orderId, autoOrder, BooleanAbilityActivationReceiver.INSTANCE); + if (!BooleanAbilityActivationReceiver.INSTANCE.isOk()) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CHANNEL, this.ability, this.target); + if (this.unit.getCurrentBehavior() != prevBeh) { + cleanupInputs(); + return this.unit.getCurrentBehavior(); + } else if (this.unit.isPaused()) { + return this; + } + + if (!instant && this.castTimeEndTick > 0) { + this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, + EnumSet.of(SecondaryTag.CHANNEL), 1.0f, true); + } + } + + if (instant) { + if (!this.doneCastTime) { + // should have already checked castable/range above, as no time delay + if (!this.unit.chargeMana(this.ability.getChargedManaCost())) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + this.ability.startCooldown(game, this.unit); + + this.ability.runBeginCastingActions(game, unit, orderId); + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this.ability, this.target); + this.doneCastTime = true; + } + CBehavior beh = tryDoEffect(game, wasChanneling); + if (beh != null) { + cleanupInputs(); + return beh; + } + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + return newBehavior; + } + + if (!this.channeling) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + } else { + final int ticksSinceCast = game.getGameTurnTick() - this.castStartTick; + if (!this.doneCastTime && ticksSinceCast >= this.castTimeEndTick) { + if (!this.isWithinRange(game)) { + // target moved too far, out of range now + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + + this.ability.checkCanUse(game, unit, orderId, autoOrder, BooleanAbilityActivationReceiver.INSTANCE); + if (!BooleanAbilityActivationReceiver.INSTANCE.isOk() + || !this.unit.chargeMana(this.ability.getChargedManaCost())) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + this.ability.startCooldown(game, this.unit); + CBehavior prevBeh = this.unit.getCurrentBehavior(); + + this.ability.runBeginCastingActions(game, unit, orderId); + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + return newBehavior; + } + + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this.ability, this.target); + if (this.unit.getCurrentBehavior() != prevBeh) { + cleanupInputs(); + return this.unit.getCurrentBehavior(); + } else if (this.unit.isPaused()) { + return this; + } + + this.channeling = localStore.getBoolean(ABLocalStoreKeys.CHANNELING); + if (!this.channeling) { + this.unit.getUnitAnimationListener().playAnimation(this.firstAnimation, + this.ability.getCastingPrimaryTag(), this.ability.getCastingSecondaryTags(), 1.0f, true); + this.firstAnimation = false; + this.unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, SequenceUtils.EMPTY, true); + } + this.doneCastTime = true; + } + if (this.channeling) { + this.unit.getUnitAnimationListener().playAnimation(false, this.ability.getCastingPrimaryTag(), + this.channelTags, 1.0f, true); + } + + if ((ticksSinceCast >= castPointTicks)) { + if (this.castPointTicks > this.castTimeEndTick && !this.isWithinRange(game)) { + // Unit moved too far, out of range now + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + CBehavior beh = tryDoEffect(game, wasChanneling); + if (beh != null) { + cleanupInputs(); + return beh; + } + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + return newBehavior; + } + } + if ((ticksSinceCast >= backswingTicks) && !this.channeling) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + } + return this; + } + + private void cleanupInputs() { + this.ability.cleanupInputs(castId); + } + + private CBehavior tryDoEffect(CSimulation game, boolean wasChanneling) { + boolean wasEffectDone = this.doneEffect; + if (!wasEffectDone) { + CBehavior prevBeh = this.unit.getCurrentBehavior(); + if (this.channeling) { + game.unitLoopSoundEffectEvent(this.unit, this.ability.getAlias()); + } else { + game.unitSoundEffectEvent(this.unit, this.ability.getAlias()); + } + this.doneEffect = true; + + if (this.unit.getCurrentBehavior() != prevBeh) { + return this.unit.getCurrentBehavior(); + } else if (this.unit.isPaused()) { + return this; + } + + this.ability.runEndCastingActions(game, unit, orderId); + this.channeling = (boolean) localStore.getBoolean(ABLocalStoreKeys.CHANNELING); + + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, this.ability, this.target); + if (this.unit.getCurrentBehavior() != prevBeh) { + return this.unit.getCurrentBehavior(); + } else if (this.unit.isPaused()) { + return this; + } + + } + this.channeling = this.channeling && this.doChannelTick(game, this.unit, this.target); + if (wasEffectDone && wasChanneling && !this.channeling) { + endChannel(game, false); + return this.unit.pollNextOrderBehavior(game); + } + return null; + } + + @Override + public void begin(final CSimulation game) { + if (ability.getItem() != null && ability.getItem().getItemType().isActivelyUsed()) { + // This is for runes/glyphs that use on pickup. We will never see an update loop + // for these + + if (!this.unit.chargeMana(this.ability.getChargedManaCost())) { + cleanupInputs(); + this.unit.beginBehavior(game, this.unit.pollNextOrderBehavior(game)); + return; + } + this.ability.startCooldown(game, this.unit); + + this.ability.runBeginCastingActions(game, unit, orderId); + + CBehavior beh = tryDoEffect(game, false); + if (beh != null) { + cleanupInputs(); + this.unit.beginBehavior(game, beh); + return; + } + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + this.unit.beginBehavior(game, newBehavior); + return; + } + + cleanupInputs(); + this.unit.beginBehavior(game, this.unit.pollNextOrderBehavior(game)); + } + } + + public boolean doChannelTick(CSimulation game, CUnit caster, AbilityTarget target) { + this.ability.runChannelTickActions(game, caster, orderId); + return (boolean) localStore.getBoolean(ABLocalStoreKeys.CHANNELING); + } + + @Override + public void end(final CSimulation game, boolean interrupted) { + checkEndChannel(game, interrupted); + Boolean preventEndEvents = this.localStore.get(ABLocalStoreKeys.PREVENTENDEVENTS + this.castId, Boolean.class); + if (preventEndEvents == null || !preventEndEvents) { + if (!interrupted) { + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this.ability, this.target); + } + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this.ability, this.target); + } + } + + private void checkEndChannel(final CSimulation game, final boolean interrupted) { + if (this.channeling) { + this.channeling = false; + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + endChannel(game, interrupted); + } + } + + private void endChannel(CSimulation game, boolean interrupted) { + this.localStore.put(ABLocalStoreKeys.INTERRUPTED, interrupted); + game.unitStopSoundEffectEvent(this.unit, this.ability.getAlias()); + this.ability.runEndChannelActions(game, unit, orderId); + cleanupInputs(); + } + + @Override + public int getHighlightOrderId() { + return this.ability.getBaseOrderId(); + } + + @Override + public boolean isWithinRange(CSimulation simulation) { + float range = this.ability.getCastRange(); + if (this.castStartTick > 0) { + range += simulation.getGameplayConstants().getSpellCastRangeBuffer(); + } + return this.unit.canReach(this.target, range); + } + + @Override + public void endMove(CSimulation game, boolean interrupted) { + if (interrupted && !preventReInterrupt) { + preventReInterrupt = true; + this.ability.runCancelPreCastActions(game, unit, orderId); + checkEndChannel(game, interrupted); + } + } + + @Override + protected CBehavior updateOnInvalidTarget(CSimulation simulation) { + return this.unit.pollNextOrderBehavior(simulation); + } + + @Override + protected boolean checkTargetStillValid(CSimulation simulation) { + return this.doneEffect || this.target.visit(this.preCastTargetableVisitor.reset(simulation, this.unit, + this.ability, this.autoOrder, this.channeling, orderId)); + } + + @Override + protected void resetBeforeMoving(CSimulation simulation) { + this.castStartTick = 0; + } + + public void setCastId(int castId) { + this.castId = castId; + } + + @Override + public boolean interruptable() { + return this.doneEffect; + } + + @Override + public CBehaviorCategory getBehaviorCategory() { + if (this.behaviorCategory != null) { + return this.behaviorCategory; + } + return CBehaviorCategory.SPELL; + } + + @Override + public CAbility getAbility() { + return ability; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorAbilityBuilderNoTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorAbilityBuilderNoTarget.java new file mode 100644 index 000000000..bc5f14437 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorAbilityBuilderNoTarget.java @@ -0,0 +1,338 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior; + +import java.util.EnumSet; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityActivationReceiver; + +public class ABBehaviorAbilityBuilderNoTarget implements ABBehavior { + private ABLocalDataStore localStore; + private ABAbilityBuilderActiveAbility ability; + + private int castStartTick = 0; + private int castTimeEndTick = 0; + private int castPointTicks = 0; + private int backswingTicks = 0; + private boolean doneCastTime = false; + private boolean doneEffect = false; + private boolean channeling = false; + + private CUnit unit; + private int orderId; + private boolean autoOrder; + + private boolean instant = false; + private CBehaviorCategory behaviorCategory = null; + private int castId = 0; + private EnumSet channelTags; + private boolean firstAnimation; + + public ABBehaviorAbilityBuilderNoTarget(final CUnit unit, final ABLocalDataStore localStore, + ABAbilityBuilderActiveAbility ability) { + this.unit = unit; + this.localStore = localStore; + this.ability = ability; + } + + public void setInstant(boolean instant) { + this.instant = instant; + } + + public void setBehaviorCategory(CBehaviorCategory behaviorCategory) { + this.behaviorCategory = behaviorCategory; + } + + @Override + public ABBehavior reset(final CSimulation game, final CWidget target, final boolean autoOrder) { + return null; + } + + @Override + public ABBehavior reset(final CSimulation game, CWidget target, int orderId, final boolean autoOrder) { + return null; + } + + @Override + public ABBehavior reset(final CSimulation game, final AbilityPointTarget target, final boolean autoOrder) { + return null; + } + + @Override + public ABBehavior reset(final CSimulation game, AbilityPointTarget target, int orderId, final boolean autoOrder) { + return null; + } + + @Override + public ABBehavior reset(final boolean autoOrder) { + this.doneCastTime = false; + this.doneEffect = false; + this.castStartTick = 0; + this.castTimeEndTick = this.ability.ignoreCastTime() ? 0 + : (int) (this.ability.getCastTime() / WarsmashConstants.SIMULATION_STEP_TIME); + this.castPointTicks = this.castTimeEndTick + + (int) (this.unit.getUnitType().getCastPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.backswingTicks = this.castPointTicks + + (int) (this.unit.getUnitType().getCastBackswingPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + this.orderId = this.ability.getBaseOrderId(); + this.firstAnimation = true; + this.autoOrder = autoOrder; + + this.channelTags = this.ability.getCastingSecondaryTags().clone(); + this.channelTags.add(SecondaryTag.CHANNEL); + return this; + } + + @Override + public ABBehavior reset(int orderId, final boolean autoOrder) { + this.doneCastTime = false; + this.doneEffect = false; + this.castStartTick = 0; + this.castTimeEndTick = this.ability.ignoreCastTime() ? 0 + : (int) (this.ability.getCastTime() / WarsmashConstants.SIMULATION_STEP_TIME); + this.castPointTicks = this.castTimeEndTick + + (int) (this.unit.getUnitType().getCastPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.backswingTicks = this.castPointTicks + + (int) (this.unit.getUnitType().getCastBackswingPoint() / WarsmashConstants.SIMULATION_STEP_TIME); + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + this.orderId = orderId; + this.firstAnimation = true; + this.autoOrder = autoOrder; + + this.channelTags = this.ability.getCastingSecondaryTags().clone(); + this.channelTags.add(SecondaryTag.CHANNEL); + return this; + } + + @Override + public CBehavior update(final CSimulation game) { + boolean wasChanneling = this.channeling; + if (this.castStartTick == 0) { + this.castStartTick = game.getGameTurnTick(); + + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CHANNEL, this.ability, null); + // In war3, non-targeted spells cannot be interrupted by pausing on spell events + + if (!instant && this.castTimeEndTick > 0) { + this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, + EnumSet.of(SecondaryTag.CHANNEL), 1.0f, true); + } + } + + if (instant) { + if (!this.doneCastTime) { + // should have already checked castable above, as no time delay + if (!this.unit.chargeMana(this.ability.getChargedManaCost())) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + this.ability.startCooldown(game, this.unit); + + this.ability.runBeginCastingActions(game, unit, orderId); + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this.ability, null); + this.doneCastTime = true; + } + CBehavior beh = tryDoEffect(game, wasChanneling); + if (beh != null) { + cleanupInputs(); + return beh; + } + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + return newBehavior; + } + if (!this.channeling) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + } else { + final int ticksSinceCast = game.getGameTurnTick() - this.castStartTick; + if (!this.doneCastTime && ticksSinceCast >= this.castTimeEndTick) { + this.ability.checkCanUse(game, unit, orderId, autoOrder, BooleanAbilityActivationReceiver.INSTANCE); + if (!BooleanAbilityActivationReceiver.INSTANCE.isOk() + || !this.unit.chargeMana(this.ability.getChargedManaCost())) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + this.ability.startCooldown(game, this.unit); + + this.ability.runBeginCastingActions(game, unit, orderId); + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + return newBehavior; + } + + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this.ability, null); + + this.channeling = localStore.getBoolean(ABLocalStoreKeys.CHANNELING); + if (!this.channeling) { + this.unit.getUnitAnimationListener().playAnimation(this.firstAnimation, this.ability.getCastingPrimaryTag(), + this.ability.getCastingSecondaryTags(), 1.0f, true); + this.firstAnimation = false; + this.unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, SequenceUtils.EMPTY, true); + } + this.doneCastTime = true; + } + if (this.channeling) { + this.unit.getUnitAnimationListener().playAnimation(false, this.ability.getCastingPrimaryTag(), + this.channelTags, 1.0f, true); + } + if ((ticksSinceCast >= castPointTicks)) { + CBehavior beh = tryDoEffect(game, wasChanneling); + if (beh != null) { + cleanupInputs(); + return beh; + } + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + return newBehavior; + } + } + if ((ticksSinceCast >= backswingTicks) && !this.channeling) { + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + } + return this; + } + + private CBehavior tryDoEffect(CSimulation game, boolean wasChanneling) { + boolean wasEffectDone = this.doneEffect; + if (!wasEffectDone) { + if (this.channeling) { + game.unitLoopSoundEffectEvent(this.unit, this.ability.getAlias()); + } else { + game.unitSoundEffectEvent(this.unit, this.ability.getAlias()); + } + this.doneEffect = true; + + this.ability.runEndCastingActions(game, unit, orderId); + this.channeling = localStore.getBoolean(ABLocalStoreKeys.CHANNELING); + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, this.ability, null); + } + this.channeling = this.channeling && this.doChannelTick(game, this.unit); + if (wasEffectDone && wasChanneling && !this.channeling) { + endChannel(game, false); + return this.unit.pollNextOrderBehavior(game); + } + return null; + } + + @Override + public void begin(final CSimulation game) { + if (ability.getItem() != null && ability.getItem().getItemType().isActivelyUsed()) { + // This is for runes/glyphs that use on pickup. We will never see an update loop + // for these + + if (!this.unit.chargeMana(this.ability.getChargedManaCost())) { + cleanupInputs(); + this.unit.beginBehavior(game, this.unit.pollNextOrderBehavior(game)); + return; + } + this.ability.startCooldown(game, this.unit); + + this.ability.runBeginCastingActions(game, unit, orderId); + + CBehavior beh = tryDoEffect(game, false); + if (beh != null) { + cleanupInputs(); + this.unit.beginBehavior(game, beh); + return; + } + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + this.unit.beginBehavior(game, newBehavior); + return; + } + + cleanupInputs(); + //this.unit.beginBehavior(game, this.unit.pollNextOrderBehavior(game)); + } + } + + public boolean doChannelTick(CSimulation game, CUnit caster) { + this.ability.runChannelTickActions(game, caster, orderId); + return localStore.getBoolean(ABLocalStoreKeys.CHANNELING); + } + + @Override + public void end(final CSimulation game, boolean interrupted) { + checkEndChannel(game, interrupted); + Boolean preventEndEvents = this.localStore.get(ABLocalStoreKeys.PREVENTENDEVENTS + this.castId, Boolean.class); + if (preventEndEvents == null || !preventEndEvents) { + if (!interrupted) { + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this.ability, null); + } + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this.ability, null); + } + } + + private void checkEndChannel(final CSimulation game, final boolean interrupted) { + if (this.channeling) { + this.channeling = false; + this.localStore.put(ABLocalStoreKeys.CHANNELING, false); + endChannel(game, interrupted); + } + } + + private void endChannel(CSimulation game, boolean interrupted) { + this.localStore.put(ABLocalStoreKeys.INTERRUPTED, interrupted); + game.unitStopSoundEffectEvent(this.unit, this.ability.getAlias()); + this.ability.runEndChannelActions(game, unit, orderId); + } + + private void cleanupInputs() { + this.ability.cleanupInputs(this.castId); + } + + @Override + public int getHighlightOrderId() { + return this.ability.getBaseOrderId(); + } + + public void setCastId(int castId) { + this.castId = castId; + } + + @Override + public boolean interruptable() { + return this.doneEffect; + } + + @Override + public CBehaviorCategory getBehaviorCategory() { + if (this.behaviorCategory != null) { + return this.behaviorCategory; + } + return CBehaviorCategory.SPELL; + } + + @Override + public CAbility getAbility() { + return ability; + } + + @Override + public T visit(final CBehaviorVisitor visitor) { + return visitor.accept(this); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorFinishTransformation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorFinishTransformation.java new file mode 100644 index 000000000..7269c9a7b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorFinishTransformation.java @@ -0,0 +1,169 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABBehaviorFinishTransformation implements CBehavior { + private CUnit sourceUnit; + private ABLocalDataStore localStore; + private OnTransformationActions actions; + private CUnit unit; + private ABAbilityBuilderAbility ability; + private CUnitType baseTypeForDuration; + private CUnitType newType; + private boolean keepRatios; + private int visibleOrderId; + private boolean permanent; + private float duration; + private int transformationTickDuration; + private float altitudeAdjustmentDelay; + private float altitudeAdjustmentDuration; + private float landingDelay; + + private boolean immediateLanding; + private boolean immediateTakeoff; + + private boolean addAlternateTagAfter; + + private boolean takingOff; + private boolean landing; + + private War3ID buffId; + private float transformationTime; + private boolean instantTransformAtDurationEnd; + + private int castStartTick = 0; + + public ABBehaviorFinishTransformation(CUnit sourceUnit, ABLocalDataStore localStore, final CUnit unit, + ABAbilityBuilderAbility ability, CUnitType newType, final boolean keepRatios, OnTransformationActions actions, + boolean addAlternateTagAfter, final int visibleOrderId, boolean permanent, float duration, + float transformationTime, float landingDelay, float altitudeAdjustmentDelay, + float altitudeAdjustmentDuration, boolean immediateLanding, boolean immediateTakeoff, War3ID buffId, + CUnitType baseTypeForDuration, boolean instantTransformAtDurationEnd) { + this.sourceUnit = sourceUnit; + this.localStore = localStore; + this.actions = actions; + this.unit = unit; + this.ability = ability; + this.newType = newType; + this.keepRatios = keepRatios; + this.visibleOrderId = visibleOrderId; + this.permanent = permanent; + this.duration = duration; + this.transformationTime = transformationTime; + // Minus one tick, as we need to wait one tick to start this behavior + this.transformationTickDuration = Math.round(transformationTime / WarsmashConstants.SIMULATION_STEP_TIME) - 1; + this.altitudeAdjustmentDelay = altitudeAdjustmentDelay; + this.altitudeAdjustmentDuration = altitudeAdjustmentDuration; + this.landingDelay = landingDelay; + + this.immediateLanding = immediateLanding; + this.immediateTakeoff = immediateTakeoff; + + this.addAlternateTagAfter = addAlternateTagAfter; + + this.buffId = buffId; + this.baseTypeForDuration = baseTypeForDuration; + this.instantTransformAtDurationEnd = instantTransformAtDurationEnd; + + this.takingOff = unit.getMovementType() != MovementType.FLY && newType.getMovementType() == MovementType.FLY; + this.landing = unit.getMovementType() == MovementType.FLY && newType.getMovementType() != MovementType.FLY; + + if (this.landing) { + this.transformationTickDuration += this.landingDelay > 0 + ? Math.round(altitudeAdjustmentDuration / WarsmashConstants.SIMULATION_STEP_TIME) + : 0; + } + } + + @Override + public CBehavior update(CSimulation game) { + if (this.castStartTick == 0) { + this.castStartTick = game.getGameTurnTick(); + ABTransformationHandler.startSlowTransformation(localStore, unit, newType, keepRatios, actions, ability, + addAlternateTagAfter, takingOff, landing, immediateTakeoff, immediateLanding, + altitudeAdjustmentDelay, landingDelay, altitudeAdjustmentDuration); + } + + final int ticksSinceCast = game.getGameTurnTick() - this.castStartTick; + if (ticksSinceCast >= this.transformationTickDuration) { + ABTransformationHandler.finishSlowTransformation(localStore, unit, newType, keepRatios, actions, ability, + addAlternateTagAfter, permanent, takingOff); + + if (instantTransformAtDurationEnd) { + ABTransformationHandler.createInstantTransformBackBuff(sourceUnit, localStore, unit, baseTypeForDuration, + keepRatios, actions.createUntransformActions(), ability, buffId, addAlternateTagAfter, + transformationTime, duration, permanent); + } else { + ABTransformationHandler.createSlowTransformBackBuff(sourceUnit, localStore, unit, baseTypeForDuration, + keepRatios, actions.createUntransformActions(), ability, buffId, addAlternateTagAfter, + transformationTime, duration, permanent, takingOff, landing, immediateTakeoff, immediateLanding, + altitudeAdjustmentDelay, landingDelay, altitudeAdjustmentDuration); + } + + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this.ability, null); + this.unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this.ability, null); + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (this.equals(newBehavior)) { + } + localStore.remove(ABLocalStoreKeys.PREVIOUSBEHAVIOR); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + cleanupInputs(); + return newBehavior; + } + cleanupInputs(); + return this.unit.pollNextOrderBehavior(game); + } + return this; + } + + private void cleanupInputs() { + if (this.ability instanceof ABAbilityBuilderActiveAbility) { + ((ABAbilityBuilderActiveAbility) this.ability).cleanupInputs(this.actions.getCastId()); + } + } + + @Override + public void begin(CSimulation game) { + } + + @Override + public void end(CSimulation game, boolean interrupted) { + } + + @Override + public int getHighlightOrderId() { + return visibleOrderId; + } + + @Override + public boolean interruptable() { + return false; + } + + @Override + public T visit(final CBehaviorVisitor visitor) { + return visitor.accept(this); + } + + @Override + public CBehaviorCategory getBehaviorCategory() { + return CBehaviorCategory.SPELL; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorSendOrder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorSendOrder.java new file mode 100644 index 000000000..b89aa7168 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABBehaviorSendOrder.java @@ -0,0 +1,62 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorVisitor; + +public class ABBehaviorSendOrder implements CBehavior { + + private CUnit unit; + private CAbility ability; + private int orderId; + private int visibleOrderId; + private CWidget target; + + public ABBehaviorSendOrder(final CUnit unit, CAbility ability, final int orderId, final int visibleOrderId, + final CWidget target) { + this.unit = unit; + this.ability = ability; + this.orderId = orderId; + this.visibleOrderId = visibleOrderId; + this.target = target; + } + + @Override + public CBehavior update(CSimulation game) { + return ability.begin(game, unit, orderId, false, target); + } + + @Override + public void begin(CSimulation game) { + } + + @Override + public void end(CSimulation game, boolean interrupted) { + } + + @Override + public int getHighlightOrderId() { + return visibleOrderId; + } + + @Override + public boolean interruptable() { + return true; + } + + @Override + public T visit(final CBehaviorVisitor visitor) { + return visitor.accept(this); + } + + @Override + public CBehaviorCategory getBehaviorCategory() { + return CBehaviorCategory.IDLE; + } + + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABOrderStartTransformation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABOrderStartTransformation.java new file mode 100644 index 000000000..a88bc652a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/ABOrderStartTransformation.java @@ -0,0 +1,64 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.COrderNoTarget; + +public class ABOrderStartTransformation extends COrderNoTarget { + private CBehavior transformBehavior; + + public ABOrderStartTransformation(final CBehavior transformBehavior, final int orderId) { + super(0, orderId, false); + this.transformBehavior = transformBehavior; + } + + @Override + public CBehavior begin(final CSimulation game, final CUnit caster) { + caster.fireOrderEvents(game, this); + return transformBehavior; + } + + @Override + public AbilityTarget getTarget(final CSimulation game) { + return null; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = (prime * result) + this.transformBehavior.hashCode(); + result = (prime * result) + this.getOrderId(); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ABOrderStartTransformation other = (ABOrderStartTransformation) obj; + if (this.transformBehavior.equals(other.transformBehavior)) { + return false; + } + if (this.getOrderId() != other.getOrderId()) { + return false; + } + return true; + } + + @Override + public void fireEvents(final CSimulation game, final CUnit unit) { + unit.fireOrderEvents(game, this); + } + +} + diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAbilityAttemptToApplyEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAbilityAttemptToApplyEffect.java new file mode 100644 index 000000000..781ed522b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAbilityAttemptToApplyEffect.java @@ -0,0 +1,59 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; + +public class ABActionAbilityAttemptToApplyEffect implements ABSingleAction { + + private ABAbilityCallback ability; + private ABUnitCallback source; + private ABUnitCallback target; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theCaster = caster; + if (source != null) { + theCaster = source.callback(theCaster, localStore, castId); + } + CUnit theTarget = target.callback(theCaster, localStore, castId); + final CAbility theAbility = this.ability.callback(caster, localStore, castId); + if (theAbility instanceof ABAbilityBuilderActiveAbility) { + ABAbilityBuilderActiveAbility active = ((ABAbilityBuilderActiveAbility) theAbility); + int orderId = active.getBaseOrderId(); + final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; + active.checkCanUse(localStore.game, theCaster, orderId, false, activationReceiver); + if (activationReceiver.isOk()) { + final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver + .getInstance().reset(); + active.checkCanTarget( + localStore.game, theCaster, orderId, (localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), Boolean.class)), + theTarget, booleanTargetReceiver); + if (booleanTargetReceiver.isTargetable()) { + if (theCaster.chargeMana(active.getChargedManaCost())) { + active.internalBegin(localStore.game, theCaster, orderId, false, theTarget); + active.startCooldown(localStore.game, theCaster); + active.runEndCastingActions(localStore.game, theCaster, orderId); + active.cleanupInputs(); + } + } + } + + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAbilityRunEndCastingActions.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAbilityRunEndCastingActions.java new file mode 100644 index 000000000..d3d336adb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAbilityRunEndCastingActions.java @@ -0,0 +1,59 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAbilityRunEndCastingActions implements ABSingleAction { + + private ABAbilityCallback ability; + private ABUnitCallback caster; + + private ABLocationCallback targetLoc; + private ABUnitCallback targetUnit; + private ABItemCallback targetItem; + private ABDestructableCallback targetDest; + + @Override + public void runAction(final CUnit originalCaster, final ABLocalDataStore localStore, final int castId) { + CUnit theCaster = originalCaster; + if (caster != null) { + theCaster = caster.callback(originalCaster, localStore, castId); + } + + AbilityTarget tar = null; + if (targetLoc != null) { + tar = targetLoc.callback(originalCaster, localStore, castId); + } else if (targetUnit != null) { + tar = targetUnit.callback(originalCaster, localStore, castId); + } else if (targetItem != null) { + tar = targetItem.callback(originalCaster, localStore, castId); + } else if (targetDest != null) { + tar = targetDest.callback(originalCaster, localStore, castId); + } + + final CAbility theAbility = this.ability.callback(originalCaster, localStore, castId); + if (theAbility instanceof ABAbilityBuilderActiveAbility) { + ABAbilityBuilderActiveAbility active = ((ABAbilityBuilderActiveAbility) theAbility); + int orderId = active.getBaseOrderId(); + + active.internalBegin(localStore.game, theCaster, orderId, false, tar); + active.runEndCastingActions(localStore.game, theCaster, orderId); + active.cleanupInputs(); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionActivateToggledAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionActivateToggledAbility.java new file mode 100644 index 000000000..bd48dc92c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionActivateToggledAbility.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionActivateToggledAbility implements ABSingleAction { + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if (localStore.originAbility instanceof ABAbilityBuilderActiveAbility) { + ((ABAbilityBuilderActiveAbility) localStore.originAbility).activate(localStore.game, caster); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AbilityActivate(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator + .getUserDataExpr("AB_LOCAL_STORE_KEY_TOGGLEDABILITY", JassTextGeneratorType.AbilityHandle) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddAbility.java new file mode 100644 index 000000000..ba8174b25 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddAbility.java @@ -0,0 +1,36 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddAbility implements ABSingleAction { + + private ABUnitCallback unit; + private ABAbilityCallback ability; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CAbility theAbility = this.ability.callback(caster, localStore, castId); + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theAbility != null) { + theUnit.add(localStore.game, theAbility); + localStore.put(ABLocalStoreKeys.LASTADDEDABILITY, theAbility); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "AddUnitAbilityAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.ability.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddNewAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddNewAbility.java new file mode 100644 index 000000000..e34f49b1d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddNewAbility.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddNewAbility implements ABSingleAction { + + private ABUnitCallback unit; + private ABIDCallback id; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CAbility ability = localStore.game.getAbilityData() + .getAbilityType(this.id.callback(caster, localStore, castId)) + .createAbility(localStore.game.getHandleIdAllocator().createId()); + localStore.put(ABLocalStoreKeys.LASTCREATEDABILITY, ability); + this.unit.callback(caster, localStore, castId).add(localStore.game, ability); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "AddNewAbilityAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddRallyAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddRallyAbility.java new file mode 100644 index 000000000..e65b7665c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionAddRallyAbility.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddRallyAbility implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CAbility ability = new CAbilityRally(localStore.game.getHandleIdAllocator().createId()); + this.unit.callback(caster, localStore, castId).add(localStore.game, ability); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "UnitAddAbility(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", 'ARal')"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionBeginChanneling.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionBeginChanneling.java new file mode 100644 index 000000000..44fb5ba3a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionBeginChanneling.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionBeginChanneling implements ABSingleAction { + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + localStore.put(ABLocalStoreKeys.CHANNELING, true); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.setUserData(ABLocalStoreKeys.CHANNELING, JassTextGeneratorType.Boolean, "true"); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionCleanUpCastInstance.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionCleanUpCastInstance.java new file mode 100644 index 000000000..b5953ed20 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionCleanUpCastInstance.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import java.util.HashSet; +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCleanUpCastInstance implements ABSingleAction { + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final Set keySet = new HashSet<>(localStore.keySet()); + for (final String key : keySet) { + if (key.contains(ABLocalStoreKeys.combineKey("#", castId))) { + localStore.remove(key); + } + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "LocalStoreCleanUpCastInstance(" + jassTextGenerator.getTriggerLocalStore() + ", " + + jassTextGenerator.getCastId() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionClickDisableAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionClickDisableAbility.java new file mode 100644 index 000000000..5c3c587e1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionClickDisableAbility.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionClickDisableAbility implements ABSingleAction { + + private ABAbilityCallback ability; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if (this.ability != null) { + final CAbility abil = ability.callback(caster, localStore, castId); + if (abil != null) { + abil.setClickDisabled(true, CAbilityDisableType.ABILITYINTERNAL); + } + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.setClickDisabled(true, CAbilityDisableType.ABILITYINTERNAL); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.ability != null) { + return "TODOJASS"; + } else { + return "TODOJASS"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionClickEnableAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionClickEnableAbility.java new file mode 100644 index 000000000..72032bdeb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionClickEnableAbility.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionClickEnableAbility implements ABSingleAction { + + private ABAbilityCallback ability; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if (this.ability != null) { + final CAbility abil = ability.callback(caster, localStore, castId); + if (abil != null) { + abil.setClickDisabled(false, CAbilityDisableType.ABILITYINTERNAL); + } + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.setClickDisabled(false, CAbilityDisableType.ABILITYINTERNAL); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.ability != null) { + return "TODOJASS"; + } else { + return "TODOJASS"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionCreateAbilityFromId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionCreateAbilityFromId.java new file mode 100644 index 000000000..ba96b4d9b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionCreateAbilityFromId.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateAbilityFromId implements ABSingleAction { + + private ABIDCallback id; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + War3ID theId = this.id.callback(caster, localStore, castId); + CAbilityType type = localStore.game.getAbilityData().getAbilityType(theId); + if (type != null) { + final CAbility ability = type.createAbility(localStore.game.getHandleIdAllocator().createId()); + localStore.put(ABLocalStoreKeys.LASTCREATEDABILITY, ability); + } else { + System.err.println("Failed to find an ability type definition for ability " + theId.asStringValue()); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "CreateAbilityFromIdAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionDeactivateToggledAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionDeactivateToggledAbility.java new file mode 100644 index 000000000..5dd31829a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionDeactivateToggledAbility.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionDeactivateToggledAbility implements ABSingleAction { + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderActiveAbility ability = (ABAbilityBuilderActiveAbility) localStore.originAbility; + ability.deactivate(localStore.game, caster); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AbilityDeactivate(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator + .getUserDataExpr("AB_LOCAL_STORE_KEY_TOGGLEDABILITY", JassTextGeneratorType.AbilityHandle) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionFinishChanneling.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionFinishChanneling.java new file mode 100644 index 000000000..b9cbd30aa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionFinishChanneling.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionFinishChanneling implements ABSingleAction { + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.put(ABLocalStoreKeys.CHANNELING, false); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.setUserData(ABLocalStoreKeys.CHANNELING, JassTextGeneratorType.Boolean, "false"); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionPrepUnownedAbilityForUse.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionPrepUnownedAbilityForUse.java new file mode 100644 index 000000000..c6296452e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionPrepUnownedAbilityForUse.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionPrepUnownedAbilityForUse implements ABSingleAction { + + private ABUnitCallback unit; + private ABAbilityCallback ability; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CAbility theAbility = this.ability.callback(caster, localStore, castId); + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theAbility != null) { + theAbility.onAddDisabled(localStore.game, theUnit); + theAbility.onAdd(localStore.game, theUnit); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "AddUnitAbilityAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.ability.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionRemoveAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionRemoveAbility.java new file mode 100644 index 000000000..ff05095e1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionRemoveAbility.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveAbility implements ABSingleAction { + + private ABUnitCallback unit; + private ABAbilityCallback ability; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + CAbility theAbility = this.ability.callback(caster, localStore, castId); + if (theAbility != null) { + theUnit.remove(localStore.game, theAbility); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "RemoveUnitAbility(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.ability.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionResetCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionResetCooldown.java new file mode 100644 index 000000000..9877b33d1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionResetCooldown.java @@ -0,0 +1,54 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABGetABAbilityByRawcodeVisitor; + +public class ABActionResetCooldown implements ABSingleAction { + + private ABIDCallback alias; + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (this.unit != null) { + theUnit = this.unit.callback(caster, localStore, castId); + } + if (this.alias != null) { + final War3ID aliasId = this.alias.callback(caster, localStore, castId); + final ABAbilityBuilderAbility abil = theUnit + .getAbility(ABGetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); + if (abil != null) { + abil.resetCooldown(localStore.game, theUnit); + } + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.resetCooldown(localStore.game, theUnit); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String unitExpression; + if (this.unit != null) { + unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); + } else { + unitExpression = jassTextGenerator.getCaster(); + } + if (this.alias != null) { + return "EndUnitAbilityCooldown(" + unitExpression + ", " + + this.alias.generateJassEquivalent(jassTextGenerator) + ")"; + } else { + return "EndAbilityCooldown(" + unitExpression + ", " + jassTextGenerator + .getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) + ")"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionSendStartCastingEvents.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionSendStartCastingEvents.java new file mode 100644 index 000000000..44c563b29 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionSendStartCastingEvents.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget.ABWidgetCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABActionSendStartCastingEvents implements ABAction { + + private ABUnitCallback caster; + private ABWidgetCallback target; + + @Override + public void runAction(final CUnit basecaster, final ABLocalDataStore localStore, final int castId) { + CUnit theUnit = basecaster; + CWidget theTarget = null; + if (caster != null) { + theUnit = caster.callback(basecaster, localStore, castId); + } + if (target != null) { + theTarget = target.callback(basecaster, localStore, castId); + } + CAbility theAbility = localStore.originAbility; + theUnit.fireSpellEvents(localStore.game, JassGameEventsWar3.EVENT_UNIT_SPELL_CHANNEL, theAbility, theTarget); + theUnit.fireSpellEvents(localStore.game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, theAbility, theTarget); + theUnit.fireSpellEvents(localStore.game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, theAbility, theTarget); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionStartCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionStartCooldown.java new file mode 100644 index 000000000..6a3f8d8af --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/ability/ABActionStartCooldown.java @@ -0,0 +1,77 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABGetABAbilityByRawcodeVisitor; + +public class ABActionStartCooldown implements ABSingleAction { + + private ABIDCallback alias; + private ABUnitCallback unit; + private ABFloatCallback cooldown; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (this.unit != null) { + theUnit = this.unit.callback(caster, localStore, castId); + } + if (this.alias != null) { + final War3ID aliasId = this.alias.callback(caster, localStore, castId); + if (this.cooldown != null) { + theUnit.beginCooldown(localStore.game, aliasId, this.cooldown.callback(caster, localStore, castId)); + } else { + final ABAbilityBuilderAbility abil = theUnit + .getAbility(ABGetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); + if (abil != null) { + abil.startCooldown(localStore.game, theUnit); + } + } + } else { + if (this.cooldown != null) { + final War3ID aliasId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + theUnit.beginCooldown(localStore.game, aliasId, this.cooldown.callback(caster, localStore, castId)); + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.startCooldown(localStore.game, theUnit); + } + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String unitExpression; + if (this.unit != null) { + unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); + } else { + unitExpression = jassTextGenerator.getCaster(); + } + if (this.alias != null) { + final String aliasExpression = this.alias.generateJassEquivalent(jassTextGenerator); + if (this.cooldown != null) { + return "StartUnitAbilityCooldown(" + unitExpression + ", " + aliasExpression + ", " + + this.cooldown.generateJassEquivalent(jassTextGenerator) + ")"; + } else { + return "StartUnitAbilityDefaultCooldown(" + unitExpression + ", " + aliasExpression + ")"; + } + } else { + if (this.cooldown != null) { + return "StartUnitAbilityCooldown(" + unitExpression + ", " + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ALIAS", JassTextGeneratorType.Integer) + + ", " + this.cooldown.generateJassEquivalent(jassTextGenerator) + ")"; + } else { + return "StartAbilityDefaultCooldown(" + unitExpression + ", " + jassTextGenerator + .getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) + ")"; + } + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionAbilitySetShowIcon.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionAbilitySetShowIcon.java new file mode 100644 index 000000000..0ac992f77 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionAbilitySetShowIcon.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAbilitySetShowIcon implements ABSingleAction { + + private ABAbilityCallback ability; + private ABBooleanCallback show; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if (this.ability != null) { + final CAbility abil = ability.callback(caster, localStore, castId); + if (abil != null) { + abil.setIconShowing(show.callback(caster, localStore, castId)); + } + } else { + localStore.originAbility.setIconShowing(show.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionAddTargetAllowed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionAddTargetAllowed.java new file mode 100644 index 000000000..0f896fb18 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionAddTargetAllowed.java @@ -0,0 +1,45 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABActionAddTargetAllowed implements ABSingleAction { + + private CTargetType targetType; + + @Override + @SuppressWarnings("unchecked") + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CAbility ability = localStore.originAbility; + if (ability != null && ability instanceof ABAbilityBuilderActiveAbility) { + ((ABAbilityBuilderActiveAbility) ability).getTargetsAllowed().add(this.targetType); + } else { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + final EnumSet targetsAllowed = levelData + .get(localStore.originAbility.getLevel() - 1).getTargetsAllowed(); + targetsAllowed.add(this.targetType); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AbilityTypeLevelDataAddTargetAllowed(" + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LEVELDATA", + JassTextGeneratorType.AbilityTypeLevelDataHandle) + + ", " + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_CURRENTLEVEL", JassTextGeneratorType.Integer) + + " - 1, TARGET_TYPE_" + this.targetType.name() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionDisableAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionDisableAbility.java new file mode 100644 index 000000000..7189f16f5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionDisableAbility.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionDisableAbility implements ABSingleAction { + + private ABAbilityCallback ability; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if (this.ability != null) { + final CAbility abil = ability.callback(caster, localStore, castId); + if (abil != null) { + abil.setDisabled(true, CAbilityDisableType.ABILITYINTERNAL); + } + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.setDisabled(true, CAbilityDisableType.ABILITYINTERNAL); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.ability != null) { + return "TODOJASS"; + } else { + return "TODOJASS"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionDisableAbilityById.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionDisableAbilityById.java new file mode 100644 index 000000000..a10a790db --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionDisableAbilityById.java @@ -0,0 +1,52 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABGetABAbilityByRawcodeVisitor; + +public class ABActionDisableAbilityById implements ABSingleAction { + + private ABIDCallback alias; + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (this.unit != null) { + theUnit = this.unit.callback(caster, localStore, castId); + } + if (this.alias != null) { + final War3ID aliasId = this.alias.callback(caster, localStore, castId); + final ABAbilityBuilderAbility abil = theUnit + .getAbility(ABGetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); + if (abil != null) { + abil.setDisabled(true, CAbilityDisableType.ABILITYINTERNAL); + } + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.setDisabled(true, CAbilityDisableType.ABILITYINTERNAL); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String unitExpression; + if (this.unit != null) { + unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); + } else { + unitExpression = jassTextGenerator.getCaster(); + } + if (this.alias != null) { + return "TODOJASS"; + } else { + return "TODOJASS"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionEnableAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionEnableAbility.java new file mode 100644 index 000000000..b6019d330 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionEnableAbility.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionEnableAbility implements ABSingleAction { + + private ABAbilityCallback ability; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if (this.ability != null) { + final CAbility abil = ability.callback(caster, localStore, castId); + if (abil != null) { + abil.setDisabled(false, CAbilityDisableType.ABILITYINTERNAL); + } + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.setDisabled(false, CAbilityDisableType.ABILITYINTERNAL); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.ability != null) { + return "TODOJASS"; + } else { + return "TODOJASS"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionEnableAbilityById.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionEnableAbilityById.java new file mode 100644 index 000000000..a780a4e69 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionEnableAbilityById.java @@ -0,0 +1,52 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABGetABAbilityByRawcodeVisitor; + +public class ABActionEnableAbilityById implements ABSingleAction { + + private ABIDCallback alias; + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (this.unit != null) { + theUnit = this.unit.callback(caster, localStore, castId); + } + if (this.alias != null) { + final War3ID aliasId = this.alias.callback(caster, localStore, castId); + final ABAbilityBuilderAbility abil = theUnit + .getAbility(ABGetABAbilityByRawcodeVisitor.getInstance().reset(aliasId)); + if (abil != null) { + abil.setDisabled(false, CAbilityDisableType.ABILITYINTERNAL); + } + } else { + final ABAbilityBuilderAbility abil = localStore.originAbility; + abil.setDisabled(false, CAbilityDisableType.ABILITYINTERNAL); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String unitExpression; + if (this.unit != null) { + unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); + } else { + unitExpression = jassTextGenerator.getCaster(); + } + if (this.alias != null) { + return "TODOJASS"; + } else { + return "TODOJASS"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionRemoveTargetAllowed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionRemoveTargetAllowed.java new file mode 100644 index 000000000..961c68b96 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionRemoveTargetAllowed.java @@ -0,0 +1,45 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABActionRemoveTargetAllowed implements ABSingleAction { + + private CTargetType targetType; + + @Override + @SuppressWarnings("unchecked") + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderAbility ability = localStore.originAbility; + if (ability != null && ability instanceof ABAbilityBuilderActiveAbility) { + ((ABAbilityBuilderActiveAbility) ability).getTargetsAllowed().remove(this.targetType); + } else { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + final EnumSet targetsAllowed = levelData + .get(localStore.originAbility.getLevel() - 1).getTargetsAllowed(); + targetsAllowed.remove(this.targetType); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AbilityTypeLevelDataRemoveTargetAllowed(" + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LEVELDATA", + JassTextGeneratorType.AbilityTypeLevelDataHandle) + + ", " + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_CURRENTLEVEL", JassTextGeneratorType.Integer) + + " - 1, TARGET_TYPE_" + this.targetType.name() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAbilityCastRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAbilityCastRange.java new file mode 100644 index 000000000..2522e8c8a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAbilityCastRange.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionSetAbilityCastRange implements ABSingleAction { + + private ABFloatCallback range; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderActiveAbility ability = localStore.get(ABLocalStoreKeys.ISTOGGLEDABILITY, + ABAbilityBuilderActiveAbility.class); + ability.setCastRange(range.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetAbilityCastRange(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_TOGGLEDABILITY", + JassTextGeneratorType.AbilityHandle) + + ", " + this.range.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAutoTargetDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAutoTargetDestructable.java new file mode 100644 index 000000000..a0b897bd5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAutoTargetDestructable.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionSetAutoTargetDestructable implements ABSingleAction { + + private ABDestructableCallback dest; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, castId), + this.dest.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.setUserData( + ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE + " + " + jassTextGenerator.getCastId(), + JassTextGeneratorType.DestructableHandle, this.dest.generateJassEquivalent(jassTextGenerator)); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAutoTargetUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAutoTargetUnit.java new file mode 100644 index 000000000..8d9dc97df --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetAutoTargetUnit.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionSetAutoTargetUnit implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), + this.unit.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.setUserData( + ABLocalStoreKeys.ABILITYTARGETEDUNIT + " + " + jassTextGenerator.getCastId(), + JassTextGeneratorType.UnitHandle, this.unit.generateJassEquivalent(jassTextGenerator)); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetPreventEndEvents.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetPreventEndEvents.java new file mode 100644 index 000000000..1b7bbd21e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/abilitydata/ABActionSetPreventEndEvents.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionSetPreventEndEvents implements ABSingleAction { + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PREVENTENDEVENTS, castId), true); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.setUserData(ABLocalStoreKeys.CHANNELING, JassTextGeneratorType.Boolean, "true"); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionAddAttackModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionAddAttackModifier.java new file mode 100644 index 000000000..178930aef --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionAddAttackModifier.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack.ABAttackModifierCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddAttackModifier implements ABAction { + + private ABUnitCallback unit; + private ABAttackModifierCallback modifier; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + target.addAttackModifier(modifier.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionCreateAttackModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionCreateAttackModifier.java new file mode 100644 index 000000000..a78fdfea8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionCreateAttackModifier.java @@ -0,0 +1,34 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackModifier; + +public class ABActionCreateAttackModifier implements ABAction { + + private ABIntegerCallback priority; + private ABBooleanCallback preLaunchCondition; + private List preLaunchModification; + private ABBooleanCallback condition; + private List modification; + + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean isUseCastId = true; + if (useCastId != null) { + isUseCastId = useCastId.callback(caster, localStore, castId); + } + ABAttackModifier modifier = new ABAttackModifier(localStore, castId, priority, preLaunchCondition, + preLaunchModification, condition, modification, isUseCastId); + + localStore.put(ABLocalStoreKeys.LASTCREATEDAMod, modifier); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionFireModifiedAttack.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionFireModifiedAttack.java new file mode 100644 index 000000000..46cc336d8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionFireModifiedAttack.java @@ -0,0 +1,69 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack.ABAttackModifierCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackModifier; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorAttackListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.TextTagConfigType; + +public class ABActionFireModifiedAttack implements ABAction { + + private ABUnitCallback unit; + private ABUnitCallback target; + private ABAttackModifierCallback modifier; + + private ABBooleanCallback showMissOnFailure; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + CUnit theTarget = target.callback(caster, localStore, castId); + + for (final CUnitAttack attack : theUnit.getCurrentAttacks()) { + if (theUnit.canReach(theTarget, attack.getRange() + attack.getRangeMotionBuffer()) + && theTarget.canBeTargetedBy(localStore.game, theUnit, attack.getTargetsAllowed()) + && (theUnit.getUnitType().getMinimumAttackRange() == 0 + || theUnit.distance(theTarget) >= theUnit.getUnitType().getMinimumAttackRange())) { + if (!theTarget.isImmuneToDamage(localStore.game, null, attack.getAttackType(), + attack.getWeaponType().getDamageType())) { + ABAttackModifier mod = null; + if (modifier != null) { + mod = modifier.callback(caster, localStore, castId); + } + CUnitAttackSettings settings = attack.initialSettings(); + if (mod != null) { + if (mod.checkPreLaunchApplication(localStore.game, theUnit, theTarget, attack)) { + mod.applyPreLaunchModification(localStore.game, theUnit, theTarget, attack, settings, null); + } + if (mod.checkApplication(localStore.game, theUnit, theTarget, attack)) { + mod.applyModification(localStore.game, theUnit, theTarget, attack, settings, null); + } + } + if (settings.getPreDamageListeners() == null) { + settings.setEmptyPreDamageListeners(); + } + + attack.launch(localStore.game, theUnit, theTarget, attack.roll(localStore.game.getSeededRandom()), + CBehaviorAttackListener.DO_NOTHING); + return; + } + } + } + boolean show = false; + if (showMissOnFailure != null) { + show = showMissOnFailure.callback(caster, localStore, castId); + } + if (show) { + localStore.game.spawnTextTag(theUnit, theUnit.getPlayerIndex(), TextTagConfigType.CRITICAL_STRIKE, "miss"); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionRemoveAttackModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionRemoveAttackModifier.java new file mode 100644 index 000000000..df7715bd4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionRemoveAttackModifier.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack.ABAttackModifierCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveAttackModifier implements ABAction { + + private ABUnitCallback unit; + private ABAttackModifierCallback modifier; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + target.removeAttackModifier(modifier.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionStartModifiedAttack.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionStartModifiedAttack.java new file mode 100644 index 000000000..b15a128ee --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/ABActionStartModifiedAttack.java @@ -0,0 +1,61 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack.ABAttackModifierCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorAttackListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.TextTagConfigType; + +public class ABActionStartModifiedAttack implements ABAction { + + private ABUnitCallback unit; + private ABUnitCallback target; + private ABAttackModifierCallback modifier; + + private ABBooleanCallback disableMove; + + private ABBooleanCallback stopOnFailure; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + CUnit theTarget = target.callback(caster, localStore, castId); + + boolean isDisableMove = false; + if (disableMove != null) { + isDisableMove = disableMove.callback(caster, localStore, castId); + } + + for (final CUnitAttack attack : theUnit.getCurrentAttacks()) { + if (theUnit.canReach(theTarget, theUnit.getAcquisitionRange()) + && theTarget.canBeTargetedBy(localStore.game, theUnit, attack.getTargetsAllowed()) + && (theUnit.distance(theTarget) >= theUnit.getUnitType().getMinimumAttackRange())) { + if (!theTarget.isImmuneToDamage(localStore.game, null, attack.getAttackType(), + attack.getWeaponType().getDamageType())) { + theUnit.beginBehavior(localStore.game, + theUnit.getAttackBehavior().reset(localStore.game, OrderIds.attack, attack, theTarget, isDisableMove, + CBehaviorAttackListener.DO_NOTHING, + modifier.callback(caster, localStore, castId)), true); + return; + } + } + } + boolean stop = true; + if (stopOnFailure != null) { + stop = stopOnFailure.callback(caster, localStore, castId); + } + if (stop) { + theUnit.performDefaultBehavior(localStore.game); + localStore.game.spawnTextTag(theUnit, theUnit.getPlayerIndex(), TextTagConfigType.CRITICAL_STRIKE, "miss"); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddAnimationTag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddAnimationTag.java new file mode 100644 index 000000000..eb3034f3c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddAnimationTag.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierAddAnimationTag implements ABAction { + + private ABStringCallback tag; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + settings.addAnimationName(SecondaryTag.valueOf(tag.callback(caster, localStore, castId))); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddPostDamageListener.java new file mode 100644 index 000000000..14fcf4a62 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddPostDamageListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPostDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierAddPostDamageListener implements ABAction { + + private ABAttackPostDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + settings.addPostDamageListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddPreDamageListener.java new file mode 100644 index 000000000..825f65255 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierAddPreDamageListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPreDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierAddPreDamageListener implements ABAction { + + private ABAttackPreDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + settings.addPreDamageListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyAllArtFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyAllArtFields.java new file mode 100644 index 000000000..e739bf115 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyAllArtFields.java @@ -0,0 +1,29 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierApplyAllArtFields implements ABAction { + + private ABBooleanCallback applyArtIfMissing; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + ABAbilityBuilderAbility abil = localStore.originAbility; + String art = abil.getAbilityStringField("Missileart"); + if ((art != null && !art.isBlank()) + || (applyArtIfMissing != null && applyArtIfMissing.callback(caster, localStore, castId))) { + settings.setProjectileArt(art); + } + settings.setProjectileSpeed(abil.getAbilityIntField("Missilespeed")); + settings.setProjectileArc(abil.getAbilityFloatField("Missilearc")); + settings.setProjectileHomingEnabled(abil.getAbilityBooleanField("MissileHoming")); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyArt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyArt.java new file mode 100644 index 000000000..976170238 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyArt.java @@ -0,0 +1,26 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierApplyArt implements ABAction { + + private ABBooleanCallback applyArtIfMissing; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + ABAbilityBuilderAbility abil = localStore.originAbility; + String art = abil.getAbilityStringField("Missileart"); + if ((art != null && !art.isBlank()) + || (applyArtIfMissing != null && applyArtIfMissing.callback(caster, localStore, castId))) { + settings.setProjectileArt(art); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyArtAndSpeed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyArtAndSpeed.java new file mode 100644 index 000000000..68ea9d7bf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyArtAndSpeed.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierApplyArtAndSpeed implements ABAction { + + private ABBooleanCallback applyArtIfMissing; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + ABAbilityBuilderAbility abil = localStore.originAbility; + String art = abil.getAbilityStringField("Missileart"); + if ((art != null && !art.isBlank()) + || (applyArtIfMissing != null && applyArtIfMissing.callback(caster, localStore, castId))) { + settings.setProjectileArt(art); + } + settings.setProjectileSpeed(abil.getAbilityIntField("Missilespeed")); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyDefaultSpeed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyDefaultSpeed.java new file mode 100644 index 000000000..605cfa97a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierApplyDefaultSpeed.java @@ -0,0 +1,19 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierApplyDefaultSpeed implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + if (settings.getProjectileSpeed() == 0) { + settings.setProjectileSpeed(900); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierPreventOtherModifications.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierPreventOtherModifications.java new file mode 100644 index 000000000..1e414046c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierPreventOtherModifications.java @@ -0,0 +1,18 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitPriorityLoopData; + +public class ABActionAttackModifierPreventOtherModifications implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitPriorityLoopData loop = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKMODLOOP, castId), + CUnitPriorityLoopData.class); + if (loop != null) + loop.preventAllOtherModifications(); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierPreventOtherSamePriorityModifications.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierPreventOtherSamePriorityModifications.java new file mode 100644 index 000000000..38c8f00fd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierPreventOtherSamePriorityModifications.java @@ -0,0 +1,18 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitPriorityLoopData; + +public class ABActionAttackModifierPreventOtherSamePriorityModifications implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitPriorityLoopData loop = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKMODLOOP, castId), + CUnitPriorityLoopData.class); + if (loop != null) + loop.preventOtherModificationsWithSamePriority(); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemoveAnimationTag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemoveAnimationTag.java new file mode 100644 index 000000000..a4a8b3645 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemoveAnimationTag.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierRemoveAnimationTag implements ABAction { + + private ABStringCallback tag; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + settings.removeAnimationName(SecondaryTag.valueOf(tag.callback(caster, localStore, castId))); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemovePostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemovePostDamageListener.java new file mode 100644 index 000000000..0db5cd63a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemovePostDamageListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPostDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierRemovePostDamageListener implements ABAction { + + private ABAttackPostDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + settings.removePostDamageListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemovePreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemovePreDamageListener.java new file mode 100644 index 000000000..52857ee74 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierRemovePreDamageListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPreDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierRemovePreDamageListener implements ABAction { + + private ABAttackPreDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + settings.removePreDamageListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackArc.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackArc.java new file mode 100644 index 000000000..8b72016c7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackArc.java @@ -0,0 +1,22 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierSetAttackArc implements ABAction { + + private ABFloatCallback arc; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + if (arc != null) { + settings.setProjectileArc(arc.callback(caster, localStore, castId)); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackDeathTime.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackDeathTime.java new file mode 100644 index 000000000..9181e02b5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackDeathTime.java @@ -0,0 +1,22 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierSetAttackDeathTime implements ABAction { + + private ABFloatCallback deathTime; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + if (deathTime != null) { + settings.setArtDeathTime(deathTime.callback(caster, localStore, castId)); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackHoming.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackHoming.java new file mode 100644 index 000000000..b015dfebc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackHoming.java @@ -0,0 +1,22 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierSetAttackHoming implements ABAction { + + private ABBooleanCallback homing; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + if (homing != null) { + settings.setProjectileHomingEnabled(homing.callback(caster, localStore, castId)); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackImpactZ.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackImpactZ.java new file mode 100644 index 000000000..999f73aea --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackImpactZ.java @@ -0,0 +1,22 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierSetAttackImpactZ implements ABAction { + + private ABFloatCallback impactZ; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + if (impactZ != null) { + settings.setImpactZ(impactZ.callback(caster, localStore, castId)); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackStartZ.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackStartZ.java new file mode 100644 index 000000000..2206cec24 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetAttackStartZ.java @@ -0,0 +1,22 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierSetAttackStartZ implements ABAction { + + private ABFloatCallback z; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + if (z != null) { + settings.setZ(z.callback(caster, localStore, castId)); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetSplashFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetSplashFields.java new file mode 100644 index 000000000..d6f3116ca --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABActionAttackModifierSetSplashFields.java @@ -0,0 +1,39 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABActionAttackModifierSetSplashFields implements ABAction { + + private ABIntegerCallback areaOfEffectFullDamage; + private ABIntegerCallback areaOfEffectMediumDamage; + private ABIntegerCallback areaOfEffectSmallDamage; + private ABFloatCallback damageFactorMedium; + private ABFloatCallback damageFactorSmall; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + if (areaOfEffectFullDamage != null) { + settings.setAreaOfEffectFullDamage(areaOfEffectFullDamage.callback(caster, localStore, castId)); + } + if (areaOfEffectMediumDamage != null) { + settings.setAreaOfEffectMediumDamage(areaOfEffectMediumDamage.callback(caster, localStore, castId)); + } + if (areaOfEffectSmallDamage != null) { + settings.setAreaOfEffectSmallDamage(areaOfEffectSmallDamage.callback(caster, localStore, castId)); + } + if (damageFactorMedium != null) { + settings.setDamageFactorMedium(damageFactorMedium.callback(caster, localStore, castId)); + } + if (damageFactorSmall != null) { + settings.setDamageFactorSmall(damageFactorSmall.callback(caster, localStore, castId)); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackAttackType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackAttackType.java new file mode 100644 index 000000000..3d557a389 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackAttackType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; + +public class ABCallbackGetModifiedAttackAttackType extends ABAttackTypeCallback { + + @Override + public CAttackType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class) + .getAttackType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackDamageType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackDamageType.java new file mode 100644 index 000000000..bd6202766 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackDamageType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +public class ABCallbackGetModifiedAttackDamageType extends ABDamageTypeCallback { + + @Override + public CDamageType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class) + .getWeaponType().getDamageType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackWeaponType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackWeaponType.java new file mode 100644 index 000000000..16740799b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/attackmodifier/internal/ABCallbackGetModifiedAttackWeaponType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABWeaponTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; + +public class ABCallbackGetModifiedAttackWeaponType extends ABWeaponTypeCallback { + + @Override + public CWeaponType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class) + .getWeaponType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionAttemptToReOrderPreviousBehavior.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionAttemptToReOrderPreviousBehavior.java new file mode 100644 index 000000000..23c0cb4a3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionAttemptToReOrderPreviousBehavior.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; + +public class ABActionAttemptToReOrderPreviousBehavior implements ABAction { + + private ABBooleanCallback checkForOrders; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + CBehavior b = localStore.get(ABLocalStoreKeys.PREVIOUSBEHAVIOR, CBehavior.class); + if (b != null && b != caster.getCurrentBehavior()) { + if (checkForOrders == null || checkForOrders.callback(caster, localStore, castId)) { + if (caster.getOrderQueue().isEmpty()) { + if (caster.order(localStore.game, b.getHighlightOrderId(), b.visit(BehaviorTargetVisitor.INSTANCE)) + && caster.getOrderQueue().isEmpty()) { + localStore.put(ABLocalStoreKeys.NEWBEHAVIOR, caster.getCurrentBehavior()); + } + } + } else { + if (caster.order(localStore.game, b.getHighlightOrderId(), b.visit(BehaviorTargetVisitor.INSTANCE)) + && caster.getOrderQueue().isEmpty()) { + localStore.put(ABLocalStoreKeys.NEWBEHAVIOR, caster.getCurrentBehavior()); + } + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionAttemptToResumePreviousBehavior.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionAttemptToResumePreviousBehavior.java new file mode 100644 index 000000000..0dc0506fb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionAttemptToResumePreviousBehavior.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAttemptToResumePreviousBehavior implements ABAction { + + private ABBooleanCallback checkForOrders; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + if (checkForOrders == null || checkForOrders.callback(caster, localStore, castId)) { + if (caster.getOrderQueue().isEmpty()) { + localStore.put(ABLocalStoreKeys.NEWBEHAVIOR, localStore.get(ABLocalStoreKeys.PREVIOUSBEHAVIOR)); + } + } else { + localStore.put(ABLocalStoreKeys.NEWBEHAVIOR, localStore.get(ABLocalStoreKeys.PREVIOUSBEHAVIOR)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionChangeAttackActionToMovement.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionChangeAttackActionToMovement.java new file mode 100644 index 000000000..cbfef428e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionChangeAttackActionToMovement.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorNextBehaviorVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CRangedBehavior; + +public class ABActionChangeAttackActionToMovement implements ABAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit targetUnit = caster; + if (unit != null) { + targetUnit = this.unit.callback(caster, localStore, castId); + } + if (targetUnit.getCurrentBehavior().getBehaviorCategory() == CBehaviorCategory.ATTACK) { + targetUnit.beginBehavior(localStore.game, + targetUnit.getMoveBehavior().reset(targetUnit.getMoveBehavior().getHighlightOrderId(), + targetUnit.getCurrentBehavior().visit(BehaviorTargetVisitor.INSTANCE)), + true); + } else if (targetUnit.getCurrentBehavior().getBehaviorCategory() == CBehaviorCategory.MOVEMENT) { + CRangedBehavior next = targetUnit.getCurrentBehavior().visit(BehaviorNextBehaviorVisitor.INSTANCE); + if (next != null && next.getBehaviorCategory() == CBehaviorCategory.ATTACK) { + targetUnit.beginBehavior(localStore.game, + targetUnit.getMoveBehavior().reset(targetUnit.getMoveBehavior().getHighlightOrderId(), + next.visit(BehaviorTargetVisitor.INSTANCE)), + true); + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionForceBeginCreatedBehavior.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionForceBeginCreatedBehavior.java new file mode 100644 index 000000000..24cbef175 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/behavior/ABActionForceBeginCreatedBehavior.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; + +public class ABActionForceBeginCreatedBehavior implements ABAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit targetUnit = caster; + if (unit != null) { + targetUnit = this.unit.callback(caster, localStore, castId); + } + CBehavior newBehavior = localStore.get(ABLocalStoreKeys.NEWBEHAVIOR, CBehavior.class); + if (newBehavior != null) { + localStore.remove(ABLocalStoreKeys.NEWBEHAVIOR); + targetUnit.beginBehavior(localStore.game, newBehavior, true); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddBuff.java new file mode 100644 index 000000000..0ba98b194 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddBuff.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddBuff implements ABSingleAction { + + private ABUnitCallback target; + private ABBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CBuff ability = this.buff.callback(caster, localStore, castId); + if (ability != null) { + this.target.callback(caster, localStore, castId).add(localStore.game, ability); + localStore.put(ABLocalStoreKeys.LASTADDEDBUFF, ability); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AddUnitBuffAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + this.buff.generateJassEquivalent(jassTextGenerator) + + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddNonStackingDisplayBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddNonStackingDisplayBuff.java new file mode 100644 index 000000000..7a8bfcf94 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddNonStackingDisplayBuff.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddNonStackingDisplayBuff implements ABSingleAction { + + private ABUnitCallback target; + private ABStringCallback key; + private ABBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CBuff ability = this.buff.callback(caster, localStore, castId); + this.target.callback(caster, localStore, castId).addNonStackingDisplayBuff(localStore.game, + this.key.callback(caster, localStore, castId), ability); + localStore.put(ABLocalStoreKeys.LASTADDEDBUFF, ability); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AddUnitNonStackingDisplayBuffAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + this.key.generateJassEquivalent(jassTextGenerator) + + ", " + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddSlowBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddSlowBuff.java new file mode 100644 index 000000000..929801eaa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddSlowBuff.java @@ -0,0 +1,59 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.defaultbuffs.ABBuffSlow; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddSlowBuff implements ABSingleAction { + + private ABUnitCallback unit; + private ABIDCallback buffId; + private ABFloatCallback duration; + + private ABBooleanCallback showIcon; + private ABBooleanCallback leveled; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + War3ID alias = null; + boolean isLeveled = false; + boolean isShowIcon = true; + if (buffId == null) { + alias = War3ID.fromString("Bfro"); + } else { + alias = buffId.callback(caster, localStore, castId); + } + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + if (showIcon != null) { + isShowIcon = showIcon.callback(caster, localStore, castId); + } + + final ABBuffSlow ability = new ABBuffSlow(localStore.game, localStore.game.getHandleIdAllocator().createId(), + alias, localStore, localStore.originAbility, caster, this.duration.callback(caster, localStore, castId), + isLeveled); + + ability.setIconShowing(isShowIcon); + + this.unit.callback(caster, localStore, castId).add(localStore.game, ability); + localStore.put(ABLocalStoreKeys.LASTADDEDBUFF, ability); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "AddUnitAbility(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", CreateSlowBuffAU(" + + jassTextGenerator.getTriggerLocalStore() + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + "))"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddStunBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddStunBuff.java new file mode 100644 index 000000000..d7caa2af0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionAddStunBuff.java @@ -0,0 +1,57 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.defaultbuffs.ABBuffStun; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddStunBuff implements ABSingleAction { + + private ABUnitCallback unit; + private ABIDCallback buffId; + private ABFloatCallback duration; + + private ABBooleanCallback showIcon; + private ABBooleanCallback leveled; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + War3ID alias = null; + boolean isLeveled = false; + boolean isShowIcon = true; + if (buffId == null) { + alias = War3ID.fromString("BSTN"); + } else { + alias = buffId.callback(caster, localStore, castId); + } + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + if (showIcon != null) { + isShowIcon = showIcon.callback(caster, localStore, castId); + } + final ABBuffStun ability = new ABBuffStun(localStore.game.getHandleIdAllocator().createId(), alias, localStore, + localStore.originAbility, caster, this.duration.callback(caster, localStore, castId), isLeveled); + ability.setIconShowing(isShowIcon); + + this.unit.callback(caster, localStore, castId).add(localStore.game, ability); + localStore.put(ABLocalStoreKeys.LASTADDEDBUFF, ability); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "AddUnitAbility(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", CreateStunBuffAU(" + + jassTextGenerator.getTriggerLocalStore() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + "))"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreatePassiveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreatePassiveBuff.java new file mode 100644 index 000000000..e1e002b57 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreatePassiveBuff.java @@ -0,0 +1,106 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABPermanentPassiveBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreatePassiveBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABBooleanCallback showIcon; + private List onAddActions; + private List onRemoveActions; + private CEffectType artType; + + private ABBooleanCallback showFx; + private ABBooleanCallback playSfx; + + private ABBooleanCallback leveled; + private ABBooleanCallback positive; + + private ABStringCallback visibilityGroup; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + ABPermanentPassiveBuff ability = null; + boolean isLeveled = false; + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + boolean isPositive = true; + if (positive != null) { + isPositive = positive.callback(caster, localStore, castId); + } + + if (showIcon != null) { + ability = new ABPermanentPassiveBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore.originAbility, caster, localStore, + onAddActions, onRemoveActions, showIcon.callback(caster, localStore, castId), castId, isLeveled, + isPositive); + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + } else { + ability = new ABPermanentPassiveBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore.originAbility, caster, localStore, + onAddActions, onRemoveActions, true, castId, isLeveled, isPositive); + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + } + if (this.artType != null) { + ability.setArtType(this.artType); + } + if (this.showFx != null) { + ability.setShowFx(this.showFx.callback(caster, localStore, castId)); + } + if (this.playSfx != null) { + ability.setPlaySfx(this.playSfx.callback(caster, localStore, castId)); + } + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (String key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), key); + } + } + if (visibilityGroup != null) { + ability.setVisibilityGroup(visibilityGroup.callback(caster, localStore, castId)); + } + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, + "CreatePassiveBuffAU_OnAddActions"); + final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, + "CreatePassiveBuffAU_OnRemoveActions"); + + return "CreatePassiveBuffAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + + ", " + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.showIcon.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.functionPointerByName(addFunctionName) + ", " + + jassTextGenerator.functionPointerByName(removeFunctionName) + ", EFFECT_TYPE_" + this.artType.name() + + ", " + this.showFx.generateJassEquivalent(jassTextGenerator) + ", " + + this.playSfx.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTargetingBuff.java new file mode 100644 index 000000000..1865baf7d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTargetingBuff.java @@ -0,0 +1,51 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTargetingBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateTargetingBuff implements ABSingleAction { + + private ABIDCallback buffId; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABTargetingBuff ability = new ABTargetingBuff(localStore.game.getHandleIdAllocator().createId(), + this.buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (String key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), key); + } + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "CreateTargetingBuffAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedArtBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedArtBuff.java new file mode 100644 index 000000000..58ae6967e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedArtBuff.java @@ -0,0 +1,113 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedArtBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreateTimedArtBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + private ABBooleanCallback showIcon; + private CEffectType artType; + + private ABBooleanCallback leveled; + private ABBooleanCallback positive; + private ABBooleanCallback dispellable; + + private ABBooleanCallback stacks; + private ABStringCallback visibilityGroup; + + private List uniqueFlags; + private Map uniqueValues; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean isLeveled = false; + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + boolean isPositive = true; + if (positive != null) { + isPositive = positive.callback(caster, localStore, castId); + } + boolean isDispellable = true; + if (dispellable != null) { + isDispellable = dispellable.callback(caster, localStore, castId); + } else { + isDispellable = localStore.originAbility.isMagic(); + } + + ABTimedArtBuff ability; + if (showIcon != null) { + ability = new ABTimedArtBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showIcon.callback(caster, localStore, castId), + isLeveled, isPositive, isDispellable); + } else { + ability = new ABTimedArtBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), isLeveled, isPositive, isDispellable); + } + if (artType != null) { + ability.setArtType(artType); + } + boolean isStacks = false; + if (stacks != null) { + isStacks = stacks.callback(caster, localStore, castId); + } + ability.setStacks(isStacks); + if (visibilityGroup != null) { + ability.setVisibilityGroup(visibilityGroup.callback(caster, localStore, castId)); + } + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (String key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), key); + } + } + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + CEffectType artTypeUsed; + if (this.artType != null) { + artTypeUsed = this.artType; + } else { + artTypeUsed = CEffectType.TARGET; + } + final String artTypeJass = "EFFECT_TYPE_" + artTypeUsed.name(); + String showIconJass; + if (this.showIcon != null) { + showIconJass = this.showIcon.generateJassEquivalent(jassTextGenerator); + } else { + showIconJass = "true"; + } + return "CreateTimedArtBuffAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + + ", " + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showIconJass + ", " + artTypeJass + + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedBuff.java new file mode 100644 index 000000000..ffd061c78 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedBuff.java @@ -0,0 +1,188 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionCreateTimedBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + private ABBooleanCallback showTimedLifeBar; + private List onAddActions; + private List onRemoveActions; + private List onExpireActions; + + private List statBuffs; + private List stateMods; + + private ABBooleanCallback showIcon; + private CEffectType artType; + private ABBooleanCallback hideArt; + + private ABBooleanCallback leveled; + private ABBooleanCallback positive; + private ABBooleanCallback dispellable; + private ABBooleanCallback magic; + private ABBooleanCallback physical; + + private ABBooleanCallback stacks; + private ABStringCallback visibilityGroup; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean showTimedLife = false; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.callback(caster, localStore, castId); + } + boolean isLeveled = false; + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + boolean isPositive = true; + if (positive != null) { + isPositive = positive.callback(caster, localStore, castId); + } + boolean isDispellable = true; + if (dispellable != null) { + isDispellable = dispellable.callback(caster, localStore, castId); + } else { + isDispellable = localStore.originAbility.isMagic(); + } + + boolean isMagic = localStore.originAbility.isMagic(); + boolean isPhysical = localStore.originAbility.isPhysical(); + if (magic != null) { + isMagic = magic.callback(caster, localStore, castId); + } + if (physical != null) { + isPhysical = physical.callback(caster, localStore, castId); + } + + ABTimedBuff ability; + if (showIcon != null) { + ability = new ABTimedBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, showIcon.callback(caster, localStore, castId), castId, isLeveled, isPositive, + isDispellable); + + } else { + ability = new ABTimedBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, castId, isLeveled, isPositive, isDispellable); + } + + if (stateMods != null) { + List buffMods = new ArrayList<>(); + for (ABStateModBuffCallback mod : stateMods) { + buffMods.add(mod.callback(caster, localStore, castId)); + } + ability.setStateMods(buffMods); + } + if (statBuffs != null) { + List buffStats = new ArrayList<>(); + for (ABNonStackingStatBuffCallback mod : statBuffs) { + buffStats.add(mod.callback(caster, localStore, castId)); + } + ability.setStatBuffs(buffStats); + } + + if (artType != null) { + ability.setArtType(artType); + } + if ((this.hideArt != null) && this.hideArt.callback(caster, localStore, castId)) { + ability.setArtType(null); + } + ability.setMagic(isMagic); + ability.setPhysical(isPhysical); + boolean isStacks = false; + if (stacks != null) { + isStacks = stacks.callback(caster, localStore, castId); + } + ability.setStacks(isStacks); + if (visibilityGroup != null) { + ability.setVisibilityGroup(visibilityGroup.callback(caster, localStore, castId)); + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (String key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), key); + } + } + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, + "CreateTimedBuffAU_OnAddActions"); + final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, + "CreateTimedBuffAU_OnRemoveActions"); + final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, + "CreateTimedBuffAU_OnExpireActions"); + + String showTimedLife = "false"; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); + } + + String showIconExpression; + if (this.showIcon != null) { + showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); + } else { + showIconExpression = "true"; + } + + CEffectType artTypeUsed = CEffectType.TARGET; + if (this.artType != null) { + artTypeUsed = this.artType; + } + String artTypeExpression; + if (this.hideArt != null) { + artTypeExpression = "null"; + } else { + artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); + } + + return "CreateTimedBuffAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + + ", " + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " + + jassTextGenerator.functionPointerByName(addFunctionName) + ", " + + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " + + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " + showIconExpression + ", " + + artTypeExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedLifeBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedLifeBuff.java new file mode 100644 index 000000000..0b88a6223 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedLifeBuff.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.util.CBuffTimedLife; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateTimedLifeBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + private ABBooleanCallback explode; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CBuffTimedLife ability = new CBuffTimedLife(localStore.game.getHandleIdAllocator().createId(), + this.buffId.callback(caster, localStore, castId), this.duration.callback(caster, localStore, castId), + this.explode.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "CreateTimedLifeBuffAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + + this.explode.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedPausedExpirationBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedPausedExpirationBuff.java new file mode 100644 index 000000000..c1acc558c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedPausedExpirationBuff.java @@ -0,0 +1,146 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedPausedExpirationBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionCreateTimedPausedExpirationBuff implements ABAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + private ABBooleanCallback showTimedLifeBar; + private List onAddActions; + private List onRemoveActions; + private List onExpireActions; + + private List statBuffs; + private List stateMods; + + private ABBooleanCallback showIcon; + private CEffectType artType; + private ABBooleanCallback hideArt; + + private ABBooleanCallback leveled; + private ABBooleanCallback positive; + private ABBooleanCallback dispellable; + private ABBooleanCallback magic; + private ABBooleanCallback physical; + + private ABBooleanCallback stacks; + private ABStringCallback visibilityGroup; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean showTimedLife = false; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.callback(caster, localStore, castId); + } + boolean isLeveled = false; + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + boolean isPositive = true; + if (positive != null) { + isPositive = positive.callback(caster, localStore, castId); + } + boolean isDispellable = true; + if (dispellable != null) { + isDispellable = dispellable.callback(caster, localStore, castId); + } else { + isDispellable = localStore.originAbility.isMagic(); + } + + boolean isMagic = localStore.originAbility.isMagic(); + boolean isPhysical = localStore.originAbility.isPhysical(); + if (magic != null) { + isMagic = magic.callback(caster, localStore, castId); + } + if (physical != null) { + isPhysical = physical.callback(caster, localStore, castId); + } + + ABTimedBuff ability; + if (showIcon != null) { + ability = new ABTimedPausedExpirationBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, showIcon.callback(caster, localStore, castId), castId, isLeveled, isPositive, + isDispellable); + + } else { + ability = new ABTimedPausedExpirationBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, castId, isLeveled, isPositive, isDispellable); + } + + if (stateMods != null) { + List buffMods = new ArrayList<>(); + for (ABStateModBuffCallback mod : stateMods) { + buffMods.add(mod.callback(caster, localStore, castId)); + } + ability.setStateMods(buffMods); + } + if (statBuffs != null) { + List buffStats = new ArrayList<>(); + for (ABNonStackingStatBuffCallback mod : statBuffs) { + buffStats.add(mod.callback(caster, localStore, castId)); + } + ability.setStatBuffs(buffStats); + } + + if (artType != null) { + ability.setArtType(artType); + } + if ((this.hideArt != null) && this.hideArt.callback(caster, localStore, castId)) { + ability.setArtType(null); + } + ability.setMagic(isMagic); + ability.setPhysical(isPhysical); + boolean isStacks = false; + if (stacks != null) { + isStacks = stacks.callback(caster, localStore, castId); + } + ability.setStacks(isStacks); + if (visibilityGroup != null) { + ability.setVisibilityGroup(visibilityGroup.callback(caster, localStore, castId)); + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (String key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), key); + } + } + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTargetingBuff.java new file mode 100644 index 000000000..0ce6f2127 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTargetingBuff.java @@ -0,0 +1,63 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTargetingBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateTimedTargetingBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + + private ABBooleanCallback stacks; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABTimedTargetingBuff ability = new ABTimedTargetingBuff(localStore.game.getHandleIdAllocator().createId(), + this.buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + this.duration.callback(caster, localStore, castId)); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (String key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), key); + } + } + boolean isStacks = false; + if (stacks != null) { + isStacks = stacks.callback(caster, localStore, castId); + } + ability.setStacks(isStacks); + + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "CreateTimedTargetingBuffAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingBuff.java new file mode 100644 index 000000000..85d16a004 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingBuff.java @@ -0,0 +1,186 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTickingBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionCreateTimedTickingBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + private ABBooleanCallback showTimedLifeBar; + private List onAddActions; + private List onRemoveActions; + private List onExpireActions; + private List onTickActions; + + private List statBuffs; + private List stateMods; + + private ABBooleanCallback showIcon; + private CEffectType artType; + + private ABBooleanCallback leveled; + private ABBooleanCallback positive; + private ABBooleanCallback dispellable; + private ABBooleanCallback magic; + private ABBooleanCallback physical; + + private ABBooleanCallback stacks; + private ABStringCallback visibilityGroup; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean showTimedLife = false; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.callback(caster, localStore, castId); + } + boolean isLeveled = false; + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + boolean isPositive = true; + if (positive != null) { + isPositive = positive.callback(caster, localStore, castId); + } + boolean isDispellable = true; + if (dispellable != null) { + isDispellable = dispellable.callback(caster, localStore, castId); + } else { + isDispellable = localStore.originAbility.isMagic(); + } + + boolean isMagic = localStore.originAbility.isMagic(); + boolean isPhysical = localStore.originAbility.isPhysical(); + if (magic != null) { + isMagic = magic.callback(caster, localStore, castId); + } + if (physical != null) { + isPhysical = physical.callback(caster, localStore, castId); + } + + ABTimedTickingBuff ability; + if (showIcon != null) { + ability = new ABTimedTickingBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, onTickActions, showIcon.callback(caster, localStore, castId), castId, isLeveled, + isPositive, isDispellable); + } else { + ability = new ABTimedTickingBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, onTickActions, castId, isLeveled, isPositive, isDispellable); + } + + if (stateMods != null) { + List buffMods = new ArrayList<>(); + for (ABStateModBuffCallback mod : stateMods) { + buffMods.add(mod.callback(caster, localStore, castId)); + } + ability.setStateMods(buffMods); + } + if (statBuffs != null) { + List buffStats = new ArrayList<>(); + for (ABNonStackingStatBuffCallback mod : statBuffs) { + buffStats.add(mod.callback(caster, localStore, castId)); + } + ability.setStatBuffs(buffStats); + } + + if (artType != null) { + ability.setArtType(artType); + } + ability.setMagic(isMagic); + ability.setPhysical(isPhysical); + boolean isStacks = false; + if (stacks != null) { + isStacks = stacks.callback(caster, localStore, castId); + } + ability.setStacks(isStacks); + if (visibilityGroup != null) { + ability.setVisibilityGroup(visibilityGroup.callback(caster, localStore, castId)); + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (ABStringCallback key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), + key.callback(caster, localStore, castId)); + } + } + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, + "CreateTimedTickingBuffAU_OnAddActions"); + final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, + "CreateTimedTickingBuffAU_OnRemoveActions"); + final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, + "CreateTimedTickingBuffAU_OnExpireActions"); + final String tickFunctionName = jassTextGenerator.createAnonymousFunction(this.onTickActions, + "CreateTimedTickingBuffAU_OnTickActions"); + + String showTimedLife = "false"; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); + } + + String showIconExpression; + if (this.showIcon != null) { + showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); + } else { + showIconExpression = "true"; + } + + CEffectType artTypeUsed = CEffectType.TARGET; + if (this.artType != null) { + artTypeUsed = this.artType; + } + String artTypeExpression; + artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); + + return "CreateTimedTickingBuffAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " + + jassTextGenerator.functionPointerByName(addFunctionName) + ", " + + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " + + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " + + jassTextGenerator.functionPointerByName(tickFunctionName) + ", " + showIconExpression + ", " + + artTypeExpression + ", " + jassTextGenerator.getCastId() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingPausedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingPausedBuff.java new file mode 100644 index 000000000..8ac1a1b61 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingPausedBuff.java @@ -0,0 +1,186 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTickingPausedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionCreateTimedTickingPausedBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + private ABBooleanCallback showTimedLifeBar; + private List onAddActions; + private List onRemoveActions; + private List onExpireActions; + private List onTickActions; + + private List statBuffs; + private List stateMods; + + private ABBooleanCallback showIcon; + private CEffectType artType; + + private ABBooleanCallback leveled; + private ABBooleanCallback positive; + private ABBooleanCallback dispellable; + private ABBooleanCallback magic; + private ABBooleanCallback physical; + + private ABBooleanCallback stacks; + private ABStringCallback visibilityGroup; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean showTimedLife = false; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.callback(caster, localStore, castId); + } + boolean isLeveled = false; + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + boolean isPositive = true; + if (positive != null) { + isPositive = positive.callback(caster, localStore, castId); + } + boolean isDispellable = true; + if (dispellable != null) { + isDispellable = dispellable.callback(caster, localStore, castId); + } else { + isDispellable = localStore.originAbility.isMagic(); + } + + boolean isMagic = localStore.originAbility.isMagic(); + boolean isPhysical = localStore.originAbility.isPhysical(); + if (magic != null) { + isMagic = magic.callback(caster, localStore, castId); + } + if (physical != null) { + isPhysical = physical.callback(caster, localStore, castId); + } + + ABTimedTickingPausedBuff ability; + if (showIcon != null) { + ability = new ABTimedTickingPausedBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, onTickActions, showIcon.callback(caster, localStore, castId), castId, isLeveled, + isPositive, isDispellable); + } else { + ability = new ABTimedTickingPausedBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, onTickActions, castId, isLeveled, isPositive, isDispellable); + } + + if (stateMods != null) { + List buffMods = new ArrayList<>(); + for (ABStateModBuffCallback mod : stateMods) { + buffMods.add(mod.callback(caster, localStore, castId)); + } + ability.setStateMods(buffMods); + } + if (statBuffs != null) { + List buffStats = new ArrayList<>(); + for (ABNonStackingStatBuffCallback mod : statBuffs) { + buffStats.add(mod.callback(caster, localStore, castId)); + } + ability.setStatBuffs(buffStats); + } + + if (artType != null) { + ability.setArtType(artType); + } + ability.setMagic(isMagic); + ability.setPhysical(isPhysical); + boolean isStacks = false; + if (stacks != null) { + isStacks = stacks.callback(caster, localStore, castId); + } + ability.setStacks(isStacks); + if (visibilityGroup != null) { + ability.setVisibilityGroup(visibilityGroup.callback(caster, localStore, castId)); + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (ABStringCallback key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), + key.callback(caster, localStore, castId)); + } + } + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, + "CreateTimedTickingPausedBuffAU_OnAddActions"); + final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, + "CreateTimedTickingPausedBuffAU_OnRemoveActions"); + final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, + "CreateTimedTickingPausedBuffAU_OnExpireActions"); + final String tickFunctionName = jassTextGenerator.createAnonymousFunction(this.onTickActions, + "CreateTimedTickingPausedBuffAU_OnTickActions"); + + String showTimedLife = "false"; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); + } + + String showIconExpression; + if (this.showIcon != null) { + showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); + } else { + showIconExpression = "true"; + } + + CEffectType artTypeUsed = CEffectType.TARGET; + if (this.artType != null) { + artTypeUsed = this.artType; + } + String artTypeExpression; + artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); + + return "CreateTimedTickingPausedBuffAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " + + jassTextGenerator.functionPointerByName(addFunctionName) + ", " + + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " + + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " + + jassTextGenerator.functionPointerByName(tickFunctionName) + ", " + showIconExpression + ", " + + artTypeExpression + ", " + jassTextGenerator.getCastId() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingPostDeathBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingPostDeathBuff.java new file mode 100644 index 000000000..477d1c5d5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionCreateTimedTickingPostDeathBuff.java @@ -0,0 +1,188 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTickingPostDeathBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionCreateTimedTickingPostDeathBuff implements ABSingleAction { + + private ABIDCallback buffId; + private ABFloatCallback duration; + private ABBooleanCallback showTimedLifeBar; + private List onAddActions; + private List onRemoveActions; + private List onExpireActions; + private List onTickActions; + + private List statBuffs; + private List stateMods; + + private ABBooleanCallback showIcon; + private CEffectType artType; + + private ABBooleanCallback leveled; + private ABBooleanCallback positive; + private ABBooleanCallback dispellable; + private ABBooleanCallback magic; + private ABBooleanCallback physical; + + private ABBooleanCallback stacks; + private ABStringCallback visibilityGroup; + + private List uniqueFlags; + private Map uniqueValues; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean showTimedLife = false; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.callback(caster, localStore, castId); + } + boolean isLeveled = false; + if (leveled != null) { + isLeveled = leveled.callback(caster, localStore, castId); + } else { + isLeveled = localStore.getBooleanOrDefault(ABLocalStoreKeys.ISABILITYLEVELED, false); + } + boolean isPositive = true; + if (positive != null) { + isPositive = positive.callback(caster, localStore, castId); + } + boolean isDispellable = true; + if (dispellable != null) { + isDispellable = dispellable.callback(caster, localStore, castId); + } else { + isDispellable = localStore.originAbility.isMagic(); + } + + boolean isMagic = localStore.originAbility.isMagic(); + boolean isPhysical = localStore.originAbility.isPhysical(); + if (magic != null) { + isMagic = magic.callback(caster, localStore, castId); + } + if (physical != null) { + isPhysical = physical.callback(caster, localStore, castId); + } + + ABTimedTickingPostDeathBuff ability; + if (showIcon != null) { + ability = new ABTimedTickingPostDeathBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, onTickActions, showIcon.callback(caster, localStore, castId), castId, isLeveled, + isPositive, isDispellable); + if (artType != null) { + ability.setArtType(artType); + } + } else { + ability = new ABTimedTickingPostDeathBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), localStore, localStore.originAbility, caster, + duration.callback(caster, localStore, castId), showTimedLife, onAddActions, onRemoveActions, + onExpireActions, onTickActions, castId, isLeveled, isPositive, isDispellable); + if (artType != null) { + ability.setArtType(artType); + } + } + + if (stateMods != null) { + List buffMods = new ArrayList<>(); + for (ABStateModBuffCallback mod : stateMods) { + buffMods.add(mod.callback(caster, localStore, castId)); + } + ability.setStateMods(buffMods); + } + if (statBuffs != null) { + List buffStats = new ArrayList<>(); + for (ABNonStackingStatBuffCallback mod : statBuffs) { + buffStats.add(mod.callback(caster, localStore, castId)); + } + ability.setStatBuffs(buffStats); + } + + ability.setMagic(isMagic); + ability.setPhysical(isPhysical); + boolean isStacks = false; + if (stacks != null) { + isStacks = stacks.callback(caster, localStore, castId); + } + ability.setStacks(isStacks); + if (visibilityGroup != null) { + ability.setVisibilityGroup(visibilityGroup.callback(caster, localStore, castId)); + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDBUFF, ability); + if (uniqueFlags != null) { + for (ABStringCallback flag : uniqueFlags) { + ability.addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + if (uniqueValues != null) { + for (String key : uniqueValues.keySet()) { + ability.addUniqueValue(uniqueValues.get(key).callback(caster, localStore, castId), key); + } + } + if (!localStore.containsKey(ABLocalStoreKeys.BUFFCASTINGUNIT)) { + localStore.put(ABLocalStoreKeys.BUFFCASTINGUNIT, caster); + } + + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, + "CreateTimedTickingPostDeathBuffAU_OnAddActions"); + final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, + "CreateTimedTickingPostDeathBuffAU_OnRemoveActions"); + final String expireFunctionName = jassTextGenerator.createAnonymousFunction(this.onExpireActions, + "CreateTimedTickingPostDeathBuffAU_OnExpireActions"); + final String tickFunctionName = jassTextGenerator.createAnonymousFunction(this.onTickActions, + "CreateTimedTickingPostDeathBuffAU_OnTickActions"); + + String showTimedLife = "false"; + if (this.showTimedLifeBar != null) { + showTimedLife = this.showTimedLifeBar.generateJassEquivalent(jassTextGenerator); + } + + String showIconExpression; + if (this.showIcon != null) { + showIconExpression = this.showIcon.generateJassEquivalent(jassTextGenerator); + } else { + showIconExpression = "true"; + } + + CEffectType artTypeUsed = CEffectType.TARGET; + if (this.artType != null) { + artTypeUsed = this.artType; + } + String artTypeExpression; + artTypeExpression = "EFFECT_TYPE_" + artTypeUsed.name(); + + return "CreateTimedTickingPostDeathBuffAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ", " + showTimedLife + ", " + + jassTextGenerator.functionPointerByName(addFunctionName) + ", " + + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " + + jassTextGenerator.functionPointerByName(expireFunctionName) + ", " + + jassTextGenerator.functionPointerByName(tickFunctionName) + ", " + showIconExpression + ", " + + artTypeExpression + ", " + jassTextGenerator.getCastId() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionDispelBuffs.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionDispelBuffs.java new file mode 100644 index 000000000..1ccdb81e7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionDispelBuffs.java @@ -0,0 +1,51 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionDispelBuffs implements ABAction { + + private ABUnitCallback source; + private ABUnitCallback unit; + private ABBooleanCallback filter; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = caster; + if (source != null) { + theCaster = source.callback(theCaster, localStore, castId); + } + CUnit theTarget = caster; + if (unit != null) { + theTarget = unit.callback(theCaster, localStore, castId); + } + + if (theTarget != null) { + List toRemove = new ArrayList<>(); + for (CAbility ability : theTarget.getAbilities()) { + if (ability.getAbilityCategory() == CAbilityCategory.BUFF) { + CBuff buff = (CBuff) ability; + localStore.put(ABLocalStoreKeys.ENUMBUFF, buff); + if (filter != null && filter.callback(theCaster, localStore, castId)) { + toRemove.add(buff); + } + } + } + + for (CBuff buff : toRemove) { + theTarget.remove(localStore.game, buff); + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionRemoveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionRemoveBuff.java new file mode 100644 index 000000000..7a5a69a13 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionRemoveBuff.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveBuff implements ABSingleAction { + + private ABUnitCallback target; + private ABBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CBuff theBuff = this.buff.callback(caster, localStore, castId); + if (theBuff != null) { + (this.target.callback(caster, localStore, castId)).remove(localStore.game, theBuff); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RemoveUnitAbility(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionRemoveNonStackingDisplayBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionRemoveNonStackingDisplayBuff.java new file mode 100644 index 000000000..38c1aa0e6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/buff/ABActionRemoveNonStackingDisplayBuff.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveNonStackingDisplayBuff implements ABSingleAction { + + private ABUnitCallback target; + private ABStringCallback key; + private ABBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CBuff ability = this.buff.callback(caster, localStore, castId); + this.target.callback(caster, localStore, castId).removeNonStackingDisplayBuff(localStore.game, + this.key.callback(caster, localStore, castId), ability); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RemoveUnitNonStackingDisplayBuff(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageArea.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageArea.java new file mode 100644 index 000000000..1dbc8d4d9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageArea.java @@ -0,0 +1,176 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.damage; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CGenericDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; + +public class ABActionDamageArea implements ABAction { + + private ABUnitCallback source; + private ABLocationCallback target; + private ABFloatCallback radius; + private ABFloatCallback damage; + private ABBooleanCallback validTarget; + + private ABFloatCallback unitSpecificDamageMod; + private ABFloatCallback maxDamage; + + private ABBooleanCallback isAttack; + private ABBooleanCallback isRanged; + private ABAttackTypeCallback attackType; + private ABDamageTypeCallback damageType; + + private ABBooleanCallback ignoreLTEZero; + private ABBooleanCallback damageInvulnerable; + private ABBooleanCallback explodeOnDeath; + private ABBooleanCallback onlyDamageSummons; + private ABBooleanCallback nonlethal; + + private List extraActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CAttackType theAttackType = CAttackType.SPELLS; + CDamageType theDamageType = CDamageType.MAGIC; + final CDamageFlags flags = new CGenericDamageFlags(false, true); + + float theDamage = damage.callback(caster, localStore, castId); + + if (isAttack != null) { + flags.setAttack(isAttack.callback(caster, localStore, castId)); + } + if (isRanged != null) { + flags.setRanged(isRanged.callback(caster, localStore, castId)); + } + if (damageInvulnerable != null) { + flags.setIgnoreInvulnerable(damageInvulnerable.callback(caster, localStore, castId)); + } + if (explodeOnDeath != null) { + flags.setExplode(explodeOnDeath.callback(caster, localStore, castId)); + } + if (onlyDamageSummons != null) { + flags.setOnlyDamageSummons(onlyDamageSummons.callback(caster, localStore, castId)); + } + if (nonlethal != null) { + flags.setNonlethal(nonlethal.callback(caster, localStore, castId)); + } + if (this.attackType != null) { + theAttackType = this.attackType.callback(caster, localStore, castId); + } + if (this.damageType != null) { + theDamageType = this.damageType.callback(caster, localStore, castId); + } + if (theDamage > 0 || ignoreLTEZero == null || !ignoreLTEZero.callback(caster, localStore, castId)) { + AbilityPointTarget loc = target.callback(caster, localStore, castId); + float pfullRad = 0; + float theMaxDamage = 0; + CUnit theSource = caster; + if (this.radius != null) { + pfullRad = this.radius.callback(caster, localStore, castId); + } + if (this.maxDamage != null) { + theMaxDamage = this.maxDamage.callback(caster, localStore, castId); + } + if (this.source != null) { + theSource = this.source.callback(caster, localStore, castId); + } + + final CAttackType ftheAttackType = theAttackType; + final CDamageType ftheDamageType = theDamageType; + final CUnit ftheSource = theSource; + final float baseDamage = damage.callback(caster, localStore, castId); + + if (theMaxDamage > 0) { + List hits = new ArrayList<>(); + List counts = new ArrayList<>(); + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), pfullRad, + new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + hits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(1f); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + + float count = 0; + for (float c : counts) { + count += c; + } + float damPerTar = baseDamage * count > theMaxDamage ? theMaxDamage / count : baseDamage; + for (CUnit hit : hits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + } + + } else { + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), pfullRad, + new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), baseDamage + * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), baseDamage); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + } + + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageAttackSplash.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageAttackSplash.java new file mode 100644 index 000000000..e4e10e462 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageAttackSplash.java @@ -0,0 +1,290 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.damage; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CGenericDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; + +public class ABActionDamageAttackSplash implements ABAction { + + private ABUnitCallback source; + private ABLocationCallback target; + private ABFloatCallback damage; + private ABFloatCallback fullDamageRadius; + private ABFloatCallback mediumDamageRadius; + private ABFloatCallback smallDamageRadius; + private ABFloatCallback damageFactorMedium; + private ABFloatCallback damageFactorSmall; + private ABBooleanCallback validTarget; + + private ABFloatCallback unitSpecificDamageMod; + private ABFloatCallback maxDamage; + + private ABBooleanCallback isAttack; + private ABBooleanCallback isRanged; + private ABAttackTypeCallback attackType; + private ABDamageTypeCallback damageType; + + private ABBooleanCallback ignoreLTEZero; + private ABBooleanCallback damageInvulnerable; + private ABBooleanCallback explodeOnDeath; + private ABBooleanCallback onlyDamageSummons; + private ABBooleanCallback nonlethal; + + private List extraActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CAttackType theAttackType = CAttackType.SPELLS; + CDamageType theDamageType = CDamageType.MAGIC; + final CDamageFlags flags = new CGenericDamageFlags(false, true); + + float theDamage = damage.callback(caster, localStore, castId); + + if (isAttack != null) { + flags.setAttack(isAttack.callback(caster, localStore, castId)); + } + if (isRanged != null) { + flags.setRanged(isRanged.callback(caster, localStore, castId)); + } + if (damageInvulnerable != null) { + flags.setIgnoreInvulnerable(damageInvulnerable.callback(caster, localStore, castId)); + } + if (explodeOnDeath != null) { + flags.setExplode(explodeOnDeath.callback(caster, localStore, castId)); + } + if (onlyDamageSummons != null) { + flags.setOnlyDamageSummons(onlyDamageSummons.callback(caster, localStore, castId)); + } + if (nonlethal != null) { + flags.setNonlethal(nonlethal.callback(caster, localStore, castId)); + } + if (this.attackType != null) { + theAttackType = this.attackType.callback(caster, localStore, castId); + } + if (this.damageType != null) { + theDamageType = this.damageType.callback(caster, localStore, castId); + } + if (theDamage > 0 || ignoreLTEZero == null || !ignoreLTEZero.callback(caster, localStore, castId)) { + AbilityPointTarget loc = target.callback(caster, localStore, castId); + float pfullRad = 0; + float pmedRad = 0; + float psmallRad = 0; + float pmedDam = 0; + float psmallDam = 0; + float theMaxDamage = 0; + CUnit theSource = caster; + if (this.fullDamageRadius != null) { + pfullRad = this.fullDamageRadius.callback(caster, localStore, castId); + } + if (this.mediumDamageRadius != null) { + pmedRad = this.mediumDamageRadius.callback(caster, localStore, castId); + } + if (this.smallDamageRadius != null) { + psmallRad = this.smallDamageRadius.callback(caster, localStore, castId); + } + if (this.damageFactorMedium != null) { + pmedDam = this.damageFactorMedium.callback(caster, localStore, castId); + } + if (this.damageFactorSmall != null) { + psmallDam = this.damageFactorSmall.callback(caster, localStore, castId); + } + if (this.maxDamage != null) { + theMaxDamage = this.maxDamage.callback(caster, localStore, castId); + } + if (this.source != null) { + theSource = this.source.callback(caster, localStore, castId); + } + + final float fullRad = pfullRad; + final float medRad = pmedRad; + final float smallRad = psmallRad; + final float medDam = pmedDam; + final float smallDam = psmallDam; + final CAttackType ftheAttackType = theAttackType; + final CDamageType ftheDamageType = theDamageType; + final CUnit ftheSource = theSource; + final float baseDamage = damage.callback(caster, localStore, castId); + + if (theMaxDamage > 0) { + List fullhits = new ArrayList<>(); + List medhits = new ArrayList<>(); + List smallhits = new ArrayList<>(); + List counts = new ArrayList<>(); + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), + Math.max(pfullRad, Math.max(medRad, smallRad)), new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + if (enumUnit.canReach(loc, fullRad)) { + fullhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(1f); + } + } else if (enumUnit.canReach(loc, medRad)) { + medhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(medDam + * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(medDam); + } + } else if (enumUnit.canReach(loc, smallRad)) { + smallhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(smallDam + * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(smallDam); + } + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + + float count = 0; + for (float c : counts) { + count += c; + } + float damPerTar = baseDamage * count > theMaxDamage + ? theMaxDamage / (fullhits.size() + medDam * medhits.size() + smallDam * smallhits.size()) + : baseDamage; + for (CUnit hit : fullhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar); + } + } + for (CUnit hit : medhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * medDam * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar * medDam); + } + } + for (CUnit hit : smallhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * smallDam * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar * smallDam); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + + } else { + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), + Math.max(Math.max(pfullRad, pmedRad), psmallRad), new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + if (enumUnit.canReach(loc, fullRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + baseDamage * unitSpecificDamageMod.callback(caster, localStore, + castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), baseDamage); + } + } else if (enumUnit.canReach(loc, medRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + baseDamage * medDam * unitSpecificDamageMod.callback(caster, + localStore, castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + baseDamage * medDam); + } + } else if (enumUnit.canReach(loc, smallRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + baseDamage * smallDam * unitSpecificDamageMod.callback(caster, + localStore, castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + baseDamage * smallDam); + } + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + } + + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageBurst.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageBurst.java new file mode 100644 index 000000000..35dca0dae --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageBurst.java @@ -0,0 +1,237 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.damage; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CGenericDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; + +public class ABActionDamageBurst implements ABAction { + + private ABUnitCallback source; + private ABLocationCallback target; + private ABFloatCallback fullDamageRadius; + private ABFloatCallback partialDamageRadius; + private ABFloatCallback damage; + private ABFloatCallback partialDamage; + private ABBooleanCallback validTarget; + + private ABFloatCallback unitSpecificDamageMod; + private ABFloatCallback maxDamage; + + private ABBooleanCallback isAttack; + private ABBooleanCallback isRanged; + private ABAttackTypeCallback attackType; + private ABDamageTypeCallback damageType; + + private ABBooleanCallback ignoreLTEZero; + private ABBooleanCallback damageInvulnerable; + private ABBooleanCallback explodeOnDeath; + private ABBooleanCallback onlyDamageSummons; + private ABBooleanCallback nonlethal; + + private List extraActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CAttackType theAttackType = CAttackType.SPELLS; + CDamageType theDamageType = CDamageType.MAGIC; + final CDamageFlags flags = new CGenericDamageFlags(false, true); + + float theDamage = damage.callback(caster, localStore, castId); + + if (isAttack != null) { + flags.setAttack(isAttack.callback(caster, localStore, castId)); + } + if (isRanged != null) { + flags.setRanged(isRanged.callback(caster, localStore, castId)); + } + if (damageInvulnerable != null) { + flags.setIgnoreInvulnerable(damageInvulnerable.callback(caster, localStore, castId)); + } + if (explodeOnDeath != null) { + flags.setExplode(explodeOnDeath.callback(caster, localStore, castId)); + } + if (onlyDamageSummons != null) { + flags.setOnlyDamageSummons(onlyDamageSummons.callback(caster, localStore, castId)); + } + if (nonlethal != null) { + flags.setNonlethal(nonlethal.callback(caster, localStore, castId)); + } + if (this.attackType != null) { + theAttackType = this.attackType.callback(caster, localStore, castId); + } + if (this.damageType != null) { + theDamageType = this.damageType.callback(caster, localStore, castId); + } + if (theDamage > 0 || ignoreLTEZero == null || !ignoreLTEZero.callback(caster, localStore, castId)) { + AbilityPointTarget loc = target.callback(caster, localStore, castId); + float pfullRad = 0; + float parRad = 0; + float parDam = 0; + float theMaxDamage = 0; + CUnit theSource = caster; + if (this.fullDamageRadius != null) { + pfullRad = this.fullDamageRadius.callback(caster, localStore, castId); + } + if (this.partialDamageRadius != null) { + parRad = this.partialDamageRadius.callback(caster, localStore, castId); + } + if (this.partialDamage != null) { + parDam = this.partialDamage.callback(caster, localStore, castId); + } + if (this.maxDamage != null) { + theMaxDamage = this.maxDamage.callback(caster, localStore, castId); + } + if (this.source != null) { + theSource = this.source.callback(caster, localStore, castId); + } + + final float fullRad = pfullRad; + final float partialRad = parRad; + final float partialDam = parDam; + final CAttackType ftheAttackType = theAttackType; + final CDamageType ftheDamageType = theDamageType; + final CUnit ftheSource = theSource; + final float baseDamage = damage.callback(caster, localStore, castId); + + if (theMaxDamage > 0) { + List fullhits = new ArrayList<>(); + List partialhits = new ArrayList<>(); + List counts = new ArrayList<>(); + float partialRatio = partialDam / baseDamage; + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), + Math.max(pfullRad, partialRad), new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + if (enumUnit.canReach(loc, fullRad)) { + fullhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(1f); + } + } else if (enumUnit.canReach(loc, partialRad)) { + partialhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(partialRatio + * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(partialRatio); + } + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + + float count = 0; + for (float c : counts) { + count += c; + } + float damPerTar = baseDamage * count > theMaxDamage + ? theMaxDamage / (fullhits.size() + partialRatio * partialhits.size()) + : baseDamage; + for (CUnit hit : fullhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar); + } + } + for (CUnit hit : partialhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * partialRatio * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar * partialRatio); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + + } else { + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), + Math.max(pfullRad, partialRad), new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + if (enumUnit.canReach(loc, fullRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + baseDamage * unitSpecificDamageMod.callback(caster, localStore, + castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), baseDamage); + } + } else if (enumUnit.canReach(loc, partialRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + partialDam * unitSpecificDamageMod.callback(caster, localStore, + castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), partialDam); + } + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + } + + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageSplash.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageSplash.java new file mode 100644 index 000000000..79a93d29f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageSplash.java @@ -0,0 +1,292 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.damage; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CGenericDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; + +public class ABActionDamageSplash implements ABAction { + + private ABUnitCallback source; + private ABLocationCallback target; + private ABFloatCallback fullDamage; + private ABFloatCallback fullDamageRadius; + private ABFloatCallback mediumDamage; + private ABFloatCallback mediumDamageRadius; + private ABFloatCallback smallDamage; + private ABFloatCallback smallDamageRadius; + private ABBooleanCallback validTarget; + + private ABFloatCallback unitSpecificDamageMod; + private ABFloatCallback maxDamage; + + private ABBooleanCallback isAttack; + private ABBooleanCallback isRanged; + private ABAttackTypeCallback attackType; + private ABDamageTypeCallback damageType; + + private ABBooleanCallback ignoreLTEZero; + private ABBooleanCallback damageInvulnerable; + private ABBooleanCallback explodeOnDeath; + private ABBooleanCallback onlyDamageSummons; + private ABBooleanCallback nonlethal; + + private List extraActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CAttackType theAttackType = CAttackType.SPELLS; + CDamageType theDamageType = CDamageType.MAGIC; + final CDamageFlags flags = new CGenericDamageFlags(false, true); + + float theDamage = fullDamage.callback(caster, localStore, castId); + + if (isAttack != null) { + flags.setAttack(isAttack.callback(caster, localStore, castId)); + } + if (isRanged != null) { + flags.setRanged(isRanged.callback(caster, localStore, castId)); + } + if (damageInvulnerable != null) { + flags.setIgnoreInvulnerable(damageInvulnerable.callback(caster, localStore, castId)); + } + if (explodeOnDeath != null) { + flags.setExplode(explodeOnDeath.callback(caster, localStore, castId)); + } + if (onlyDamageSummons != null) { + flags.setOnlyDamageSummons(onlyDamageSummons.callback(caster, localStore, castId)); + } + if (nonlethal != null) { + flags.setNonlethal(nonlethal.callback(caster, localStore, castId)); + } + if (this.attackType != null) { + theAttackType = this.attackType.callback(caster, localStore, castId); + } + if (this.damageType != null) { + theDamageType = this.damageType.callback(caster, localStore, castId); + } + if (theDamage > 0 || ignoreLTEZero == null || !ignoreLTEZero.callback(caster, localStore, castId)) { + AbilityPointTarget loc = target.callback(caster, localStore, castId); + float pfullRad = 0; + float pmedRad = 0; + float psmallRad = 0; + float pmedDam = 0; + float psmallDam = 0; + float theMaxDamage = 0; + CUnit theSource = caster; + if (this.fullDamageRadius != null) { + pfullRad = this.fullDamageRadius.callback(caster, localStore, castId); + } + if (this.mediumDamageRadius != null) { + pmedRad = this.mediumDamageRadius.callback(caster, localStore, castId); + } + if (this.smallDamageRadius != null) { + psmallRad = this.smallDamageRadius.callback(caster, localStore, castId); + } + if (this.mediumDamage != null) { + pmedDam = this.mediumDamage.callback(caster, localStore, castId); + } + if (this.smallDamage != null) { + psmallDam = this.smallDamage.callback(caster, localStore, castId); + } + if (this.maxDamage != null) { + theMaxDamage = this.maxDamage.callback(caster, localStore, castId); + } + if (this.source != null) { + theSource = this.source.callback(caster, localStore, castId); + } + + final float fullRad = pfullRad; + final float medRad = pmedRad; + final float smallRad = psmallRad; + final float medDam = pmedDam; + final float smallDam = psmallDam; + final CAttackType ftheAttackType = theAttackType; + final CDamageType ftheDamageType = theDamageType; + final CUnit ftheSource = theSource; + final float baseDamage = fullDamage.callback(caster, localStore, castId); + + if (theMaxDamage > 0) { + List fullhits = new ArrayList<>(); + List medhits = new ArrayList<>(); + List smallhits = new ArrayList<>(); + List counts = new ArrayList<>(); + float medRatio = medDam / baseDamage; + float smallRatio = smallDam / baseDamage; + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), + Math.max(pfullRad, Math.max(medRad, smallRad)), new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + if (enumUnit.canReach(loc, fullRad)) { + fullhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(1f); + } + } else if (enumUnit.canReach(loc, medRad)) { + medhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(medRatio + * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(medRatio); + } + } else if (enumUnit.canReach(loc, smallRad)) { + smallhits.add(enumUnit); + if (unitSpecificDamageMod != null) { + counts.add(smallRatio + * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + counts.add(smallRatio); + } + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + + float count = 0; + for (float c : counts) { + count += c; + } + float damPerTar = baseDamage * count > theMaxDamage + ? theMaxDamage / (fullhits.size() + medRatio * medhits.size() + smallRatio * smallhits.size()) + : baseDamage; + + for (CUnit hit : fullhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar); + } + } + for (CUnit hit : medhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * medRatio * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar * medRatio); + } + } + for (CUnit hit : smallhits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), hit); + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), + damPerTar * smallRatio * unitSpecificDamageMod.callback(caster, localStore, castId)); + } else { + hit.damage(localStore.game, ftheSource, flags, ftheAttackType, ftheDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damPerTar * smallRatio); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + + } else { + localStore.game.getWorldCollision().enumUnitsInRange(loc.getX(), loc.getY(), + Math.max(Math.max(pfullRad, pmedRad), psmallRad), new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), + enumUnit); + if (validTarget == null || validTarget.callback(caster, localStore, castId)) { + if (enumUnit.canReach(loc, fullRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + baseDamage * unitSpecificDamageMod.callback(caster, localStore, + castId)); + } else { + + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), baseDamage); + } + } else if (enumUnit.canReach(loc, medRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + medDam * unitSpecificDamageMod.callback(caster, localStore, + castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), medDam); + } + } else if (enumUnit.canReach(loc, smallRad)) { + if (extraActions != null) { + for (ABAction action : extraActions) { + action.runAction(caster, localStore, castId); + } + } + if (unitSpecificDamageMod != null) { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), + smallDam * unitSpecificDamageMod.callback(caster, localStore, + castId)); + } else { + enumUnit.damage(localStore.game, ftheSource, flags, ftheAttackType, + ftheDamageType, CWeaponSoundTypeJass.WHOKNOWS.name(), smallDam); + } + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + return false; + } + }); + } + + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageTarget.java new file mode 100644 index 000000000..3741253e9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionDamageTarget.java @@ -0,0 +1,105 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.damage; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CGenericDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; + +public class ABActionDamageTarget implements ABSingleAction { + + private ABUnitCallback source; + private ABUnitCallback target; + private ABBooleanCallback isAttack; + private ABBooleanCallback isRanged; + private ABAttackTypeCallback attackType; + private ABDamageTypeCallback damageType; + private ABFloatCallback damage; + + private ABBooleanCallback ignoreLTEZero; + private ABBooleanCallback damageInvulnerable; + private ABBooleanCallback explodeOnDeath; + private ABBooleanCallback onlyDamageSummons; + private ABBooleanCallback nonlethal; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CAttackType theAttackType = CAttackType.SPELLS; + CDamageType theDamageType = CDamageType.MAGIC; + CDamageFlags flags = new CGenericDamageFlags(false, true); + + float theDamage = damage.callback(caster, localStore, castId); + + if (isAttack != null) { + flags.setAttack(isAttack.callback(caster, localStore, castId)); + } + if (isRanged != null) { + flags.setRanged(isRanged.callback(caster, localStore, castId)); + } + if (damageInvulnerable != null) { + flags.setIgnoreInvulnerable(damageInvulnerable.callback(caster, localStore, castId)); + } + if (explodeOnDeath != null) { + flags.setExplode(explodeOnDeath.callback(caster, localStore, castId)); + } + if (onlyDamageSummons != null) { + flags.setOnlyDamageSummons(onlyDamageSummons.callback(caster, localStore, castId)); + } + if (nonlethal != null) { + flags.setNonlethal(nonlethal.callback(caster, localStore, castId)); + } + if (this.attackType != null) { + theAttackType = this.attackType.callback(caster, localStore, castId); + } + if (this.damageType != null) { + theDamageType = this.damageType.callback(caster, localStore, castId); + } + if (theDamage > 0 || ignoreLTEZero == null || !ignoreLTEZero.callback(caster, localStore, castId)) { + target.callback(caster, localStore, castId).damage(localStore.game, + source.callback(caster, localStore, castId), flags, theAttackType, theDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damage.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String attackExpression = "false"; + String rangedExpression = "true"; + String attackTypeExpression = "ATTACK_TYPE_NORMAL"; + String damageTypeExpression = "DAMAGE_TYPE_MAGIC"; + if (this.isAttack != null) { + attackExpression = this.isAttack.generateJassEquivalent(jassTextGenerator); + } + if (this.isRanged != null) { + rangedExpression = this.isRanged.generateJassEquivalent(jassTextGenerator); + } + if (this.attackType != null) { + attackTypeExpression = this.attackType.generateJassEquivalent(jassTextGenerator); + } + if (this.damageType != null) { + damageTypeExpression = this.damageType.generateJassEquivalent(jassTextGenerator); + } + if (this.ignoreLTEZero == null) { + return "UnitDamageTarget(" + this.source.generateJassEquivalent(jassTextGenerator) + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.damage.generateJassEquivalent(jassTextGenerator) + ", " + attackExpression + ", " + + rangedExpression + ", " + attackTypeExpression + ", " + damageTypeExpression + ", " + + "WEAPON_TYPE_WHOKNOWS)"; + } + return "UnitDamageTargetAU(" + this.source.generateJassEquivalent(jassTextGenerator) + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.damage.generateJassEquivalent(jassTextGenerator) + ", " + attackExpression + ", " + + rangedExpression + ", " + attackTypeExpression + ", " + damageTypeExpression + ", " + + this.ignoreLTEZero.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionHeal.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionHeal.java new file mode 100644 index 000000000..23e9e986c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/damage/ABActionHeal.java @@ -0,0 +1,43 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.damage; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionHeal implements ABSingleAction { + + private ABUnitCallback target; + private ABFloatCallback amount; + private ABBooleanCallback isPercent; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean percent = false; + if (this.isPercent != null) { + percent = this.isPercent.callback(caster, localStore, castId); + } + if (percent) { + final CUnit targetUnit = this.target.callback(caster, localStore, castId); + targetUnit.heal(localStore.game, + this.amount.callback(caster, localStore, castId) * targetUnit.getMaximumLife()); + } else { + this.target.callback(caster, localStore, castId).heal(localStore.game, + this.amount.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String percentExpression = "false"; + if (this.isPercent != null) { + percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); + } + return "HealUnitAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/datastore/ABActionDeleteStoredKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/datastore/ABActionDeleteStoredKey.java new file mode 100644 index 000000000..ab45e6a03 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/datastore/ABActionDeleteStoredKey.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.datastore; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionDeleteStoredKey implements ABAction { + + private ABStringCallback key; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.remove(key.callback(caster, localStore, castId)); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/datastore/ABActionStoreValueLocally.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/datastore/ABActionStoreValueLocally.java new file mode 100644 index 000000000..b800a63dd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/datastore/ABActionStoreValueLocally.java @@ -0,0 +1,75 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.datastore; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionStoreValueLocally implements ABSingleAction { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + private ABCallback valueToStore; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + localStore.put(ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), + castId), this.valueToStore.callback(caster, localStore, castId)); + } else { + localStore.put(ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + this.valueToStore.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String args = jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + this.valueToStore.generateJassEquivalent(jassTextGenerator); + + if (this.valueToStore instanceof ABStringCallback) { + if (this.instanceValue == null) { + return "SetLocalStoreUserCastStringAU(" + args + ")"; + } else { + return "StoreStringLocallyAU(" + args + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + } else if ((this.valueToStore instanceof ABIntegerCallback) || (this.valueToStore instanceof ABIDCallback)) { + if (this.instanceValue == null) { + return "SetLocalStoreUserCastIntegerAU(" + args + ")"; + } else { + return "StoreIntegerLocallyAU(" + args + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + } else if (this.valueToStore instanceof ABBooleanCallback) { + if (this.instanceValue == null) { + return "SetLocalStoreUserCastBooleanAU(" + args + ")"; + } else { + return "StoreBooleanLocallyAU(" + args + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + } else if (this.valueToStore instanceof ABFloatCallback) { + if (this.instanceValue == null) { + return "SetLocalStoreUserCastRealAU(" + args + ")"; + } else { + return "StoreRealLocallyAU(" + args + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + } else { + if (this.instanceValue == null) { + return "SetLocalStoreUserCastHandleAU(" + args + ")"; + } else { + return "StoreHandleLocallyAU(" + args + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionCreateDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionCreateDestructable.java new file mode 100644 index 000000000..669c159ef --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionCreateDestructable.java @@ -0,0 +1,55 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateDestructable implements ABAction { + + private ABIDCallback id; + private ABLocationCallback location; + private ABFloatCallback facing; + private ABFloatCallback scale; + private ABIntegerCallback variation; + + private ABBooleanCallback playBirthAnim; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + float theFacing = 0; + float theScale = 1; + int theVariation = 0; + boolean play = true; + if (this.facing != null) { + theFacing = this.facing.callback(caster, localStore, castId); + } + if (this.scale != null) { + theScale = this.scale.callback(caster, localStore, castId); + } + if (this.variation != null) { + theVariation = this.variation.callback(caster, localStore, castId); + } + if (this.playBirthAnim != null) { + play = this.playBirthAnim.callback(caster, localStore, castId); + } + final AbilityPointTarget location = this.location.callback(caster, localStore, castId); + final CDestructable createdDest = localStore.game.createDestructable(this.id.callback(caster, localStore, castId), + location.getX(), location.getY(), theFacing, theScale, theVariation); + if (play) { + createdDest.getUnitAnimationListener().playAnimation(true, PrimaryTag.BIRTH, SequenceUtils.EMPTY, 1.0f, + true); + } + localStore.put(ABLocalStoreKeys.LASTCREATEDDESTRUCTABLE, createdDest); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionDamageDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionDamageDestructable.java new file mode 100644 index 000000000..cff5ef93a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionDamageDestructable.java @@ -0,0 +1,83 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructable; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CGenericDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; + +public class ABActionDamageDestructable implements ABSingleAction { + + private ABUnitCallback source; + private ABDestructableCallback target; + private ABBooleanCallback isAttack; + private ABBooleanCallback isRanged; + private ABAttackTypeCallback attackType; + private ABDamageTypeCallback damageType; + private ABFloatCallback damage; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + boolean isItAttack = false; + boolean isItRanged = true; + CAttackType theAttackType = CAttackType.SPELLS; + CDamageType theDamageType = CDamageType.MAGIC; + + if (this.isAttack != null) { + isItAttack = this.isAttack.callback(caster, localStore, castId); + } + if (this.isRanged != null) { + isItRanged = this.isRanged.callback(caster, localStore, castId); + } + if (this.attackType != null) { + theAttackType = this.attackType.callback(caster, localStore, castId); + } + if (this.damageType != null) { + theDamageType = this.damageType.callback(caster, localStore, castId); + } + + target.callback(caster, localStore, castId).damage(localStore.game, source.callback(caster, localStore, castId), + new CGenericDamageFlags(isItAttack, isItRanged), theAttackType, theDamageType, + CWeaponSoundTypeJass.WHOKNOWS.name(), damage.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + // TODO Auto-generated method stub +// native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean + + String attackExpression = "false"; + if (this.isAttack != null) { + attackExpression = this.isAttack.generateJassEquivalent(jassTextGenerator); + } + String rangedExpression = "true"; + if (this.isRanged != null) { + rangedExpression = this.isRanged.generateJassEquivalent(jassTextGenerator); + } + String attackTypeExpression = "ATTACK_TYPE_SPELLS"; + String damageTypeExpression = "DAMAGE_TYPE_MAGIC"; + if (this.attackType != null) { + attackTypeExpression = this.attackType.generateJassEquivalent(jassTextGenerator); + } + if (this.damageType != null) { + damageTypeExpression = this.damageType.generateJassEquivalent(jassTextGenerator); + } + + return "UnitDamageTarget(" + this.source.generateJassEquivalent(jassTextGenerator) + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.damage.generateJassEquivalent(jassTextGenerator) + ", " + attackExpression + ", " + + rangedExpression + ", " + attackTypeExpression + ", " + damageTypeExpression + + ", WEAPON_TYPE_WHOKNOWS)"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionKillDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionKillDestructable.java new file mode 100644 index 000000000..f49b9d8b5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionKillDestructable.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionKillDestructable implements ABAction { + + private ABDestructableCallback dest; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + dest.callback(caster, localStore, castId).setLife(localStore.game, 0); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionRemoveDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionRemoveDestructable.java new file mode 100644 index 000000000..b62935bd7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructable/ABActionRemoveDestructable.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveDestructable implements ABAction { + + private ABDestructableCallback dest; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + localStore.game.removeDestructable(dest.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionAddDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionAddDestructableBuff.java new file mode 100644 index 000000000..373bdd4df --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionAddDestructableBuff.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructablebuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff.ABDestructableBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddDestructableBuff implements ABSingleAction { + + private ABDestructableCallback target; + private ABDestructableBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CDestructableBuff ability = this.buff.callback(caster, localStore, castId); + this.target.callback(caster, localStore, castId).add(localStore.game, ability); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AddDestructableBuff(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionCreateDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionCreateDestructableBuff.java new file mode 100644 index 000000000..1f51f1471 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionCreateDestructableBuff.java @@ -0,0 +1,58 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructablebuff; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateDestructableBuff implements ABSingleAction { + + private ABIDCallback buffId; + private List onAddActions; + private List onRemoveActions; + private List onDeathActions; + + private ABBooleanCallback dispellable; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean isDispellable = false; + if (dispellable != null) { + isDispellable = dispellable.callback(caster, localStore, castId); + } + CDestructableBuff ability = new ABDestructableBuff(localStore.game.getHandleIdAllocator().createId(), + buffId.callback(caster, localStore, castId), + castId != ABConstants.NO_CAST_ID ? localStore.getIntOrDefault( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), + localStore.originAbility.getLevel()) : localStore.originAbility.getLevel(), + localStore, onAddActions, onRemoveActions, onDeathActions, castId, caster, isDispellable); + + localStore.put(ABLocalStoreKeys.LASTCREATEDDESTBUFF, ability); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String addFunctionName = jassTextGenerator.createAnonymousFunction(this.onAddActions, + "CreateDestructableBuffAU_OnAddActions"); + final String removeFunctionName = jassTextGenerator.createAnonymousFunction(this.onRemoveActions, + "CreateDestructableBuffAU_OnRemoveActions"); + final String deathFunctionName = jassTextGenerator.createAnonymousFunction(this.onDeathActions, + "CreateDestructableBuffAU_OnDeathActions"); + + return "CreateDestructableBuffAU(" + jassTextGenerator.getCaster() + ", " + + this.buffId.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + + jassTextGenerator.functionPointerByName(addFunctionName) + ", " + + jassTextGenerator.functionPointerByName(removeFunctionName) + ", " + + jassTextGenerator.functionPointerByName(deathFunctionName) + ", " + jassTextGenerator.getCastId() + + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionDispelDestructableBuffs.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionDispelDestructableBuffs.java new file mode 100644 index 000000000..db2a1fd54 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionDispelDestructableBuffs.java @@ -0,0 +1,46 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructablebuff; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionDispelDestructableBuffs implements ABAction { + + private ABUnitCallback source; + private ABDestructableCallback dest; + private ABBooleanCallback filter; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = caster; + if (source != null) { + theCaster = source.callback(theCaster, localStore, castId); + } + CDestructable theTarget = dest.callback(theCaster, localStore, castId); + + if (theTarget != null && theTarget.getBuffs() != null) { + List toRemove = new ArrayList<>(); + for (CDestructableBuff buff : theTarget.getBuffs()) { + localStore.put(ABLocalStoreKeys.ENUMDESTBUFF, buff); + if (filter != null && filter.callback(theCaster, localStore, castId)) { + toRemove.add(buff); + } + } + localStore.remove(ABLocalStoreKeys.ENUMDESTBUFF); + + for (CDestructableBuff buff : toRemove) { + theTarget.remove(localStore.game, buff); + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionRemoveDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionRemoveDestructableBuff.java new file mode 100644 index 000000000..d3ad89f23 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/destructablebuff/ABActionRemoveDestructableBuff.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructablebuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff.ABDestructableBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveDestructableBuff implements ABSingleAction { + + private ABDestructableCallback target; + private ABDestructableBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CDestructableBuff ability = this.buff.callback(caster, localStore, castId); + this.target.callback(caster, localStore, castId).remove(localStore.game, ability); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RemoveDestructableBuff(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionCreateTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionCreateTimeOfDayEvent.java new file mode 100644 index 000000000..acdecca9c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionCreateTimeOfDayEvent.java @@ -0,0 +1,66 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.timeofday; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; + +public class ABActionCreateTimeOfDayEvent implements ABSingleAction { + + private List actions; + private ABFloatCallback startTime; + private ABFloatCallback endTime; + + private ABStringCallback equalityId; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + String eqId = null; + float st = 0; + float et = Float.MAX_VALUE; + if (this.equalityId != null) { + eqId = this.equalityId.callback(caster, localStore, castId); + } + if (this.startTime != null) { + st = this.startTime.callback(caster, localStore, castId); + } + if (this.endTime != null) { + et = this.endTime.callback(caster, localStore, castId); + } + + final ABTimeOfDayEvent event = new ABTimeOfDayEvent(caster, localStore, castId, this.actions, st, et, eqId); + + localStore.put(ABLocalStoreKeys.LASTCREATEDTODEVENT, event); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String actionsFuncName = jassTextGenerator.createAnonymousFunction(this.actions, + "CreateABTimeOfDayEventAU_Actions"); + + String startTimeExpression = "0"; + String endTimeExpression = Long.toString(Long.MAX_VALUE) + ".0"; + String equalityIdExpression = null; + if (this.equalityId != null) { + equalityIdExpression = this.equalityId.generateJassEquivalent(jassTextGenerator); + } + if (this.startTime != null) { + startTimeExpression = this.startTime.generateJassEquivalent(jassTextGenerator); + } + if (this.endTime != null) { + endTimeExpression = this.endTime.generateJassEquivalent(jassTextGenerator); + } + + return "CreateABTimeOfDayEventAU(" + jassTextGenerator.functionPointerByName(actionsFuncName) + ", " + + startTimeExpression + ", " + endTimeExpression + ", " + this.equalityId + ", " + + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + ", " + + jassTextGenerator.getCastId() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionRegisterTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionRegisterTimeOfDayEvent.java new file mode 100644 index 000000000..a8d4cc34f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionRegisterTimeOfDayEvent.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.timeofday; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent.ABTimeOfDayEventCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRegisterTimeOfDayEvent implements ABSingleAction { + + private ABTimeOfDayEventCallback event; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.game.registerTimeOfDayEvent(this.event.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RegisterABTimeOfDayEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionRegisterUniqueTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionRegisterUniqueTimeOfDayEvent.java new file mode 100644 index 000000000..f5dcbab68 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionRegisterUniqueTimeOfDayEvent.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.timeofday; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent.ABTimeOfDayEventCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; + +public class ABActionRegisterUniqueTimeOfDayEvent implements ABSingleAction { + + private ABTimeOfDayEventCallback event; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABTimeOfDayEvent ev = this.event.callback(caster, localStore, castId); + if (!localStore.game.isTimeOfDayEventRegistered(ev)) { + localStore.game.registerTimeOfDayEvent(ev); + } + + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RegisterUniqueABTimeOfDayEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionUnregisterTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionUnregisterTimeOfDayEvent.java new file mode 100644 index 000000000..c9260fe0c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/timeofday/ABActionUnregisterTimeOfDayEvent.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.timeofday; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent.ABTimeOfDayEventCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionUnregisterTimeOfDayEvent implements ABSingleAction { + + private ABTimeOfDayEventCallback event; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + localStore.game.unregisterTimeOfDayEvent(this.event.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "UnregisterABTimeOfDayEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionCreateWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionCreateWidgetEvent.java new file mode 100644 index 000000000..8a320542f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionCreateWidgetEvent.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.widget; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget.ABWidgetCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABActionCreateWidgetEvent implements ABAction { + + private ABWidgetCallback widget; + private ABBooleanCallback condition; + private List actions; + + private JassGameEventsWar3 eventType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + + final ABWidgetEvent event = new ABWidgetEvent(caster, localStore, castId, + this.widget.callback(caster, localStore, castId), this.eventType, this.condition, this.actions); + + localStore.put(ABLocalStoreKeys.LASTCREATEDWIDEVENT, event); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionRegisterWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionRegisterWidgetEvent.java new file mode 100644 index 000000000..ad48c6e6b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionRegisterWidgetEvent.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.widget; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent.ABWidgetEventCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; + +public class ABActionRegisterWidgetEvent implements ABSingleAction { + + private ABWidgetEventCallback event; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + ABWidgetEvent theEvent = event.callback(caster, localStore, castId); + theEvent.getWidget().addEvent(theEvent); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RegisterABWidgetEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionUnregisterWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionUnregisterWidgetEvent.java new file mode 100644 index 000000000..8b6b5e26d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/events/widget/ABActionUnregisterWidgetEvent.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.widget; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent.ABWidgetEventCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; + +public class ABActionUnregisterWidgetEvent implements ABSingleAction { + + private ABWidgetEventCallback event; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + ABWidgetEvent theEvent = event.callback(caster, localStore, castId); + theEvent.remove(); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "UnregisterABWidgetEvent(" + this.event.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/floatingtext/ABActionCreateFloatingTextOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/floatingtext/ABActionCreateFloatingTextOnUnit.java new file mode 100644 index 000000000..41f92b668 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/floatingtext/ABActionCreateFloatingTextOnUnit.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.floatingtext; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.TextTagConfigType; + +public class ABActionCreateFloatingTextOnUnit implements ABSingleAction { + + private ABUnitCallback target; + private TextTagConfigType textType; + private ABStringCallback message; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.game.spawnTextTag(this.target.callback(caster, localStore, castId), caster.getPlayerIndex(), + this.textType, this.message.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "CreateTextTagFromConfig(" + this.target.generateJassEquivalent(jassTextGenerator) + + ", TEXT_TAG_CONFIG_TYPE_" + this.textType.name() + ", " + + this.message.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/floatingtext/ABActionCreateNumericFloatingTextOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/floatingtext/ABActionCreateNumericFloatingTextOnUnit.java new file mode 100644 index 000000000..69cf04b8f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/floatingtext/ABActionCreateNumericFloatingTextOnUnit.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.floatingtext; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.TextTagConfigType; + +public class ABActionCreateNumericFloatingTextOnUnit implements ABSingleAction { + + private ABUnitCallback target; + private TextTagConfigType textType; + private ABFloatCallback amount; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + float theAmount = 0; + if (this.amount != null) { + theAmount = this.amount.callback(caster, localStore, castId); + } + + localStore.game.spawnTextTag(this.target.callback(caster, localStore, castId), caster.getPlayerIndex(), + this.textType, (int) (theAmount)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "CreateIntTextTagFromConfig(" + this.target.generateJassEquivalent(jassTextGenerator) + + ", TEXT_TAG_CONFIG_TYPE_" + this.textType.name() + ", R2I(" + + this.amount.generateJassEquivalent(jassTextGenerator) + "))"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectAtLocation.java new file mode 100644 index 000000000..d19c05e74 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectAtLocation.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateSpellEffectAtLocation implements ABAction { + + private ABLocationCallback location; + private ABFloatCallback facing; + private ABIDCallback id; + private CEffectType effectType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final AbilityPointTarget loc = this.location.callback(caster, localStore, castId); + float dir = 0; + if (this.facing != null) { + dir = this.facing.callback(caster, localStore, castId); + } + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + final SimulationRenderComponent ret = localStore.game.spawnSpellEffectOnPoint(loc.getX(), loc.getY(), dir, theId, + this.effectType, 0); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectAtPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectAtPoint.java new file mode 100644 index 000000000..f468f1616 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectAtPoint.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateSpellEffectAtPoint implements ABAction { + + private ABFloatCallback x; + private ABFloatCallback y; + private ABFloatCallback facing; + private ABIDCallback id; + private CEffectType effectType; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + float dir = 0; + if (facing != null) { + dir = facing.callback(caster, localStore, castId); + } + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + SimulationRenderComponent ret = localStore.game.spawnSpellEffectOnPoint(x.callback(caster, localStore, castId), + y.callback(caster, localStore, castId), dir, theId, effectType, 0); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectOnUnit.java new file mode 100644 index 000000000..992607264 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateSpellEffectOnUnit.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateSpellEffectOnUnit implements ABAction { + + private ABUnitCallback target; + private ABIDCallback id; + private CEffectType effectType; + private ABIntegerCallback index; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + if (index == null) { + SimulationRenderComponent ret = localStore.game.createPersistentSpellEffectOnUnit( + (target.callback(caster, localStore, castId)), theId, this.effectType); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } else { + SimulationRenderComponent ret = localStore.game.createPersistentSpellEffectOnUnit( + (target.callback(caster, localStore, castId)), this.id.callback(caster, localStore, castId), + this.effectType, this.index.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectAtLocation.java new file mode 100644 index 000000000..415f2a03f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectAtLocation.java @@ -0,0 +1,47 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreateTemporarySpellEffectAtLocation implements ABSingleAction { + + private ABLocationCallback location; + private ABFloatCallback facing; + private ABIDCallback id; + private CEffectType effectType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget loc = this.location.callback(caster, localStore, castId); + float dir = 0; + if (this.facing != null) { + dir = this.facing.callback(caster, localStore, castId); + } + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + localStore.game.spawnTemporarySpellEffectOnPoint(loc.getX(), loc.getY(), dir, theId, this.effectType, 0); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.facing != null) { + throw new UnsupportedOperationException("AddSpellEffectByIdLoc with facing"); + } + return "DestroyEffect(AddSpellEffectByIdLoc(" + this.id.generateJassEquivalent(jassTextGenerator) + + ", EFFECT_TYPE_" + this.effectType.name() + ", " + + this.location.generateJassEquivalent(jassTextGenerator) + ", null))"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectAtPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectAtPoint.java new file mode 100644 index 000000000..4da936b67 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectAtPoint.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreateTemporarySpellEffectAtPoint implements ABSingleAction { + + private ABFloatCallback x; + private ABFloatCallback y; + private ABFloatCallback facing; + private ABIDCallback id; + private CEffectType effectType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + float dir = 0; + if (this.facing != null) { + dir = this.facing.callback(caster, localStore, castId); + } + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + localStore.game.spawnTemporarySpellEffectOnPoint(this.x.callback(caster, localStore, castId), + this.y.callback(caster, localStore, castId), dir, + theId, this.effectType, 0); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.facing != null) { + throw new UnsupportedOperationException("AddSpellEffectByIdLoc with facing"); + } + return "DestroyEffect(AddSpellEffectById(" + this.id.generateJassEquivalent(jassTextGenerator) + + ", EFFECT_TYPE_" + this.effectType.name() + ", " + this.x.generateJassEquivalent(jassTextGenerator) + + ", " + this.y.generateJassEquivalent(jassTextGenerator) + ", null))"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectOnUnit.java new file mode 100644 index 000000000..aed5a7568 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionCreateTemporarySpellEffectOnUnit.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreateTemporarySpellEffectOnUnit implements ABSingleAction { + + private ABUnitCallback target; + private ABIDCallback id; + private CEffectType effectType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + localStore.game.createTemporarySpellEffectOnUnit((this.target.callback(caster, localStore, castId)), theId, + this.effectType); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "DestroyEffect(AddSpellEffectTargetById(" + this.id.generateJassEquivalent(jassTextGenerator) + + ", EFFECT_TYPE_" + this.effectType.name() + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", null))"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionRemoveEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionRemoveEffect.java new file mode 100644 index 000000000..b6217b49e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/ABActionRemoveEffect.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx.ABFXCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveEffect implements ABSingleAction { + + private ABFXCallback effect; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + this.effect.callback(caster, localStore, castId).remove(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "DestroyEffect(" + this.effect.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/group/ABActionCreateGroupEffectAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/group/ABActionCreateGroupEffectAtLocation.java new file mode 100644 index 000000000..2255cfde0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/group/ABActionCreateGroupEffectAtLocation.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.group; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects.ABGroupEffect; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreateGroupEffectAtLocation implements ABAction { + + private ABLocationCallback location; + private ABFloatCallback radius; + private ABIDCallback id; + private CEffectType effectType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final AbilityPointTarget loc = this.location.callback(caster, localStore, castId); + float rad = radius.callback(caster, localStore, castId); + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + final ABGroupEffect ret = new ABGroupEffect(loc, rad, theId, effectType); + localStore.game.registerTimer(ret); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/lightning/ABActionCreateLightningEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/lightning/ABActionCreateLightningEffect.java new file mode 100644 index 000000000..03e49f594 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/lightning/ABActionCreateLightningEffect.java @@ -0,0 +1,46 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.lightning; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; + +public class ABActionCreateLightningEffect implements ABAction { + + private ABUnitCallback origin; + private ABUnitCallback target; + private ABIDCallback id; + private ABFloatCallback duration; + private ABIntegerCallback index; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + int i = 0; + if (index != null) { + i = index.callback(caster, localStore, castId); + } + War3ID theId = null; + if (id == null) { + theId = localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } else { + theId = id.callback(caster, localStore, castId); + } + if (duration != null) { + SimulationRenderComponentLightning ret = localStore.game.createAbilityLightning( + origin.callback(caster, localStore, castId), theId, i, + target.callback(caster, localStore, castId), + duration.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDLIGHTNING, ret); + } else { + SimulationRenderComponentLightning ret = localStore.game.createAbilityLightning( + origin.callback(caster, localStore, castId), theId, i, + target.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDLIGHTNING, ret); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/lightning/ABActionRemoveLightningEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/lightning/ABActionRemoveLightningEffect.java new file mode 100644 index 000000000..410806b94 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/lightning/ABActionRemoveLightningEffect.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.lightning; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx.ABLightningCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveLightningEffect implements ABAction { + + private ABLightningCallback effect; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + effect.callback(caster, localStore, castId).remove(); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateLoopingSoundEffectAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateLoopingSoundEffectAtLocation.java new file mode 100644 index 000000000..5d1737ac6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateLoopingSoundEffectAtLocation.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.sound; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateLoopingSoundEffectAtLocation implements ABAction { + + private ABLocationCallback location; + private ABIDCallback id; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + SimulationRenderComponent ret = localStore.game.locationSoundEffectEvent(loc.getX(), loc.getY(), + this.id.callback(caster, localStore, castId), true); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateLoopingSoundEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateLoopingSoundEffectOnUnit.java new file mode 100644 index 000000000..890fe1843 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateLoopingSoundEffectOnUnit.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.sound; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateLoopingSoundEffectOnUnit implements ABAction { + + private ABUnitCallback unit; + private ABIDCallback id; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + SimulationRenderComponent ret = localStore.game.unitLoopSoundEffectEvent( + (unit.callback(caster, localStore, castId)), this.id.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateSoundEffectAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateSoundEffectAtLocation.java new file mode 100644 index 000000000..6483deffc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateSoundEffectAtLocation.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.sound; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateSoundEffectAtLocation implements ABAction { + + private ABLocationCallback location; + private ABIDCallback id; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + SimulationRenderComponent ret = localStore.game.locationSoundEffectEvent(loc.getX(), loc.getY(), + this.id.callback(caster, localStore, castId), false); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateSoundEffectOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateSoundEffectOnUnit.java new file mode 100644 index 000000000..39fc12b61 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/sound/ABActionCreateSoundEffectOnUnit.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.sound; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateSoundEffectOnUnit implements ABAction { + + private ABUnitCallback unit; + private ABIDCallback id; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + SimulationRenderComponent ret = localStore.game.unitSoundEffectEvent( + (unit.callback(caster, localStore, castId)), this.id.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, ret); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/splat/ABActionCreateUberSplat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/splat/ABActionCreateUberSplat.java new file mode 100644 index 000000000..795771398 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/splat/ABActionCreateUberSplat.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.splat; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABActionCreateUberSplat implements ABAction { + + private ABIDCallback id; + private ABLocationCallback location; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + SimulationRenderComponent splat = localStore.game.createStaticUberSplat(loc.getX(), loc.getY(), + id.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, splat); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainBowlAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainBowlAtLocation.java new file mode 100644 index 000000000..13ebc8769 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainBowlAtLocation.java @@ -0,0 +1,57 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.terrain; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects.ABTerrainBowlEffect; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects.ABTerrainEffect; + +public class ABActionCreateTerrainBowlAtLocation implements ABAction { + + private ABLocationCallback location; + private ABFloatCallback radius; + private ABFloatCallback depth; + private ABFloatCallback sinkTime; + private ABFloatCallback staticTime; + private ABFloatCallback fillTime; + + private ABFloatCallback stopDuration; + private ABFloatCallback startDepth; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget loc = this.location.callback(caster, localStore, castId); + final float rad = radius.callback(caster, localStore, castId); + final float theDepth = -1 * depth.callback(caster, localStore, castId); + float startDep = 0; + if (startDepth != null) { + startDep = startDepth.callback(caster, localStore, castId); + } + + float snkTm = 0; + float sttTm = 0; + float fllTm = 0; + float stpTm = 0; + if (sinkTime != null) { + snkTm = sinkTime.callback(caster, localStore, castId); + } + if (staticTime != null) { + sttTm = staticTime.callback(caster, localStore, castId); + } + if (fillTime != null) { + fllTm = fillTime.callback(caster, localStore, castId); + } + if (stopDuration != null) { + stpTm = stopDuration.callback(caster, localStore, castId); + } + + ABTerrainEffect fx = new ABTerrainBowlEffect(localStore.game, loc, rad, theDepth, snkTm, sttTm, fllTm, stpTm, + startDep); + localStore.game.registerTimer(fx); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, fx); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainRippleAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainRippleAtLocation.java new file mode 100644 index 000000000..46f41425a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainRippleAtLocation.java @@ -0,0 +1,66 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.terrain; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects.ABTerrainEffect; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects.ABTerrainRippleEffect; + +public class ABActionCreateTerrainRippleAtLocation implements ABAction { + + private ABLocationCallback location; + + private ABFloatCallback startRadius; + private ABFloatCallback finalRadius; + private ABFloatCallback radius; + + private ABFloatCallback depth; + + private ABFloatCallback duration; + private ABIntegerCallback rippleCount; + + private ABFloatCallback period; + + private ABIntegerCallback spaceWaves; + private ABIntegerCallback timeWaves; + private ABBooleanCallback onlyNegative; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget loc = this.location.callback(caster, localStore, castId); + + float startRad = 0; + float endRad = 0; + if (radius != null) { + startRad = radius.callback(caster, localStore, castId); + endRad = startRad; + } else { + startRad = startRadius.callback(caster, localStore, castId); + endRad = finalRadius.callback(caster, localStore, castId); + } + final float theDepth = depth.callback(caster, localStore, castId); + final float thePeriod = period.callback(caster, localStore, castId); + final int swaves = spaceWaves.callback(caster, localStore, castId); + final int twaves = timeWaves.callback(caster, localStore, castId); + final boolean onlyNeg = onlyNegative.callback(caster, localStore, castId); + + int intervals = 0; + if (rippleCount != null) { + intervals = rippleCount.callback(caster, localStore, castId); + } else { + final float dur = duration.callback(caster, localStore, castId); + intervals = ((int) dur) * 2; + } + + ABTerrainEffect fx = new ABTerrainRippleEffect(localStore.game, loc, startRad, endRad, theDepth, thePeriod, + intervals, swaves, twaves, onlyNeg); + localStore.game.registerTimer(fx); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, fx); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainWaveAtLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainWaveAtLocation.java new file mode 100644 index 000000000..5e05136f5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionCreateTerrainWaveAtLocation.java @@ -0,0 +1,44 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.terrain; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects.ABTerrainEffect; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects.ABTerrainWaveEffect; + +public class ABActionCreateTerrainWaveAtLocation implements ABAction { + + private ABLocationCallback startLocation; + private ABLocationCallback targetLocation; + private ABFloatCallback radius; + private ABFloatCallback depth; + private ABFloatCallback distance; + private ABFloatCallback speed; + private ABIntegerCallback trailTime; + private ABIntegerCallback count; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final AbilityPointTarget loc = this.startLocation.callback(caster, localStore, castId); + final AbilityPointTarget tarloc = this.targetLocation.callback(caster, localStore, castId); + final float rad = radius.callback(caster, localStore, castId); + final float theDepth = depth.callback(caster, localStore, castId); + final float dist = distance.callback(caster, localStore, castId); + final float spd = speed.callback(caster, localStore, castId); + final int trlTime = trailTime.callback(caster, localStore, castId); + int cnt = 1; + if (count != null) { + cnt = count.callback(caster, localStore, castId); + } + + ABTerrainEffect fx = new ABTerrainWaveEffect(localStore.game, loc, tarloc, rad, theDepth, dist, spd, trlTime, cnt); + localStore.game.registerTimer(fx); + localStore.put(ABLocalStoreKeys.LASTCREATEDFX, fx); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionModifyTerrainVertex.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionModifyTerrainVertex.java new file mode 100644 index 000000000..e6089812f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/fx/terrain/ABActionModifyTerrainVertex.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.terrain; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionModifyTerrainVertex implements ABAction { + + private ABLocationCallback location; + private ABFloatCallback dz; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget loc = this.location.callback(caster, localStore, castId); + localStore.game.adjustTerrain(loc.x, loc.y, dz.callback(caster, localStore, castId)); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/gamestate/ABActionSetFalseTimeOfDay.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/gamestate/ABActionSetFalseTimeOfDay.java new file mode 100644 index 000000000..55a31081a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/gamestate/ABActionSetFalseTimeOfDay.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.gamestate; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetFalseTimeOfDay implements ABSingleAction { + + private ABIntegerCallback hour; + private ABIntegerCallback minute; + private ABFloatCallback duration; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + localStore.game.addFalseTimeOfDay(this.hour.callback(caster, localStore, castId), + this.minute.callback(caster, localStore, castId), + this.duration.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetFalseTimeOfDay(" + this.hour.generateJassEquivalent(jassTextGenerator) + ", " + + this.minute.generateJassEquivalent(jassTextGenerator) + ", " + + this.duration.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/item/ABActionChargeItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/item/ABActionChargeItem.java new file mode 100644 index 000000000..70069e043 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/item/ABActionChargeItem.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.item; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionChargeItem implements ABSingleAction { + + private ABItemCallback item; + private ABBooleanCallback checkForPerish; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CItem it = null; + if (this.item == null) { + final ABAbilityBuilderAbility ability = localStore.originAbility; + + it = ability.getItem(); + } else { + it = this.item.callback(caster, localStore, castId); + } + + it.setCharges(it.getCharges() - 1); + if ((this.checkForPerish != null) && this.checkForPerish.callback(caster, localStore, castId) + && it.getItemType().isPerishable() && (it.getCharges() == 0)) { + it.forceDropIfHeld(localStore.game); + localStore.game.removeItem(it); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String itemExpression = "null"; + if (this.item != null) { + itemExpression = this.item.generateJassEquivalent(jassTextGenerator); + } + String checkForPerishExpression = "false"; + if (this.checkForPerish != null) { + checkForPerishExpression = this.checkForPerish.generateJassEquivalent(jassTextGenerator); + } + return "ChargeItemAU(" + itemExpression + ", " + checkForPerishExpression + ", " + + jassTextGenerator.getTriggerLocalStore() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/item/ABActionTransformItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/item/ABActionTransformItem.java new file mode 100644 index 000000000..9dfdc03f5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/item/ABActionTransformItem.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.item; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionTransformItem implements ABAction { + + private ABItemCallback item; + private ABIDCallback newType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CItem it = this.item.callback(caster, localStore, castId); + War3ID type = newType.callback(caster, localStore, castId); + it.setTypeId(localStore.game, type); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/destructable/ABActionIterateDestructablesInRangeOfLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/destructable/ABActionIterateDestructablesInRangeOfLocation.java new file mode 100644 index 000000000..ee8984664 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/destructable/ABActionIterateDestructablesInRangeOfLocation.java @@ -0,0 +1,78 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.destructable; + +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructableEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionIterateDestructablesInRangeOfLocation implements ABAction { + + private static final Rectangle recycleRect = new Rectangle(); + + private ABLocationCallback location; + private ABFloatCallback range; + private List iterationActions; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget target = this.location.callback(caster, localStore, castId); + final Float rangeVal = this.range.callback(caster, localStore, castId); + + recycleRect.set(target.getX() - rangeVal, target.getY() - rangeVal, rangeVal * 2, rangeVal * 2); + localStore.game.getWorldCollision().enumDestructablesInRect(recycleRect, new CDestructableEnumFunction() { + @Override + public boolean call(final CDestructable enumDest) { + if (enumDest.distance(target.getX(), target.getY()) < rangeVal) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMDESTRUCTABLE, castId), enumDest); + for (final ABAction iterationAction : ABActionIterateDestructablesInRangeOfLocation.this.iterationActions) { + iterationAction.runAction(caster, localStore, castId); + } + } + return false; + } + }); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMDESTRUCTABLE, castId)); + } + + @Override + public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { + final List modifiedActionList = new ArrayList<>(this.iterationActions); + modifiedActionList.add(0, new JassTextGeneratorCallStmt() { + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetLocalStoreDestructableHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMDESTRUCTABLE + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetEnumDestructable()" + ")"; + } + }); + final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, + "DestsInRangeEnumActions"); + + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + // TODO this BJ function uses <= range instead of < range + sb.append("call EnumDestructablesInCircleBJ(" + this.range.generateJassEquivalent(jassTextGenerator) + ", " + + this.location.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.functionPointerByName(iterationActionsName) + ")"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMDESTRUCTABLE + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInGroup.java similarity index 83% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInGroup.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInGroup.java index 76763925a..0fef25488 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInGroup.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInGroup.java @@ -1,19 +1,18 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Set; import com.etheller.warsmash.parsers.jass.JassTextGenerator; import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitgroupcallbacks.ABUnitGroupCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup.ABUnitGroupCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; public class ABActionIterateUnitsInGroup implements ABAction { private static final boolean ALLOW_BREAK_JASS = true; @@ -22,21 +21,20 @@ public class ABActionIterateUnitsInGroup implements ABAction { private List iterationActions; @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Set unitSet = this.unitGroup.callback(game, caster, localStore, castId); + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final Set unitSet = this.unitGroup.callback(caster, localStore, castId); final List unitList = new ArrayList<>(unitSet); for (final CUnit enumUnit : unitList) { - localStore.put(ABLocalStoreKeys.ENUMUNIT + castId, enumUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), enumUnit); for (final ABAction iterationAction : this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); + iterationAction.runAction(caster, localStore, castId); } final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); if ((brk != null) && brk) { break; } } - localStore.remove(ABLocalStoreKeys.ENUMUNIT + castId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); } @Override @@ -118,8 +116,7 @@ public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerat sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); jassTextGenerator.println(sb.toString()); - } - else { + } else { // else use ForGroup final List modifiedActionList = new ArrayList<>(this.iterationActions); modifiedActionList.add(0, new JassTextGeneratorCallStmt() { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInQueue.java similarity index 78% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInQueue.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInQueue.java index 1b4e3cf94..bffa962fb 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInQueue.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInQueue.java @@ -1,17 +1,16 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Queue; import com.etheller.warsmash.parsers.jass.JassTextGenerator; import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitqueue.ABUnitQueueCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue.ABUnitQueueCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; public class ABActionIterateUnitsInQueue implements ABAction { @@ -19,21 +18,20 @@ public class ABActionIterateUnitsInQueue implements ABAction { private List iterationActions; @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { - final Queue unitQueue = this.queue.callback(game, caster, localStore, castId); + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final Queue unitQueue = this.queue.callback(caster, localStore, castId); final List unitList = new ArrayList<>(unitQueue); for (final CUnit enumUnit : unitList) { - localStore.put(ABLocalStoreKeys.ENUMUNIT + castId, enumUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), enumUnit); for (final ABAction iterationAction : this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); + iterationAction.runAction(caster, localStore, castId); } final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); if ((brk != null) && brk) { break; } } - localStore.remove(ABLocalStoreKeys.ENUMUNIT + castId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfLocationMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfLocationMatchingCondition.java new file mode 100644 index 000000000..33f04e584 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfLocationMatchingCondition.java @@ -0,0 +1,133 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit; + +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionIterateUnitsInRangeOfLocationMatchingCondition implements ABAction { + + private static final Rectangle recycleRect = new Rectangle(); + + private ABLocationCallback location; + private ABFloatCallback range; + private List iterationActions; + private ABBooleanCallback condition; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget target = this.location.callback(caster, localStore, castId); + final Float rangeVal = this.range.callback(caster, localStore, castId); + + recycleRect.set(target.getX() - rangeVal, target.getY() - rangeVal, rangeVal * 2, rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (enumUnit.canReach(target, rangeVal)) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), enumUnit); + if (condition == null || condition.callback(caster, localStore, castId)) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), enumUnit); + for (ABAction iterationAction : iterationActions) { + iterationAction.runAction(caster, localStore, castId); + } + } + } + return false; + } + }); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + } + + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final List modifiedActionList = new ArrayList<>(this.iterationActions); + modifiedActionList.add(0, new JassTextGeneratorCallStmt() { + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; + } + }); + if (this.condition != null) { + modifiedActionList.add(0, new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ")"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("if not "); + sb.append(ABActionIterateUnitsInRangeOfLocationMatchingCondition.this.condition + .generateJassEquivalent(jassTextGenerator)); + sb.append(" then"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent + 1, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } + }); + } + modifiedActionList.add(new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + } + }); + final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, + "UnitsInRangeOfLocEnumActions"); + + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("// TODO: use a global filter"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call GroupEnumUnitsInRangeOfLoc(au_tempGroup, " + + this.location.generateJassEquivalent(jassTextGenerator) + ", " + + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" + + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfLocationMatchingConditionWithSort.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfLocationMatchingConditionWithSort.java new file mode 100644 index 000000000..b9eef1335 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfLocationMatchingConditionWithSort.java @@ -0,0 +1,147 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit; + +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitComparator; + +public class ABActionIterateUnitsInRangeOfLocationMatchingConditionWithSort implements ABAction { + + private static final Rectangle recycleRect = new Rectangle(); + + private ABLocationCallback location; + private ABFloatCallback range; + private List iterationActions; + private ABBooleanCallback condition; + + private ABIntegerCallback sort; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget target = this.location.callback(caster, localStore, castId); + final Float rangeVal = this.range.callback(caster, localStore, castId); + + List foundUnits = new ArrayList<>(); + recycleRect.set(target.getX() - rangeVal, target.getY() - rangeVal, rangeVal * 2, rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (enumUnit.canReach(target, rangeVal)) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), enumUnit); + if (condition == null || condition.callback(caster, localStore, castId)) { + foundUnits.add(enumUnit); + } + } + return false; + } + }); + if (sort != null) { + ABUnitComparator comp = new ABUnitComparator(caster, localStore, castId, sort); + foundUnits.sort(comp); + } + + for (CUnit unit : foundUnits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), unit); + for (ABAction iterationAction : iterationActions) { + iterationAction.runAction(caster, localStore, castId); + } + } + + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + } + + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final List modifiedActionList = new ArrayList<>(this.iterationActions); + modifiedActionList.add(0, new JassTextGeneratorCallStmt() { + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; + } + }); + if (this.condition != null) { + modifiedActionList.add(0, new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ")"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("if not "); + sb.append(ABActionIterateUnitsInRangeOfLocationMatchingConditionWithSort.this.condition + .generateJassEquivalent(jassTextGenerator)); + sb.append(" then"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent + 1, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } + }); + } + modifiedActionList.add(new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + } + }); + final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, + "UnitsInRangeOfLocEnumActions"); + + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("// TODO: use a global filter"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call GroupEnumUnitsInRangeOfLoc(au_tempGroup, " + + this.location.generateJassEquivalent(jassTextGenerator) + ", " + + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" + + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfUnitMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfUnitMatchingCondition.java new file mode 100644 index 000000000..09c85626c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfUnitMatchingCondition.java @@ -0,0 +1,133 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit; + +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionIterateUnitsInRangeOfUnitMatchingCondition implements ABAction { + + private static final Rectangle recycleRect = new Rectangle(); + private List iterationActions; + private ABBooleanCallback condition; + + private ABUnitCallback originUnit; + private ABFloatCallback range; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit originUnitTarget = this.originUnit.callback(caster, localStore, castId); + final Float rangeVal = this.range.callback(caster, localStore, castId); + + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal)) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), enumUnit); + if (condition == null || condition.callback(caster, localStore, castId)) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), enumUnit); + for (ABAction iterationAction : iterationActions) { + iterationAction.runAction(caster, localStore, castId); + } + } + } + return false; + } + }); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + } + + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final List modifiedActionList = new ArrayList<>(this.iterationActions); + modifiedActionList.add(0, new JassTextGeneratorCallStmt() { + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; + } + }); + if (this.condition != null) { + modifiedActionList.add(0, new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ")"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("if not "); + sb.append(ABActionIterateUnitsInRangeOfUnitMatchingCondition.this.condition + .generateJassEquivalent(jassTextGenerator)); + sb.append(" then"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent + 1, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } + }); + } + modifiedActionList.add(new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + } + }); + final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, + "UnitsInRangeOfUnitEnumActions"); + + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("// TODO: use a global filter"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call GroupEnumUnitsInRangeOfUnit(au_tempGroup, " + + this.originUnit.generateJassEquivalent(jassTextGenerator) + ", " + + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" + + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfUnitMatchingConditionWithSort.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfUnitMatchingConditionWithSort.java new file mode 100644 index 000000000..9449abec0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRangeOfUnitMatchingConditionWithSort.java @@ -0,0 +1,147 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit; + +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitComparator; + +public class ABActionIterateUnitsInRangeOfUnitMatchingConditionWithSort implements ABAction { + + private static final Rectangle recycleRect = new Rectangle(); + private List iterationActions; + private ABBooleanCallback condition; + + private ABIntegerCallback sort; + + private ABUnitCallback originUnit; + private ABFloatCallback range; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit originUnitTarget = this.originUnit.callback(caster, localStore, castId); + final Float rangeVal = this.range.callback(caster, localStore, castId); + + List foundUnits = new ArrayList<>(); + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal)) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), enumUnit); + if (condition == null || condition.callback(caster, localStore, castId)) { + foundUnits.add(enumUnit); + } + } + return false; + } + }); + if (sort != null) { + ABUnitComparator comp = new ABUnitComparator(caster, localStore, castId, sort); + foundUnits.sort(comp); + } + + for (CUnit unit : foundUnits) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), unit); + for (ABAction iterationAction : iterationActions) { + iterationAction.runAction(caster, localStore, castId); + } + } + + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + } + + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final List modifiedActionList = new ArrayList<>(this.iterationActions); + modifiedActionList.add(0, new JassTextGeneratorCallStmt() { + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ") // filter unit used intentionally as enum"; + } + }); + if (this.condition != null) { + modifiedActionList.add(0, new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, final JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("SetLocalStoreUnitHandle(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "), " + + "GetFilterUnit()" + ")"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("if not "); + sb.append(ABActionIterateUnitsInRangeOfUnitMatchingConditionWithSort.this.condition + .generateJassEquivalent(jassTextGenerator)); + sb.append(" then"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent + 1, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } + }); + } + modifiedActionList.add(new JassTextGeneratorStmt() { + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("return false"); + jassTextGenerator.println(sb.toString()); + } + }); + final String iterationActionsName = jassTextGenerator.createAnonymousFunction(modifiedActionList, + "UnitsInRangeOfUnitEnumActions"); + + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("// TODO: use a global filter"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call GroupEnumUnitsInRangeOfUnit(au_tempGroup, " + + this.originUnit.generateJassEquivalent(jassTextGenerator) + ", " + + this.range.generateJassEquivalent(jassTextGenerator) + ", Filter(" + + jassTextGenerator.functionPointerByName(iterationActionsName) + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + "))"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRect.java similarity index 76% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRect.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRect.java index dc20001a3..a4a44ab43 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/structural/ABActionIterateUnitsInRect.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/iterator/unit/ABActionIterateUnitsInRect.java @@ -1,18 +1,17 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.structural; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit; import java.util.ArrayList; import java.util.List; -import java.util.Map; import com.badlogic.gdx.math.Rectangle; import com.etheller.warsmash.parsers.jass.JassTextGenerator; import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; public class ABActionIterateUnitsInRect implements ABAction { @@ -24,20 +23,19 @@ public class ABActionIterateUnitsInRect implements ABAction { private List iterationActions; @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, - final int castId) { + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { recycleRect.set(this.x1, this.y1, this.x2 - this.x1, this.y2 - this.y1); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { @Override public boolean call(final CUnit enumUnit) { - localStore.put(ABLocalStoreKeys.ENUMUNIT + castId, enumUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), enumUnit); for (final ABAction iterationAction : ABActionIterateUnitsInRect.this.iterationActions) { - iterationAction.runAction(game, caster, localStore, castId); + iterationAction.runAction(caster, localStore, castId); } return false; } }); - localStore.remove(ABLocalStoreKeys.ENUMUNIT + castId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId)); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionListRemove.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionListRemove.java new file mode 100644 index 000000000..f3c03500c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionListRemove.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionListRemove implements ABAction { + + private ABListCallback list; + private ABIntegerCallback index; + private ABCallback object; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final List l = this.list.callback(caster, localStore, castId); + if (object != null) { + l.remove(object.callback(caster, localStore, castId)); + } else { + l.remove(index.callback(caster, localStore, castId).intValue()); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionLocationListAdd.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionLocationListAdd.java new file mode 100644 index 000000000..b10f8090f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionLocationListAdd.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionLocationListAdd implements ABAction { + + private ABListCallback list; + private ABLocationCallback location; + private ABIntegerCallback index; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final List l = this.list.callback(caster, localStore, castId); + if (index != null) { + l.add(index.callback(caster, localStore, castId), + location.callback(caster, localStore, castId)); + } else { + l.add(location.callback(caster, localStore, castId)); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionSortableListRemove.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionSortableListRemove.java new file mode 100644 index 000000000..a8c489d48 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/list/ABActionSortableListRemove.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABSortableListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSortableListRemove implements ABAction { + + private ABSortableListCallback list; + private ABIntegerCallback index; + private ABCallback object; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final List l = this.list.callback(caster, localStore, castId); + if (object != null) { + l.remove(object.callback(caster, localStore, castId)); + } else { + l.remove(index.callback(caster, localStore, castId).intValue()); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/order/ABActionIssueStopOrder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/order/ABActionIssueStopOrder.java new file mode 100644 index 000000000..f1580e50a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/order/ABActionIssueStopOrder.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.order; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionIssueStopOrder implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + targetUnit.performDefaultBehavior(localStore.game); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "DoStopOrder(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/player/ABActionGiveResourcesToPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/player/ABActionGiveResourcesToPlayer.java new file mode 100644 index 000000000..593b58ace --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/player/ABActionGiveResourcesToPlayer.java @@ -0,0 +1,43 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.player; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABActionGiveResourcesToPlayer implements ABSingleAction { + + private ABPlayerCallback player; + private ABIntegerCallback gold; + private ABIntegerCallback lumber; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CPlayer p = this.player.callback(caster, localStore, castId); + if (this.gold != null) { + p.addGold(this.gold.callback(caster, localStore, castId)); + } + if (this.lumber != null) { + p.addLumber(this.lumber.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String goldExpression = "0"; + if (this.gold != null) { + goldExpression = this.gold.generateJassEquivalent(jassTextGenerator); + } + String lumberExpression = "0"; + if (this.lumber != null) { + lumberExpression = this.lumber.generateJassEquivalent(jassTextGenerator); + } + + return "GiveResourcesToPlayerAU(" + this.player.generateJassEquivalent(jassTextGenerator) + ", " + + goldExpression + ", " + lumberExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/player/ABActionSetAbilityEnabledForPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/player/ABActionSetAbilityEnabledForPlayer.java new file mode 100644 index 000000000..334043292 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/player/ABActionSetAbilityEnabledForPlayer.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.player; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABActionSetAbilityEnabledForPlayer implements ABSingleAction { + + private ABPlayerCallback player; + private ABIDCallback abilityId; + private ABBooleanCallback enabled; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CPlayer p = this.player.callback(caster, localStore, castId); + boolean e = true; + if (this.enabled != null) { + e = this.enabled.callback(caster, localStore, castId); + } + p.setAbilityEnabled(localStore.game, this.abilityId.callback(caster, localStore, castId), e); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String enabledExpression = "true"; + if (this.enabled != null) { + enabledExpression = this.enabled.generateJassEquivalent(jassTextGenerator); + } + return "SetPlayerAbilityAvailable(" + this.player.generateJassEquivalent(jassTextGenerator) + ", " + + this.abilityId.generateJassEquivalent(jassTextGenerator) + ", " + enabledExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedCollisionProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedCollisionProjectile.java new file mode 100644 index 000000000..aad2255c8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedCollisionProjectile.java @@ -0,0 +1,201 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABCollisionProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionCreateLocationTargetedCollisionProjectile implements ABSingleAction { + + private ABUnitCallback source; + private ABLocationCallback sourceLoc; + private ABLocationCallback target; + private ABIDCallback id; + private ABFloatCallback speed; + private ABBooleanCallback homing; + + private List onLaunch; + private List onPreHits; + private List canHitTarget; + private List onHit; + + private ABIntegerCallback maxHits; + private ABIntegerCallback hitsPerTarget; + private ABFloatCallback radius; + private ABFloatCallback startingRadius; + private ABFloatCallback endingRadius; + private ABFloatCallback collisionInterval; + private ABBooleanCallback provideCounts; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + Float theSpeed = null; + Boolean isHoming = null; + int theMaxHits = 0; + int theHitsPerTarget = 1; + float theStartingRadius = 0; + float theEndingRadius = 0; + float theCollisionInterval = 0.05f; + boolean isProvideCounts = false; + final CUnit theSource = this.source.callback(caster, localStore, castId); + AbilityTarget sourceLocation = theSource; + + if (this.sourceLoc != null) { + sourceLocation = this.sourceLoc.callback(caster, localStore, castId); + } + if (this.maxHits != null) { + theMaxHits = this.maxHits.callback(caster, localStore, castId); + } + if (this.hitsPerTarget != null) { + theHitsPerTarget = this.hitsPerTarget.callback(caster, localStore, castId); + } + if (this.radius != null) { + final float rad = this.radius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } else { + if (this.endingRadius != null) { + theStartingRadius = this.startingRadius.callback(caster, localStore, castId); + theEndingRadius = this.endingRadius.callback(caster, localStore, castId); + } else { + final float rad = this.startingRadius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } + } + if (this.collisionInterval != null) { + theCollisionInterval = this.collisionInterval.callback(caster, localStore, castId); + } + if (this.provideCounts != null) { + isProvideCounts = this.provideCounts.callback(caster, localStore, castId); + } + + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } + + final AbilityPointTarget theTarget = this.target.callback(caster, localStore, castId); + + final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, + this.canHitTarget, this.onHit, caster, localStore, castId); + + final CProjectile proj = localStore.game.createCollisionProjectile(theSource, + this.id.callback(caster, localStore, castId), sourceLocation.getX(), sourceLocation.getY(), + (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theSpeed, isHoming, theTarget, + theMaxHits, theHitsPerTarget, theStartingRadius, theEndingRadius, theCollisionInterval, listener, + isProvideCounts); + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, + "CreateLocationTargetedCollisionProjectileAU_OnLaunch"); + final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, + "CreateLocationTargetedCollisionProjectileAU_OnPreHits"); + final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, + "CreateLocationTargetedCollisionProjectileAU_CanHitTarget"); + final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, + "CreateLocationTargetedCollisionProjectileAU_OnHit"); + + final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); + String sourceLocExpression; + if (this.sourceLoc != null) { + sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); + } else { + sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; + } + + String maxHitsExpression = "0"; + if (this.maxHits != null) { + maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); + } + + String hitsPerTargetExpression = "1"; + if (this.hitsPerTarget != null) { + hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); + } + + String startingRadiusExpression; + String endingRadiusExpression; + if (this.radius != null) { + final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } else { + if (this.endingRadius != null) { + startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); + } else { + final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } + } + + String collisionIntervalExpression = "0.05"; + if (this.collisionInterval != null) { + collisionIntervalExpression = this.collisionInterval.generateJassEquivalent(jassTextGenerator); + } + + String provideCountsExpression = "false"; + if (this.provideCounts != null) { + provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); + } + if (this.speed != null) { + if (this.homing != null) { + String homingExpression = "true"; + if (this.homing != null) { + homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); + } + return "CreateLocationTargetedCollisionProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + homingExpression + ", " + + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + + ", " + collisionIntervalExpression + ", " + provideCountsExpression + ")"; + + } else { + throw new UnsupportedOperationException(); + } + } else if (this.homing != null) { + throw new UnsupportedOperationException(); + } + + return "CreateLocationTargetedCollisionProjectileAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " + + collisionIntervalExpression + ", " + provideCountsExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedProjectile.java new file mode 100644 index 000000000..3fe104a0e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedProjectile.java @@ -0,0 +1,108 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionCreateLocationTargetedProjectile implements ABSingleAction { + + private ABUnitCallback source; + private ABLocationCallback sourceLoc; + private ABLocationCallback target; + private ABIDCallback id; + private ABFloatCallback speed; + private ABBooleanCallback homing; + + private List onLaunch; + private List onHit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + Float theSpeed = null; + Boolean isHoming = null; + final CUnit theSource = this.source.callback(caster, localStore, castId); + AbilityTarget sourceLocation = theSource; + + if (this.sourceLoc != null) { + sourceLocation = this.sourceLoc.callback(caster, localStore, castId); + } + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } + + final AbilityPointTarget theTarget = this.target.callback(caster, localStore, castId); + + final CAbilityProjectileListener listener = new ABProjectileListener(this.onLaunch, this.onHit, caster, + localStore, castId); + + final CProjectile proj = localStore.game.createProjectile(theSource, + this.id.callback(caster, localStore, castId), sourceLocation.getX(), sourceLocation.getY(), + (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theSpeed, isHoming, theTarget, listener); + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, + "CreateLocationTargetedProjectileAU_OnLaunch"); + final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, + "CreateLocationTargetedProjectileAU_OnHit"); + + final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); + String sourceLocExpression; + if (this.sourceLoc != null) { + sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); + } else { + sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; + } + + if (this.speed != null) { + if (this.homing != null) { + String homingExpression = "true"; + if (this.homing != null) { + homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); + } + return "CreateLocationTargetedProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + homingExpression + ", " + + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ")"; + + } else { + throw new UnsupportedOperationException(); + } + } else if (this.homing != null) { + throw new UnsupportedOperationException(); + } + + return "CreateLocationTargetedProjectileAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedPseudoProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedPseudoProjectile.java new file mode 100644 index 000000000..cf9a73ad8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateLocationTargetedPseudoProjectile.java @@ -0,0 +1,242 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABCollisionProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreateLocationTargetedPseudoProjectile implements ABSingleAction { + + private ABUnitCallback source; + private ABLocationCallback sourceLoc; + private ABLocationCallback target; + private ABIDCallback id; + private CEffectType effectType; + private ABIntegerCallback effectArtIndex; + private ABFloatCallback speed; + private ABBooleanCallback homing; + + private List onLaunch; + private List onPreHits; + private List canHitTarget; + private List onHit; + + private ABIntegerCallback maxHits; + private ABIntegerCallback hitsPerTarget; + private ABFloatCallback radius; + private ABFloatCallback startingRadius; + private ABFloatCallback endingRadius; + private ABFloatCallback projectileStepInterval; + private ABIntegerCallback projectileArtSkip; + private ABBooleanCallback provideCounts; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + float theSpeed = 0; + boolean isHoming = false; + int theMaxHits = 0; + int theHitsPerTarget = 1; + float theStartingRadius = 0; + float theEndingRadius = 0; + float theCollisionInterval = 0.25f; + CEffectType theEffectType = CEffectType.SPECIAL; + int theEffectArtIndex = 0; + boolean isProvideCounts = false; + final CUnit theSource = this.source.callback(caster, localStore, castId); + AbilityTarget sourceLocation = theSource; + int theArtSkip = 1; + + if (this.sourceLoc != null) { + sourceLocation = this.sourceLoc.callback(caster, localStore, castId); + } + if (this.effectType != null) { + theEffectType = this.effectType; + } + if (this.effectArtIndex != null) { + theEffectArtIndex = this.effectArtIndex.callback(caster, localStore, castId); + } + + if (this.maxHits != null) { + theMaxHits = this.maxHits.callback(caster, localStore, castId); + } + if (this.hitsPerTarget != null) { + theHitsPerTarget = this.hitsPerTarget.callback(caster, localStore, castId); + } + if (this.radius != null) { + final float rad = this.radius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } else { + if (this.endingRadius != null) { + theStartingRadius = this.startingRadius.callback(caster, localStore, castId); + theEndingRadius = this.endingRadius.callback(caster, localStore, castId); + } else { + final float rad = this.startingRadius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } + } + if (this.projectileStepInterval != null) { + theCollisionInterval = this.projectileStepInterval.callback(caster, localStore, castId); + } + if (this.projectileArtSkip != null) { + theArtSkip = this.projectileArtSkip.callback(caster, localStore, castId); + } + if (this.provideCounts != null) { + isProvideCounts = this.provideCounts.callback(caster, localStore, castId); + } + + final GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } else { + theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } else { + isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); + } + + final AbilityPointTarget theTarget = this.target.callback(caster, localStore, castId); + + final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, + this.canHitTarget, this.onHit, caster, localStore, castId); + + final CProjectile proj = localStore.game.createPseudoProjectile(theSource, + this.id.callback(caster, localStore, castId), theEffectType, theEffectArtIndex, sourceLocation.getX(), + sourceLocation.getY(), (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theSpeed, + theCollisionInterval, theArtSkip, isHoming, theTarget, theMaxHits, theHitsPerTarget, theStartingRadius, + theEndingRadius, listener, isProvideCounts); + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, + "CreateLocationTargetedPseudoProjectileAU_OnLaunch"); + final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, + "CreateLocationTargetedPseudoProjectileAU_OnPreHits"); + final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, + "CreateLocationTargetedPseudoProjectileAU_CanHitTarget"); + final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, + "CreateLocationTargetedPseudoProjectileAU_OnHit"); + + CEffectType theEffectType = CEffectType.SPECIAL; + if (this.effectType != null) { + theEffectType = this.effectType; + } + final String effectTypeExpression = "EFFECT_TYPE_" + theEffectType.name(); + String theEffectArtIndex = "0"; + if (this.effectArtIndex != null) { + theEffectArtIndex = this.effectArtIndex.generateJassEquivalent(jassTextGenerator); + } + + final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); + String sourceLocExpression; + if (this.sourceLoc != null) { + sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); + } else { + sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; + } + + String maxHitsExpression = "0"; + if (this.maxHits != null) { + maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); + } + + String hitsPerTargetExpression = "1"; + if (this.hitsPerTarget != null) { + hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); + } + + String startingRadiusExpression; + String endingRadiusExpression; + if (this.radius != null) { + final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } else { + if (this.endingRadius != null) { + startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); + } else { + final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } + } + + String collisionIntervalExpression = "0.25"; + if (this.projectileStepInterval != null) { + collisionIntervalExpression = this.projectileStepInterval.generateJassEquivalent(jassTextGenerator); + } + + String artSkipExpression = "1"; + if (this.projectileArtSkip != null) { + artSkipExpression = this.projectileArtSkip.generateJassEquivalent(jassTextGenerator); + } + + String provideCountsExpression = "false"; + if (this.provideCounts != null) { + provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); + } + if (this.speed != null) { + if (this.homing != null) { + String homingExpression = "true"; + if (this.homing != null) { + homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); + } + return "CreateLocationTargetedPseudoProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " + + theEffectArtIndex + ", " + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + + homingExpression + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + + ", " + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression + + ")"; + + } else { + throw new UnsupportedOperationException(); + } + } else if (this.homing != null) { + throw new UnsupportedOperationException(); + } + + return "CreateLocationTargetedPseudoProjectileAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " + + theEffectArtIndex + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " + + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedBouncingProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedBouncingProjectile.java new file mode 100644 index 000000000..02f59808c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedBouncingProjectile.java @@ -0,0 +1,279 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attacksettings.ABAttackSettingsCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABNearestUnitComparator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitComparator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABActionCreateUnitTargetedBouncingProjectile implements ABAction { + + private static final Rectangle recycleRect = new Rectangle(); + + private ABUnitCallback source; + private ABLocationCallback sourceLoc; + private ABUnitCallback target; + + private ABIDCallback id; + private ABFloatCallback speed; + private ABBooleanCallback homing; + private ABAttackSettingsCallback settings; + + private List onLaunch; + private List onHit; + + private ABBooleanCallback condition; + private ABIntegerCallback sort; + + private ABFloatCallback range; + private ABIntegerCallback bounces; + private ABFloatCallback bounceDelay; + + private ABBooleanCallback allowMultipleBouncesPerUnit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit theSource = caster; + if (source != null) { + theSource = this.source.callback(caster, localStore, castId); + } + AbilityTarget sourceLocation = theSource; + + if (this.sourceLoc != null) { + sourceLocation = this.sourceLoc.callback(caster, localStore, castId); + } + + final CUnit theTarget = this.target.callback(caster, localStore, castId); + + final boolean multiBounce; + if (allowMultipleBouncesPerUnit != null) { + multiBounce = allowMultipleBouncesPerUnit.callback(caster, localStore, castId); + } else { + multiBounce = localStore.game.getGameplayConstants().isAllowMultiBounce(); + } + final Set hitUnits; + if (!multiBounce) { + hitUnits = new HashSet<>(); + hitUnits.add(theTarget); + } else { + hitUnits = null; + } + + final CAbilityProjectileListener listener = new CAbilityProjectileListener() { + + @Override + public void onLaunch(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onLaunch != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), projectile); + for (ABAction action : onLaunch) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + } + } + + @Override + public void onHit(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onHit != null) { + CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), projectile); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId), targetUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId), targetDest); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId), + new AbilityPointTarget(projectile.getX(), projectile.getY())); + for (ABAction action : onHit) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId)); + } + startPerformJump(caster, localStore, castId, theTarget, multiBounce, hitUnits, + bounces.callback(caster, localStore, castId)); + } + }; + + CProjectile proj = null; + if (id != null) { + Float theSpeed = null; + Boolean isHoming = null; + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } + proj = localStore.game.createProjectile(theSource, this.id.callback(caster, localStore, castId), + sourceLocation.getX(), sourceLocation.getY(), + (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theSpeed, isHoming, theTarget, + listener); + } else if (settings != null) { + proj = localStore.game.createProjectile(theSource, this.settings.callback(caster, localStore, castId), + sourceLocation.getX(), sourceLocation.getY(), + (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theTarget, listener); + } + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + private void startPerformJump(final CUnit caster, final ABLocalDataStore localStore, final int castId, + final CUnit originUnitTarget, final boolean multiBounce, final Set hitUnits, + final int remainingJumps) { + if (remainingJumps <= 0) { + return; + } + float delay = 0; + if (bounceDelay != null) { + delay = bounceDelay.callback(caster, localStore, castId); + } + if (delay > 0) { + CTimer runner = new CTimer() { + @Override + public void onFire(CSimulation simulation) { + performJump(caster, localStore, castId, originUnitTarget, multiBounce, hitUnits, remainingJumps); + } + }; + runner.setTimeoutTime(delay); + runner.start(localStore.game); + } else { + performJump(caster, localStore, castId, originUnitTarget, multiBounce, hitUnits, remainingJumps); + } + } + + private void performJump(final CUnit caster, final ABLocalDataStore localStore, final int castId, + final CUnit originUnitTarget, final boolean multiBounce, final Set hitUnits, + final int remainingJumps) { + if (originUnitTarget == null) { + return; + } + + final Float rangeVal = this.range.callback(caster, localStore, castId); + + List foundUnits = new ArrayList<>(); + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal) && (multiBounce || !hitUnits.contains(enumUnit))) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), enumUnit); + if (condition == null || condition.callback(caster, localStore, castId)) { + foundUnits.add(enumUnit); + } + } + return false; + } + }); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + + final CUnit jumpUnit; + if (foundUnits.size() > 0) { + if (sort != null) { + ABUnitComparator comp = new ABUnitComparator(caster, localStore, castId, sort); + foundUnits.sort(comp); + } else { + foundUnits.sort(ABNearestUnitComparator.INSTANCE); + } + + jumpUnit = foundUnits.get(0); + } else { + jumpUnit = null; + } + + if (jumpUnit != null) { + + if (!multiBounce) { + hitUnits.add(jumpUnit); + } + + final CAbilityProjectileListener listener = new CAbilityProjectileListener() { + + @Override + public void onLaunch(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onLaunch != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), + projectile); + for (ABAction action : onLaunch) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + } + } + + @Override + public void onHit(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onHit != null) { + CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), + projectile); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId), + targetUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId), + targetDest); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId), + new AbilityPointTarget(projectile.getX(), projectile.getY())); + for (ABAction action : onHit) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId)); + } + startPerformJump(caster, localStore, castId, jumpUnit, multiBounce, hitUnits, + bounces.callback(caster, localStore, castId)); + } + }; + + CProjectile proj = null; + if (id != null) { + Float theSpeed = null; + Boolean isHoming = null; + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } + proj = localStore.game.createProjectile(caster, this.id.callback(caster, localStore, castId), + originUnitTarget.getX(), originUnitTarget.getY(), + (float) AbilityTarget.angleBetween(originUnitTarget, jumpUnit), theSpeed, isHoming, jumpUnit, + listener); + } else if (settings != null) { + proj = localStore.game.createProjectile(caster, this.settings.callback(caster, localStore, castId), + originUnitTarget.getX(), originUnitTarget.getY(), + (float) AbilityTarget.angleBetween(originUnitTarget, jumpUnit), jumpUnit, listener); + } + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedCollisionProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedCollisionProjectile.java new file mode 100644 index 000000000..f0544ecbc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedCollisionProjectile.java @@ -0,0 +1,200 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABCollisionProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionCreateUnitTargetedCollisionProjectile implements ABSingleAction { + + private ABUnitCallback source; + private ABLocationCallback sourceLoc; + private ABUnitCallback target; + private ABIDCallback id; + private ABFloatCallback speed; + private ABBooleanCallback homing; + + private List onLaunch; + private List onPreHits; + private List canHitTarget; + private List onHit; + + private ABIntegerCallback maxHits; + private ABIntegerCallback hitsPerTarget; + private ABFloatCallback radius; + private ABFloatCallback startingRadius; + private ABFloatCallback endingRadius; + private ABFloatCallback collisionInterval; + private ABBooleanCallback provideCounts; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + Float theSpeed = null; + Boolean isHoming = null; + int theMaxHits = 0; + int theHitsPerTarget = 1; + float theStartingRadius = 0; + float theEndingRadius = 0; + float theCollisionInterval = 0.05f; + boolean isProvideCounts = false; + final CUnit theSource = this.source.callback(caster, localStore, castId); + AbilityTarget sourceLocation = theSource; + + if (this.sourceLoc != null) { + sourceLocation = this.sourceLoc.callback(caster, localStore, castId); + } + if (this.maxHits != null) { + theMaxHits = this.maxHits.callback(caster, localStore, castId); + } + if (this.hitsPerTarget != null) { + theHitsPerTarget = this.hitsPerTarget.callback(caster, localStore, castId); + } + if (this.radius != null) { + final float rad = this.radius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } else { + if (this.endingRadius != null) { + theStartingRadius = this.startingRadius.callback(caster, localStore, castId); + theEndingRadius = this.endingRadius.callback(caster, localStore, castId); + } else { + final float rad = this.startingRadius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } + } + if (this.collisionInterval != null) { + theCollisionInterval = this.collisionInterval.callback(caster, localStore, castId); + } + if (this.provideCounts != null) { + isProvideCounts = this.provideCounts.callback(caster, localStore, castId); + } + + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } + + final CUnit theTarget = this.target.callback(caster, localStore, castId); + + final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, + this.canHitTarget, this.onHit, caster, localStore, castId); + + final CProjectile proj = localStore.game.createCollisionProjectile(theSource, + this.id.callback(caster, localStore, castId), sourceLocation.getX(), sourceLocation.getY(), + (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theSpeed, isHoming, theTarget, + theMaxHits, theHitsPerTarget, theStartingRadius, theEndingRadius, theCollisionInterval, listener, + isProvideCounts); + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, + "CreateLocationTargetedCollisionProjectileAU_OnLaunch"); + final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, + "CreateLocationTargetedCollisionProjectileAU_OnPreHits"); + final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, + "CreateLocationTargetedCollisionProjectileAU_CanHitTarget"); + final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, + "CreateLocationTargetedCollisionProjectileAU_OnHit"); + + final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); + String sourceLocExpression; + if (this.sourceLoc != null) { + sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); + } else { + sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; + } + + String maxHitsExpression = "0"; + if (this.maxHits != null) { + maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); + } + + String hitsPerTargetExpression = "1"; + if (this.hitsPerTarget != null) { + hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); + } + + String startingRadiusExpression; + String endingRadiusExpression; + if (this.radius != null) { + final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } else { + if (this.endingRadius != null) { + startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); + } else { + final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } + } + + String collisionIntervalExpression = "0.05"; + if (this.collisionInterval != null) { + collisionIntervalExpression = this.collisionInterval.generateJassEquivalent(jassTextGenerator); + } + + String provideCountsExpression = "false"; + if (this.provideCounts != null) { + provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); + } + if (this.speed != null) { + if (this.homing != null) { + String homingExpression = "true"; + if (this.homing != null) { + homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); + } + return "CreateUnitTargetedCollisionProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + homingExpression + ", " + + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + + ", " + collisionIntervalExpression + ", " + provideCountsExpression + ")"; + + } else { + throw new UnsupportedOperationException(); + } + } else if (this.homing != null) { + throw new UnsupportedOperationException(); + } + + return "CreateUnitTargetedCollisionProjectileAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " + + collisionIntervalExpression + ", " + provideCountsExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedProjectile.java new file mode 100644 index 000000000..2fd09831b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedProjectile.java @@ -0,0 +1,114 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attacksettings.ABAttackSettingsCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionCreateUnitTargetedProjectile implements ABSingleAction { + + private ABUnitCallback source; + private ABLocationCallback sourceLoc; + private ABUnitCallback target; + private ABIDCallback id; + private ABAttackSettingsCallback settings; + private ABFloatCallback speed; + private ABBooleanCallback homing; + + private List onLaunch; + private List onHit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit theSource = this.source.callback(caster, localStore, castId); + AbilityTarget sourceLocation = theSource; + + if (this.sourceLoc != null) { + sourceLocation = this.sourceLoc.callback(caster, localStore, castId); + } + + final CUnit theTarget = this.target.callback(caster, localStore, castId); + + final CAbilityProjectileListener listener = new ABProjectileListener(this.onLaunch, this.onHit, caster, + localStore, castId); + + CProjectile proj = null; + if (id != null) { + Float theSpeed = null; + Boolean isHoming = null; + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } + proj = localStore.game.createProjectile(theSource, this.id.callback(caster, localStore, castId), + sourceLocation.getX(), sourceLocation.getY(), + (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theSpeed, isHoming, theTarget, + listener); + } else if (settings != null) { + proj = localStore.game.createProjectile(theSource, this.settings.callback(caster, localStore, castId), + sourceLocation.getX(), sourceLocation.getY(), + (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theTarget, listener); + } + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String onLaunchFunc = jassTextGenerator.createAnonymousFunction(this.onLaunch, + "CreateUnitTargetedProjectileAU_OnLaunch"); + final String onHitFunc = jassTextGenerator.createAnonymousFunction(this.onHit, + "CreateUnitTargetedProjectileAU_OnHit"); + + final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); + String sourceLocExpression; + if (this.sourceLoc != null) { + sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); + } else { + sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; + } + + if (this.speed != null) { + if (this.homing != null) { + return "CreateUnitTargetedProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + sourceUnitExpression + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + + this.homing.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.functionPointerByName(onLaunchFunc) + ", " + + jassTextGenerator.functionPointerByName(onHitFunc) + ")"; + + } else { + throw new UnsupportedOperationException(); + } + } else if (this.homing != null) { + throw new UnsupportedOperationException(); + } + + return "CreateUnitTargetedProjectileAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + sourceUnitExpression + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.functionPointerByName(onLaunchFunc) + ", " + + jassTextGenerator.functionPointerByName(onHitFunc) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedPseudoProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedPseudoProjectile.java new file mode 100644 index 000000000..77ef64c2a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionCreateUnitTargetedPseudoProjectile.java @@ -0,0 +1,241 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile.ABCollisionProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class ABActionCreateUnitTargetedPseudoProjectile implements ABSingleAction { + + private ABUnitCallback source; + private ABLocationCallback sourceLoc; + private ABUnitCallback target; + private ABIDCallback id; + private CEffectType effectType; + private ABIntegerCallback effectArtIndex; + private ABFloatCallback speed; + private ABBooleanCallback homing; + + private List onLaunch; + private List onPreHits; + private List canHitTarget; + private List onHit; + + private ABIntegerCallback maxHits; + private ABIntegerCallback hitsPerTarget; + private ABFloatCallback radius; + private ABFloatCallback startingRadius; + private ABFloatCallback endingRadius; + private ABFloatCallback projectileStepInterval; + private ABIntegerCallback projectileArtSkip; + private ABBooleanCallback provideCounts; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + float theSpeed = 0; + boolean isHoming = false; + int theMaxHits = 0; + int theHitsPerTarget = 1; + float theStartingRadius = 0; + float theEndingRadius = 0; + float theCollisionInterval = 0.25f; + CEffectType theEffectType = CEffectType.SPECIAL; + int theEffectArtIndex = 0; + boolean isProvideCounts = false; + final CUnit theSource = this.source.callback(caster, localStore, castId); + AbilityTarget sourceLocation = theSource; + int theArtSkip = 1; + + if (this.sourceLoc != null) { + sourceLocation = this.sourceLoc.callback(caster, localStore, castId); + } + if (this.effectType != null) { + theEffectType = this.effectType; + } + if (this.effectArtIndex != null) { + theEffectArtIndex = this.effectArtIndex.callback(caster, localStore, castId); + } + + if (this.maxHits != null) { + theMaxHits = this.maxHits.callback(caster, localStore, castId); + } + if (this.hitsPerTarget != null) { + theHitsPerTarget = this.hitsPerTarget.callback(caster, localStore, castId); + } + if (this.radius != null) { + final float rad = this.radius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } else { + if (this.endingRadius != null) { + theStartingRadius = this.startingRadius.callback(caster, localStore, castId); + theEndingRadius = this.endingRadius.callback(caster, localStore, castId); + } else { + final float rad = this.startingRadius.callback(caster, localStore, castId); + theStartingRadius = rad; + theEndingRadius = rad; + } + } + if (this.projectileStepInterval != null) { + theCollisionInterval = this.projectileStepInterval.callback(caster, localStore, castId); + } + if (this.projectileArtSkip != null) { + theArtSkip = this.projectileArtSkip.callback(caster, localStore, castId); + } + if (this.provideCounts != null) { + isProvideCounts = this.provideCounts.callback(caster, localStore, castId); + } + + final GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + + if (this.speed != null) { + theSpeed = this.speed.callback(caster, localStore, castId); + } else { + theSpeed = editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); + } + if (this.homing != null) { + isHoming = this.homing.callback(caster, localStore, castId); + } else { + isHoming = editorData.getFieldAsBoolean(AbilityFields.PROJECTILE_HOMING_ENABLED, 0); + } + + final CUnit theTarget = this.target.callback(caster, localStore, castId); + + final ABCollisionProjectileListener listener = new ABCollisionProjectileListener(this.onLaunch, this.onPreHits, + this.canHitTarget, this.onHit, caster, localStore, castId); + + final CProjectile proj = localStore.game.createPseudoProjectile(theSource, + this.id.callback(caster, localStore, castId), theEffectType, theEffectArtIndex, sourceLocation.getX(), + sourceLocation.getY(), (float) AbilityTarget.angleBetween(sourceLocation, theTarget), theSpeed, + theCollisionInterval, theArtSkip, isHoming, theTarget, theMaxHits, theHitsPerTarget, theStartingRadius, + theEndingRadius, listener, isProvideCounts); + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.LASTCREATEDPROJECTILE, castId), proj); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String launchFunctionName = jassTextGenerator.createAnonymousFunction(this.onLaunch, + "CreateUnitTargetedPseudoProjectileAU_OnLaunch"); + final String preHitsFunctionName = jassTextGenerator.createAnonymousFunction(this.onPreHits, + "CreateUnitTargetedPseudoProjectileAU_OnPreHits"); + final String canHitTargetFunctionName = jassTextGenerator.createAnonymousBooleanFunction(this.canHitTarget, + "CreateUnitTargetedPseudoProjectileAU_CanHitTarget"); + final String hitFunctionName = jassTextGenerator.createAnonymousFunction(this.onHit, + "CreateUnitTargetedPseudoProjectileAU_OnHit"); + + CEffectType theEffectType = CEffectType.SPECIAL; + if (this.effectType != null) { + theEffectType = this.effectType; + } + final String effectTypeExpression = "EFFECT_TYPE_" + theEffectType.name(); + String theEffectArtIndex = "0"; + if (this.effectArtIndex != null) { + theEffectArtIndex = this.effectArtIndex.generateJassEquivalent(jassTextGenerator); + } + + final String sourceUnitExpression = this.source.generateJassEquivalent(jassTextGenerator); + String sourceLocExpression; + if (this.sourceLoc != null) { + sourceLocExpression = this.sourceLoc.generateJassEquivalent(jassTextGenerator); + } else { + sourceLocExpression = "GetUnitLoc(" + sourceUnitExpression + ")"; + } + + String maxHitsExpression = "0"; + if (this.maxHits != null) { + maxHitsExpression = this.maxHits.generateJassEquivalent(jassTextGenerator); + } + + String hitsPerTargetExpression = "1"; + if (this.hitsPerTarget != null) { + hitsPerTargetExpression = this.hitsPerTarget.generateJassEquivalent(jassTextGenerator); + } + + String startingRadiusExpression; + String endingRadiusExpression; + if (this.radius != null) { + final String radiusExpression = this.radius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } else { + if (this.endingRadius != null) { + startingRadiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + endingRadiusExpression = this.endingRadius.generateJassEquivalent(jassTextGenerator); + } else { + final String radiusExpression = this.startingRadius.generateJassEquivalent(jassTextGenerator); + startingRadiusExpression = radiusExpression; + endingRadiusExpression = radiusExpression; + } + } + + String collisionIntervalExpression = "0.25"; + if (this.projectileStepInterval != null) { + collisionIntervalExpression = this.projectileStepInterval.generateJassEquivalent(jassTextGenerator); + } + + String artSkipExpression = "1"; + if (this.projectileArtSkip != null) { + artSkipExpression = this.projectileArtSkip.generateJassEquivalent(jassTextGenerator); + } + + String provideCountsExpression = "false"; + if (this.provideCounts != null) { + provideCountsExpression = this.provideCounts.generateJassEquivalent(jassTextGenerator); + } + if (this.speed != null) { + if (this.homing != null) { + String homingExpression = "true"; + if (this.homing != null) { + homingExpression = this.homing.generateJassEquivalent(jassTextGenerator); + } + return "CreateUnitTargetedPseudoProjectileAnySpeedAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " + + theEffectArtIndex + ", " + this.speed.generateJassEquivalent(jassTextGenerator) + ", " + + homingExpression + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + + ", " + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression + + ")"; + + } else { + throw new UnsupportedOperationException(); + } + } else if (this.homing != null) { + throw new UnsupportedOperationException(); + } + + return "CreateUnitTargetedPseudoProjectileAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + + this.source.generateJassEquivalent(jassTextGenerator) + ", " + sourceLocExpression + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ", " + effectTypeExpression + ", " + + theEffectArtIndex + ", " + jassTextGenerator.functionPointerByName(launchFunctionName) + ", " + + jassTextGenerator.functionPointerByName(preHitsFunctionName) + ", Condition(" + + jassTextGenerator.functionPointerByName(canHitTargetFunctionName) + "), " + + jassTextGenerator.functionPointerByName(hitFunctionName) + ", " + maxHitsExpression + ", " + + hitsPerTargetExpression + ", " + startingRadiusExpression + ", " + endingRadiusExpression + ", " + + collisionIntervalExpression + ", " + artSkipExpression + ", " + provideCountsExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetAttackProjectileDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetAttackProjectileDamage.java new file mode 100644 index 000000000..386d6cfb2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetAttackProjectileDamage.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionSetAttackProjectileDamage implements ABSingleAction { + + private ABProjectileCallback projectile; + private ABFloatCallback damage; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + + final CProjectile proj = this.projectile.callback(caster, localStore, castId); + + if ((proj != null) && (proj instanceof CAttackProjectile)) { + final float dm = this.damage.callback(caster, localStore, castId); + System.err.println("Setting proj damage from " + ((CAttackProjectile) proj).getDamage() + " to " + dm); + ((CAttackProjectile) proj).setDamage(dm); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetAttackProjectileDamage(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " + + this.damage.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileDone.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileDone.java new file mode 100644 index 000000000..c1a00117d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileDone.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionSetProjectileDone implements ABSingleAction { + + private ABProjectileCallback projectile; + private ABBooleanCallback done; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + + final CProjectile proj = this.projectile.callback(caster, localStore, castId); + + proj.setDone(this.done.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetProjectileDone(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " + + this.done.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileReflected.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileReflected.java new file mode 100644 index 000000000..c5b3edcd0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileReflected.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionSetProjectileReflected implements ABSingleAction { + + private ABProjectileCallback projectile; + private ABBooleanCallback reflected; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + + final CProjectile proj = this.projectile.callback(caster, localStore, castId); + + if (this.reflected != null) { + proj.setReflected(this.reflected.callback(caster, localStore, castId)); + } + else { + proj.setReflected(true); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + String reflectedExpression = "true"; + if (this.reflected != null) { + reflectedExpression = this.reflected.generateJassEquivalent(jassTextGenerator); + } + return "SetProjectileReflected(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " + + reflectedExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileTarget.java new file mode 100644 index 000000000..8db2b1e8a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/projectile/ABActionSetProjectileTarget.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABActionSetProjectileTarget implements ABSingleAction { + + private ABProjectileCallback projectile; + private ABUnitCallback target; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + + final CProjectile proj = this.projectile.callback(caster, localStore, castId); + + proj.setTarget(this.target.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "SetProjectileTargetUnit(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/reaction/ABActionCheckAbilityEffectReaction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/reaction/ABActionCheckAbilityEffectReaction.java new file mode 100644 index 000000000..44919e4ad --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/reaction/ABActionCheckAbilityEffectReaction.java @@ -0,0 +1,125 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.reaction; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionCheckAbilityEffectReaction implements ABSingleAction { + + private ABUnitCallback target; + private List onHitActions; + private List onBlockActions; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit tarU = caster; + if (this.target != null) { + tarU = this.target.callback(caster, localStore, castId); + } + if (tarU.checkForAbilityEffectReaction(localStore.game, caster, localStore.originAbility)) { + if (this.onHitActions != null) { + for (final ABAction periodicAction : this.onHitActions) { + periodicAction.runAction(caster, localStore, castId); + } + } + } else { + if (this.onBlockActions != null) { + for (final ABAction periodicAction : this.onBlockActions) { + periodicAction.runAction(caster, localStore, castId); + } + } + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + final String onBlockFunc = jassTextGenerator.createAnonymousFunction(this.onBlockActions, + "CheckAbilityEffectReactionAU_OnBlock"); + final String onHitFunc = jassTextGenerator.createAnonymousFunction(this.onHitActions, + "CheckAbilityEffectReactionAU_OnHit"); + String tarU; + if (this.target != null) { + tarU = this.target.generateJassEquivalent(jassTextGenerator); + } else { + tarU = jassTextGenerator.getCaster(); + } + return "CheckAbilityEffectReactionAU(" + jassTextGenerator.getCaster() + ", " + + jassTextGenerator.getTriggerLocalStore() + ", " + jassTextGenerator.getCastId() + ", " + tarU + ", " + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) + + ", " + jassTextGenerator.functionPointerByName(onHitFunc) + ", " + + jassTextGenerator.functionPointerByName(onBlockFunc) + ")"; + } + + @Override + public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { + String tarU; + if (this.target != null) { + tarU = this.target.generateJassEquivalent(jassTextGenerator); + } else { + tarU = jassTextGenerator.getCaster(); + } + + final StringBuilder sb = new StringBuilder(); + if ((this.onHitActions == null) || this.onHitActions.isEmpty()) { + if ((this.onBlockActions != null) && !this.onBlockActions.isEmpty()) { + JassTextGenerator.Util.indent(indent, sb); + sb.append("if not CheckUnitForAbilityEffectReaction("); + sb.append(tarU); + sb.append(", "); + sb.append(jassTextGenerator.getCaster()); + sb.append(", "); + sb.append(jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", + JassTextGeneratorType.AbilityHandle)); + sb.append(") then"); + jassTextGenerator.println(sb.toString()); + + for (final ABAction onHitAction : this.onBlockActions) { + onHitAction.generateJassEquivalent(indent + 1, jassTextGenerator); + } + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } + } else { + JassTextGenerator.Util.indent(indent, sb); + sb.append("if CheckUnitForAbilityEffectReaction("); + sb.append(tarU); + sb.append(", "); + sb.append(jassTextGenerator.getCaster()); + sb.append(", "); + sb.append(jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", + JassTextGeneratorType.AbilityHandle)); + sb.append(") then"); + jassTextGenerator.println(sb.toString()); + + for (final ABAction onHitAction : this.onHitActions) { + onHitAction.generateJassEquivalent(indent + 1, jassTextGenerator); + } + + if ((this.onBlockActions != null) && !this.onBlockActions.isEmpty()) { + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("else"); + jassTextGenerator.println(sb.toString()); + + for (final ABAction onHitAction : this.onBlockActions) { + onHitAction.generateJassEquivalent(indent + 1, jassTextGenerator); + } + } + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } + + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCheckAbilityProjReaction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/reaction/ABActionCheckAbilityProjReaction.java similarity index 77% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCheckAbilityProjReaction.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/reaction/ABActionCheckAbilityProjReaction.java index cf3707611..ff16827e8 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionCheckAbilityProjReaction.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/reaction/ABActionCheckAbilityProjReaction.java @@ -1,15 +1,14 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.reaction; import java.util.List; -import java.util.Map; import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.projectile.ABProjectileCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; public class ABActionCheckAbilityProjReaction implements ABSingleAction { @@ -19,24 +18,24 @@ public class ABActionCheckAbilityProjReaction implements ABSingleAction { private List onBlockActions; @Override - public void runAction(final CSimulation game, final CUnit caster, final Map localStore, + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { CUnit tarU = caster; if (this.target != null) { - tarU = this.target.callback(game, caster, localStore, castId); + tarU = this.target.callback(caster, localStore, castId); } - if (tarU.checkForAbilityProjReaction(game, caster, - this.projectile.callback(game, caster, localStore, castId))) { + if (tarU.checkForAbilityProjReaction(localStore.game, caster, + this.projectile.callback(caster, localStore, castId))) { if (this.onHitActions != null) { for (final ABAction periodicAction : this.onHitActions) { - periodicAction.runAction(game, caster, localStore, castId); + periodicAction.runAction(caster, localStore, castId); } } } else { if (this.onBlockActions != null) { for (final ABAction periodicAction : this.onBlockActions) { - periodicAction.runAction(game, caster, localStore, castId); + periodicAction.runAction(caster, localStore, castId); } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionAddDefenseBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionAddDefenseBonus.java new file mode 100644 index 000000000..026f6432d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionAddDefenseBonus.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddDefenseBonus implements ABSingleAction { + + private ABUnitCallback targetUnit; + private ABFloatCallback defenseValue; + private ABBooleanCallback percentage; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit target = this.targetUnit.callback(caster, localStore, castId); + + if (this.percentage.callback(caster, localStore, castId)) { + // TODO need to fix percents + target.setTemporaryDefenseBonus( + target.getTemporaryDefenseBonus() + this.defenseValue.callback(caster, localStore, castId)); + } else { + target.setTemporaryDefenseBonus( + target.getTemporaryDefenseBonus() + this.defenseValue.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "UnitAddDefenseBonus(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " + + this.defenseValue.generateJassEquivalent(jassTextGenerator) + ")//, " + + this.percentage.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionAddNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionAddNonStackingStatBuff.java new file mode 100644 index 000000000..b88473cad --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionAddNonStackingStatBuff.java @@ -0,0 +1,28 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddNonStackingStatBuff implements ABSingleAction { + + private ABUnitCallback targetUnit; + private ABNonStackingStatBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit target = this.targetUnit.callback(caster, localStore, castId); + + target.addNonStackingStatBuff(localStore.game, this.buff.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AddUnitNonStackingStatBuff(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " + + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionCreateNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionCreateNonStackingStatBuff.java new file mode 100644 index 000000000..32501e190 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionCreateNonStackingStatBuff.java @@ -0,0 +1,38 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABNonStackingStatBuffTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABActionCreateNonStackingStatBuff implements ABSingleAction { + + private ABNonStackingStatBuffTypeCallback buffType; + private ABStringCallback stackingKey; + private ABFloatCallback value; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final NonStackingStatBuff buff = new NonStackingStatBuff( + this.buffType.callback(caster, localStore, castId), + this.stackingKey.callback(caster, localStore, castId), + this.value.callback(caster, localStore, castId)); + + localStore.put(ABLocalStoreKeys.LASTCREATEDNSSB, buff); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "CreateNonStackingStatBuffAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.buffType.generateJassEquivalent(jassTextGenerator) + ", " + + this.stackingKey.generateJassEquivalent(jassTextGenerator) + ", " + + this.value.generateJassEquivalent(jassTextGenerator) + ")"; + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRecomputeStatBuffsOnUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRecomputeStatBuffsOnUnit.java new file mode 100644 index 000000000..601aaaa04 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRecomputeStatBuffsOnUnit.java @@ -0,0 +1,34 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABNonStackingStatBuffTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; + +public class ABActionRecomputeStatBuffsOnUnit implements ABSingleAction { + + private ABUnitCallback targetUnit; + private ABNonStackingStatBuffTypeCallback buffType; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CUnit unit = this.targetUnit.callback(caster, localStore, castId); + NonStackingStatBuffType btype = this.buffType.callback(caster, localStore, castId); + if (btype.isHeroStat()) { + unit.computeDerivedHeroFields(localStore.game, btype); + } else { + unit.computeDerivedFields(btype); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RecomputeStatBuffsOnUnit(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " + + this.buffType.generateJassEquivalent(jassTextGenerator) + ")"; + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRemoveDefenseBonus.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRemoveDefenseBonus.java new file mode 100644 index 000000000..693a2c368 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRemoveDefenseBonus.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveDefenseBonus implements ABSingleAction { + + private ABUnitCallback targetUnit; + private ABFloatCallback defenseValue; + private ABBooleanCallback percentage; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit target = this.targetUnit.callback(caster, localStore, castId); + + if (this.percentage.callback(caster, localStore, castId)) { + // TODO need to fix percents + target.setTemporaryDefenseBonus( + target.getTemporaryDefenseBonus() - this.defenseValue.callback(caster, localStore, castId)); + } else { + target.setTemporaryDefenseBonus( + target.getTemporaryDefenseBonus() - this.defenseValue.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "UnitAddDefenseBonus(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", -(" + + this.defenseValue.generateJassEquivalent(jassTextGenerator) + "))//, " + + this.percentage.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRemoveNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRemoveNonStackingStatBuff.java new file mode 100644 index 000000000..28d6ee8dc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionRemoveNonStackingStatBuff.java @@ -0,0 +1,29 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveNonStackingStatBuff implements ABSingleAction { + + private ABUnitCallback targetUnit; + private ABNonStackingStatBuffCallback buff; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CUnit target = this.targetUnit.callback(caster, localStore, castId); + + target.removeNonStackingStatBuff(localStore.game, this.buff.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RemoveUnitNonStackingStatBuff(" + this.targetUnit.generateJassEquivalent(jassTextGenerator) + ", " + + this.buff.generateJassEquivalent(jassTextGenerator) + ")"; + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionUpdateNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionUpdateNonStackingStatBuff.java new file mode 100644 index 000000000..f2b253646 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/stats/ABActionUpdateNonStackingStatBuff.java @@ -0,0 +1,28 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.ABNonStackingStatBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABActionUpdateNonStackingStatBuff implements ABSingleAction { + + private ABNonStackingStatBuffCallback buff; + private ABFloatCallback value; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final NonStackingStatBuff buffObj = this.buff.callback(caster, localStore, castId); + buffObj.setValue(this.value.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "UpdateNonStackingStatBuff(" + this.buff.generateJassEquivalent(jassTextGenerator) + ", " + + this.value.generateJassEquivalent(jassTextGenerator) + ")"; + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionBreak.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionBreak.java new file mode 100644 index 000000000..5c79fc30e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionBreak.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionBreak implements ABSingleAction { + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + localStore.put(ABLocalStoreKeys.BREAK, true); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.setUserDataExpr("AB_LOCAL_STORE_KEY_BREAK", JassTextGeneratorType.Boolean, "true"); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionChainEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionChainEffect.java new file mode 100644 index 000000000..58ba753a0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionChainEffect.java @@ -0,0 +1,167 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABNearestUnitComparator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitComparator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABActionChainEffect implements ABAction { + + private static final Rectangle recycleRect = new Rectangle(); + private List actions; + private ABBooleanCallback condition; + private ABIntegerCallback sort; + + private ABUnitCallback target; + + private ABBooleanCallback lightningFromCaster; + private ABIDCallback lightningId; + private ABIntegerCallback lightningIndex; + + private ABFloatCallback range; + private ABIntegerCallback bounces; + private ABFloatCallback bounceDelay; + + private ABBooleanCallback allowMultipleBouncesPerUnit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit originUnitTarget = this.target.callback(caster, localStore, castId); + boolean multiBounce = localStore.game.getGameplayConstants().isAllowMultiBounce(); + if (allowMultipleBouncesPerUnit != null) { + multiBounce = allowMultipleBouncesPerUnit.callback(caster, localStore, castId); + } + Set hitUnits = null; + if (!multiBounce) { + hitUnits = new HashSet<>(); + hitUnits.add(originUnitTarget); + } + + if (lightningFromCaster == null || lightningFromCaster.callback(caster, localStore, castId)) { + if (lightningId != null) { + int lidx = 0; + if (lightningIndex != null) { + lidx = lightningIndex.callback(caster, localStore, castId); + } + localStore.game.createAbilityLightning(caster, lightningId.callback(caster, localStore, castId), lidx, + originUnitTarget, 2f); + } + } + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CHAINUNIT, castId), originUnitTarget); + for (ABAction iterationAction : actions) { + iterationAction.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CHAINUNIT, castId)); + + startPerformJump(caster, localStore, castId, originUnitTarget, multiBounce, hitUnits, + bounces.callback(caster, localStore, castId)); + + } + + private void startPerformJump(final CUnit caster, final ABLocalDataStore localStore, final int castId, + final CUnit originUnitTarget, final boolean multiBounce, final Set hitUnits, + final int remainingJumps) { + if (remainingJumps <= 0) { + return; + } + float delay = 0; + if (bounceDelay != null) { + delay = bounceDelay.callback(caster, localStore, castId); + } + if (delay > 0) { + CTimer runner = new CTimer() { + @Override + public void onFire(CSimulation simulation) { + performJump(caster, localStore, castId, originUnitTarget, multiBounce, hitUnits, + remainingJumps - 1); + } + }; + runner.setTimeoutTime(delay); + runner.start(localStore.game); + } else { + performJump(caster, localStore, castId, originUnitTarget, multiBounce, hitUnits, remainingJumps - 1); + } + } + + private void performJump(final CUnit caster, final ABLocalDataStore localStore, final int castId, + final CUnit originUnitTarget, final boolean multiBounce, final Set hitUnits, + final int remainingJumps) { + if (originUnitTarget == null) { + return; + } + + final Float rangeVal = this.range.callback(caster, localStore, castId); + + List foundUnits = new ArrayList<>(); + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget != enumUnit && originUnitTarget.canReach(enumUnit, rangeVal) + && (multiBounce || !hitUnits.contains(enumUnit))) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), enumUnit); + if (condition == null || condition.callback(caster, localStore, castId)) { + foundUnits.add(enumUnit); + } + } + return false; + } + }); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + + CUnit jumpUnit = null; + if (foundUnits.size() > 0) { + if (sort != null) { + ABUnitComparator comp = new ABUnitComparator(caster, localStore, castId, sort); + foundUnits.sort(comp); + } else { + foundUnits.sort(ABNearestUnitComparator.INSTANCE); + } + + jumpUnit = foundUnits.get(0); + } + + if (jumpUnit != null) { + if (lightningId != null) { + int lidx = 0; + if (lightningIndex != null) { + lidx = lightningIndex.callback(caster, localStore, castId); + } + localStore.game.createAbilityLightning(originUnitTarget, + lightningId.callback(caster, localStore, castId), lidx, jumpUnit, 2f); + } + + if (!multiBounce) { + hitUnits.add(jumpUnit); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CHAINUNIT, castId), jumpUnit); + for (ABAction iterationAction : actions) { + iterationAction.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CHAINUNIT, castId)); + } + + if (remainingJumps > 0) { + startPerformJump(caster, localStore, castId, jumpUnit, multiBounce, hitUnits, remainingJumps); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionCreateSubroutine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionCreateSubroutine.java new file mode 100644 index 000000000..7f91069c8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionCreateSubroutine.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateSubroutine implements ABSingleAction { + + private ABStringCallback name; + private ABBooleanCallback instanceValue; + private List actions; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + localStore.put(ABLocalStoreKeys.combineSubroutineInstanceKey( + this.name.callback(caster, localStore, castId), castId), this.actions); + } + else { + localStore.put( + ABLocalStoreKeys.combineSubroutineKey(this.name.callback(caster, localStore, castId), castId), + this.actions); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + final String subroutineFunctionName = jassTextGenerator.createAnonymousFunction(this.actions, + "CreateSubroutineAU"); + + String instanceValueExpression = "true"; + if (this.instanceValue == null) { + instanceValueExpression = this.instanceValue.generateJassEquivalent(jassTextGenerator); + } + + return "CreateSubroutineAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.name.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + instanceValueExpression + ", " + jassTextGenerator.functionPointerByName(subroutineFunctionName) + + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionFor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionFor.java new file mode 100644 index 000000000..b349ad344 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionFor.java @@ -0,0 +1,104 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionFor implements ABAction { + + private ABIntegerCallback times; + private List actions; + + private ABCallback unique; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final int max = this.times.callback(caster, localStore, castId); + for (int i = 0; i < max; i++) { + if (this.unique != null) { + localStore.put(ABLocalStoreKeys.combineKey( + ABLocalStoreKeys.ITERATORCOUNT + "$" + this.unique.callback(caster, localStore, castId), + castId), i); + } else { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ITERATORCOUNT, castId), i); + } + for (final ABAction iterationAction : this.actions) { + iterationAction.runAction(caster, localStore, castId); + } + final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); + if ((brk != null) && brk) { + break; + } + } + } + + @Override + public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + + final String keyExpression = "AB_LOCAL_STORE_KEY_ITERATORCOUNT + I2S(" + jassTextGenerator.getCastId() + ")"; + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call " + jassTextGenerator.setUserDataExpr(keyExpression, JassTextGeneratorType.Integer, "0")); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("loop"); + jassTextGenerator.println(sb.toString()); + final int childIndent = indent + 1; + sb.setLength(0); + JassTextGenerator.Util.indent(childIndent, sb); + sb.append("exitwhen "); + sb.append(jassTextGenerator.getUserDataExpr(keyExpression, JassTextGeneratorType.Integer)); + sb.append(" >= "); + sb.append(this.times.generateJassEquivalent(jassTextGenerator)); + jassTextGenerator.println(sb.toString()); + + for (final ABAction action : this.actions) { + action.generateJassEquivalent(childIndent, jassTextGenerator); + } + + sb.setLength(0); + JassTextGenerator.Util.indent(childIndent, sb); + sb.append("if "); + sb.append(jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_BREAK", JassTextGeneratorType.Boolean)); + sb.append(" then"); + jassTextGenerator.println(sb.toString()); + + final int breakBranchIndent = childIndent + 1; + sb.setLength(0); + JassTextGenerator.Util.indent(breakBranchIndent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_BREAK)"); + jassTextGenerator.println(sb.toString()); + sb.setLength(0); + JassTextGenerator.Util.indent(breakBranchIndent, sb); + sb.append("exitwhen true // break"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(childIndent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(childIndent, sb); + sb.append("call " + jassTextGenerator.setUserDataExpr(keyExpression, JassTextGeneratorType.Integer, + jassTextGenerator.getUserDataExpr(keyExpression, JassTextGeneratorType.Integer) + " + 1")); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endloop"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionIf.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionIf.java new file mode 100644 index 000000000..d431f689d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionIf.java @@ -0,0 +1,63 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionIf implements ABAction { + + private ABBooleanCallback condition; + private List thenActions; + private List elseActions; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + if (condition.callback(caster, localStore, castId)) { + if (this.thenActions != null) { + for (ABAction periodicAction : thenActions) { + periodicAction.runAction(caster, localStore, castId); + } + } + } else { + if (this.elseActions != null) { + for (final ABAction periodicAction : this.elseActions) { + periodicAction.runAction(caster, localStore, castId); + } + } + } + } + + @Override + public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("if "); + sb.append(this.condition.generateJassEquivalent(jassTextGenerator)); + sb.append(" then"); + jassTextGenerator.println(sb.toString()); + final int childIndent = indent + 1; + if (this.thenActions != null) { + for (final ABAction action : this.thenActions) { + action.generateJassEquivalent(childIndent, jassTextGenerator); + } + } + if (this.elseActions != null) { + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("else"); + jassTextGenerator.println(sb.toString()); + for (final ABAction action : this.elseActions) { + action.generateJassEquivalent(childIndent, jassTextGenerator); + } + } + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionPeriodicExecute.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionPeriodicExecute.java new file mode 100644 index 000000000..7b59b2de0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionPeriodicExecute.java @@ -0,0 +1,121 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionPeriodicExecute implements ABAction { + private final static int HARD_LOOP_CAP = 100; + + private List periodicActions; + private ABFloatCallback delaySeconds; + private ABBooleanCallback initialTick; + + private ABCallback unique; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + float nextActiveTick = 0; + Object u = null; + if (this.unique != null) { + u = this.unique.callback(caster, localStore, castId); + if (localStore + .containsKey(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId) + "$" + u)) { + nextActiveTick = localStore + .getFloat(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId) + "$" + u); + } + } else { + if (localStore.containsKey(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId))) { + nextActiveTick = localStore + .getFloat(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId)); + } + } + + final int currentTick = localStore.game.getGameTurnTick(); + int iter = 0; + boolean run = true; + while (run && currentTick >= (int) nextActiveTick && iter < HARD_LOOP_CAP) { + if (nextActiveTick <= 0) { + if ((this.initialTick != null) && this.initialTick.callback(caster, localStore, castId)) { + for (final ABAction periodicAction : this.periodicActions) { + periodicAction.runAction(caster, localStore, castId); + final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); + if ((brk != null) && brk) { + run = false; + break; + } + } + } + nextActiveTick = currentTick + (this.delaySeconds.callback(caster, localStore, castId) + / WarsmashConstants.SIMULATION_STEP_TIME); + } else { + for (final ABAction periodicAction : this.periodicActions) { + periodicAction.runAction(caster, localStore, castId); + final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); + if ((brk != null) && brk) { + run = false; + break; + } + } + nextActiveTick += (this.delaySeconds.callback(caster, localStore, castId) + / WarsmashConstants.SIMULATION_STEP_TIME); + } + iter++; + } + + if (this.unique != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId) + "$" + u, + nextActiveTick); + } else { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId), nextActiveTick); + } + } + + @Override + public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { + String uniquenessKeyExpression; + if (this.unique != null) { + uniquenessKeyExpression = "I2S(" + jassTextGenerator.getCastId() + ") + \"$\" + " + + this.unique.generateJassEquivalent(jassTextGenerator); + } else { + uniquenessKeyExpression = "I2S(" + jassTextGenerator.getCastId() + ")"; + } + String initialTickExpression; + if (this.initialTick != null) { + initialTickExpression = this.initialTick.generateJassEquivalent(jassTextGenerator); + } else { + initialTickExpression = "false"; + } + + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("if PeriodicExecuteAU("); + sb.append(jassTextGenerator.getTriggerLocalStore()); + sb.append(", "); + sb.append(this.delaySeconds.generateJassEquivalent(jassTextGenerator)); + sb.append(", "); + sb.append(initialTickExpression); + sb.append(", "); + sb.append(uniquenessKeyExpression); + sb.append(") then"); + jassTextGenerator.println(sb.toString()); + final int childIndent = indent + 1; + if (this.periodicActions != null) { + for (final ABAction action : this.periodicActions) { + action.generateJassEquivalent(childIndent, jassTextGenerator); + } + } + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionResetPeriodicExecute.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionResetPeriodicExecute.java new file mode 100644 index 000000000..58a9a1949 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionResetPeriodicExecute.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionResetPeriodicExecute implements ABAction { + + private ABCallback unique; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + if (this.unique != null) { + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId) + "$" + + this.unique.callback(caster, localStore, castId)); + } else { + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PERIODICNEXTTICK, castId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunReuseAction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunReuseAction.java new file mode 100644 index 000000000..1620a53d9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunReuseAction.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABActionRunReuseAction implements ABSingleAction { + + private ABStringCallback name; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseActions() != null) { + List actions = config.getReuseActions().get(keyS); + if (actions != null && !actions.isEmpty()) { + for (final ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } else { +// System.err.println("Trying to run ReuseAction, but key is missing or empty: " + keyS); + } + } else { +// System.err.println("Trying to run ReuseAction ("+keyS+"), but none defined"); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunReuseActionWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunReuseActionWithArguments.java new file mode 100644 index 000000000..3b44fbd2a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunReuseActionWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABActionRunReuseActionWithArguments implements ABSingleAction { + + private ABStringCallback name; + private Map arguments; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseActions() != null) { + List actions = config.getReuseActions().get(keyS); + if (actions != null && !actions.isEmpty()) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + for (final ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } else { +// System.err.println("Trying to run ReuseAction with args, but key is missing or empty: " + keyS); + } + } else { +// System.err.println("Trying to run ReuseAction with args (\"+keyS+\"), but none defined"); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunSubroutine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunSubroutine.java new file mode 100644 index 000000000..4d5de81e7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionRunSubroutine.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionRunSubroutine implements ABSingleAction { + + private ABStringCallback name; + private ABBooleanCallback instanceValue; + + @Override + @SuppressWarnings("unchecked") + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + List actions; + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + actions = (List) localStore.get(ABLocalStoreKeys + .combineSubroutineInstanceKey(this.name.callback(caster, localStore, castId), castId)); + } else { + actions = (List) localStore.get(ABLocalStoreKeys + .combineSubroutineKey(this.name.callback(caster, localStore, castId), castId)); + } + if (actions != null) { + for (final ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String instanceValueExpression = "true"; + if (this.instanceValue != null) { + instanceValueExpression = this.instanceValue.generateJassEquivalent(jassTextGenerator); + } + + return "RunSubroutineAU(" + jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + + ", " + jassTextGenerator.getCastId() + ", " + this.name.generateJassEquivalent(jassTextGenerator) + + ", " + instanceValueExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionWhile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionWhile.java new file mode 100644 index 000000000..bf6ece2b2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/structural/ABActionWhile.java @@ -0,0 +1,77 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionWhile implements ABAction { + + private ABBooleanCallback condition; + private List loopActions; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + while (condition.callback(caster, localStore, castId)) { + for (ABAction periodicAction : loopActions) { + periodicAction.runAction(caster, localStore, castId); + } + final Boolean brk = (Boolean) localStore.remove(ABLocalStoreKeys.BREAK); + if ((brk != null) && brk) { + break; + } + } + } + + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("loop"); + jassTextGenerator.println(sb.toString()); + final int childIndent = indent + 1; + sb.setLength(0); + JassTextGenerator.Util.indent(childIndent, sb); + sb.append("exitwhen not "); + sb.append(this.condition.generateJassEquivalent(jassTextGenerator)); + jassTextGenerator.println(sb.toString()); + + for (final ABAction action : this.loopActions) { + action.generateJassEquivalent(childIndent, jassTextGenerator); + } + + sb.setLength(0); + JassTextGenerator.Util.indent(childIndent, sb); + sb.append("if "); + sb.append(jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_BREAK", JassTextGeneratorType.Boolean)); + sb.append(" then"); + jassTextGenerator.println(sb.toString()); + + final int breakBranchIndent = childIndent + 1; + sb.setLength(0); + JassTextGenerator.Util.indent(breakBranchIndent, sb); + sb.append("call FlushChildLocalStore(" + jassTextGenerator.getTriggerLocalStore() + + ", AB_LOCAL_STORE_KEY_BREAK)"); + jassTextGenerator.println(sb.toString()); + sb.setLength(0); + JassTextGenerator.Util.indent(breakBranchIndent, sb); + sb.append("exitwhen true // break"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(childIndent, sb); + sb.append("endif"); + jassTextGenerator.println(sb.toString()); + + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("endloop"); + jassTextGenerator.println(sb.toString()); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionCreateTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionCreateTimer.java new file mode 100644 index 000000000..fa0a92346 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionCreateTimer.java @@ -0,0 +1,74 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.timer; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABActionCreateTimer implements ABSingleAction { + + private ABFloatCallback timeout; + private ABBooleanCallback repeats; + private List actions; + private ABBooleanCallback startTimer; + private ABFloatCallback delay; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + + final CTimer timer = new ABTimer(caster, localStore, this.actions, castId); + timer.setTimeoutTime(this.timeout.callback(caster, localStore, castId)); + localStore.put(ABLocalStoreKeys.LASTCREATEDTIMER, timer); + + if ((this.repeats != null) && this.repeats.callback(caster, localStore, castId)) { + timer.setRepeats(true); + if ((this.startTimer == null) || this.startTimer.callback(caster, localStore, castId)) { + if (this.delay != null) { + timer.startRepeatingTimerWithDelay(localStore.game, this.delay.callback(caster, localStore, castId)); + } else { + timer.start(localStore.game); + } + localStore.put(ABLocalStoreKeys.LASTSTARTEDTIMER, timer); + } + } else { + if ((this.startTimer == null) || this.startTimer.callback(caster, localStore, castId)) { + timer.start(localStore.game); + localStore.put(ABLocalStoreKeys.LASTSTARTEDTIMER, timer); + } + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + final String funcName = jassTextGenerator.createAnonymousFunction(this.actions, "CreateTimerAU_OnTimerFire"); + + String repeatsExpression = "false"; + if (this.repeats != null) { + repeatsExpression = this.repeats.generateJassEquivalent(jassTextGenerator); + } + + String startTimerExpression = "true"; + if (this.startTimer != null) { + startTimerExpression = this.startTimer.generateJassEquivalent(jassTextGenerator); + } + + final String args = jassTextGenerator.getCaster() + ", " + jassTextGenerator.getTriggerLocalStore() + ", " + + jassTextGenerator.getCastId() + ", " + this.timeout.generateJassEquivalent(jassTextGenerator) + ", " + + repeatsExpression + ", " + jassTextGenerator.functionPointerByName(funcName) + ", " + + startTimerExpression; + + if (this.delay != null) { + return "CreateTimerDelayedAU(" + args + ", " + this.delay.generateJassEquivalent(jassTextGenerator) + ")"; + } else { + return "CreateTimerAU(" + args + ")"; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionKillTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionKillTimer.java new file mode 100644 index 000000000..ceb3f1b73 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionKillTimer.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.timer; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer.ABTimerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionKillTimer implements ABSingleAction { + + private ABTimerCallback timer; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + this.timer.callback(caster, localStore, castId).kill(localStore.game); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "PauseTimer(" + this.timer.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionRemoveTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionRemoveTimer.java new file mode 100644 index 000000000..a8cffe362 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionRemoveTimer.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.timer; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer.ABTimerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveTimer implements ABSingleAction { + + private ABTimerCallback timer; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + this.timer.callback(caster, localStore, castId).pause(localStore.game); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "PauseTimer(" + this.timer.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionStartTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionStartTimer.java new file mode 100644 index 000000000..e6a49c817 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionStartTimer.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.timer; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer.ABTimerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABActionStartTimer implements ABSingleAction { + + private ABTimerCallback timer; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CTimer t = this.timer.callback(caster, localStore, castId); + t.start(localStore.game); + localStore.put(ABLocalStoreKeys.LASTSTARTEDTIMER, t); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "StartTimerAU(" + this.timer.generateJassEquivalent(jassTextGenerator) + ", " + + jassTextGenerator.getTriggerLocalStore() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionUpdateTimerTimeout.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionUpdateTimerTimeout.java new file mode 100644 index 000000000..017fbb806 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/timer/ABActionUpdateTimerTimeout.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.timer; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer.ABTimerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABActionUpdateTimerTimeout implements ABSingleAction { + + private ABTimerCallback timer; + private ABFloatCallback timeout; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CTimer theT = this.timer.callback(caster, localStore, castId); + theT.resetTimeoutTime(this.timeout.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "ABTimerSetTimeoutTime(" + this.timer.generateJassEquivalent(jassTextGenerator) + ", " + + this.timeout.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionAbilityAddUniqueFlag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionAbilityAddUniqueFlag.java new file mode 100644 index 000000000..e021d561e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionAbilityAddUniqueFlag.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniqueflag; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAbilityAddUniqueFlag implements ABSingleAction { + + private ABAbilityCallback ability; + private ABStringCallback flag; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CAbility theAbility = this.ability.callback(caster, localStore, castId); + if (theAbility instanceof ABAbilityBuilderAbility) { + ((ABAbilityBuilderAbility) theAbility).addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionAbilityRemoveUniqueFlag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionAbilityRemoveUniqueFlag.java new file mode 100644 index 000000000..1a70fe5b4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionAbilityRemoveUniqueFlag.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniqueflag; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAbilityRemoveUniqueFlag implements ABSingleAction { + + private ABAbilityCallback ability; + private ABStringCallback flag; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CAbility theAbility = this.ability.callback(caster, localStore, castId); + if (theAbility instanceof ABAbilityBuilderAbility) { + ((ABAbilityBuilderAbility) theAbility).removeUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionBuffAddUniqueFlag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionBuffAddUniqueFlag.java new file mode 100644 index 000000000..773faaa6c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionBuffAddUniqueFlag.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniqueflag; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionBuffAddUniqueFlag implements ABSingleAction { + + private ABBuffCallback buff; + private ABStringCallback flag; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CBuff theBuff = this.buff.callback(caster, localStore, castId); + if (theBuff instanceof ABBuff) { + ((ABBuff)theBuff).addUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionBuffRemoveUniqueFlag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionBuffRemoveUniqueFlag.java new file mode 100644 index 000000000..5d489f17d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniqueflag/ABActionBuffRemoveUniqueFlag.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniqueflag; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionBuffRemoveUniqueFlag implements ABSingleAction { + + private ABBuffCallback buff; + private ABStringCallback flag; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CBuff theBuff = this.buff.callback(caster, localStore, castId); + if (theBuff instanceof ABBuff) { + ((ABBuff)theBuff).removeUniqueFlag(flag.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionAbilityRemoveUniqueValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionAbilityRemoveUniqueValue.java new file mode 100644 index 000000000..f1d3b23e6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionAbilityRemoveUniqueValue.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniquevalue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAbilityRemoveUniqueValue implements ABAction { + + private ABAbilityCallback ability; + private ABStringCallback key; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CAbility theAbility = null; + if (ability != null) { + theAbility = ability.callback(caster, localStore, castId); + } else { + theAbility = localStore.originAbility; + } + theAbility.removeUniqueValue(key.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionAbilityStoreUniqueValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionAbilityStoreUniqueValue.java new file mode 100644 index 000000000..c7ae55aa4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionAbilityStoreUniqueValue.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniquevalue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAbilityStoreUniqueValue implements ABAction { + + private ABAbilityCallback ability; + private ABStringCallback key; + private ABCallback valueToStore; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CAbility theAbility = null; + if (ability != null) { + theAbility = ability.callback(caster, localStore, castId); + } else { + theAbility = localStore.originAbility; + } + theAbility.addUniqueValue(valueToStore.callback(caster, localStore, castId), + key.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionBuffRemoveUniqueValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionBuffRemoveUniqueValue.java new file mode 100644 index 000000000..d218d5779 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionBuffRemoveUniqueValue.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniquevalue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionBuffRemoveUniqueValue implements ABAction { + + private ABBuffCallback buff; + private ABStringCallback key; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CBuff theAbility = buff.callback(caster, localStore, castId); + theAbility.removeUniqueValue(key.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionBuffStoreUniqueValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionBuffStoreUniqueValue.java new file mode 100644 index 000000000..44230910d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/uniquevalue/ABActionBuffStoreUniqueValue.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniquevalue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionBuffStoreUniqueValue implements ABAction { + + private ABBuffCallback buff; + private ABStringCallback key; + private ABCallback valueToStore; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CBuff theAbility = buff.callback(caster, localStore, castId); + theAbility.addUniqueValue(valueToStore.callback(caster, localStore, castId), key.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionCreateUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionCreateUnit.java new file mode 100644 index 000000000..8ae5612d1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionCreateUnit.java @@ -0,0 +1,79 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitClassification; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABActionCreateUnit implements ABSingleAction { + + private ABIDCallback id; + private ABPlayerCallback owner; + private ABLocationCallback loc; + private ABFloatCallback facing; + + private ABBooleanCallback addSummonedTag; + private ABBooleanCallback removeFood; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + War3ID theId = id.callback(caster, localStore, castId); + if (theId == null) { + return; + } + + CPlayer thePlayer = null; + float theFacing = 0; + if (this.owner != null) { + thePlayer = this.owner.callback(caster, localStore, castId); + } else { + thePlayer = localStore.game.getPlayer(caster.getPlayerIndex()); + } + if (this.facing != null) { + theFacing = this.facing.callback(caster, localStore, castId); + } + final AbilityPointTarget location = this.loc.callback(caster, localStore, castId); + final CUnit createdUnit = localStore.game.createUnitSimple(theId, thePlayer.getId(), location.getX(), + location.getY(), theFacing); + + if (addSummonedTag == null || addSummonedTag.callback(caster, localStore, castId)) { + createdUnit.addClassification(CUnitClassification.SUMMONED); + } + + if (removeFood != null && removeFood.callback(caster, localStore, castId)) { + thePlayer.setUnitFoodUsed(createdUnit, 0); + thePlayer.setUnitFoodMade(createdUnit, 0); + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDUNIT, createdUnit); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String playerIndexExpression; + if (this.owner != null) { + playerIndexExpression = this.owner.generateJassEquivalent(jassTextGenerator); + } else { + playerIndexExpression = "TODOJASS(" + jassTextGenerator.getCaster() + ")"; + } + + String facingExpression = "bj_UNIT_FACING"; + if (this.facing != null) { + facingExpression = this.facing.generateJassEquivalent(jassTextGenerator); + } + + return "CreateUnitAtLoc(" + playerIndexExpression + ", " + this.id.generateJassEquivalent(jassTextGenerator) + + ", " + this.loc.generateJassEquivalent(jassTextGenerator) + ", " + facingExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionHideUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionHideUnit.java new file mode 100644 index 000000000..5eae71a6e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionHideUnit.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionHideUnit implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + targetUnit.setHidden(true); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "ShowUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", false)"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionKillUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionKillUnit.java new file mode 100644 index 000000000..355db82cd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionKillUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionKillUnit implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + targetUnit.kill(localStore.game); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "KillUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionRemoveUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionRemoveUnit.java new file mode 100644 index 000000000..89c89e9d0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionRemoveUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveUnit implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + localStore.game.removeUnit(targetUnit); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "RemoveUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionResurrect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionResurrect.java new file mode 100644 index 000000000..86fd77e93 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionResurrect.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionResurrect implements ABSingleAction { + + private ABUnitCallback target; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.target.callback(caster, localStore, castId); + if (targetUnit.isDead()) { + targetUnit.resurrect(localStore.game); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "ResurrectUnit(" + this.target.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionSetExplodesOnDeath.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionSetExplodesOnDeath.java new file mode 100644 index 000000000..fc1581042 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionSetExplodesOnDeath.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetExplodesOnDeath implements ABAction { + + private ABUnitCallback unit; + private ABBooleanCallback explodes; + private ABIDCallback buffId; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + targetUnit.setExplodesOnDeath(this.explodes.callback(caster, localStore, castId)); + if (this.buffId != null) { + targetUnit.setExplodesOnDeathBuffId(this.buffId.callback(caster, localStore, castId)); + } + } + + @Override + public void generateJassEquivalent(int indent, JassTextGenerator jassTextGenerator) { + final StringBuilder sb = new StringBuilder(); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call SetUnitExploded("); + sb.append(this.unit.generateJassEquivalent(jassTextGenerator)); + sb.append(", "); + sb.append(this.explodes.generateJassEquivalent(jassTextGenerator)); + sb.append(")"); + jassTextGenerator.println(sb.toString()); + + if (this.buffId != null) { + sb.setLength(0); + JassTextGenerator.Util.indent(indent, sb); + sb.append("call SetUnitExplodeOnDeathBuffId("); + sb.append(this.unit.generateJassEquivalent(jassTextGenerator)); + sb.append(", "); + sb.append(this.buffId.generateJassEquivalent(jassTextGenerator)); + sb.append(")"); + jassTextGenerator.println(sb.toString()); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionStartSacrificingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionStartSacrificingUnit.java new file mode 100644 index 000000000..796831457 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionStartSacrificingUnit.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionStartSacrificingUnit implements ABSingleAction { + + private ABUnitCallback unit; + private ABUnitCallback sacrifice; + private ABIDCallback id; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit theUnit = this.unit.callback(caster, localStore, castId); + theUnit.queueSacrificingUnit(localStore.game, this.id.callback(caster, localStore, castId), + this.sacrifice.callback(caster, localStore, castId)); + theUnit.notifyOrdersChanged(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "StartSacrificingUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.sacrifice.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionStartTrainingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionStartTrainingUnit.java new file mode 100644 index 000000000..70f721119 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionStartTrainingUnit.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionStartTrainingUnit implements ABSingleAction { + + private ABUnitCallback unit; + private ABIDCallback id; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit theUnit = this.unit.callback(caster, localStore, castId); + theUnit.queueTrainingUnit(localStore.game, this.id.callback(caster, localStore, castId)); + theUnit.notifyOrdersChanged(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "StartTrainingUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.id.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionUnhideUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionUnhideUnit.java new file mode 100644 index 000000000..9e81915ad --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/ABActionUnhideUnit.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionUnhideUnit implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + targetUnit.setHidden(false); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "ShowUnit(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", true)"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionAddSecondaryAnimationTag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionAddSecondaryAnimationTag.java new file mode 100644 index 000000000..a47cc29c5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionAddSecondaryAnimationTag.java @@ -0,0 +1,31 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.animation; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddSecondaryAnimationTag implements ABSingleAction { + + private ABUnitCallback unit; + private ABStringCallback tag; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + if (targetUnit.getUnitAnimationListener() + .addSecondaryTag(SecondaryTag.valueOf(this.tag.callback(caster, localStore, castId)))) { + targetUnit.getUnitAnimationListener().forceResetCurrentAnimation(); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AddUnitAnimationProperties(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.tag.generateJassEquivalent(jassTextGenerator) + ", true)"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionPlayAnimation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionPlayAnimation.java new file mode 100644 index 000000000..05ab906b5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionPlayAnimation.java @@ -0,0 +1,60 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.animation; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionPlayAnimation implements ABSingleAction { + + private ABUnitCallback unit; + private ABStringCallback tag; + + private ABBooleanCallback force; + private ABFloatCallback speed; + private ABBooleanCallback allowVariations; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + boolean f = true; + float s = 1f; + boolean av = false; + if (this.force != null) { + f = this.force.callback(caster, localStore, castId); + } + if (this.speed != null) { + s = this.speed.callback(caster, localStore, castId); + } + if (this.allowVariations != null) { + av = this.allowVariations.callback(caster, localStore, castId); + } + + targetUnit.getUnitAnimationListener().playAnimation(f, + PrimaryTag.valueOf(this.tag.callback(caster, localStore, castId)), SequenceUtils.EMPTY, s, av); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + // TODO: the stuff exposed by warsmash below is not in jass yet + if ((this.force != null) && !this.force.generateJassEquivalent(jassTextGenerator).equals("true")) { + throw new UnsupportedOperationException(); + } + if ((this.allowVariations != null) + && !this.allowVariations.generateJassEquivalent(jassTextGenerator).equals("true")) { + throw new UnsupportedOperationException(); + } + if (this.speed != null) { + throw new UnsupportedOperationException(); + } + return "SetUnitAnimation(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.tag.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionQueueAnimation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionQueueAnimation.java new file mode 100644 index 000000000..92a13bfda --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionQueueAnimation.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.animation; + +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionQueueAnimation implements ABAction { + + private ABUnitCallback unit; + private ABStringCallback tag; + + private ABBooleanCallback allowVariations; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + boolean av = false; + if (this.allowVariations != null) { + av = this.allowVariations.callback(caster, localStore, castId); + } + + targetUnit.getUnitAnimationListener().queueAnimation( + PrimaryTag.valueOf(this.tag.callback(caster, localStore, castId)), SequenceUtils.EMPTY, av); + } + + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionRemoveSecondaryAnimationTag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionRemoveSecondaryAnimationTag.java new file mode 100644 index 000000000..3ea31cafe --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/animation/ABActionRemoveSecondaryAnimationTag.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.animation; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveSecondaryAnimationTag implements ABSingleAction { + + private ABUnitCallback unit; + private ABStringCallback tag; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + if (targetUnit.getUnitAnimationListener() + .removeSecondaryTag(SecondaryTag.valueOf(this.tag.callback(caster, localStore, castId)))) { + targetUnit.getUnitAnimationListener().forceResetCurrentAnimation(); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "AddUnitAnimationProperties(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.tag.generateJassEquivalent(jassTextGenerator) + ", false)"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionDivideUnitAlpha.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionDivideUnitAlpha.java new file mode 100644 index 000000000..6d03dd0df --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionDivideUnitAlpha.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.art; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionDivideUnitAlpha implements ABSingleAction { + + private ABUnitCallback unit; + private ABFloatCallback value; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + final float[] color = localStore.game.getUnitVertexColor(targetUnit); + + localStore.game.changeUnitVertexColor(targetUnit, color[0], color[1], color[2], + color[3] / this.value.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + throw new UnsupportedOperationException(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionMultiplyUnitAlpha.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionMultiplyUnitAlpha.java new file mode 100644 index 000000000..c0cb25a8b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionMultiplyUnitAlpha.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.art; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionMultiplyUnitAlpha implements ABSingleAction { + + private ABUnitCallback unit; + private ABFloatCallback value; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + final float[] color = localStore.game.getUnitVertexColor(targetUnit); + + localStore.game.changeUnitVertexColor(targetUnit, color[0], color[1], color[2], + color[3] * this.value.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + throw new UnsupportedOperationException(); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionMultiplyUnitScale.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionMultiplyUnitScale.java new file mode 100644 index 000000000..f984277ac --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionMultiplyUnitScale.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.art; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionMultiplyUnitScale implements ABSingleAction { + + private ABUnitCallback unit; + private ABFloatCallback value; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + localStore.game.changeUnitScale(targetUnit, value.callback(caster, localStore, castId), true); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "JASSTODO"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionSetUnitAlpha.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionSetUnitAlpha.java new file mode 100644 index 000000000..76e5728f3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/art/ABActionSetUnitAlpha.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.art; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetUnitAlpha implements ABSingleAction { + + private ABUnitCallback unit; + private ABFloatCallback value; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + final float[] color = localStore.game.getUnitVertexColor(targetUnit); + + localStore.game.changeUnitVertexColor(targetUnit, color[0], color[1], color[2], + this.value.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + throw new UnsupportedOperationException(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/movement/ABActionSetUnitFlyHeight.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/movement/ABActionSetUnitFlyHeight.java new file mode 100644 index 000000000..ecb604e6f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/movement/ABActionSetUnitFlyHeight.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.movement; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetUnitFlyHeight implements ABSingleAction { + + private ABUnitCallback unit; + private ABFloatCallback height; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + targetUnit.setFlyHeight(this.height.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "SetUnitFlyHeight(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + this.height.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/movement/ABActionSetUnitMovementTypeNoCollision.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/movement/ABActionSetUnitMovementTypeNoCollision.java new file mode 100644 index 000000000..1f7d8e850 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/movement/ABActionSetUnitMovementTypeNoCollision.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.movement; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetUnitMovementTypeNoCollision implements ABSingleAction { + + private ABUnitCallback unit; + private ABBooleanCallback active; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + if (this.active != null) { + targetUnit.setNoCollisionMovementType(this.active.callback(caster, localStore, castId)); + } else { + targetUnit.setNoCollisionMovementType(true); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String activeExpression = "true"; + if (this.active != null) { + activeExpression = this.active.generateJassEquivalent(jassTextGenerator); + } + return "SetUnitMovementTypeNoCollision(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", " + + activeExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionAddMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionAddMp.java new file mode 100644 index 000000000..074d49741 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionAddMp.java @@ -0,0 +1,47 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddMp implements ABSingleAction { + + private ABUnitCallback target; + private ABFloatCallback amount; + private ABBooleanCallback isPercent; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean percent = false; + if (this.isPercent != null) { + percent = this.isPercent.callback(caster, localStore, castId); + } + final CUnit targetUnit = this.target.callback(caster, localStore, castId); + if (percent) { + targetUnit.setMana(Math.max(Math.min( + targetUnit.getMana() + + (this.amount.callback(caster, localStore, castId) * targetUnit.getMaximumMana()), + targetUnit.getMaximumMana()), 0)); + } + else { + targetUnit.setMana( + Math.max(Math.min(targetUnit.getMana() + this.amount.callback(caster, localStore, castId), + targetUnit.getMaximumMana()), 0)); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String percentExpression = "false"; + if (this.isPercent != null) { + percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); + } + return "AddMpAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetHp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetHp.java new file mode 100644 index 000000000..e0d684f4a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetHp.java @@ -0,0 +1,43 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetHp implements ABSingleAction { + + private ABUnitCallback target; + private ABFloatCallback amount; + private ABBooleanCallback isPercent; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean percent = false; + if (this.isPercent != null) { + percent = this.isPercent.callback(caster, localStore, castId); + } + if (percent) { + final CUnit targetUnit = this.target.callback(caster, localStore, castId); + targetUnit.setCurrentHp(localStore.game, + this.amount.callback(caster, localStore, castId) * targetUnit.getMaximumLife()); + } + else { + this.target.callback(caster, localStore, castId).setCurrentHp(localStore.game, + this.amount.callback(caster, localStore, castId)); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String percentExpression = "false"; + if (this.isPercent != null) { + percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); + } + return "SetUnitHpAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetMp.java new file mode 100644 index 000000000..d00e2c8e9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetMp.java @@ -0,0 +1,44 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetMp implements ABSingleAction { + + private ABUnitCallback target; + private ABFloatCallback amount; + private ABBooleanCallback isPercent; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean percent = false; + if (this.isPercent != null) { + percent = this.isPercent.callback(caster, localStore, castId); + } + final CUnit targetUnit = this.target.callback(caster, localStore, castId); + if (percent) { + targetUnit.setMana(Math + .max(Math.min(this.amount.callback(caster, localStore, castId) * targetUnit.getMaximumMana(), + targetUnit.getMaximumMana()), 0)); + } else { + targetUnit.setMana(Math.max( + Math.min(this.amount.callback(caster, localStore, castId), targetUnit.getMaximumMana()), 0)); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String percentExpression = "false"; + if (this.isPercent != null) { + percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); + } + return "SetUnitMpAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + + this.amount.generateJassEquivalent(jassTextGenerator) + ", " + percentExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetSpeed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetSpeed.java new file mode 100644 index 000000000..331d90514 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSetSpeed.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.stats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetSpeed implements ABAction { + + private ABUnitCallback unit; + private ABIntegerCallback value; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + targetUnit.setSpeed(value.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSubtractMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSubtractMp.java new file mode 100644 index 000000000..45c125309 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/stats/ABActionSubtractMp.java @@ -0,0 +1,46 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.stats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSubtractMp implements ABSingleAction { + + private ABUnitCallback unit; + private ABFloatCallback amount; + private ABBooleanCallback isPercent; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean percent = false; + if (this.isPercent != null) { + percent = this.isPercent.callback(caster, localStore, castId); + } + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + if (percent) { + targetUnit.setMana(Math.max(Math.min( + targetUnit.getMana() + - (this.amount.callback(caster, localStore, castId) * targetUnit.getMaximumMana()), + targetUnit.getMaximumMana()), 0)); + } + else { + targetUnit.setMana( + Math.max(Math.min(targetUnit.getMana() - this.amount.callback(caster, localStore, castId), + targetUnit.getMaximumMana()), 0)); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String percentExpression = "false"; + if (this.isPercent != null) { + percentExpression = this.isPercent.generateJassEquivalent(jassTextGenerator); + } + return "AddMpAU(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", -(" + + this.amount.generateJassEquivalent(jassTextGenerator) + "), " + percentExpression + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionMergeUnits.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionMergeUnits.java new file mode 100644 index 000000000..2f7445599 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionMergeUnits.java @@ -0,0 +1,98 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.transformation; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionMergeUnits implements ABSingleAction { + + private ABUnitCallback unit1; + private ABUnitCallback unit2; + private ABIDCallback newUnitId; + private ABLocationCallback location; + private ABFloatCallback facing; + + private ABIntegerCallback playerIndex; + private ABBooleanCallback resetHpMp; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + int thePlayerId = caster.getPlayerIndex(); + float theFacing = caster.getFacing(); + AbilityPointTarget loc = null; + if (this.playerIndex != null) { + thePlayerId = this.playerIndex.callback(caster, localStore, castId); + } + if (this.facing != null) { + theFacing = this.facing.callback(caster, localStore, castId); + } + if (this.location != null) { + loc = this.location.callback(caster, localStore, castId); + } else { + loc = new AbilityPointTarget(caster.getX(), caster.getY()); + } + + final CUnit u1 = this.unit1.callback(caster, localStore, castId); + final CUnit u2 = this.unit2.callback(caster, localStore, castId); + + final float newHPPcnt = ((u1.getLife() / u1.getMaximumLife()) + (u2.getLife() / u2.getMaximumLife())) / 2; + final float newMPPcnt = ((u1.getMana() / u1.getMaximumMana()) + (u2.getMana() / u2.getMaximumMana())) / 2; + + final CUnit createdUnit = localStore.game.createUnit(this.newUnitId.callback(caster, localStore, castId), + thePlayerId, loc.getX(), loc.getY(), theFacing); + if ((this.resetHpMp == null) || !this.resetHpMp.callback(caster, localStore, castId)) { + createdUnit.setLife(localStore.game, newHPPcnt * createdUnit.getMaximumLife()); + createdUnit.setMana(newMPPcnt * createdUnit.getMaximumMana()); + } + localStore.game.unitPreferredSelectionReplacement(u1, createdUnit); + localStore.game.unitPreferredSelectionReplacement(u2, createdUnit); + + localStore.game.removeUnit(u1); + localStore.game.removeUnit(u2); + + localStore.put(ABLocalStoreKeys.LASTCREATEDUNIT, createdUnit); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String playerExpression; + if (this.playerIndex != null) { + playerExpression = "Player(" + this.playerIndex.generateJassEquivalent(jassTextGenerator) + ")"; + } else { + playerExpression = "GetOwningPlayer(" + jassTextGenerator.getCaster() + ")"; + } + String facingExpression; + if (this.facing != null) { + facingExpression = this.facing.generateJassEquivalent(jassTextGenerator); + } else { + facingExpression = "GetUnitFacing(" + jassTextGenerator.getCaster() + ")"; + } + String locExpression; + if (this.location != null) { + locExpression = this.location.generateJassEquivalent(jassTextGenerator); + } else { + locExpression = "GetUnitLoc(" + jassTextGenerator.getCaster() + ")"; + } + + String resetHpMpExpression = "false"; + if (this.resetHpMp != null) { + resetHpMpExpression = this.resetHpMp.generateJassEquivalent(jassTextGenerator); + } + + return "MergeUnitsAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.unit1.generateJassEquivalent(jassTextGenerator) + ", " + + this.unit2.generateJassEquivalent(jassTextGenerator) + ", " + + this.newUnitId.generateJassEquivalent(jassTextGenerator) + ", " + locExpression + ", " + + facingExpression + ", " + playerExpression + ", " + resetHpMpExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnit.java new file mode 100644 index 000000000..d1dbd0b00 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnit.java @@ -0,0 +1,197 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.transformation; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorFinishTransformation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABActionTransformUnit implements ABAction { + + private ABUnitCallback unit; + private ABIDCallback baseUnitId; + private ABIDCallback alternateUnitId; + + private ABBooleanCallback keepRatios; + + private ABBooleanCallback immediateLanding; // true: play morph immediately, false: play morph after + private ABBooleanCallback immediateTakeOff; // true: play morph immediately, false: play morph after + private ABBooleanCallback permanent; // remove ability after transform + private ABBooleanCallback requiresPayment; +// private ABBooleanCallback uninterruptable; + + private ABFloatCallback altitudeAdjustmentDelay; // time before the unit starts changing height, only applies if + // going not flying->flying + private ABFloatCallback altitudeAdjustmentTime; // the time spent changing height, only applies if one type is + // flying + private ABFloatCallback landingDelayTime; // Added to the transform time, only applies when going flying->not flying + + private ABFloatCallback transformTime; // the time the unit is locked for the transformation + + private ABFloatCallback duration; // the time before the unit is forced to change back (doesn't charge for it) + private ABIDCallback buffId; + private ABBooleanCallback instantTransformAtDurationEnd; + + private ABBooleanCallback onlyTransformToAlternate; + + private List onTransformActions; + private List onUntransformActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit u1 = caster; + if (unit != null) { + u1 = unit.callback(caster, localStore, castId); + } + War3ID baseId = baseUnitId.callback(caster, localStore, castId); + War3ID altId = alternateUnitId.callback(caster, localStore, castId); + CPlayer pl = localStore.game.getPlayer(u1.getPlayerIndex()); + boolean charge = false; + boolean addAlternateTagAfter = false; + if (this.requiresPayment != null) { + charge = this.requiresPayment.callback(caster, localStore, castId); + } + ABAbilityBuilderAbility abil = localStore.originAbility; + + if (baseId == null || altId == null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + + CUnitType targetType = null; + + boolean onlyToAlt = false; + if (onlyTransformToAlternate != null) { + onlyToAlt = onlyTransformToAlternate.callback(caster, localStore, castId); + } + + if (!onlyToAlt && u1.getTypeId().equals(altId)) { + // Transforming back + targetType = localStore.game.getUnitData().getUnitType(baseId); + if (targetType.equals(u1.getUnitType())) { + // No need to do anything + return; + } + } else { + // Transforming to alt + addAlternateTagAfter = true; + targetType = localStore.game.getUnitData().getUnitType(altId); + } + + int goldCost = 0; + int lumberCost = 0; + Integer foodCost = null; + if (charge) { + if (localStore.game.getGameplayConstants().isRelativeUpgradeCosts()) { + goldCost = targetType.getGoldCost() - u1.getUnitType().getGoldCost(); + lumberCost = targetType.getLumberCost() - u1.getUnitType().getLumberCost(); + if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + } else { + goldCost = targetType.getGoldCost(); + lumberCost = targetType.getLumberCost(); + if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + } + foodCost = Math.max(targetType.getFoodUsed() - u1.getUnitType().getFoodUsed(), 0); + if (foodCost > 0 && pl.getFoodUsed() + foodCost > pl.getFoodCap()) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + } + OnTransformationActions actions = new OnTransformationActions(goldCost, lumberCost, foodCost, + onTransformActions, onUntransformActions, castId); + + boolean perm = false; + boolean isKeepRatios = true; + float dur = 0; + float transTime = 0; + float landTime = 0; + float atlAdDelay = 0; + float altAdTime = 0; + boolean imLand = false; + boolean imTakeOff = false; + War3ID theBuffId = null; + boolean instant = false; + if (permanent != null) { + perm = permanent.callback(caster, localStore, castId); + } + if (keepRatios != null) { + isKeepRatios = keepRatios.callback(caster, localStore, castId); + } + if (duration != null) { + dur = duration.callback(caster, localStore, castId); + } + if (transformTime != null) { + transTime = transformTime.callback(caster, localStore, castId); + } + if (landingDelayTime != null) { + landTime = landingDelayTime.callback(caster, localStore, castId); + } + if (altitudeAdjustmentDelay != null) { + atlAdDelay = altitudeAdjustmentDelay.callback(caster, localStore, castId); + } + if (altitudeAdjustmentTime != null) { + altAdTime = altitudeAdjustmentTime.callback(caster, localStore, castId); + } + if (immediateLanding != null) { + imLand = immediateLanding.callback(caster, localStore, castId); + } + if (immediateTakeOff != null) { + imTakeOff = immediateTakeOff.callback(caster, localStore, castId); + } + if (buffId != null) { + theBuffId = buffId.callback(caster, localStore, castId); + } + if (instantTransformAtDurationEnd != null) { + instant = instantTransformAtDurationEnd.callback(caster, localStore, castId); + } + + if (transTime > 0) { + int orderId = -1; + if (abil instanceof ABAbilityBuilderActiveAbility) { + ABAbilityBuilderActiveAbility activeabil = (ABAbilityBuilderActiveAbility) abil; + orderId = addAlternateTagAfter ? activeabil.getBaseOrderId() : activeabil.getOffOrderId(); + } + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.TRANSFORMINGTOALT, castId), + addAlternateTagAfter); + localStore.put(ABLocalStoreKeys.NEWBEHAVIOR, + new ABBehaviorFinishTransformation(caster, localStore, u1, abil, targetType, isKeepRatios, actions, + addAlternateTagAfter, orderId, perm, dur, transTime, landTime, atlAdDelay, altAdTime, + imLand, imTakeOff, theBuffId, localStore.game.getUnitData().getUnitType(baseId), instant)); + } else { + ABTransformationHandler.instantTransformation(localStore, u1, targetType, isKeepRatios, actions, abil, + addAlternateTagAfter, perm, true); + if (dur > 0) { + OnTransformationActions unActions = new OnTransformationActions(-goldCost, -lumberCost, null, null, + onUntransformActions, castId); + ABTransformationHandler.createInstantTransformBackBuff(caster, localStore, u1, + localStore.game.getUnitData().getUnitType(baseId), isKeepRatios, unActions, abil, theBuffId, + addAlternateTagAfter, transTime, dur, perm); + } + u1.fireSpellEvents(localStore.game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, abil, null); + u1.fireSpellEvents(localStore.game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, abil, null); + } + + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnitAppearance.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnitAppearance.java new file mode 100644 index 000000000..111c26075 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnitAppearance.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.transformation; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionTransformUnitAppearance implements ABAction { + + private ABUnitCallback unit; + private ABIDCallback id; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit = this.unit.callback(caster, localStore, castId); + localStore.game.unitUpdatedType(targetUnit, id.callback(caster, localStore, castId), false); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnitInstant.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnitInstant.java new file mode 100644 index 000000000..d4b92bf87 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformUnitInstant.java @@ -0,0 +1,164 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.transformation; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABDelayInstantTransformationTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABActionTransformUnitInstant implements ABAction { + + private ABUnitCallback unit; + private ABIDCallback baseUnitId; + private ABIDCallback alternateUnitId; + + private ABBooleanCallback keepRatios; + + private ABBooleanCallback permanent; // remove ability after transform + private ABBooleanCallback requiresPayment; + + private ABFloatCallback transformTime; // the time the unit is locked for the transformation + + private ABBooleanCallback onlyTransformToAlternate; + + private ABFloatCallback duration; // the time before the unit is forced to change back (doesn't charge for it) + private ABIDCallback buffId; + + private List onTransformActions; + private List onUntransformActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit u1 = caster; + if (unit != null) { + u1 = unit.callback(caster, localStore, castId); + } + War3ID baseId = null; + War3ID altId = alternateUnitId.callback(caster, localStore, castId); + CPlayer pl = localStore.game.getPlayer(u1.getPlayerIndex()); + boolean charge = false; + boolean addAlternateTagAfter = false; + boolean perm = false; + if (permanent != null) { + perm = permanent.callback(caster, localStore, castId); + } + if (this.requiresPayment != null) { + charge = this.requiresPayment.callback(caster, localStore, castId); + } + ABAbilityBuilderAbility abil = localStore.originAbility; + + CUnitType baseType = null; + if (baseUnitId == null) { + baseId = u1.getUnitType().getTypeId(); + baseType = u1.getUnitType(); + } else { + baseId = baseUnitId.callback(caster, localStore, castId); + baseType = localStore.game.getUnitData().getUnitType(baseId); + + } + + if (baseId == null || altId == null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + + CUnitType targetType = null; + + boolean onlyToAlt = false; + if (onlyTransformToAlternate != null) { + onlyToAlt = onlyTransformToAlternate.callback(caster, localStore, castId); + } + + if (!onlyToAlt && u1.getTypeId().equals(altId)) { + // Transforming back + targetType = baseType; + if (perm || targetType.equals(u1.getUnitType())) { + // No need to do anything + return; + } + + } else { + // Transforming to alt + addAlternateTagAfter = true; + targetType = localStore.game.getUnitData().getUnitType(altId); + } + + int goldCost = 0; + int lumberCost = 0; + Integer foodCost = null; + if (charge) { + if (localStore.game.getGameplayConstants().isRelativeUpgradeCosts()) { + goldCost = targetType.getGoldCost() - u1.getUnitType().getGoldCost(); + lumberCost = targetType.getLumberCost() - u1.getUnitType().getLumberCost(); + if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + } else { + goldCost = targetType.getGoldCost(); + lumberCost = targetType.getLumberCost(); + if (goldCost > pl.getGold() || lumberCost > pl.getLumber()) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + } + foodCost = Math.max(targetType.getFoodUsed() - u1.getUnitType().getFoodUsed(), 0); + if (foodCost > 0 && pl.getFoodUsed() + foodCost > pl.getFoodCap()) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + } + OnTransformationActions actions = new OnTransformationActions(goldCost, lumberCost, foodCost, + onTransformActions, onUntransformActions, castId); + OnTransformationActions unActions = new OnTransformationActions(-goldCost, -lumberCost, null, null, + onUntransformActions, castId); + + boolean isKeepRatios = true; + float dur = 0; + float transTime = 0; + War3ID theBuffId = null; + if (keepRatios != null) { + isKeepRatios = keepRatios.callback(caster, localStore, castId); + } + if (permanent != null) { + perm = permanent.callback(caster, localStore, castId); + } + if (duration != null) { + dur = duration.callback(caster, localStore, castId); + } + if (transformTime != null) { + transTime = transformTime.callback(caster, localStore, castId); + } + if (buffId != null) { + theBuffId = buffId.callback(caster, localStore, castId); + } + + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.TRANSFORMINGTOALT, castId), addAlternateTagAfter); + if (transTime > 0) { + ABTransformationHandler.playMorphAnimation(u1, addAlternateTagAfter); + new ABDelayInstantTransformationTimer(caster, localStore, u1, actions, addAlternateTagAfter, transTime, + baseType, targetType, isKeepRatios, abil, theBuffId, transTime, dur).start(localStore.game); + } else { + ABTransformationHandler.instantTransformation(localStore, u1, targetType, isKeepRatios, actions, abil, + addAlternateTagAfter, perm, true); + if (dur > 0) { + ABTransformationHandler.createInstantTransformBackBuff(caster, localStore, u1, baseType, isKeepRatios, + unActions, abil, theBuffId, addAlternateTagAfter, transTime, dur, perm); + } + } + + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformedUnitAbilityAdd.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformedUnitAbilityAdd.java new file mode 100644 index 000000000..0d86e3685 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformedUnitAbilityAdd.java @@ -0,0 +1,168 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.transformation; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; + +public class ABActionTransformedUnitAbilityAdd implements ABAction { + + private ABUnitCallback unit; + private ABIDCallback baseUnitId; + private ABIDCallback alternateUnitId; + + private ABBooleanCallback keepRatios; + + private ABBooleanCallback instantTransformAtDurationEnd; // should the transform back be instant? + + private ABBooleanCallback permanent; // remove ability after transform + private ABBooleanCallback requiresPayment; + private ABFloatCallback duration; // the time before the unit is forced to change back (doesn't charge for it) + private ABFloatCallback transformTime; // the time the unit is locked for the transformation (for slow) or spends + // animating (for instant) + private ABIDCallback buffId; + + // Used for slow transform back + private ABBooleanCallback immediateLanding; // true: play morph immediately, false: play morph after + private ABBooleanCallback immediateTakeOff; // true: play morph immediately, false: play morph after + private ABFloatCallback altitudeAdjustmentDelay; // time before the unit starts changing height, only applies if + // going not flying->flying + private ABFloatCallback altitudeAdjustmentTime; // the time spent changing height, only applies if one type is + // flying + private ABFloatCallback landingDelayTime; // Added to the transform time, only applies when going flying->not flying + + private List onTransformActions; + private List onUntransformActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit u1 = caster; + if (unit != null) { + u1 = unit.callback(caster, localStore, castId); + } + War3ID baseId = baseUnitId.callback(caster, localStore, castId); + War3ID altId = alternateUnitId.callback(caster, localStore, castId); + ABAbilityBuilderAbility abil = localStore.originAbility; + + if (baseId == null || altId == null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.FAILEDTOCAST, castId), true); + return; + } + + CUnitType baseType = localStore.game.getUnitData().getUnitType(baseId); + + // Always Transforming back + CUnitType targetType = baseType; + if (targetType.equals(u1.getUnitType())) { + // No need to do anything + return; + } + + boolean instant = false; + boolean perm = false; + boolean charge = false; + boolean isKeepRatios = true; + float dur = 0; + float transTime = 0; + float landTime = 0; + float atlAdDelay = 0; + float altAdTime = 0; + boolean imLand = false; + boolean imTakeOff = false; + War3ID theBuffId = null; + if (instantTransformAtDurationEnd != null) { + instant = instantTransformAtDurationEnd.callback(caster, localStore, castId); + } + if (permanent != null) { + perm = permanent.callback(caster, localStore, castId); + } + if (this.requiresPayment != null) { + charge = this.requiresPayment.callback(caster, localStore, castId); + } + if (keepRatios != null) { + isKeepRatios = keepRatios.callback(caster, localStore, castId); + } + if (duration != null) { + dur = duration.callback(caster, localStore, castId); + } + if (transformTime != null) { + transTime = transformTime.callback(caster, localStore, castId); + } + if (landingDelayTime != null) { + landTime = landingDelayTime.callback(caster, localStore, castId); + } + if (altitudeAdjustmentDelay != null) { + atlAdDelay = altitudeAdjustmentDelay.callback(caster, localStore, castId); + } + if (altitudeAdjustmentTime != null) { + altAdTime = altitudeAdjustmentTime.callback(caster, localStore, castId); + } + if (immediateLanding != null) { + imLand = immediateLanding.callback(caster, localStore, castId); + } + if (immediateTakeOff != null) { + imTakeOff = immediateTakeOff.callback(caster, localStore, castId); + } + if (buffId != null) { + theBuffId = buffId.callback(caster, localStore, castId); + } + + ABTransformationHandler.setTags(u1, true); + if (perm) { + u1.remove(localStore.game, abil); + } + if (onTransformActions != null) { + for (ABAction action : onTransformActions) { + action.runAction(u1, localStore, castId); + } + } + + if (dur > 0 && !perm) { + OnTransformationActions actions; + if (charge) { + int goldCost = 0; + int lumberCost = 0; + Integer foodCost = null; + if (localStore.game.getGameplayConstants().isRelativeUpgradeCosts()) { + + goldCost = baseType.getGoldCost() - u1.getUnitType().getGoldCost(); + lumberCost = baseType.getLumberCost() - u1.getUnitType().getLumberCost(); + } else { + goldCost = baseType.getGoldCost(); + lumberCost = baseType.getLumberCost(); + } + actions = new OnTransformationActions(goldCost, lumberCost, foodCost, null, onUntransformActions, + castId); + } else { + actions = new OnTransformationActions(onUntransformActions, castId); + } + + if (instant) { + ABTransformationHandler.createInstantTransformBackBuff(caster, localStore, u1, baseType, isKeepRatios, + actions, abil, theBuffId, true, transTime, dur, perm); + } else { + boolean takingOff = u1.getMovementType() != MovementType.FLY + && baseType.getMovementType() == MovementType.FLY; + boolean landing = u1.getMovementType() == MovementType.FLY + && baseType.getMovementType() != MovementType.FLY; + ABTransformationHandler.createSlowTransformBackBuff(caster, localStore, u1, baseType, isKeepRatios, + actions, abil, theBuffId, true, transTime, dur, perm, takingOff, landing, imTakeOff, imLand, + atlAdDelay, landTime, altAdTime); + } + } + + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformedUnitAbilityRemove.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformedUnitAbilityRemove.java new file mode 100644 index 000000000..cb817e112 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/transformation/ABActionTransformedUnitAbilityRemove.java @@ -0,0 +1,69 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.transformation; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; + +public class ABActionTransformedUnitAbilityRemove implements ABAction { + + private ABUnitCallback unit; + private ABIDCallback baseUnitId; + private ABIDCallback alternateUnitId; + + private ABBooleanCallback keepRatios; + + private ABBooleanCallback permanent; + + private List onUntransformActions; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean perm = false; + if (permanent != null) { + perm = permanent.callback(caster, localStore, castId); + } + if (!perm) { + CUnit u1 = caster; + if (unit != null) { + u1 = unit.callback(caster, localStore, castId); + } + War3ID baseId = baseUnitId.callback(caster, localStore, castId); + War3ID altId = alternateUnitId.callback(caster, localStore, castId); + ABAbilityBuilderAbility abil = localStore.originAbility; + + if (baseId == null || altId == null) { + return; + } + + // Only care if already transformed + CUnitType targetType = localStore.game.getUnitData().getUnitType(altId); + if (!targetType.equals(u1.getUnitType())) { + // No need to do anything + return; + } + + boolean isKeepRatios = true; + if (keepRatios != null) { + isKeepRatios = keepRatios.callback(caster, localStore, castId); + } + CUnitType baseType = localStore.game.getUnitData().getUnitType(baseId); + + if (onUntransformActions != null) { + for (ABAction action : onUntransformActions) { + action.runAction(u1, localStore, castId); + } + } + ABTransformationHandler.setUnitID(localStore, u1, baseType, isKeepRatios, perm, null, abil, true); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionDisableWorkerAbilities.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionDisableWorkerAbilities.java similarity index 79% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionDisableWorkerAbilities.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionDisableWorkerAbilities.java index 46529b336..873f8f875 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionDisableWorkerAbilities.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionDisableWorkerAbilities.java @@ -1,9 +1,6 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.worker; import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; @@ -18,8 +15,9 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityAcolyteHarvest; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityHarvest; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityWispHarvest; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; public class ABActionDisableWorkerAbilities implements ABSingleAction { @@ -27,10 +25,10 @@ public class ABActionDisableWorkerAbilities implements ABSingleAction { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { CUnit targetUnit = caster; if (this.unit != null) { - targetUnit = this.unit.callback(game, caster, localStore, castId); + targetUnit = this.unit.callback(caster, localStore, castId); } final Class[] workerAbils = { CAbilityAcolyteHarvest.class, CAbilityHarvest.class, CAbilityWispHarvest.class, @@ -42,7 +40,7 @@ public void runAction(CSimulation game, CUnit caster, Map localS if (abil != null) { abil.setDisabled(true, CAbilityDisableType.TRANSFORMATION); abil.setIconShowing(false); - targetUnit.checkDisabledAbilities(game, true); + targetUnit.checkDisabledAbilities(localStore.game, true); } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionEnableWorkerAbilities.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionEnableWorkerAbilities.java similarity index 79% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionEnableWorkerAbilities.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionEnableWorkerAbilities.java index 2202563c2..4b43fd5a8 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/behavior/action/unit/ABActionEnableWorkerAbilities.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionEnableWorkerAbilities.java @@ -1,9 +1,6 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.action.unit; - -import java.util.Map; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.worker; import com.etheller.warsmash.parsers.jass.JassTextGenerator; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; @@ -18,8 +15,9 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityAcolyteHarvest; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityHarvest; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityWispHarvest; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.callback.unitcallbacks.ABUnitCallback; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; public class ABActionEnableWorkerAbilities implements ABSingleAction { @@ -27,10 +25,10 @@ public class ABActionEnableWorkerAbilities implements ABSingleAction { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void runAction(CSimulation game, CUnit caster, Map localStore, final int castId) { + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { CUnit targetUnit = caster; if (this.unit != null) { - targetUnit = this.unit.callback(game, caster, localStore, castId); + targetUnit = this.unit.callback(caster, localStore, castId); } final Class[] workerAbils = { CAbilityAcolyteHarvest.class, CAbilityHarvest.class, CAbilityWispHarvest.class, @@ -42,7 +40,7 @@ public void runAction(CSimulation game, CUnit caster, Map localS if (abil != null) { abil.setDisabled(false, CAbilityDisableType.TRANSFORMATION); abil.setIconShowing(true); - targetUnit.checkDisabledAbilities(game, false); + targetUnit.checkDisabledAbilities(localStore.game, false); } } } @@ -52,8 +50,7 @@ public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { String casterExpression; if (this.unit != null) { casterExpression = this.unit.generateJassEquivalent(jassTextGenerator); - } - else { + } else { casterExpression = jassTextGenerator.getCaster(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionInstantReturnResources.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionInstantReturnResources.java new file mode 100644 index 000000000..18da5bc1f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionInstantReturnResources.java @@ -0,0 +1,68 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.worker; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityHarvest; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.ResourceType; + +public class ABActionInstantReturnResources implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit targetUnit = caster; + if (this.unit != null) { + targetUnit = this.unit.callback(caster, localStore, castId); + } + + final CAbilityHarvest harv = targetUnit.getFirstAbilityOfType(CAbilityHarvest.class); + if ((harv != null) && (harv.getCarriedResourceType() != null) && (harv.getCarriedResourceAmount() > 0)) { + final CPlayer pl = localStore.game.getPlayer(targetUnit.getPlayerIndex()); + switch (harv.getCarriedResourceType()) { + case FOOD: + // This might be a bad idea? Not sure it will ever matter + pl.setFoodCap(Math.min(pl.getFoodCap() + harv.getCarriedResourceAmount(), pl.getFoodCapCeiling())); + localStore.game.unitGainResourceEvent(targetUnit, pl.getId(), harv.getCarriedResourceType(), + harv.getCarriedResourceAmount()); + harv.setCarriedResources(ResourceType.FOOD, 0); + break; + case GOLD: + pl.addGold(harv.getCarriedResourceAmount()); + localStore.game.unitGainResourceEvent(targetUnit, pl.getId(), harv.getCarriedResourceType(), + harv.getCarriedResourceAmount()); + harv.setCarriedResources(ResourceType.GOLD, 0); + break; + case LUMBER: + pl.addLumber(harv.getCarriedResourceAmount()); + localStore.game.unitGainResourceEvent(targetUnit, pl.getId(), harv.getCarriedResourceType(), + harv.getCarriedResourceAmount()); + harv.setCarriedResources(ResourceType.LUMBER, 0); + break; + case MANA: + // ?? + break; + default: + break; + + } + } + + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String targetExpression; + if (this.unit != null) { + targetExpression = this.unit.generateJassEquivalent(jassTextGenerator); + } else { + targetExpression = jassTextGenerator.getCaster(); + } + return "UnitInstantReturnResources(" + targetExpression + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionSendUnitBackToWork.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionSendUnitBackToWork.java new file mode 100644 index 000000000..02a6710a4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unit/worker/ABActionSendUnitBackToWork.java @@ -0,0 +1,46 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.worker; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABTimer; + +public class ABActionSendUnitBackToWork implements ABSingleAction { + + private ABUnitCallback unit; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit targetUnit; + if (this.unit != null) { + targetUnit = this.unit.callback(caster, localStore, castId); + } else { + targetUnit = caster; + } + + final ABTimer timer = new ABTimer(caster, localStore, null, castId) { + @Override + public void onFire(CSimulation simulation) { + targetUnit.backToWork(localStore.game, null); + } + }; + timer.setRepeats(false); + timer.setTimeoutTime(0f); + timer.start(localStore.game); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String unitExpression; + if (this.unit != null) { + unitExpression = this.unit.generateJassEquivalent(jassTextGenerator); + } else { + unitExpression = jassTextGenerator.getCaster(); + } + return "SendUnitBackToWorkAU(" + unitExpression + ", " + jassTextGenerator.getTriggerLocalStore() + ", " + + jassTextGenerator.getCastId() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionAddUnitToGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionAddUnitToGroup.java new file mode 100644 index 000000000..fb94313d2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionAddUnitToGroup.java @@ -0,0 +1,31 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup.ABUnitGroupCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddUnitToGroup implements ABSingleAction { + + private ABUnitGroupCallback group; + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final Set groupSet = this.group.callback(caster, localStore, castId); + final CUnit rUnit = this.unit.callback(caster, localStore, castId); + groupSet.add(rUnit); + localStore.put(ABLocalStoreKeys.LASTADDEDUNIT, rUnit); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GroupAddUnitAU(" + this.group.generateJassEquivalent(jassTextGenerator) + ", " + + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionCreateUnitGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionCreateUnitGroup.java new file mode 100644 index 000000000..a39bcd74e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionCreateUnitGroup.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitgroup; + +import java.util.HashSet; +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateUnitGroup implements ABSingleAction { + + private String name; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final Set group = new HashSet<>(); + if (this.name != null) { + localStore.put("_unitgroup_" + this.name, group); + } + localStore.put(ABLocalStoreKeys.LASTCREATEDUNITGROUP, group); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.name != null) { + return "CreateNamedGroupAU(" + jassTextGenerator.getTriggerLocalStore() + ", \"" + this.name + "\")"; + } + return "CreateGroupAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionRemoveUnitFromGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionRemoveUnitFromGroup.java new file mode 100644 index 000000000..2925ef366 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitgroup/ABActionRemoveUnitFromGroup.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup.ABUnitGroupCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionRemoveUnitFromGroup implements ABSingleAction { + + private ABUnitGroupCallback group; + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final Set groupSet = this.group.callback(caster, localStore, castId); + final CUnit rUnit = this.unit.callback(caster, localStore, castId); + groupSet.remove(rUnit); + localStore.put(ABLocalStoreKeys.LASTREMOVEDDUNIT, rUnit); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GroupRemoveUnitAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.group.generateJassEquivalent(jassTextGenerator) + ", " + + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionAddAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionAddAttackPostDamageListener.java new file mode 100644 index 000000000..67ddd5364 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionAddAttackPostDamageListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPostDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddAttackPostDamageListener implements ABAction { + + private ABUnitCallback unit; + private ABAttackPostDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + target.addPostDamageListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionAddAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionAddAttackPreDamageListener.java new file mode 100644 index 000000000..988d843b1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionAddAttackPreDamageListener.java @@ -0,0 +1,23 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackPreDamageListenerPriorityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPreDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddAttackPreDamageListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAttackPreDamageListenerPriorityCallback priority; + private ABAttackPreDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.addPreDamageListener(priority.callback(caster, localStore, castId), + listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionCreateAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionCreateAttackPostDamageListener.java new file mode 100644 index 000000000..8da7c6b46 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionCreateAttackPostDamageListener.java @@ -0,0 +1,30 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPostDamageListener; + +public class ABActionCreateAttackPostDamageListener implements ABAction { + + private ABIntegerCallback priority; + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABAttackPostDamageListener listener = new ABAttackPostDamageListener(localStore, priority, actions, castId, + ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDAPoDL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionCreateAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionCreateAttackPreDamageListener.java new file mode 100644 index 000000000..88c5ef50c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionCreateAttackPreDamageListener.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPreDamageListener; + +public class ABActionCreateAttackPreDamageListener implements ABAction { + + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABAttackPreDamageListener listener = new ABAttackPreDamageListener(localStore, actions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDAPrDL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionRemoveAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionRemoveAttackPostDamageListener.java new file mode 100644 index 000000000..27e7c8cc0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionRemoveAttackPostDamageListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPostDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveAttackPostDamageListener implements ABAction { + + private ABUnitCallback unit; + private ABAttackPostDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + target.removePostDamageListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionRemoveAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionRemoveAttackPreDamageListener.java new file mode 100644 index 000000000..57954f3bc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/ABActionRemoveAttackPreDamageListener.java @@ -0,0 +1,23 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackPreDamageListenerPriorityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackPreDamageListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveAttackPreDamageListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAttackPreDamageListenerPriorityCallback priority; + private ABAttackPreDamageListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.removePreDamageListener(priority.callback(caster, localStore, castId), + listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerAddBonusDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerAddBonusDamage.java new file mode 100644 index 000000000..f969b1e95 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerAddBonusDamage.java @@ -0,0 +1,78 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +public class ABActionPreDamageListenerAddBonusDamage implements ABAction { + + private ABFloatCallback value; + private ABDamageTypeCallback damageType; + private ABAttackTypeCallback attackType; + + private ABBooleanCallback inheritFlags; + private ABBooleanCallback isRanged; + + private ABBooleanCallback isIgnoreInvulnerable; + private ABBooleanCallback isExplode; + private ABBooleanCallback isOnlyDamageSummons; + private ABBooleanCallback isNonlethal; + private ABBooleanCallback isPassLimitedMagicImmune; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CDamageType theDamageType = null; + if (damageType != null) { + theDamageType = damageType.callback(caster, localStore, castId); + } + CAttackType theAttackType = null; + if (attackType != null) { + theAttackType = attackType.callback(caster, localStore, castId); + } + + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + + CDamageFlags theFlags = null; + if (inheritFlags == null || inheritFlags.callback(caster, localStore, castId)) { + theFlags = damage.getPrimaryDamageFlags().copy(); + } else if (isRanged != null || isIgnoreInvulnerable != null || isExplode != null || isOnlyDamageSummons != null + || isNonlethal != null || isPassLimitedMagicImmune != null) { + boolean ranged; + if (isRanged == null) { + ranged = damage.getPrimaryDamageFlags().isRanged(); + } else { + ranged = isRanged.callback(caster, localStore, castId); + } + theFlags = new CAttackDamageFlags(ranged); + } + + if (isIgnoreInvulnerable != null) { + theFlags.setIgnoreInvulnerable(isIgnoreInvulnerable.callback(caster, localStore, castId)); + } + if (isExplode != null) { + theFlags.setExplode(isExplode.callback(caster, localStore, castId)); + } + if (isOnlyDamageSummons != null) { + theFlags.setOnlyDamageSummons(isOnlyDamageSummons.callback(caster, localStore, castId)); + } + if (isNonlethal != null) { + theFlags.setNonlethal(isNonlethal.callback(caster, localStore, castId)); + } + if (isPassLimitedMagicImmune != null) { + theFlags.setPassLimitedMagicImmune(isPassLimitedMagicImmune.callback(caster, localStore, castId)); + } + + damage.addBonusDamage(value.callback(caster, localStore, castId), theAttackType, theDamageType, theFlags); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerAddDamageMultiplier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerAddDamageMultiplier.java new file mode 100644 index 000000000..ac4f4aaa8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerAddDamageMultiplier.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABActionPreDamageListenerAddDamageMultiplier implements ABAction { + + private ABFloatCallback value; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + damage.addDamageMultiplier(value.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerLockDamageModifications.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerLockDamageModifications.java new file mode 100644 index 000000000..c09b299b3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerLockDamageModifications.java @@ -0,0 +1,17 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABActionPreDamageListenerLockDamageModifications implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + damage.lock(); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerSetMiss.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerSetMiss.java new file mode 100644 index 000000000..8e7b8a712 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionPreDamageListenerSetMiss.java @@ -0,0 +1,24 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABActionPreDamageListenerSetMiss implements ABAction { + + private ABBooleanCallback miss; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + if (miss != null) { + damage.setMiss(miss.callback(caster, localStore, castId)); + } else { + damage.setMiss(true); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionSetPreDamageStacking.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionSetPreDamageStacking.java new file mode 100644 index 000000000..2e402cf8d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalaction/ABActionSetPreDamageStacking.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABActionSetPreDamageStacking implements ABAction { + + private ABBooleanCallback allowStacking; + private ABBooleanCallback allowSamePriorityStacking; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + + if (allowStacking != null && !allowStacking.callback(caster, localStore, castId)) { + damage.preventAllOtherModifications(); + } + if (allowSamePriorityStacking != null && !allowSamePriorityStacking.callback(caster, localStore, castId)) { + damage.preventOtherModificationsWithSamePriority(); + } + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackBaseDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackBaseDamage.java new file mode 100644 index 000000000..8b34bcf03 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackBaseDamage.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABCallbackGetAttackBaseDamage extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + return settings.getBaseDamage(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackDamageType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackDamageType.java new file mode 100644 index 000000000..d67670304 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackDamageType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +public class ABCallbackGetAttackDamageType extends ABDamageTypeCallback { + + @Override + public CDamageType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class)) + .getWeaponType().getDamageType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackMaximumSplashRadius.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackMaximumSplashRadius.java new file mode 100644 index 000000000..206586a46 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackMaximumSplashRadius.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABCallbackGetAttackMaximumSplashRadius extends ABIntegerCallback { + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + return Math.max(settings.getAreaOfEffectFullDamage(), + Math.max(settings.getAreaOfEffectMediumDamage(), settings.getAreaOfEffectSmallDamage())); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackType.java new file mode 100644 index 000000000..062f22855 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; + +public class ABCallbackGetAttackType extends ABAttackTypeCallback { + + @Override + public CAttackType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class)) + .getAttackType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackWeaponType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackWeaponType.java new file mode 100644 index 000000000..3034ef4e7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcallback/ABCallbackGetAttackWeaponType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABWeaponTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; + +public class ABCallbackGetAttackWeaponType extends ABWeaponTypeCallback { + + @Override + public CWeaponType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class)) + .getWeaponType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsAttackArtillery.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsAttackArtillery.java new file mode 100644 index 000000000..4d72dc451 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsAttackArtillery.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcondition; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackMissileLine; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackMissileSplash; + +public class ABConditionIsAttackArtillery extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnitAttack attack = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), + CUnitAttack.class); + if (attack instanceof CUnitAttackMissileSplash) { + return ((CUnitAttackMissileSplash) attack).isArtillery(); + } + if (attack instanceof CUnitAttackMissileLine) { + return ((CUnitAttackMissileLine) attack).isArtillery(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsAttackHoming.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsAttackHoming.java new file mode 100644 index 000000000..d45876389 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsAttackHoming.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcondition; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABConditionIsAttackHoming extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnitAttackSettings settings = localStore + .get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), CUnitAttackSettings.class); + return settings.isProjectileHomingEnabled(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsUnitValidSplashDamageTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsUnitValidSplashDamageTarget.java new file mode 100644 index 000000000..3dfbfe40b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/attack/internalcondition/ABConditionIsUnitValidSplashDamageTarget.java @@ -0,0 +1,51 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcondition; + +import java.util.EnumSet; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackMissileSplash; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; + +public class ABConditionIsUnitValidSplashDamageTarget extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABUnitCallback unit; + private ABBooleanCallback targetedEffect; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = casterUnit; + + EnumSet targetsAllowed = null; + + CUnitAttack atk = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class); + if (atk instanceof CUnitAttackMissileSplash) { + targetsAllowed = ((CUnitAttackMissileSplash) atk).getAreaOfEffectTargets(); + } else { + return false; + } + + if (targetsAllowed.isEmpty()) { + return true; + } + final CUnit theUnit = this.unit.callback(casterUnit, localStore, castId); + boolean te = false; + if (this.caster != null) { + theCaster = this.caster.callback(casterUnit, localStore, castId); + } + if (this.targetedEffect != null) { + te = this.targetedEffect.callback(theCaster, localStore, castId); + } + + return theUnit.canBeTargetedBy(localStore.game, theCaster, te, targetsAllowed, + BooleanAbilityTargetCheckReceiver.getInstance().reset()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionAddBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionAddBehaviorChangeListener.java new file mode 100644 index 000000000..bfc44cf52 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionAddBehaviorChangeListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABBehaviorChangeListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddBehaviorChangeListener implements ABAction { + + private ABUnitCallback unit; + private ABBehaviorChangeListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + target.addBehaviorChangeListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionCreateBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionCreateBehaviorChangeListener.java new file mode 100644 index 000000000..0d430f25b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionCreateBehaviorChangeListener.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABBehaviorChangeListener; + +public class ABActionCreateBehaviorChangeListener implements ABAction { + + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABBehaviorChangeListener listener = new ABBehaviorChangeListener(localStore, actions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDBCL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionRemoveBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionRemoveBehaviorChangeListener.java new file mode 100644 index 000000000..8d51dcb61 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/ABActionRemoveBehaviorChangeListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABBehaviorChangeListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveBehaviorChangeListener implements ABAction { + + private ABUnitCallback unit; + private ABBehaviorChangeListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + target.removeBehaviorChangeListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/internalcallback/ABCallbackGetNewBehaviorTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/internalcallback/ABCallbackGetNewBehaviorTarget.java new file mode 100644 index 000000000..b29bc2163 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/internalcallback/ABCallbackGetNewBehaviorTarget.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target.ABTargetCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.BehaviorTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; + +public class ABCallbackGetNewBehaviorTarget extends ABTargetCallback { + + @Override + public AbilityTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CBehavior beh = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.POSTCHANGEBEHAVIOR, castId), + CBehavior.class); + AbilityTarget tar = beh.visit(BehaviorTargetVisitor.INSTANCE); + + return tar; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/internalcondition/ABConditionIsNewBehaviorCategoryInList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/internalcondition/ABConditionIsNewBehaviorCategoryInList.java new file mode 100644 index 000000000..c9441b508 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/behavior/internalcondition/ABConditionIsNewBehaviorCategoryInList.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior.internalcondition; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; + +public class ABConditionIsNewBehaviorCategoryInList extends ABBooleanCallback { + + private List list; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, int castId) { + CBehavior beh = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.POSTCHANGEBEHAVIOR, castId), + CBehavior.class); + CBehaviorCategory cat = CBehaviorCategory.IDLE; + if (beh != null) { + cat = beh.getBehaviorCategory(); + } + return list.contains(cat); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionAddDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionAddDamageTakenListener.java new file mode 100644 index 000000000..6305d1342 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionAddDamageTakenListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABDamageTakenListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddDamageTakenListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABDamageTakenListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.addDamageTakenListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionAddDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionAddDamageTakenModificationListener.java new file mode 100644 index 000000000..7950dee42 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionAddDamageTakenModificationListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABDamageTakenModificationListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddDamageTakenModificationListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABDamageTakenModificationListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.addDamageTakenModificationListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionCreateDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionCreateDamageTakenListener.java new file mode 100644 index 000000000..c6b463e2d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionCreateDamageTakenListener.java @@ -0,0 +1,29 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenListener; + +public class ABActionCreateDamageTakenListener implements ABAction { + + private ABIntegerCallback priority; + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABDamageTakenListener listener = new ABDamageTakenListener(localStore, priority, actions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDDTL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionCreateDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionCreateDamageTakenModificationListener.java new file mode 100644 index 000000000..31dc19f5f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionCreateDamageTakenModificationListener.java @@ -0,0 +1,30 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenModificationListener; + +public class ABActionCreateDamageTakenModificationListener implements ABAction { + + private ABIntegerCallback priority; + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABDamageTakenModificationListener listener = new ABDamageTakenModificationListener(localStore, priority, + actions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDDTML, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionRemoveDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionRemoveDamageTakenListener.java new file mode 100644 index 000000000..df73e6e38 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionRemoveDamageTakenListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABDamageTakenListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveDamageTakenListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABDamageTakenListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.removeDamageTakenListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionRemoveDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionRemoveDamageTakenModificationListener.java new file mode 100644 index 000000000..1d95a3dfc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/ABActionRemoveDamageTakenModificationListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABDamageTakenModificationListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveDamageTakenModificationListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABDamageTakenModificationListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.removeDamageTakenModificationListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalaction/ABActionDamageTakenModificationMultiplyDamageMultiplier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalaction/ABActionDamageTakenModificationMultiplyDamageMultiplier.java new file mode 100644 index 000000000..8bdab0ea0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalaction/ABActionDamageTakenModificationMultiplyDamageMultiplier.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABActionDamageTakenModificationMultiplyDamageMultiplier implements ABAction { + + private ABFloatCallback multiplier; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + damage.addDamageMultiplier(multiplier.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalaction/ABActionDamageTakenModificationSetDamageMultiplier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalaction/ABActionDamageTakenModificationSetDamageMultiplier.java new file mode 100644 index 000000000..c741212c9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalaction/ABActionDamageTakenModificationSetDamageMultiplier.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABActionDamageTakenModificationSetDamageMultiplier implements ABAction { + + private ABFloatCallback multiplier; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + + damage.setDamageMultiplier(multiplier.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalcondition/ABConditionIsTriggeringDamageAnAttack.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalcondition/ABConditionIsTriggeringDamageAnAttack.java new file mode 100644 index 000000000..c1feda6e8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalcondition/ABConditionIsTriggeringDamageAnAttack.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken.internalcondition; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABConditionIsTriggeringDamageAnAttack extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), CDamageCalculation.class)) + .getPrimaryDamageFlags().isAttack(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalcondition/ABConditionIsTriggeringDamageRanged.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalcondition/ABConditionIsTriggeringDamageRanged.java new file mode 100644 index 000000000..c50001ddf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/damagetaken/internalcondition/ABConditionIsTriggeringDamageRanged.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken.internalcondition; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +public class ABConditionIsTriggeringDamageRanged extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), CDamageCalculation.class)) + .getPrimaryDamageFlags().isRanged(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionAddDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionAddDeathReplacementEffect.java new file mode 100644 index 000000000..81d5f4e97 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionAddDeathReplacementEffect.java @@ -0,0 +1,23 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDeathReplacementPriorityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABDeathReplacementCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddDeathReplacementEffect implements ABAction { + + private ABUnitCallback target; + private ABDeathReplacementPriorityCallback priority; + private ABDeathReplacementCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit targetUnit = target.callback(caster, localStore, castId); + + targetUnit.addDeathReplacementEffect(priority.callback(caster, localStore, castId), listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionCreateDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionCreateDeathReplacementEffect.java new file mode 100644 index 000000000..35a3cec2d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionCreateDeathReplacementEffect.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDeathReplacementEffect; + +public class ABActionCreateDeathReplacementEffect implements ABAction { + + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABDeathReplacementEffect listener = new ABDeathReplacementEffect(localStore, actions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDDRE, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionRemoveDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionRemoveDeathReplacementEffect.java new file mode 100644 index 000000000..e384f3ff2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/ABActionRemoveDeathReplacementEffect.java @@ -0,0 +1,22 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDeathReplacementPriorityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABDeathReplacementCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveDeathReplacementEffect implements ABAction { + + private ABUnitCallback target; + private ABDeathReplacementPriorityCallback priority; + private ABDeathReplacementCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + target.callback(caster, localStore, castId).removeDeathReplacementEffect( + priority.callback(caster, localStore, castId), listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementFinishReincarnating.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementFinishReincarnating.java new file mode 100644 index 000000000..b8e82e919 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementFinishReincarnating.java @@ -0,0 +1,17 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionDeathReplacementFinishReincarnating implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + caster.setFalseDeath(false); + localStore.game.getWorldCollision().addUnit(caster); + caster.getUnitAnimationListener().playAnimation(true, PrimaryTag.STAND, SequenceUtils.EMPTY, 1.0f, true); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementSetReincarnating.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementSetReincarnating.java new file mode 100644 index 000000000..a858843d3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementSetReincarnating.java @@ -0,0 +1,26 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementResult; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementStacking; + +public class ABActionDeathReplacementSetReincarnating implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitDeathReplacementResult result = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHRESULT, castId), CUnitDeathReplacementResult.class); + CUnitDeathReplacementStacking stacking = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHSTACKING, castId), + CUnitDeathReplacementStacking.class); + + stacking.setAllowStacking(false); + stacking.setAllowSamePriorityStacking(false); + result.setReincarnating(true); + caster.setFalseDeath(true); + localStore.game.getWorldCollision().removeUnit(caster); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementSetReviving.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementSetReviving.java new file mode 100644 index 000000000..ef636df12 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/death/internalaction/ABActionDeathReplacementSetReviving.java @@ -0,0 +1,24 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementResult; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementStacking; + +public class ABActionDeathReplacementSetReviving implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnitDeathReplacementResult result = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHRESULT, castId), CUnitDeathReplacementResult.class); + CUnitDeathReplacementStacking stacking = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHSTACKING, castId), + CUnitDeathReplacementStacking.class); + + stacking.setAllowStacking(false); + stacking.setAllowSamePriorityStacking(false); + result.setReviving(true); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionAddEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionAddEvasionListener.java new file mode 100644 index 000000000..a0f853332 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionAddEvasionListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.evasion; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABEvasionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddEvasionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABEvasionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.addEvasionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionCreateEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionCreateEvasionListener.java new file mode 100644 index 000000000..1c91c189e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionCreateEvasionListener.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.evasion; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackEvasionListener; + +public class ABActionCreateEvasionListener implements ABAction { + + private List conditions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABAttackEvasionListener listener = new ABAttackEvasionListener(localStore, conditions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDAEL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionRemoveEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionRemoveEvasionListener.java new file mode 100644 index 000000000..add0ead33 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/evasion/ABActionRemoveEvasionListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.evasion; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABEvasionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveEvasionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABEvasionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.removeEvasionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAbilityEffectReactionListener.java new file mode 100644 index 000000000..3699eba53 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAbilityEffectReactionListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAbilityEffectReactionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddAbilityEffectReactionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAbilityEffectReactionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.addAbilityEffectReactionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAbilityProjReactionListener.java new file mode 100644 index 000000000..e06cd38c2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAbilityProjReactionListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAbilityProjReactionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddAbilityProjReactionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAbilityProjReactionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.addAbilityProjReactionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAttackProjReactionListener.java new file mode 100644 index 000000000..bf7cedd58 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionAddAttackProjReactionListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackProjReactionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionAddAttackProjReactionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAttackProjReactionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.addAttackProjReactionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAbilityEffectReactionListener.java new file mode 100644 index 000000000..11286253e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAbilityEffectReactionListener.java @@ -0,0 +1,28 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityEffectReactionListener; + +public class ABActionCreateAbilityEffectReactionListener implements ABAction { + + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABAbilityEffectReactionListener listener = new ABAbilityEffectReactionListener(localStore, actions, castId, + ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDAbERL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAbilityProjReactionListener.java new file mode 100644 index 000000000..9b2f4e6ed --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAbilityProjReactionListener.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityProjReactionListener; + +public class ABActionCreateAbilityProjReactionListener implements ABAction { + + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABAbilityProjReactionListener listener = new ABAbilityProjReactionListener(localStore, actions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDAbPRL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAttackProjReactionListener.java new file mode 100644 index 000000000..919052319 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionCreateAttackProjReactionListener.java @@ -0,0 +1,27 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackProjReactionListener; + +public class ABActionCreateAttackProjReactionListener implements ABAction { + + private List actions; + private ABBooleanCallback useCastId; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + boolean ucid = true; + if (useCastId != null) { + ucid = useCastId.callback(caster, localStore, castId); + } + ABAttackProjReactionListener listener = new ABAttackProjReactionListener(localStore, actions, castId, ucid); + + localStore.put(ABLocalStoreKeys.LASTCREATEDAtkPRL, listener); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAbilityEffectReactionListener.java new file mode 100644 index 000000000..5fcea7608 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAbilityEffectReactionListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAbilityEffectReactionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveAbilityEffectReactionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAbilityEffectReactionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.removeAbilityEffectReactionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAbilityProjReactionListener.java new file mode 100644 index 000000000..605899114 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAbilityProjReactionListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAbilityProjReactionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveAbilityProjReactionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAbilityProjReactionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.removeAbilityProjReactionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAttackProjReactionListener.java new file mode 100644 index 000000000..1e0981b3f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/ABActionRemoveAttackProjReactionListener.java @@ -0,0 +1,20 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABAttackProjReactionListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveAttackProjReactionListener implements ABAction { + + private ABUnitCallback targetUnit; + private ABAttackProjReactionListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + + target.removeAttackProjReactionListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalaction/ABActionReactionPreventHit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalaction/ABActionReactionPreventHit.java new file mode 100644 index 000000000..dbe9e043f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalaction/ABActionReactionPreventHit.java @@ -0,0 +1,14 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction.internalaction; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionReactionPreventHit implements ABAction { + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONALLOWHIT, castId), false); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalcallback/ABCallbackGetReactionAttackProjectileAttackType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalcallback/ABCallbackGetReactionAttackProjectileAttackType.java new file mode 100644 index 000000000..b875842f4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalcallback/ABCallbackGetReactionAttackProjectileAttackType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; + +public class ABCallbackGetReactionAttackProjectileAttackType extends ABAttackTypeCallback { + + @Override + public CAttackType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKPROJ, castId), CAttackProjectile.class)) + .getUnitAttack().getAttackType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalcallback/ABCallbackGetReactionAttackProjectileDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalcallback/ABCallbackGetReactionAttackProjectileDamage.java new file mode 100644 index 000000000..1611a6d2a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/reaction/internalcallback/ABCallbackGetReactionAttackProjectileDamage.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction.internalcallback; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; + +public class ABCallbackGetReactionAttackProjectileDamage extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKPROJ, castId), CAttackProjectile.class)) + .getDamage(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalactions/ABActionSubtractTotalDamageDealt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalactions/ABActionSubtractTotalDamageDealt.java new file mode 100644 index 000000000..fed9a7c30 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalactions/ABActionSubtractTotalDamageDealt.java @@ -0,0 +1,32 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.sharedinternalactions; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +/* + * This can technically be called in any of: + * EvasionListener, PostDamageListener, PreDamageListener, DamageTakenListener, DamageTakenModificationListener + * Though note that the PostDamageListener and DamageTakenListener happen after the damage is dealt to the unit. + * + * It's really meant for PreDamageListener and DamageTakenModificationListener + */ +public class ABActionSubtractTotalDamageDealt implements ABAction { + + private ABFloatCallback amount; + private ABFloatCallback minimum; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + float theMin = 0; + if (minimum != null) { + theMin = minimum.callback(caster, localStore, castId); + } + CDamageCalculation damage = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), + CDamageCalculation.class); + damage.subtractTotalDamageDealt(amount.callback(caster, localStore, castId), theMin); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetFinalTotalDamageDealt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetFinalTotalDamageDealt.java new file mode 100644 index 000000000..e9ccd18c6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetFinalTotalDamageDealt.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.sharedinternalcallbacks; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +/* + * This can technically be called in any of: + * EvasionListener, PostDamageListener, PreDamageListener, DamageTakenListener, DamageTakenModificationListener + * + * It's really meant for DamageTaken or PostDamage, as in other cases may expect other changes to be made after + */ +public class ABCallbackGetFinalTotalDamageDealt extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), CDamageCalculation.class)) + .computeFinalDamage(localStore.game, caster); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetRawTotalDamageDealt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetRawTotalDamageDealt.java new file mode 100644 index 000000000..c88813b16 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetRawTotalDamageDealt.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.sharedinternalcallbacks; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +/* + * This can technically be called in any of: + * EvasionListener, PostDamageListener, PreDamageListener, DamageTakenListener, DamageTakenModificationListener + * + * It's really meant for PreDamage or DamageTakenModification, when modifying the base damage (think mana shield) + */ +public class ABCallbackGetRawTotalDamageDealt extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), CDamageCalculation.class)) + .computeRawTotalDamage(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetTriggeringAttackType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetTriggeringAttackType.java new file mode 100644 index 000000000..baeee1af7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetTriggeringAttackType.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.sharedinternalcallbacks; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; + +/* + * This can technically be called in any of: + * EvasionListener, PostDamageListener, PreDamageListener, DamageTakenListener, DamageTakenModificationListener + * + */ +public class ABCallbackGetTriggeringAttackType extends ABAttackTypeCallback { + + @Override + public CAttackType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), CDamageCalculation.class)) + .getAttackType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetTriggeringDamageType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetTriggeringDamageType.java new file mode 100644 index 000000000..304cc2a11 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/sharedinternalcallbacks/ABCallbackGetTriggeringDamageType.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.sharedinternalcallbacks; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +/* + * This can technically be called in any of: + * EvasionListener, PostDamageListener, PreDamageListener, DamageTakenListener, DamageTakenModificationListener + * + */ +public class ABCallbackGetTriggeringDamageType extends ABDamageTypeCallback { + + @Override + public CDamageType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, castId), CDamageCalculation.class)) + .getPrimaryDamageType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionAddUnitStateListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionAddUnitStateListener.java new file mode 100644 index 000000000..9881bec62 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionAddUnitStateListener.java @@ -0,0 +1,23 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.state; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABUnitStateListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddUnitStateListener implements ABAction { + + private ABUnitCallback unit; + private ABUnitStateListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + localStore.put(ABLocalStoreKeys.LASTSTATELISTENERADDEDUNIT, target); + target.addStateListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionCreateUnitStateListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionCreateUnitStateListener.java new file mode 100644 index 000000000..84a3d9f98 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionCreateUnitStateListener.java @@ -0,0 +1,34 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.state; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABUnitStateListener; + +public class ABActionCreateUnitStateListener implements ABAction { + + private List onLifeChanged; + private List onManaChanged; + private List onOrdersChanged; + private List onQueueChanged; + private List onRallyPointChanged; + private List onWaypointsChanged; + private List onHeroStatsChanged; + private List onInventoryChanged; + private List onAttacksChanged; + private List onAbilitiesChanged; + private List onUpgradesChanged; + private List onHideStateChanged; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + ABUnitStateListener modifier = new ABUnitStateListener(caster, localStore, castId, onLifeChanged, onManaChanged, + onOrdersChanged, onQueueChanged, onRallyPointChanged, onWaypointsChanged, onHeroStatsChanged, + onInventoryChanged, onAttacksChanged, onAbilitiesChanged, onUpgradesChanged, onHideStateChanged); + + localStore.put(ABLocalStoreKeys.LASTCREATEDUSL, modifier); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionRemoveUnitStateListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionRemoveUnitStateListener.java new file mode 100644 index 000000000..e9dc0ff87 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitlisteners/state/ABActionRemoveUnitStateListener.java @@ -0,0 +1,21 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.state; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.ABUnitStateListenerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveUnitStateListener implements ABAction { + + private ABUnitCallback unit; + private ABUnitStateListenerCallback listener; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnit target = unit.callback(caster, localStore, castId); + + target.removeStateListener(listener.callback(caster, localStore, castId)); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionAddUnitToQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionAddUnitToQueue.java new file mode 100644 index 000000000..c91c57c82 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionAddUnitToQueue.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue.ABUnitQueueCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionAddUnitToQueue implements ABSingleAction { + + private ABUnitQueueCallback queue; + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final Queue groupQueue = this.queue.callback(caster, localStore, castId); + final CUnit rUnit = this.unit.callback(caster, localStore, castId); + groupQueue.add(rUnit); + localStore.put(ABLocalStoreKeys.LASTADDEDUNIT, rUnit); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GroupAddUnitAU(" + this.queue.generateJassEquivalent(jassTextGenerator) + ", " + + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionClearUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionClearUnitQueue.java new file mode 100644 index 000000000..76e43a5e9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionClearUnitQueue.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue.ABUnitQueueCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionClearUnitQueue implements ABSingleAction { + + private ABUnitQueueCallback queue; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final Queue groupQueue = this.queue.callback(caster, localStore, castId); + groupQueue.clear(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GroupClear(" + this.queue.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionCreateUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionCreateUnitQueue.java new file mode 100644 index 000000000..838498e62 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionCreateUnitQueue.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitqueue; + +import java.util.LinkedList; +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionCreateUnitQueue implements ABSingleAction { + + private String name; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final Queue queue = new LinkedList<>(); + if (this.name != null) { + localStore.put("_unitqueue_" + this.name, queue); + } + localStore.put(ABLocalStoreKeys.LASTCREATEDUNITQUEUE, queue); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.name != null) { + return "CreateNamedQueueAU(" + jassTextGenerator.getTriggerLocalStore() + ", \"" + this.name + "\")"; + } + return "CreateQueueAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionRemoveUnitFromQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionRemoveUnitFromQueue.java new file mode 100644 index 000000000..e8c16fe07 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitqueue/ABActionRemoveUnitFromQueue.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue.ABUnitQueueCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABSingleAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABActionRemoveUnitFromQueue implements ABSingleAction { + + private ABUnitQueueCallback queue; + private ABUnitCallback unit; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final Queue groupQueue = this.queue.callback(caster, localStore, castId); + final CUnit rUnit = this.unit.callback(caster, localStore, castId); + groupQueue.remove(rUnit); + localStore.put(ABLocalStoreKeys.LASTREMOVEDDUNIT, rUnit); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GroupRemoveUnitAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.queue.generateJassEquivalent(jassTextGenerator) + ", " + + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionAddStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionAddStateModBuff.java new file mode 100644 index 000000000..6eb8add7e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionAddStateModBuff.java @@ -0,0 +1,23 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitstate; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionAddStateModBuff implements ABAction { + + private ABUnitCallback targetUnit; + private ABStateModBuffCallback buff; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + StateModBuff theBuff = buff.callback(caster, localStore, castId); + + target.addStateModBuff(theBuff); + target.computeUnitState(localStore.game, theBuff.getBuffType()); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionCreateStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionCreateStateModBuff.java new file mode 100644 index 000000000..776674e94 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionCreateStateModBuff.java @@ -0,0 +1,28 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitstate; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs.ABLongCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuffType; + +public class ABActionCreateStateModBuff implements ABAction { + + private StateModBuffType buffType; + private ABLongCallback value; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + StateModBuff buff = null; + if (value != null) { + buff = new StateModBuff(buffType, value.callback(caster, localStore, castId)); + } else { + buff = new StateModBuff(buffType, 1); + } + + localStore.put(ABLocalStoreKeys.LASTCREATEDSMB, buff); + } + } \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionRemoveStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionRemoveStateModBuff.java new file mode 100644 index 000000000..cbbf9dadf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionRemoveStateModBuff.java @@ -0,0 +1,23 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitstate; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionRemoveStateModBuff implements ABAction { + + private ABUnitCallback targetUnit; + private ABStateModBuffCallback buff; + + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CUnit target = targetUnit.callback(caster, localStore, castId); + StateModBuff theBuff = buff.callback(caster, localStore, castId); + + target.removeStateModBuff(theBuff); + target.computeUnitState(localStore.game, theBuff.getBuffType()); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionSetUnitFadeTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionSetUnitFadeTimer.java new file mode 100644 index 000000000..849364ae7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionSetUnitFadeTimer.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitstate; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer.ABTimerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABActionSetUnitFadeTimer implements ABAction { + + private ABUnitCallback targetUnit; + private ABTimerCallback timer; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final CUnit target = this.targetUnit.callback(caster, localStore, castId); + final CTimer theTimer = this.timer.callback(caster, localStore, castId); + + target.setFadeTimer(theTimer); + } +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionUpdateStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionUpdateStateModBuff.java new file mode 100644 index 000000000..53a7373b0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/unitstate/ABActionUpdateStateModBuff.java @@ -0,0 +1,23 @@ + +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitstate; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs.ABLongCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.ABStateModBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABActionUpdateStateModBuff implements ABAction { + + private ABStateModBuffCallback buff; + private ABLongCallback value; + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final StateModBuff buffObj = this.buff.callback(caster, localStore, castId); + buffObj.setValue(this.value.callback(caster, localStore, castId)); + } + +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateLocationVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateLocationVisionModifier.java new file mode 100644 index 000000000..4d72e5ed7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateLocationVisionModifier.java @@ -0,0 +1,42 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.vision; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CCircleFogModifier; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CTimedCircleFogModifier; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CFogState; + +public class ABActionCreateLocationVisionModifier implements ABAction { + + private ABLocationCallback location; + private ABFloatCallback radius; + private ABFloatCallback duration; + private ABPlayerCallback player; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + CFogModifier vision; + final AbilityPointTarget loc = this.location.callback(caster, localStore, castId); + if (this.duration == null) { + vision = new CCircleFogModifier(CFogState.VISIBLE, this.radius.callback(caster, localStore, castId), + loc.getX(), loc.getY()); + } + else { + vision = new CTimedCircleFogModifier(CFogState.VISIBLE, + this.radius.callback(caster, localStore, castId), loc.getX(), loc.getY(), + this.duration.callback(caster, localStore, castId)); + } + if (this.player != null) { + this.player.callback(caster, localStore, castId).addFogModifer(localStore.game, vision, false); + } + localStore.put(ABLocalStoreKeys.LASTCREATEDVISIONMODIFIER, vision); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateProjectileVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateProjectileVisionModifier.java new file mode 100644 index 000000000..ceb6eba3a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateProjectileVisionModifier.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.vision; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CProjectileVisionFogModifier; + +public class ABActionCreateProjectileVisionModifier implements ABAction { + + private ABProjectileCallback projectile; + private ABPlayerCallback player; + private ABFloatCallback radius; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + final CProjectileVisionFogModifier vision = new CProjectileVisionFogModifier( + this.projectile.callback(caster, localStore, castId), + radius.callback(caster, localStore, castId)); + if (this.player != null) { + this.player.callback(caster, localStore, castId).addFogModifer(localStore.game, vision, false); + } + localStore.put(ABLocalStoreKeys.LASTCREATEDVISIONMODIFIER, vision); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateUnitVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateUnitVisionModifier.java new file mode 100644 index 000000000..aa6d66171 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionCreateUnitVisionModifier.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.vision; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CUnitVisionFogModifier; + +public class ABActionCreateUnitVisionModifier implements ABAction { + + private ABUnitCallback unit; + private ABPlayerCallback player; + private ABBooleanCallback alwaysNightVision; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + boolean alwaysNight = false; + if (this.alwaysNightVision != null) { + alwaysNight = this.alwaysNightVision.callback(caster, localStore, castId); + } + + final CUnitVisionFogModifier vision = new CUnitVisionFogModifier(this.unit.callback(caster, localStore, castId), + alwaysNight); + if (this.player != null) { + this.player.callback(caster, localStore, castId).addFogModifer(localStore.game, vision, false); + } + localStore.put(ABLocalStoreKeys.LASTCREATEDVISIONMODIFIER, vision); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionRemoveVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionRemoveVisionModifier.java new file mode 100644 index 000000000..8b4db5031 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionRemoveVisionModifier.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.vision; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier.ABVisionModifierCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionRemoveVisionModifier implements ABAction { + + private ABVisionModifierCallback modifier; + private ABPlayerCallback player; + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + player.callback(caster, localStore, castId).removeFogModifer(localStore.game, + modifier.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionSetBurrowPlaceholder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionSetBurrowPlaceholder.java new file mode 100644 index 000000000..051d41882 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/action/vision/ABActionSetBurrowPlaceholder.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.vision; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionSetBurrowPlaceholder implements ABAction { + + @Override + public void runAction(CUnit caster, ABLocalDataStore localStore, int castId) { + // TODO Auto-generated method stub + + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ABCallbackNull.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ABCallbackNull.java new file mode 100644 index 000000000..b9e9043ff --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ABCallbackNull.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackNull implements ABCallback { + + @Override + public Object callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return null; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABAbilityCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABAbilityCallback.java new file mode 100644 index 000000000..fc8e9d428 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABAbilityCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABAbilityCallback implements ABCallback { + + abstract public CAbility callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackArgumentAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackArgumentAbility.java new file mode 100644 index 000000000..e6c495dc6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackArgumentAbility.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentAbility extends ABAbilityCallback { + + private ABStringCallback name; + + @Override + public CAbility callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABAbilityCallback) { + return ((ABAbilityCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseAbilityCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetAbilityById.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetAbilityById.java new file mode 100644 index 000000000..be7b0555f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetAbilityById.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABGetABAbilityByRawcodeVisitor; + +public class ABCallbackGetAbilityById extends ABAbilityCallback { + + private ABIDCallback id; + private ABUnitCallback unit; + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (this.unit != null) { + theUnit = this.unit.callback(caster, localStore, castId); + } + return theUnit.getAbility( + ABGetABAbilityByRawcodeVisitor.getInstance().reset(this.id.callback(caster, localStore, castId))); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetBuffSourceAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetBuffSourceAbility.java new file mode 100644 index 000000000..785741154 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetBuffSourceAbility.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffSourceAbility extends ABAbilityCallback { + + private ABBuffCallback buff; + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return buff.callback(caster, localStore, castId).getSourceAbility(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetLastCreatedAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetLastCreatedAbility.java new file mode 100644 index 000000000..a142b124e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetLastCreatedAbility.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedAbility extends ABAbilityCallback { + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDABILITY, CAbility.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDABILITY", + JassTextGeneratorType.AbilityHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetMatchingAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetMatchingAbility.java new file mode 100644 index 000000000..a754cac36 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetMatchingAbility.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetMatchingAbility extends ABAbilityCallback { + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.MATCHINGABILITY, CAbility.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_MATCHINGABILITY", + JassTextGeneratorType.AbilityHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetPartnerAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetPartnerAbility.java new file mode 100644 index 000000000..5b8bd7b09 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetPartnerAbility.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetPartnerAbility extends ABAbilityCallback { + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTPARTNERABILITY, CAbility.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTPARTNERABILITY", + JassTextGeneratorType.AbilityHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetReactionAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetReactionAbility.java new file mode 100644 index 000000000..335ccf447 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetReactionAbility.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetReactionAbility extends ABAbilityCallback { + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.REACTIONABILITY, CAbility.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_REACTIONABILITY", + JassTextGeneratorType.AbilityHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetStoredAbilityByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetStoredAbilityByKey.java new file mode 100644 index 000000000..55a586120 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetStoredAbilityByKey.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredAbilityByKey extends ABAbilityCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CAbility.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CAbility.class); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.instanceValue == null) { + return "GetLocalStoreUserCastAbilityHandleAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; + } + return "GetStoredAbilityAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetThisAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetThisAbility.java new file mode 100644 index 000000000..8f0bebc75 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackGetThisAbility.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetThisAbility extends ABAbilityCallback { + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.originAbility; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackInlineConditionAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackInlineConditionAbility.java new file mode 100644 index 000000000..4e3771304 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackInlineConditionAbility.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionAbility extends ABAbilityCallback { + + private ABBooleanCallback condition; + private ABAbilityCallback pass; + private ABAbilityCallback fail; + + @Override + public CAbility callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackReuseAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackReuseAbility.java new file mode 100644 index 000000000..9b5327dd8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackReuseAbility.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseAbility extends ABAbilityCallback { + + private ABStringCallback name; + + @Override + public CAbility callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABAbilityCallback) { + return ((ABAbilityCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseAbilityCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseAbilityCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackReuseAbilityWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackReuseAbilityWithArguments.java new file mode 100644 index 000000000..44b7b198e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/ability/ABCallbackReuseAbilityWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseAbilityWithArguments extends ABAbilityCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CAbility callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABAbilityCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABAbilityCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseAbilityCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseAbilityCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABAttackModifierCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABAttackModifierCallback.java new file mode 100644 index 000000000..a9b75ff4e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABAttackModifierCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackModifier; + +public abstract class ABAttackModifierCallback implements ABCallback { + + abstract public ABAttackModifier callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABCallbackGetLastCreatedAttackModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABCallbackGetLastCreatedAttackModifier.java new file mode 100644 index 000000000..75046fc41 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABCallbackGetLastCreatedAttackModifier.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackModifier; + +public class ABCallbackGetLastCreatedAttackModifier extends ABAttackModifierCallback { + + @Override + public ABAttackModifier callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDAMod, ABAttackModifier.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABCallbackGetStoredAttackModifierByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABCallbackGetStoredAttackModifierByKey.java new file mode 100644 index 000000000..d6dde81b9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attack/ABCallbackGetStoredAttackModifierByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackModifier; + +public class ABCallbackGetStoredAttackModifierByKey extends ABAttackModifierCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABAttackModifier callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABAttackModifier.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABAttackModifier.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABAttackSettingsCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABAttackSettingsCallback.java new file mode 100644 index 000000000..3c4ffbb7b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABAttackSettingsCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attacksettings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public abstract class ABAttackSettingsCallback implements ABCallback { + + abstract public CUnitAttackSettings callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetCurrentAttackSettings.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetCurrentAttackSettings.java new file mode 100644 index 000000000..5ec20ce3d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetCurrentAttackSettings.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attacksettings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABCallbackGetCurrentAttackSettings extends ABAttackSettingsCallback { + + @Override + public CUnitAttackSettings callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, castId), + CUnitAttackSettings.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetLastCreatedAttackSettings.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetLastCreatedAttackSettings.java new file mode 100644 index 000000000..22351d59e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetLastCreatedAttackSettings.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attacksettings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABCallbackGetLastCreatedAttackSettings extends ABAttackSettingsCallback { + + @Override + public CUnitAttackSettings callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDASettings, CUnitAttackSettings.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetStoredAttackSettingsByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetStoredAttackSettingsByKey.java new file mode 100644 index 000000000..61e2d25b1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/attacksettings/ABCallbackGetStoredAttackSettingsByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attacksettings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABCallbackGetStoredAttackSettingsByKey extends ABAttackSettingsCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CUnitAttackSettings callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CUnitAttackSettings.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CUnitAttackSettings.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABBuffCallback.java new file mode 100644 index 000000000..735655c14 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABBuffCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABBuffCallback implements ABCallback { + + abstract public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackArgumentBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackArgumentBuff.java new file mode 100644 index 000000000..df3c6b366 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackArgumentBuff.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentBuff extends ABBuffCallback { + + private ABStringCallback name; + + @Override + public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABBuffCallback) { + return ((ABBuffCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseBuffCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackEnumBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackEnumBuff.java new file mode 100644 index 000000000..07eb212bf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackEnumBuff.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackEnumBuff extends ABBuffCallback { + + @Override + public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.ENUMBUFF, CBuff.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ENUMBUFF", JassTextGeneratorType.BuffHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetBuffById.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetBuffById.java new file mode 100644 index 000000000..1bf9f9f20 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetBuffById.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffById extends ABBuffCallback { + + private ABUnitCallback unit; + private ABIDCallback id; + + @Override + public CBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = unit.callback(caster, localStore, castId); + War3ID theId = id.callback(caster, localStore, castId); + if (theUnit != null) { + for (CAbility ability : theUnit.getAbilities()) { + if (ability instanceof CBuff) { + if (((CBuff) ability).getAlias() == theId) { + return (CBuff) ability; + } + } + } + } + return null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetLastCreatedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetLastCreatedBuff.java new file mode 100644 index 000000000..5bcd50798 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetLastCreatedBuff.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedBuff extends ABBuffCallback { + + @Override + public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDBUFF, CBuff.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDBUFF", + JassTextGeneratorType.BuffHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetMatchingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetMatchingBuff.java new file mode 100644 index 000000000..8a28e209e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetMatchingBuff.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetMatchingBuff extends ABBuffCallback { + + @Override + public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.MATCHINGBUFF, CBuff.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_MATCHINGBUFF", JassTextGeneratorType.BuffHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetStoredBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetStoredBuffByKey.java new file mode 100644 index 000000000..b1b152abc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackGetStoredBuffByKey.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredBuffByKey extends ABBuffCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CBuff.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CBuff.class); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.instanceValue == null) { + return "GetLocalStoreUserCastBuffHandleAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; + } + return "GetStoredBuffAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackInlineConditionBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackInlineConditionBuff.java new file mode 100644 index 000000000..5c6c57ff0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackInlineConditionBuff.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionBuff extends ABBuffCallback { + + private ABBooleanCallback condition; + private ABBuffCallback pass; + private ABBuffCallback fail; + + @Override + public CBuff callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackReuseBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackReuseBuff.java new file mode 100644 index 000000000..7966a3bea --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackReuseBuff.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseBuff extends ABBuffCallback { + + private ABStringCallback name; + + @Override + public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABBuffCallback) { + return ((ABBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseBuffCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackReuseBuffWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackReuseBuffWithArguments.java new file mode 100644 index 000000000..fbc2940ec --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackReuseBuffWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseBuffWithArguments extends ABBuffCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABBuffCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseBuffCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackThisBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackThisBuff.java new file mode 100644 index 000000000..45b253733 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/buff/ABCallbackThisBuff.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackThisBuff extends ABBuffCallback { + + @Override + public CBuff callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.BUFF, CBuff.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ENUMBUFF", JassTextGeneratorType.BuffHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackArgumentDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackArgumentDestructable.java new file mode 100644 index 000000000..4c0351e8a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackArgumentDestructable.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentDestructable extends ABDestructableCallback { + + private ABStringCallback name; + + @Override + public CDestructable callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABDestructableCallback) { + return ((ABDestructableCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseDestructableCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetAbilityTargetedDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetAbilityTargetedDestructable.java new file mode 100644 index 000000000..fbacb8637 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetAbilityTargetedDestructable.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAbilityTargetedDestructable extends ABDestructableCallback { + + @Override + public CDestructable callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.ABILITYTARGETEDDESTRUCTABLE, CDestructable.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetAttackedDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetAttackedDestructable.java new file mode 100644 index 000000000..44ebafd02 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetAttackedDestructable.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAttackedDestructable extends ABDestructableCallback { + + @Override + public CDestructable callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityTarget tar = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, castId), + AbilityTarget.class); + return tar.visit(AbilityTargetVisitor.DESTRUCTABLE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetEnumDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetEnumDestructable.java new file mode 100644 index 000000000..76f816808 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetEnumDestructable.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetEnumDestructable extends ABDestructableCallback { + + @Override + public CDestructable callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMDESTRUCTABLE, castId), CDestructable.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetLastCreatedDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetLastCreatedDestructable.java new file mode 100644 index 000000000..3f1907b38 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetLastCreatedDestructable.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedDestructable extends ABDestructableCallback { + + @Override + public CDestructable callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDDESTRUCTABLE, CDestructable.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetProjectileHitDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetProjectileHitDestructable.java new file mode 100644 index 000000000..8dec3d7aa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetProjectileHitDestructable.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetProjectileHitDestructable extends ABDestructableCallback { + + @Override + public CDestructable callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId), CDestructable.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetStoredDestructableByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetStoredDestructableByKey.java new file mode 100644 index 000000000..74576d715 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackGetStoredDestructableByKey.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredDestructableByKey extends ABDestructableCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CDestructable callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CDestructable.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CDestructable.class); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackInlineConditionDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackInlineConditionDestructable.java new file mode 100644 index 000000000..87b88b3d5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackInlineConditionDestructable.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionDestructable extends ABDestructableCallback { + + private ABBooleanCallback condition; + private ABDestructableCallback pass; + private ABDestructableCallback fail; + + @Override + public CDestructable callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackReuseDestructable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackReuseDestructable.java new file mode 100644 index 000000000..0b595a2f2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackReuseDestructable.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseDestructable extends ABDestructableCallback { + + private ABStringCallback name; + + @Override + public CDestructable callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABDestructableCallback) { + return ((ABDestructableCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseDestructableCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseDestructableCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackReuseDestructableWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackReuseDestructableWithArguments.java new file mode 100644 index 000000000..b075c2ab2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABCallbackReuseDestructableWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseDestructableWithArguments extends ABDestructableCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CDestructable callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABDestructableCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABDestructableCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseDestructableCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseDestructableCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABDestructableCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABDestructableCallback.java new file mode 100644 index 000000000..b640992f9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructable/ABDestructableCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABDestructableCallback implements ABCallback { + + abstract public CDestructable callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackArgumentDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackArgumentDestructableBuff.java new file mode 100644 index 000000000..96e856274 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackArgumentDestructableBuff.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentDestructableBuff extends ABDestructableBuffCallback { + + private ABStringCallback name; + + @Override + public CDestructableBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABDestructableBuffCallback) { + return ((ABDestructableBuffCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseDestructableBuffCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackEnumDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackEnumDestructableBuff.java new file mode 100644 index 000000000..451f9af55 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackEnumDestructableBuff.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackEnumDestructableBuff extends ABDestructableBuffCallback { + + @Override + public CDestructableBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.ENUMDESTBUFF, CDestructableBuff.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackGetLastCreatedDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackGetLastCreatedDestructableBuff.java new file mode 100644 index 000000000..54990988c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackGetLastCreatedDestructableBuff.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedDestructableBuff extends ABDestructableBuffCallback { + + @Override + public CDestructableBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDDESTBUFF, CDestructableBuff.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackGetStoredDestructableBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackGetStoredDestructableBuffByKey.java new file mode 100644 index 000000000..da21e1e97 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackGetStoredDestructableBuffByKey.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredDestructableBuffByKey extends ABDestructableBuffCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CDestructableBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CDestructableBuff.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CDestructableBuff.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackInlineConditionDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackInlineConditionDestructableBuff.java new file mode 100644 index 000000000..825432d70 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackInlineConditionDestructableBuff.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionDestructableBuff extends ABDestructableBuffCallback { + + private ABBooleanCallback condition; + private ABDestructableBuffCallback pass; + private ABDestructableBuffCallback fail; + + @Override + public CDestructableBuff callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackMatchingDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackMatchingDestructableBuff.java new file mode 100644 index 000000000..d8d82e33f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackMatchingDestructableBuff.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackMatchingDestructableBuff extends ABDestructableBuffCallback { + + @Override + public CDestructableBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.MATCHINGDESTBUFF, CDestructableBuff.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackReuseDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackReuseDestructableBuff.java new file mode 100644 index 000000000..04a86f7b4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackReuseDestructableBuff.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseDestructableBuff extends ABDestructableBuffCallback { + + private ABStringCallback name; + + @Override + public CDestructableBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABDestructableBuffCallback) { + return ((ABDestructableBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseDestructableBuffCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseDestructableBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackReuseDestructableBuffWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackReuseDestructableBuffWithArguments.java new file mode 100644 index 000000000..9e5872fd6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABCallbackReuseDestructableBuffWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseDestructableBuffWithArguments extends ABDestructableBuffCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CDestructableBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABDestructableBuffCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABDestructableBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseDestructableBuffCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseDestructableBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABDestructableBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABDestructableBuffCallback.java new file mode 100644 index 000000000..b8d9bea3a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/destructablebuff/ABDestructableBuffCallback.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABDestructableBuffCallback implements ABCallback { + + abstract public CDestructableBuff callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAttackPreDamageListenerPriorityCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAttackPreDamageListenerPriorityCallback.java new file mode 100644 index 000000000..5cce47b82 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAttackPreDamageListenerPriorityCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerPriority; + +public abstract class ABAttackPreDamageListenerPriorityCallback implements ABCallback { + + abstract public CUnitAttackPreDamageListenerPriority callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAttackTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAttackTypeCallback.java new file mode 100644 index 000000000..deee00a79 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAttackTypeCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; + +public abstract class ABAttackTypeCallback implements ABCallback { + + abstract public CAttackType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAutocastTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAutocastTypeCallback.java new file mode 100644 index 000000000..167059101 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABAutocastTypeCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABAutocastTypeCallback implements ABCallback { + + abstract public AutocastType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackConditionalAutocastType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackConditionalAutocastType.java new file mode 100644 index 000000000..4e89965ec --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackConditionalAutocastType.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackConditionalAutocastType extends ABAutocastTypeCallback { + + private ABBooleanCallback condition; + private ABAutocastTypeCallback value1; + private ABAutocastTypeCallback value2; + + @Override + public AutocastType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (condition.callback(caster, localStore, castId)) { + return value1.callback(caster, localStore, castId); + } + return value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetAttackTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetAttackTypeFromString.java new file mode 100644 index 000000000..807db934c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetAttackTypeFromString.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; + +public class ABCallbackGetAttackTypeFromString extends ABAttackTypeCallback { + + private ABStringCallback id; + + @Override + public CAttackType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return CAttackType.valueOf(id.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetAutocastTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetAutocastTypeFromString.java new file mode 100644 index 000000000..0d8b520b1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetAutocastTypeFromString.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAutocastTypeFromString extends ABAutocastTypeCallback { + + private ABStringCallback id; + + @Override + public AutocastType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return AutocastType.valueOf(id.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetDamageTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetDamageTypeFromString.java new file mode 100644 index 000000000..492e99ac2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetDamageTypeFromString.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABCallbackRawString; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +public class ABCallbackGetDamageTypeFromString extends ABDamageTypeCallback { + + private ABStringCallback id; + + @Override + public CDamageType callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return CDamageType.valueOf(this.id.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.id instanceof ABCallbackRawString) { + // if possible, convert it directly, no shenanigans + final String value = ((ABCallbackRawString) this.id).getValue(); + return "DAMAGE_TYPE_" + value; + } + return "String2DamageType(" + this.id.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetDefenseTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetDefenseTypeFromString.java new file mode 100644 index 000000000..06e48a07e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetDefenseTypeFromString.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; + +public class ABCallbackGetDefenseTypeFromString extends ABDefenseTypeCallback { + + private ABStringCallback id; + + @Override + public CDefenseType callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return CDefenseType.valueOf(this.id.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetMovementTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetMovementTypeFromString.java new file mode 100644 index 000000000..da79fc67f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetMovementTypeFromString.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetMovementTypeFromString extends ABMovementTypeCallback { + + private ABStringCallback id; + + @Override + public MovementType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return MovementType.valueOf(this.id.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetNonStackingStatBuffTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetNonStackingStatBuffTypeFromString.java new file mode 100644 index 000000000..82ad4fb09 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetNonStackingStatBuffTypeFromString.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABCallbackRawString; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; + +public class ABCallbackGetNonStackingStatBuffTypeFromString extends ABNonStackingStatBuffTypeCallback { + + private ABStringCallback id; + + @Override + public NonStackingStatBuffType callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return NonStackingStatBuffType.valueOf(this.id.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.id instanceof ABCallbackRawString) { + // if possible, convert it directly, no shenanigans + final String value = ((ABCallbackRawString) this.id).getValue(); + return "NON_STACKING_STAT_BUFF_TYPE_" + value; + } + return "String2NonStackingStatBuffType(" + this.id.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredAttackTypeByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredAttackTypeByKey.java new file mode 100644 index 000000000..034f90360 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredAttackTypeByKey.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; + +public class ABCallbackGetStoredAttackTypeByKey extends ABAttackTypeCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CAttackType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CAttackType.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CAttackType.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredDamageTypeByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredDamageTypeByKey.java new file mode 100644 index 000000000..ddde27900 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredDamageTypeByKey.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +public class ABCallbackGetStoredDamageTypeByKey extends ABDamageTypeCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CDamageType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CDamageType.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CDamageType.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredDefenseTypeByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredDefenseTypeByKey.java new file mode 100644 index 000000000..0f570aba4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredDefenseTypeByKey.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; + +public class ABCallbackGetStoredDefenseTypeByKey extends ABDefenseTypeCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CDefenseType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CDefenseType.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CDefenseType.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredMovementTypeByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredMovementTypeByKey.java new file mode 100644 index 000000000..f5a7065d9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredMovementTypeByKey.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredMovementTypeByKey extends ABMovementTypeCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public MovementType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + MovementType.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + MovementType.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredTargetTypeByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredTargetTypeByKey.java new file mode 100644 index 000000000..63f3e5ca8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredTargetTypeByKey.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABCallbackGetStoredTargetTypeByKey extends ABTargetTypeCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CTargetType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CTargetType.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CTargetType.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredWeaponTypeByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredWeaponTypeByKey.java new file mode 100644 index 000000000..c3bae160e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetStoredWeaponTypeByKey.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; + +public class ABCallbackGetStoredWeaponTypeByKey extends ABWeaponTypeCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CWeaponType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CWeaponType.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CWeaponType.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetTargetTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetTargetTypeFromString.java new file mode 100644 index 000000000..028cfe764 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetTargetTypeFromString.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABCallbackGetTargetTypeFromString extends ABTargetTypeCallback { + + private ABStringCallback id; + + @Override + public CTargetType callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return CTargetType.valueOf(this.id.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitDefenseType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitDefenseType.java new file mode 100644 index 000000000..6671ccc22 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitDefenseType.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; + +public class ABCallbackGetUnitDefenseType extends ABDefenseTypeCallback { + + private ABUnitCallback unit; + + @Override + public CDefenseType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return unit.callback(caster, localStore, castId).getDefenseType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitMovementType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitMovementType.java new file mode 100644 index 000000000..12c2daf3d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitMovementType.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitMovementType extends ABMovementTypeCallback { + + private ABUnitCallback unit; + + @Override + public MovementType callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return unit.callback(caster, localStore, castId).getMovementType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitTypeMovementType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitTypeMovementType.java new file mode 100644 index 000000000..986e5151c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetUnitTypeMovementType.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitTypeMovementType extends ABMovementTypeCallback { + + private ABIDCallback type; + + @Override + public MovementType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + War3ID theType = type.callback(caster, localStore, castId); + return localStore.game.getUnitData().getUnitType(theType).getMovementType(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetWeaponTypeFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetWeaponTypeFromString.java new file mode 100644 index 000000000..003b193fc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackGetWeaponTypeFromString.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABCallbackRawString; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; + +public class ABCallbackGetWeaponTypeFromString extends ABWeaponTypeCallback { + + private ABStringCallback id; + + @Override + public CWeaponType callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return CWeaponType.valueOf(this.id.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.id instanceof ABCallbackRawString) { + // if possible, convert it directly, no shenanigans + final String value = ((ABCallbackRawString) this.id).getValue(); + return "WEAPON_TYPE_" + value; + } + return "String2WeaponType(" + this.id.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawDeathEffectPriority.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawDeathEffectPriority.java new file mode 100644 index 000000000..7df731c8e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawDeathEffectPriority.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementEffectPriority; + +public class ABCallbackRawDeathEffectPriority extends ABDeathReplacementPriorityCallback { + + private CUnitDeathReplacementEffectPriority priority; + + @Override + public CUnitDeathReplacementEffectPriority callback(CUnit caster, ABLocalDataStore localStore, + final int castId) { + return priority; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawPreDamageListenerPriority.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawPreDamageListenerPriority.java new file mode 100644 index 000000000..0de85ea2c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawPreDamageListenerPriority.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerPriority; + +public class ABCallbackRawPreDamageListenerPriority extends ABAttackPreDamageListenerPriorityCallback { + + private CUnitAttackPreDamageListenerPriority priority; + + @Override + public CUnitAttackPreDamageListenerPriority callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return priority; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawTargetType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawTargetType.java new file mode 100644 index 000000000..22c5e3d55 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawTargetType.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABCallbackRawTargetType extends ABTargetTypeCallback { + + private CTargetType value; + + @Override + public CTargetType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawWeaponType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawWeaponType.java new file mode 100644 index 000000000..7ef3615a0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABCallbackRawWeaponType.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; + +public class ABCallbackRawWeaponType extends ABWeaponTypeCallback { + + private CWeaponType value; + + @Override + public CWeaponType callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDamageTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDamageTypeCallback.java new file mode 100644 index 000000000..bbd902d88 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDamageTypeCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +public abstract class ABDamageTypeCallback implements ABCallback { + + abstract public CDamageType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDeathReplacementPriorityCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDeathReplacementPriorityCallback.java new file mode 100644 index 000000000..ffdec0bd3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDeathReplacementPriorityCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementEffectPriority; + +public abstract class ABDeathReplacementPriorityCallback implements ABCallback { + + abstract public CUnitDeathReplacementEffectPriority callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDefenseTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDefenseTypeCallback.java new file mode 100644 index 000000000..247b4ec4a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABDefenseTypeCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; + +public abstract class ABDefenseTypeCallback implements ABCallback { + + abstract public CDefenseType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABMovementTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABMovementTypeCallback.java new file mode 100644 index 000000000..20adfcc55 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABMovementTypeCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABMovementTypeCallback implements ABCallback { + + abstract public MovementType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABNonStackingStatBuffTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABNonStackingStatBuffTypeCallback.java new file mode 100644 index 000000000..0b65f0fba --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABNonStackingStatBuffTypeCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; + +public abstract class ABNonStackingStatBuffTypeCallback implements ABCallback { + + abstract public NonStackingStatBuffType callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABTargetTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABTargetTypeCallback.java new file mode 100644 index 000000000..6194894d3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABTargetTypeCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public abstract class ABTargetTypeCallback implements ABCallback { + + abstract public CTargetType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABWeaponTypeCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABWeaponTypeCallback.java new file mode 100644 index 000000000..a984043a7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/enums/ABWeaponTypeCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; + +public abstract class ABWeaponTypeCallback implements ABCallback { + + abstract public CWeaponType callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackArgumentTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackArgumentTimeOfDayEvent.java new file mode 100644 index 000000000..3b8e66ee8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackArgumentTimeOfDayEvent.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; + +public class ABCallbackArgumentTimeOfDayEvent extends ABTimeOfDayEventCallback { + + private ABStringCallback name; + + @Override + public ABTimeOfDayEvent callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABTimeOfDayEventCallback) { + return ((ABTimeOfDayEventCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseTimeOfDayEventCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackGetLastCreatedTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackGetLastCreatedTimeOfDayEvent.java new file mode 100644 index 000000000..c4d7401b8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackGetLastCreatedTimeOfDayEvent.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; + +public class ABCallbackGetLastCreatedTimeOfDayEvent extends ABTimeOfDayEventCallback { + + @Override + public ABTimeOfDayEvent callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDTODEVENT, ABTimeOfDayEvent.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackGetStoredTimeOfDayEventByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackGetStoredTimeOfDayEventByKey.java new file mode 100644 index 000000000..5bf3f6c63 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackGetStoredTimeOfDayEventByKey.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; + +public class ABCallbackGetStoredTimeOfDayEventByKey extends ABTimeOfDayEventCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABTimeOfDayEvent callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABTimeOfDayEvent.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABTimeOfDayEvent.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackInlineConditionTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackInlineConditionTimeOfDayEvent.java new file mode 100644 index 000000000..8055513fa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackInlineConditionTimeOfDayEvent.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; + +public class ABCallbackInlineConditionTimeOfDayEvent extends ABTimeOfDayEventCallback { + + private ABBooleanCallback condition; + private ABTimeOfDayEventCallback pass; + private ABTimeOfDayEventCallback fail; + + @Override + public ABTimeOfDayEvent callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackReuseTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackReuseTimeOfDayEvent.java new file mode 100644 index 000000000..cfba74cad --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackReuseTimeOfDayEvent.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseTimeOfDayEvent extends ABTimeOfDayEventCallback { + + private ABStringCallback name; + + @Override + public ABTimeOfDayEvent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABTimeOfDayEventCallback) { + return ((ABTimeOfDayEventCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseTimeOfDayEventCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseTimeOfDayEventCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackReuseTimeOfDayEventWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackReuseTimeOfDayEventWithArguments.java new file mode 100644 index 000000000..28e11afda --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABCallbackReuseTimeOfDayEventWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseTimeOfDayEventWithArguments extends ABTimeOfDayEventCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public ABTimeOfDayEvent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABTimeOfDayEventCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABTimeOfDayEventCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseTimeOfDayEventCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseTimeOfDayEventCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABTimeOfDayEventCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABTimeOfDayEventCallback.java new file mode 100644 index 000000000..db6883a8f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/timeevent/ABTimeOfDayEventCallback.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABTimeOfDayEvent; + +public abstract class ABTimeOfDayEventCallback implements ABCallback { + + abstract public ABTimeOfDayEvent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackArgumentWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackArgumentWidgetEvent.java new file mode 100644 index 000000000..c2bdc55ca --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackArgumentWidgetEvent.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; + +public class ABCallbackArgumentWidgetEvent extends ABWidgetEventCallback { + + private ABStringCallback name; + + @Override + public ABWidgetEvent callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABWidgetEventCallback) { + return ((ABWidgetEventCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseWidgetEventCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackGetLastCreatedWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackGetLastCreatedWidgetEvent.java new file mode 100644 index 000000000..467e8d6dc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackGetLastCreatedWidgetEvent.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; + +public class ABCallbackGetLastCreatedWidgetEvent extends ABWidgetEventCallback { + + @Override + public ABWidgetEvent callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDWIDEVENT, ABWidgetEvent.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackGetStoredWidgetEventByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackGetStoredWidgetEventByKey.java new file mode 100644 index 000000000..1526ac228 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackGetStoredWidgetEventByKey.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; + +public class ABCallbackGetStoredWidgetEventByKey extends ABWidgetEventCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABWidgetEvent callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABWidgetEvent.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABWidgetEvent.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackInlineConditionWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackInlineConditionWidgetEvent.java new file mode 100644 index 000000000..ff4856103 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackInlineConditionWidgetEvent.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; + +public class ABCallbackInlineConditionWidgetEvent extends ABWidgetEventCallback { + + private ABBooleanCallback condition; + private ABWidgetEventCallback pass; + private ABWidgetEventCallback fail; + + @Override + public ABWidgetEvent callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackReuseWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackReuseWidgetEvent.java new file mode 100644 index 000000000..fccf0fa1b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackReuseWidgetEvent.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseWidgetEvent extends ABWidgetEventCallback { + + private ABStringCallback name; + + @Override + public ABWidgetEvent callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABWidgetEventCallback) { + return ((ABWidgetEventCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseWidgetEventCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseWidgetEventCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackReuseWidgetEventWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackReuseWidgetEventWithArguments.java new file mode 100644 index 000000000..6b47832cd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABCallbackReuseWidgetEventWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseWidgetEventWithArguments extends ABWidgetEventCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public ABWidgetEvent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABWidgetEventCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABWidgetEventCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseWidgetEventCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseWidgetEventCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABWidgetEventCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABWidgetEventCallback.java new file mode 100644 index 000000000..ab8f71ce2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/event/widgetevent/ABWidgetEventCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event.ABWidgetEvent; + +public abstract class ABWidgetEventCallback implements ABCallback { + + abstract public ABWidgetEvent callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackAddFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackAddFloat.java new file mode 100644 index 000000000..345f42e63 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackAddFloat.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackAddFloat extends ABFloatCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) + value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackArgumentFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackArgumentFloat.java new file mode 100644 index 000000000..92c498c29 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackArgumentFloat.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentFloat extends ABFloatCallback { + + private ABStringCallback name; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABFloatCallback) { + return ((ABFloatCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseFloatCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackCeilFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackCeilFloat.java new file mode 100644 index 000000000..8a5081a31 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackCeilFloat.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCeilFloat extends ABFloatCallback { + + private ABFloatCallback value; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) Math.ceil(value.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackCos.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackCos.java new file mode 100644 index 000000000..d9b53e48f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackCos.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCos extends ABFloatCallback { + + private ABFloatCallback angle; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) StrictMath.cos(angle.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackDegToRad.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackDegToRad.java new file mode 100644 index 000000000..586b334c9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackDegToRad.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackDegToRad extends ABFloatCallback { + + private ABFloatCallback angle; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) StrictMath.toRadians(angle.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackDivideFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackDivideFloat.java new file mode 100644 index 000000000..6f697fa43 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackDivideFloat.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackDivideFloat extends ABFloatCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return this.value1.callback(caster, localStore, castId) + / this.value2.callback(caster, localStore, castId); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return this.value1.generateJassEquivalent(jassTextGenerator) + " / " + + this.value2.generateJassEquivalent(jassTextGenerator); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackFMaxValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackFMaxValue.java new file mode 100644 index 000000000..0fc91220e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackFMaxValue.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackFMaxValue extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return Float.MAX_VALUE; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackFloorFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackFloorFloat.java new file mode 100644 index 000000000..a03116618 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackFloorFloat.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackFloorFloat extends ABFloatCallback { + + private ABFloatCallback value; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) Math.floor(value.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityArea.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityArea.java new file mode 100644 index 000000000..83cb6f0b6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityArea.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityArea extends ABFloatCallback { + + private ABAbilityCallback ability; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (ability == null) { + ABAbilityBuilderAbility abil = localStore.originAbility; + return abil.getArea(); + } else { + CAbility abil = ability.callback(caster, localStore, castId); + if (abil instanceof ABAbilityBuilderAbility) { + return ((ABAbilityBuilderAbility) abil).getArea(); + } else { + return 0f; + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCastRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCastRange.java new file mode 100644 index 000000000..0d697bcd5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCastRange.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityCastRange extends ABFloatCallback { + + private ABAbilityCallback ability; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (ability == null) { + ABAbilityBuilderAbility abil = localStore.originAbility; + return abil.getCastRange(); + } else { + CAbility abil = ability.callback(caster, localStore, castId); + if (abil instanceof ABAbilityBuilderAbility) { + return ((ABAbilityBuilderAbility) abil).getCastRange(); + } else { + return 0f; + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCastTime.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCastTime.java new file mode 100644 index 000000000..e52c75409 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCastTime.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityCastTime extends ABFloatCallback { + + @SuppressWarnings("unchecked") + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderAbility ability = localStore.originAbility; + if (ability != null) { + return ability.getCastTime(); + } else { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + return levelData.get(localStore.getLevelDataInstanceLevel(castId)).getCastTime(); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityCastTimeAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCooldown.java new file mode 100644 index 000000000..a7dc1cb1c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityCooldown.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityCooldown extends ABFloatCallback { + + private ABAbilityCallback ability; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (ability == null) { + ABAbilityBuilderAbility abil = localStore.originAbility; + return abil.getCooldown(); + } else { + CAbility abil = ability.callback(caster, localStore, castId); + if (abil instanceof ABAbilityBuilderAbility) { + return ((ABAbilityBuilderAbility) abil).getCooldown(); + } else { + return 0f; + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityDataAsFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityDataAsFloat.java new file mode 100644 index 000000000..bcfd082e9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityDataAsFloat.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsFloat extends ABFloatCallback { + + private ABDataFieldLetter dataField; + + @SuppressWarnings("unchecked") + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + final String data = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData() + .get(this.dataField.getIndex()); + if (data.contains("-") || data.isEmpty()) { + return 0f; + } + + return Float.parseFloat(data); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityDataAsFloatAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" + + this.dataField.name() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityDuration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityDuration.java new file mode 100644 index 000000000..dc048fa2e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityDuration.java @@ -0,0 +1,41 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; + +public class ABCallbackGetAbilityDuration extends ABFloatCallback { + + private ABUnitCallback target; + + @SuppressWarnings("unchecked") + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + if (this.target != null) { + final CUnit tar = this.target.callback(caster, localStore, castId); + if (tar.isHero() || tar.isUnitType(CUnitTypeJass.RESISTANT)) { + return levelData.get(localStore.getLevelDataInstanceLevel(castId)).getDurationHero(); + } + } + return levelData.get(localStore.getLevelDataInstanceLevel(castId)).getDurationNormal(); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.target != null) { + return "GetAbilityDurationForTargetAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ")"; + } + return "GetAbilityDurationAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; + + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityHeroDuration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityHeroDuration.java new file mode 100644 index 000000000..fc389f317 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityHeroDuration.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityHeroDuration extends ABFloatCallback { + + @SuppressWarnings("unchecked") + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + return levelData.get(localStore.getLevelDataInstanceLevel(castId)).getDurationHero(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityProjectileSpeed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityProjectileSpeed.java new file mode 100644 index 000000000..b4f437b52 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityProjectileSpeed.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAbilityProjectileSpeed extends ABFloatCallback { + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + + final GameObject editorData = localStore.get(ABLocalStoreKeys.ABILITYEDITORDATA, GameObject.class); + return editorData.getFieldAsFloat(AbilityFields.PROJECTILE_SPEED, 0); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityUniqueValueFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityUniqueValueFloat.java new file mode 100644 index 000000000..484603525 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAbilityUniqueValueFloat.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityUniqueValueFloat extends ABFloatCallback { + + private ABAbilityCallback ability; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CAbility theAbility = ability.callback(caster, localStore, castId); + Float theVal = theAbility.getUniqueValue(keyS, Float.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return 0.0f; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAngleBetweenLocations.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAngleBetweenLocations.java new file mode 100644 index 000000000..c3b2dd30d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetAngleBetweenLocations.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAngleBetweenLocations extends ABFloatCallback { + + private ABLocationCallback origin; + private ABLocationCallback target; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget o = this.origin.callback(caster, localStore, castId); + final AbilityPointTarget t = this.target.callback(caster, localStore, castId); + + final double dx = t.getX() - o.getX(); + final double dy = t.getY() - o.getY(); + return (float) StrictMath.atan2(dy, dx); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "AngleBetweenPointsAU(" + this.origin.generateJassEquivalent(jassTextGenerator) + ", " + + this.target.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetBuffDurationElapsed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetBuffDurationElapsed.java new file mode 100644 index 000000000..5d6fd7b48 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetBuffDurationElapsed.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffDurationElapsed extends ABFloatCallback { + + private ABBuffCallback buff; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final CBuff theBuff = buff.callback(caster, localStore, castId); + return theBuff.getDurationMax() - theBuff.getDurationRemaining(localStore.game, caster); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetBuffUniqueValueFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetBuffUniqueValueFloat.java new file mode 100644 index 000000000..9034bc422 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetBuffUniqueValueFloat.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffUniqueValueFloat extends ABFloatCallback { + + private ABBuffCallback buff; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CBuff theBuff = buff.callback(caster, localStore, castId); + Float theVal = theBuff.getUniqueValue(keyS, Float.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return 0.0f; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetDistanceBetweenLocations.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetDistanceBetweenLocations.java new file mode 100644 index 000000000..ac09a6dd6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetDistanceBetweenLocations.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetDistanceBetweenLocations extends ABFloatCallback { + + private ABLocationCallback origin; + private ABLocationCallback target; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget o = origin.callback(caster, localStore, castId); + AbilityPointTarget t = target.callback(caster, localStore, castId); + + return o.dst(t); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetDistanceBetweenUnits.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetDistanceBetweenUnits.java new file mode 100644 index 000000000..558e9e897 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetDistanceBetweenUnits.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetDistanceBetweenUnits extends ABFloatCallback { + + private ABUnitCallback origin; + private ABUnitCallback target; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit o = origin.callback(caster, localStore, castId); + CUnit t = target.callback(caster, localStore, castId); + + return (float) o.distance(t); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetLocationX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetLocationX.java new file mode 100644 index 000000000..4ab8b71ca --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetLocationX.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetLocationX extends ABFloatCallback { + + private ABLocationCallback location; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return location.callback(caster, localStore, castId).getX(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetLocationY.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetLocationY.java new file mode 100644 index 000000000..a4845764c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetLocationY.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetLocationY extends ABFloatCallback { + + private ABLocationCallback location; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return location.callback(caster, localStore, castId).getY(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetStoredFloatByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetStoredFloatByKey.java new file mode 100644 index 000000000..8122e9d6a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetStoredFloatByKey.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredFloatByKey extends ABFloatCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + Float.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + Float.class); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.instanceValue == null) { + return "GetLocalStoreUserCastRealAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; + } + return "GetStoredRealAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitAcquisitionRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitAcquisitionRange.java new file mode 100644 index 000000000..b549c973b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitAcquisitionRange.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitAcquisitionRange extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = unit.callback(caster, localStore, castId); + if (theUnit.getAcquisitionRange() > 0) { + return theUnit.getAcquisitionRange(); + } + return (float) theUnit.getUnitType().getSightRadiusDay(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCastPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCastPoint.java new file mode 100644 index 000000000..d1cae4fbd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCastPoint.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitCastPoint extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit.callback(caster, localStore, castId).getUnitType().getCastPoint(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCurrentHp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCurrentHp.java new file mode 100644 index 000000000..edf169c15 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCurrentHp.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitCurrentHp extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit == null ? caster.getLife() : this.unit.callback(caster, localStore, castId).getLife(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GetUnitState(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", UNIT_STATE_LIFE)"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCurrentMana.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCurrentMana.java new file mode 100644 index 000000000..b458b8b34 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitCurrentMana.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitCurrentMana extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit == null ? caster.getMana() : unit.callback(caster, localStore, castId).getMana(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitFacing.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitFacing.java new file mode 100644 index 000000000..e04419a91 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitFacing.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitFacing extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return this.unit.callback(caster, localStore, castId).getFacing(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GetUnitFacing(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitInitialMana.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitInitialMana.java new file mode 100644 index 000000000..5972b58b4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitInitialMana.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitInitialMana extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) unit.callback(caster, localStore, castId).getUnitType().getManaInitial(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitLocationX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitLocationX.java new file mode 100644 index 000000000..76f59df6f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitLocationX.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitLocationX extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit.callback(caster, localStore, castId).getX(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitLocationY.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitLocationY.java new file mode 100644 index 000000000..cb4cd078c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackGetUnitLocationY.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitLocationY extends ABFloatCallback { + + private ABUnitCallback unit; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit.callback(caster, localStore, castId).getY(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackInlineConditionFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackInlineConditionFloat.java new file mode 100644 index 000000000..81d3c2d8f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackInlineConditionFloat.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionFloat extends ABFloatCallback { + + private ABBooleanCallback condition; + private ABFloatCallback pass; + private ABFloatCallback fail; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackIntToFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackIntToFloat.java new file mode 100644 index 000000000..620847c77 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackIntToFloat.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIntToFloat extends ABFloatCallback { + + private ABIntegerCallback value; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return this.value.callback(caster, localStore, castId).floatValue(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return this.value.generateJassEquivalent(jassTextGenerator); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMaxFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMaxFloat.java new file mode 100644 index 000000000..e64058d9b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMaxFloat.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMaxFloat extends ABFloatCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return Math.max(this.value1.callback(caster, localStore, castId), + this.value2.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RMaxBJ(" + this.value1.generateJassEquivalent(jassTextGenerator) + ", " + + this.value2.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMinFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMinFloat.java new file mode 100644 index 000000000..69eae0221 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMinFloat.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMinFloat extends ABFloatCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return Math.min(this.value1.callback(caster, localStore, castId), + this.value2.callback(caster, localStore, castId)); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "RMinBJ(" + this.value1.generateJassEquivalent(jassTextGenerator) + ", " + + this.value2.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMultiplyFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMultiplyFloat.java new file mode 100644 index 000000000..2483cd16c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackMultiplyFloat.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMultiplyFloat extends ABFloatCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) * value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackNegativeFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackNegativeFloat.java new file mode 100644 index 000000000..2f3ad0411 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackNegativeFloat.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackNegativeFloat extends ABFloatCallback { + + private ABFloatCallback value; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return -1 * this.value.callback(caster, localStore, castId); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "-(" + this.value.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackOneGameTick.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackOneGameTick.java new file mode 100644 index 000000000..84bb8ca61 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackOneGameTick.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackOneGameTick extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return WarsmashConstants.SIMULATION_STEP_TIME + 0.000001f; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackPi.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackPi.java new file mode 100644 index 000000000..da073c853 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackPi.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackPi extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) StrictMath.PI; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRandomBoundedFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRandomBoundedFloat.java new file mode 100644 index 000000000..6b474327b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRandomBoundedFloat.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRandomBoundedFloat extends ABFloatCallback { + + private ABFloatCallback bound; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getSeededRandom().nextFloat(bound.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRandomFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRandomFloat.java new file mode 100644 index 000000000..3acba5e24 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRandomFloat.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRandomFloat extends ABFloatCallback { + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getSeededRandom().nextFloat(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRawFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRawFloat.java new file mode 100644 index 000000000..3ad8cc7ea --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackRawFloat.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRawFloat extends ABFloatCallback { + + private Float value; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return this.value; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return this.value.toString(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackReuseFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackReuseFloat.java new file mode 100644 index 000000000..d464e2b52 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackReuseFloat.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseFloat extends ABFloatCallback { + + private ABStringCallback name; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABFloatCallback) { + return ((ABFloatCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseFloatCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseFloatCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackReuseFloatWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackReuseFloatWithArguments.java new file mode 100644 index 000000000..dd102e83c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackReuseFloatWithArguments.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseFloatWithArguments extends ABFloatCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABFloatCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABFloatCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseFloatCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseFloatCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackSin.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackSin.java new file mode 100644 index 000000000..e3022be4e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackSin.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackSin extends ABFloatCallback { + + private ABFloatCallback angle; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) StrictMath.sin(angle.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackSubtractFloat.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackSubtractFloat.java new file mode 100644 index 000000000..0f788f66c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackSubtractFloat.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackSubtractFloat extends ABFloatCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Float callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return this.value1.callback(caster, localStore, castId) + - this.value2.callback(caster, localStore, castId); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return this.value1.generateJassEquivalent(jassTextGenerator) + " - " + + this.value2.generateJassEquivalent(jassTextGenerator); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackTan.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackTan.java new file mode 100644 index 000000000..d77770ab2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackTan.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackTan extends ABFloatCallback { + + private ABFloatCallback angle; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (float) StrictMath.tan(angle.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackTicksForDuration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackTicksForDuration.java new file mode 100644 index 000000000..ff52e9748 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABCallbackTicksForDuration.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackTicksForDuration extends ABFloatCallback { + + private ABFloatCallback duration; + + @Override + public Float callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return duration.callback(caster, localStore, castId) / WarsmashConstants.SIMULATION_STEP_TIME; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABFloatCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABFloatCallback.java new file mode 100644 index 000000000..e5d2ae18c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/floats/ABFloatCallback.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABFloatCallback implements ABCallback { + + abstract public Float callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackArgumentFX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackArgumentFX.java new file mode 100644 index 000000000..4f0230c7c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackArgumentFX.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABCallbackArgumentFX extends ABFXCallback { + + private ABStringCallback name; + + @Override + public SimulationRenderComponent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABFXCallback) { + return ((ABFXCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseFXCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetLastCreatedFX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetLastCreatedFX.java new file mode 100644 index 000000000..6cbd3eaa2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetLastCreatedFX.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABCallbackGetLastCreatedFX extends ABFXCallback { + + @Override + public SimulationRenderComponent callback(CUnit caster, ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDFX, SimulationRenderComponent.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetLastCreatedLightningEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetLastCreatedLightningEffect.java new file mode 100644 index 000000000..a117447ec --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetLastCreatedLightningEffect.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; + +public class ABCallbackGetLastCreatedLightningEffect extends ABLightningCallback { + + @Override + public SimulationRenderComponentLightning callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDLIGHTNING, SimulationRenderComponentLightning.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetStoredFXByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetStoredFXByKey.java new file mode 100644 index 000000000..7b216ef2d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetStoredFXByKey.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABCallbackGetStoredFXByKey extends ABFXCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public SimulationRenderComponent callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + SimulationRenderComponent.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + SimulationRenderComponent.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetStoredLightningByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetStoredLightningByKey.java new file mode 100644 index 000000000..8ce3ea6cc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackGetStoredLightningByKey.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; + +public class ABCallbackGetStoredLightningByKey extends ABLightningCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public SimulationRenderComponentLightning callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + SimulationRenderComponentLightning.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + SimulationRenderComponentLightning.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackInlineConditionFX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackInlineConditionFX.java new file mode 100644 index 000000000..5a1abef34 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackInlineConditionFX.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABCallbackInlineConditionFX extends ABFXCallback { + + private ABBooleanCallback condition; + private ABFXCallback pass; + private ABFXCallback fail; + + @Override + public SimulationRenderComponent callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackReuseFX.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackReuseFX.java new file mode 100644 index 000000000..fcd6bc4c3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackReuseFX.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABCallbackReuseFX extends ABFXCallback { + + private ABStringCallback name; + + @Override + public SimulationRenderComponent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABFXCallback) { + return ((ABFXCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseFXCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseFXCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackReuseFXWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackReuseFXWithArguments.java new file mode 100644 index 000000000..4dec2d1f7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABCallbackReuseFXWithArguments.java @@ -0,0 +1,50 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABCallbackReuseFXWithArguments extends ABFXCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public SimulationRenderComponent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABFXCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABFXCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseFXCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseFXCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABFXCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABFXCallback.java new file mode 100644 index 000000000..96d6e1e1e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABFXCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public abstract class ABFXCallback implements ABCallback { + + abstract public SimulationRenderComponent callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABLightningCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABLightningCallback.java new file mode 100644 index 000000000..c9d29633d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/fx/ABLightningCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponentLightning; + +public abstract class ABLightningCallback implements ABCallback { + + abstract public SimulationRenderComponentLightning callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackArgumentID.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackArgumentID.java new file mode 100644 index 000000000..42b8002de --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackArgumentID.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentID extends ABIDCallback { + + private ABStringCallback name; + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABIDCallback) { + return ((ABIDCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseIDCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsID.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsID.java new file mode 100644 index 000000000..96808a18f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsID.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsID extends ABIDCallback { + + private ABDataFieldLetter dataField; + + @SuppressWarnings("unchecked") + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + final String data = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData() + .get(this.dataField.getIndex()); + if ((data == null) || "-".equals(data) || data.isBlank() || "_".equals(data)) { + return War3ID.NONE; + } + return War3ID.fromString(data); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityDataAsIDAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" + + this.dataField.name() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsIDFromList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsIDFromList.java new file mode 100644 index 000000000..7dabf6446 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsIDFromList.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsIDFromList extends ABIDCallback { + + private ABDataFieldLetter dataField; + private ABIntegerCallback index; + + @SuppressWarnings("unchecked") + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + final String data = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData() + .get(this.dataField.getIndex()); + if ((data == null) || "-".equals(data) || data.isBlank() || "_".equals(data)) { + return War3ID.NONE; + } + String[] ids = data.split(","); + int i = 0; + if (index != null) { + i = index.callback(caster, localStore, castId); + } + String tar = ids[Math.min(Math.max(i, 0), ids.length - 1)]; + if ((tar == null) || "-".equals(tar) || tar.isBlank() || "_".equals(tar)) { + return War3ID.NONE; + } + return War3ID.fromString(tar); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityDataAsIDAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" + + this.dataField.name() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsRandomIDFromList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsRandomIDFromList.java new file mode 100644 index 000000000..fef91a004 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityDataAsRandomIDFromList.java @@ -0,0 +1,43 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsRandomIDFromList extends ABIDCallback { + + private ABDataFieldLetter dataField; + + @SuppressWarnings("unchecked") + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + final String data = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData() + .get(this.dataField.getIndex()); + if ((data == null) || "-".equals(data) || data.isBlank() || "_".equals(data)) { + return War3ID.NONE; + } + String[] ids = data.split(","); + int i = localStore.game.getSeededRandom().nextInt(ids.length); + String tar = ids[i]; + if ((tar == null) || "-".equals(tar) || tar.isBlank() || "_".equals(tar)) { + return War3ID.NONE; + } + return War3ID.fromString(tar); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityDataAsIDAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" + + this.dataField.name() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityUniqueValueId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityUniqueValueId.java new file mode 100644 index 000000000..a4d3ca890 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityUniqueValueId.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityUniqueValueId extends ABIDCallback { + + private ABAbilityCallback ability; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CAbility theAbility = ability.callback(caster, localStore, castId); + War3ID theVal = theAbility.getUniqueValue(keyS, War3ID.class); + System.err.println("Get Unique ID Val: " + (theVal != null ? theVal.asStringValue() : null)); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return War3ID.NONE; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityUnitId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityUnitId.java new file mode 100644 index 000000000..2c99f7007 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAbilityUnitId.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityUnitId extends ABIDCallback { + + @SuppressWarnings("unchecked") + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + War3ID unitId = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getUnitId(); + if (unitId == null) { + return War3ID.NONE; + } + return unitId; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAlias.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAlias.java new file mode 100644 index 000000000..f46937ff4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetAlias.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAlias extends ABIDCallback { + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ALIAS", JassTextGeneratorType.Integer); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetBuffAlias.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetBuffAlias.java new file mode 100644 index 000000000..ad3f07429 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetBuffAlias.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffAlias extends ABIDCallback { + + private ABBuffCallback buff; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return buff.callback(caster, localStore, castId).getAlias(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetBuffIdFromCode.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetBuffIdFromCode.java new file mode 100644 index 000000000..d9baa8938 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetBuffIdFromCode.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetBuffIdFromCode extends ABIDCallback { + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return (localStore.get(ABLocalStoreKeys.CODE, War3ID.class)).set(0, 'B'); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ALIAS", JassTextGeneratorType.Integer); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetCode.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetCode.java new file mode 100644 index 000000000..81e4b3b4e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetCode.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetCode extends ABIDCallback { + + private ABAbilityCallback ability; + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + if (ability != null) { + return ability.callback(caster, localStore, castId).getCode(); + } + return localStore.get(ABLocalStoreKeys.CODE, War3ID.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ALIAS", JassTextGeneratorType.Integer); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetFirstBuffId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetFirstBuffId.java new file mode 100644 index 000000000..ead249e7a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetFirstBuffId.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetFirstBuffId extends ABIDCallback { + + private ABIDCallback defaultId; + + @SuppressWarnings("unchecked") + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final List buffs = ((List) localStore + .get(ABLocalStoreKeys.LEVELDATA)).get(localStore.getLevelDataInstanceLevel(castId)).getBuffs(); + if ((buffs != null) && !buffs.isEmpty()) { + return buffs.get(0); + } + if (defaultId != null) { + return defaultId.callback(caster, localStore, castId); + } + return null; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetFirstBuffIdAU(" + jassTextGenerator.getTriggerLocalStore() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetFirstEffectId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetFirstEffectId.java new file mode 100644 index 000000000..e9613d6bb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetFirstEffectId.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetFirstEffectId extends ABIDCallback { + + @SuppressWarnings("unchecked") + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + List effects = ((List) localStore.get(ABLocalStoreKeys.LEVELDATA)) + .get(localStore.getLevelDataInstanceLevel(castId)).getEffects(); + if (effects != null && !effects.isEmpty()) { + return effects.get(0); + } + return null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetItemType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetItemType.java new file mode 100644 index 000000000..4ec82d09b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetItemType.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetItemType extends ABIDCallback { + + private ABItemCallback item; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return item.callback(caster, localStore, castId).getTypeId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetNonCurrentTransformType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetNonCurrentTransformType.java new file mode 100644 index 000000000..2802d6ea5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetNonCurrentTransformType.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetNonCurrentTransformType extends ABIDCallback { + + private ABUnitCallback unit; + private ABIDCallback baseUnitId; + private ABIDCallback alternateUnitId; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit u1 = caster; + if (unit != null) { + u1 = unit.callback(caster, localStore, castId); + } + War3ID baseId = baseUnitId.callback(caster, localStore, castId); + War3ID altId = alternateUnitId.callback(caster, localStore, castId); + + if (altId == null || u1.getTypeId().equals(altId)) { + return baseId; + } else { + return altId; + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetSecondBuffId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetSecondBuffId.java new file mode 100644 index 000000000..0fbfefd21 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetSecondBuffId.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetSecondBuffId extends ABIDCallback { + + @SuppressWarnings("unchecked") + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + List buffs = ((List) localStore.get(ABLocalStoreKeys.LEVELDATA)) + .get(localStore.getLevelDataInstanceLevel(castId)).getBuffs(); + + if (buffs != null && buffs.size() > 1) { + return buffs.get(1); + } + return null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetStoredIDByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetStoredIDByKey.java new file mode 100644 index 000000000..51f260b2c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetStoredIDByKey.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredIDByKey extends ABIDCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + War3ID.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + War3ID.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetUnitType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetUnitType.java new file mode 100644 index 000000000..ce8f8b0d1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetUnitType.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitType extends ABIDCallback { + + private ABUnitCallback unit; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (unit == null) { + return caster.getTypeId(); + } + return unit.callback(caster, localStore, castId).getTypeId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetWar3IDFromString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetWar3IDFromString.java new file mode 100644 index 000000000..f5b33dc22 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackGetWar3IDFromString.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetWar3IDFromString extends ABIDCallback { + + private String id; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return War3ID.fromString(this.id); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "'" + this.id + "'"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackInlineConditionID.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackInlineConditionID.java new file mode 100644 index 000000000..ce4369a65 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackInlineConditionID.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionID extends ABIDCallback { + + private ABBooleanCallback condition; + private ABIDCallback pass; + private ABIDCallback fail; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackNullIfFalse.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackNullIfFalse.java new file mode 100644 index 000000000..3f9315980 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackNullIfFalse.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackNullIfFalse extends ABIDCallback { + + private ABBooleanCallback condition; + private ABIDCallback value; + + @Override + public War3ID callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return value.callback(caster, localStore, castId); + } + return null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackRandomItemId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackRandomItemId.java new file mode 100644 index 000000000..3a42415b2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackRandomItemId.java @@ -0,0 +1,47 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItemType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABRandomTypeHandler; + +public class ABCallbackRandomItemId extends ABIDCallback { + + private ABIDCallback previousId; + private ABIntegerCallback level; + private ABBooleanCallback ignoreValidFlag; + private ABBooleanCallback ignoreRandomFlag; + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if (previousId == null && level == null && ignoreValidFlag == null && ignoreRandomFlag == null) { + return ABRandomTypeHandler.getRandomItemType(localStore.game).getTypeId(); + } + + War3ID id = null; + int lv = -1; + boolean valid = true; + boolean random = false; + if (previousId != null) { + id = previousId.callback(caster, localStore, castId); + } + if (level != null) { + lv = level.callback(caster, localStore, castId); + } + if (ignoreValidFlag != null) { + valid = ignoreValidFlag.callback(caster, localStore, castId); + } + if (ignoreRandomFlag != null) { + random = ignoreRandomFlag.callback(caster, localStore, castId); + } + CItemType type = ABRandomTypeHandler.getRandomItemType(localStore.game, id, lv, valid, random); + if (type == null) { + return null; + } + return type.getTypeId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackRandomMechanicalCritterId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackRandomMechanicalCritterId.java new file mode 100644 index 000000000..a5fcc3510 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackRandomMechanicalCritterId.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABRandomTypeHandler; + +public class ABCallbackRandomMechanicalCritterId extends ABIDCallback { + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + CUnitType id = ABRandomTypeHandler.getRandomMechanicalCritterType(localStore.game); + if (id == null) { + return null; + } + return id.getTypeId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackReuseID.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackReuseID.java new file mode 100644 index 000000000..51d43f8f0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackReuseID.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseID extends ABIDCallback { + + private ABStringCallback name; + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABIDCallback) { + return ((ABIDCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseIDCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseIDCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackReuseIDWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackReuseIDWithArguments.java new file mode 100644 index 000000000..629d7b412 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABCallbackReuseIDWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseIDWithArguments extends ABIDCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABIDCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABIDCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseIDCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseIDCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABIDCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABIDCallback.java new file mode 100644 index 000000000..317f5c3d5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/id/ABIDCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABIDCallback implements ABCallback { + + @Override + abstract public War3ID callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackAddInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackAddInteger.java new file mode 100644 index 000000000..cab155e21 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackAddInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackAddInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) + value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackAndInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackAndInteger.java new file mode 100644 index 000000000..0b9d4ec01 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackAndInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackAndInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) & value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackArgumentInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackArgumentInteger.java new file mode 100644 index 000000000..3f55d85b0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackArgumentInteger.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentInteger extends ABIntegerCallback { + + private ABStringCallback name; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABIntegerCallback) { + return ((ABIntegerCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseIntegerCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountBuffsOnUnitMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountBuffsOnUnitMatchingCondition.java new file mode 100644 index 000000000..23982d400 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountBuffsOnUnitMatchingCondition.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackCountBuffsOnUnitMatchingCondition extends ABIntegerCallback { + + private ABUnitCallback unit; + private ABBooleanCallback condition; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit u = caster; + if (unit != null) { + u = unit.callback(caster, localStore, castId); + } + int c = 0; + for (CAbility ability : u.getAbilities()) { + if (ability.getAbilityCategory() == CAbilityCategory.BUFF) { + CBuff buff = (CBuff) ability; + localStore.put(ABLocalStoreKeys.MATCHINGBUFF, buff); + if (condition != null && condition.callback(caster, localStore, castId)) { + c++; + } + } + } + + return c; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountUnitsInRangeOfLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountUnitsInRangeOfLocation.java new file mode 100644 index 000000000..92797b75b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountUnitsInRangeOfLocation.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCountUnitsInRangeOfLocation extends ABIntegerCallback { + + private static final Rectangle recycleRect = new Rectangle(); + private ABLocationCallback location; + private ABFloatCallback range; + + private int count = 0; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget origin = location.callback(caster, localStore, castId); + Float rangeVal = range.callback(caster, localStore, castId); + + recycleRect.set(origin.getX() - rangeVal, origin.getY() - rangeVal, rangeVal * 2, rangeVal * 2); + count = 0; + + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (enumUnit.canReach(origin, rangeVal)) { + count++; + } + return false; + } + }); + return count; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountUnitsInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountUnitsInRangeOfUnit.java new file mode 100644 index 000000000..b01c28980 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackCountUnitsInRangeOfUnit.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCountUnitsInRangeOfUnit extends ABIntegerCallback { + + private static final Rectangle recycleRect = new Rectangle(); + private ABUnitCallback unit; + private ABFloatCallback range; + + private int count = 0; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit originUnitTarget = unit.callback(caster, localStore, castId); + Float rangeVal = range.callback(caster, localStore, castId); + + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + count = 0; + + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal)) { + count++; + } + return false; + } + }); + return count; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackDetectionDropdownConversion.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackDetectionDropdownConversion.java new file mode 100644 index 000000000..2d747dfc0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackDetectionDropdownConversion.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackDetectionDropdownConversion extends ABIntegerCallback { + + private ABIntegerCallback value; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + int val = value.callback(caster, localStore, castId); + switch(val) { + case 1: + return 1; + case 2: + return 2; + case 3: + return 127; + default: + + } + return 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackDivideInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackDivideInteger.java new file mode 100644 index 000000000..61d1f5ae6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackDivideInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackDivideInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) / value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityCastTimeAsInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityCastTimeAsInteger.java new file mode 100644 index 000000000..fb89865d3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityCastTimeAsInteger.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityCastTimeAsInteger extends ABIntegerCallback { + + @SuppressWarnings("unchecked") + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderAbility ability = localStore.originAbility; + if (ability != null) { + return (int) ability.getCastTime(); + } else { + List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + return (int) levelData.get(localStore.getLevelDataInstanceLevel(castId)).getCastTime(); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityDataAsInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityDataAsInteger.java new file mode 100644 index 000000000..4e751be1d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityDataAsInteger.java @@ -0,0 +1,36 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsInteger extends ABIntegerCallback { + + private ABDataFieldLetter dataField; + + @SuppressWarnings("unchecked") + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + final String data = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData() + .get(this.dataField.getIndex()); + if ("-".equals(data)) { + return 0; + } + return Integer.parseInt(data); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityDataAsIntegerAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" + + this.dataField.name() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityHandleAsInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityHandleAsInteger.java new file mode 100644 index 000000000..706f8de3d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityHandleAsInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityHandleAsInteger extends ABIntegerCallback { + + private ABAbilityCallback ability; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return ability.callback(caster, localStore, castId).getHandleId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityManaCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityManaCost.java new file mode 100644 index 000000000..0b577dece --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityManaCost.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityManaCost extends ABIntegerCallback { + + private ABAbilityCallback ability; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (ability == null) { + ABAbilityBuilderActiveAbility abil = (ABAbilityBuilderActiveAbility) localStore.originAbility; + return abil.getChargedManaCost(); + } else { + CAbility abil = ability.callback(caster, localStore, castId); + if (abil instanceof ABAbilityBuilderActiveAbility) { + return ((ABAbilityBuilderActiveAbility) abil).getChargedManaCost(); + } else { + return 0; + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityTargetAttachmentPoints.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityTargetAttachmentPoints.java new file mode 100644 index 000000000..649c94bfc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityTargetAttachmentPoints.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityTargetAttachmentPoints extends ABIntegerCallback { + + private ABAbilityCallback ability; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (ability == null) { + ABAbilityBuilderAbility abil = localStore.originAbility; + return abil.getAbilityIntField("Targetattachcount"); + } else { + CAbility abil = ability.callback(caster, localStore, castId); + if (abil instanceof ABAbilityBuilderAbility) { + return ((ABAbilityBuilderAbility) abil).getAbilityIntField("Targetattachcount"); + } else { + return 0; + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityUniqueValueInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityUniqueValueInteger.java new file mode 100644 index 000000000..574a3cb58 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetAbilityUniqueValueInteger.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityUniqueValueInteger extends ABIntegerCallback { + + private ABAbilityCallback ability; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CAbility theAbility = ability.callback(caster, localStore, castId); + Integer theVal = theAbility.getUniqueValue(keyS, Integer.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetBuffHandleAsInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetBuffHandleAsInteger.java new file mode 100644 index 000000000..8cec81c71 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetBuffHandleAsInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffHandleAsInteger extends ABIntegerCallback { + + private ABBuffCallback buff; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return buff.callback(caster, localStore, castId).getHandleId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetBuffUniqueValueInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetBuffUniqueValueInteger.java new file mode 100644 index 000000000..1f2735c46 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetBuffUniqueValueInteger.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffUniqueValueInteger extends ABIntegerCallback { + + private ABBuffCallback buff; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CBuff theBuff = buff.callback(caster, localStore, castId); + Integer theVal = theBuff.getUniqueValue(keyS, Integer.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetCastId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetCastId.java new file mode 100644 index 000000000..750755229 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetCastId.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetCastId extends ABIntegerCallback { + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return castId; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetIntegerFromList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetIntegerFromList.java new file mode 100644 index 000000000..09a2fe361 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetIntegerFromList.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABSortableListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetIntegerFromList extends ABIntegerCallback { + + private ABSortableListCallback list; + private ABIntegerCallback index; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return list.callback(caster, localStore, castId).get(index.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemCharges.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemCharges.java new file mode 100644 index 000000000..056f3c147 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemCharges.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetItemCharges extends ABIntegerCallback { + + private ABItemCallback item; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer slot = localStore.get(ABLocalStoreKeys.ITEMSLOT, Integer.class); + if (slot != null) { + return slot; + } + + CItem theItem; + if (item != null) { + theItem = item.callback(caster, localStore, castId); + } else { + theItem = localStore.originItem; + } + + if (theItem == null) { + return null; + } + return theItem.getCharges(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemLevel.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemLevel.java new file mode 100644 index 000000000..e71cb48a5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemLevel.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetItemLevel extends ABIntegerCallback { + + private ABItemCallback item; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer slot = localStore.get(ABLocalStoreKeys.ITEMSLOT, Integer.class); + if (slot != null) { + return slot; + } + + CItem theItem; + if (item != null) { + theItem = item.callback(caster, localStore, castId); + } else { + theItem = localStore.originItem; + } + + if (theItem == null) { + return null; + } + return theItem.getItemType().getLevel(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemMaxCharges.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemMaxCharges.java new file mode 100644 index 000000000..caa6364d4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemMaxCharges.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetItemMaxCharges extends ABIntegerCallback { + + private ABItemCallback item; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer slot = localStore.get(ABLocalStoreKeys.ITEMSLOT, Integer.class); + if (slot != null) { + return slot; + } + + CItem theItem; + if (item != null) { + theItem = item.callback(caster, localStore, castId); + } else { + theItem = localStore.originItem; + } + + if (theItem == null) { + return null; + } + return theItem.getItemType().getNumberOfCharges(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemSlot.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemSlot.java new file mode 100644 index 000000000..66bf908f3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetItemSlot.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetItemSlot extends ABIntegerCallback { + + private ABItemCallback item; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer slot = localStore.get(ABLocalStoreKeys.ITEMSLOT, Integer.class); + if (slot != null) { + return slot; + } + + CItem theItem; + if (item != null) { + theItem = item.callback(caster, localStore, castId); + } else { + theItem = localStore.originItem; + } + + if (theItem == null || theItem.getContainedInventory() == null) { + return null; + } + return theItem.getContainedInventory().getSlot(theItem); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetListSize.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetListSize.java new file mode 100644 index 000000000..a002547ca --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetListSize.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetListSize extends ABIntegerCallback { + + private ABListCallback list; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return list.callback(caster, localStore, castId).size(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetNeutralHostilePlayerId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetNeutralHostilePlayerId.java new file mode 100644 index 000000000..8f65b810b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetNeutralHostilePlayerId.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetNeutralHostilePlayerId extends ABIntegerCallback { + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return WarsmashConstants.MAX_PLAYERS - 4; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetNeutralPassivePlayerId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetNeutralPassivePlayerId.java new file mode 100644 index 000000000..dc859659d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetNeutralPassivePlayerId.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetNeutralPassivePlayerId extends ABIntegerCallback { + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return WarsmashConstants.MAX_PLAYERS - 1; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetPlayerId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetPlayerId.java new file mode 100644 index 000000000..b4ec3f1f7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetPlayerId.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetPlayerId extends ABIntegerCallback { + + private ABPlayerCallback player; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return player.callback(caster, localStore, castId).getId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetProjectileDestructableTargets.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetProjectileDestructableTargets.java new file mode 100644 index 000000000..085463914 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetProjectileDestructableTargets.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetProjectileDestructableTargets extends ABIntegerCallback { + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEDESTTARGETS, castId), Integer.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetProjectileUnitTargets.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetProjectileUnitTargets.java new file mode 100644 index 000000000..246d32c0b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetProjectileUnitTargets.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetProjectileUnitTargets extends ABIntegerCallback { + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEUNITTARGETS, castId), Integer.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_PROJECTILEUNITTARGETS + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.Integer); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetSortableListSize.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetSortableListSize.java new file mode 100644 index 000000000..d90e5e6a9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetSortableListSize.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABSortableListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetSortableListSize extends ABIntegerCallback { + + private ABSortableListCallback list; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return list.callback(caster, localStore, castId).size(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetSpellLevel.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetSpellLevel.java new file mode 100644 index 000000000..822039f13 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetSpellLevel.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetSpellLevel extends ABIntegerCallback { + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return castId != ABConstants.NO_CAST_ID + ? localStore.getIntOrDefault(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId), + localStore.originAbility.getLevel()) + : localStore.originAbility.getLevel(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetStoredIntegerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetStoredIntegerByKey.java new file mode 100644 index 000000000..3e3985faf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetStoredIntegerByKey.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredIntegerByKey extends ABIntegerCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + Integer.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + Integer.class); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.instanceValue == null) { + return "GetLocalStoreUserCastIntegerAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; + } + return "GetStoredIntegerAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitGroupSize.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitGroupSize.java new file mode 100644 index 000000000..41de36b5d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitGroupSize.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup.ABUnitGroupCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitGroupSize extends ABIntegerCallback { + + private ABUnitGroupCallback group; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return group.callback(caster, localStore, castId).size(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitHandleAsInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitHandleAsInteger.java new file mode 100644 index 000000000..9415f274b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitHandleAsInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitHandleAsInteger extends ABIntegerCallback { + + private ABUnitCallback unit; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit.callback(caster, localStore, castId).getHandleId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitMaximumHp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitMaximumHp.java new file mode 100644 index 000000000..79d95f527 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitMaximumHp.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitMaximumHp extends ABIntegerCallback { + + private ABUnitCallback unit; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit == null ? caster.getMaximumLife() + : this.unit.callback(caster, localStore, castId).getMaximumLife(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitMaximumMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitMaximumMp.java new file mode 100644 index 000000000..fca645ecc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitMaximumMp.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitMaximumMp extends ABIntegerCallback { + + private ABUnitCallback unit; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit == null ? caster.getMaximumMana() + : unit.callback(caster, localStore, castId).getMaximumMana(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitQueueSize.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitQueueSize.java new file mode 100644 index 000000000..fe13dff96 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitQueueSize.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue.ABUnitQueueCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitQueueSize extends ABIntegerCallback { + + private ABUnitQueueCallback queue; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return queue.callback(caster, localStore, castId).size(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeFoodCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeFoodCost.java new file mode 100644 index 000000000..eb6a28b23 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeFoodCost.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitTypeFoodCost extends ABIntegerCallback { + + private ABIDCallback id; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getUnitData().getUnitType(id.callback(caster, localStore, castId)).getFoodUsed(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeGoldCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeGoldCost.java new file mode 100644 index 000000000..fcd890e7f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeGoldCost.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitTypeGoldCost extends ABIntegerCallback { + + private ABIDCallback id; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getUnitData().getUnitType(id.callback(caster, localStore, castId)).getGoldCost(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeLumberCost.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeLumberCost.java new file mode 100644 index 000000000..f68cfdc8c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeLumberCost.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitTypeLumberCost extends ABIntegerCallback { + + private ABIDCallback id; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getUnitData().getUnitType(id.callback(caster, localStore, castId)).getLumberCost(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeSpeed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeSpeed.java new file mode 100644 index 000000000..e2f326ed0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackGetUnitTypeSpeed.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitTypeSpeed extends ABIntegerCallback { + + private ABIDCallback id; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getUnitData().getUnitType(id.callback(caster, localStore, castId)).getSpeed(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackInlineConditionInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackInlineConditionInteger.java new file mode 100644 index 000000000..eb0e4ba4b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackInlineConditionInteger.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionInteger extends ABIntegerCallback { + + private ABBooleanCallback condition; + private ABIntegerCallback pass; + private ABIntegerCallback fail; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerIf.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerIf.java new file mode 100644 index 000000000..dafabd180 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerIf.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIntegerIf extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + private ABBooleanCallback condition; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (condition == null || !condition.callback(caster, localStore, castId)) { + return value2.callback(caster, localStore, castId); + } + return value1.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerZeroIfFalse.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerZeroIfFalse.java new file mode 100644 index 000000000..42a7da281 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerZeroIfFalse.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIntegerZeroIfFalse extends ABIntegerCallback { + + private ABIntegerCallback value; + private ABBooleanCallback bool; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (bool == null || !bool.callback(caster, localStore, castId)) { + return 0; + } + return value.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerZeroIfNull.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerZeroIfNull.java new file mode 100644 index 000000000..994f5ae11 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIntegerZeroIfNull.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIntegerZeroIfNull extends ABIntegerCallback { + + private ABIntegerCallback value; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v = value.callback(caster, localStore, castId); + return v == null ? 0 : v; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIterator.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIterator.java new file mode 100644 index 000000000..643ec90c4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackIterator.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackIterator extends ABIntegerCallback { + + private ABCallback unique; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (this.unique != null) { + return localStore.get(ABLocalStoreKeys.combineKey( + ABLocalStoreKeys.ITERATORCOUNT + "$" + this.unique.callback(caster, localStore, castId), castId), + Integer.class); + } else { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ITERATORCOUNT, castId), Integer.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMaxInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMaxInteger.java new file mode 100644 index 000000000..d8badfeca --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMaxInteger.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMaxInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return Math.max(value1.callback(caster, localStore, castId), + value2.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMinInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMinInteger.java new file mode 100644 index 000000000..e566fea23 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMinInteger.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMinInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return Math.min(value1.callback(caster, localStore, castId), + value2.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMultiplyInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMultiplyInteger.java new file mode 100644 index 000000000..69ba92b49 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackMultiplyInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMultiplyInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) * value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackOrInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackOrInteger.java new file mode 100644 index 000000000..4232f090a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackOrInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackOrInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) | value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackPlayerToStateModValue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackPlayerToStateModValue.java new file mode 100644 index 000000000..01edff988 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackPlayerToStateModValue.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackPlayerToStateModValue extends ABIntegerCallback { + + private ABPlayerCallback player; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return 1 << player.callback(caster, localStore, castId).getId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackRandomInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackRandomInteger.java new file mode 100644 index 000000000..05c79cbe6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackRandomInteger.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRandomInteger extends ABIntegerCallback { + + private ABIntegerCallback lowerBound; + private ABIntegerCallback upperBound; + + private ABIntegerCallback bound; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (bound != null) { + return localStore.game.getSeededRandom().nextInt(bound.callback(caster, localStore, castId)); + } + int low = Integer.MIN_VALUE; + int high = Integer.MAX_VALUE; + if (upperBound != null) { + low = 0; + high = upperBound.callback(caster, localStore, castId); + } + if (lowerBound != null) { + low = lowerBound.callback(caster, localStore, castId); + } + return localStore.game.getSeededRandom().nextInt(low, high); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackRawInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackRawInteger.java new file mode 100644 index 000000000..856690441 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackRawInteger.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRawInteger extends ABIntegerCallback { + + private Integer value; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return this.value; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return this.value.toString(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackReuseInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackReuseInteger.java new file mode 100644 index 000000000..d76136c33 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackReuseInteger.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseInteger extends ABIntegerCallback { + + private ABStringCallback name; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABIntegerCallback) { + return ((ABIntegerCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseIntegerCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseIntegerCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackReuseIntegerWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackReuseIntegerWithArguments.java new file mode 100644 index 000000000..2d325156f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackReuseIntegerWithArguments.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseIntegerWithArguments extends ABIntegerCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABIntegerCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABIntegerCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseIntegerCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseIntegerCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackSubtractInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackSubtractInteger.java new file mode 100644 index 000000000..8f7f19426 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackSubtractInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackSubtractInteger extends ABIntegerCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) - value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackTruncateFloatToInteger.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackTruncateFloatToInteger.java new file mode 100644 index 000000000..7ea46e84f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABCallbackTruncateFloatToInteger.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackTruncateFloatToInteger extends ABIntegerCallback { + + private ABFloatCallback value; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value.callback(caster, localStore, castId).intValue(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABIntegerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABIntegerCallback.java new file mode 100644 index 000000000..9e1178c17 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/integers/ABIntegerCallback.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABIntegerCallback implements ABCallback { + + abstract public Integer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackArgumentItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackArgumentItem.java new file mode 100644 index 000000000..8613e5c95 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackArgumentItem.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentItem extends ABItemCallback { + + private ABStringCallback name; + + @Override + public CItem callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABItemCallback) { + return ((ABItemCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseItemCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetAbilityTargetedItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetAbilityTargetedItem.java new file mode 100644 index 000000000..94253df90 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetAbilityTargetedItem.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAbilityTargetedItem extends ABItemCallback { + + @Override + public CItem callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDITEM, castId), CItem.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetAttackedItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetAttackedItem.java new file mode 100644 index 000000000..72a8fc69f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetAttackedItem.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAttackedItem extends ABItemCallback { + + @Override + public CItem callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityTarget tar = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, castId), + AbilityTarget.class); + return tar.visit(AbilityTargetVisitor.ITEM); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetLastCreatedItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetLastCreatedItem.java new file mode 100644 index 000000000..4fc0778e8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetLastCreatedItem.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedItem extends ABItemCallback { + + @Override + public CItem callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDITEM, CItem.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetStoredItemByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetStoredItemByKey.java new file mode 100644 index 000000000..96ae791f9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackGetStoredItemByKey.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredItemByKey extends ABItemCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CItem callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CItem.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CItem.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackInlineConditionItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackInlineConditionItem.java new file mode 100644 index 000000000..6d8f0a708 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackInlineConditionItem.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionItem extends ABItemCallback { + + private ABBooleanCallback condition; + private ABItemCallback pass; + private ABItemCallback fail; + + @Override + public CItem callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackReuseItem.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackReuseItem.java new file mode 100644 index 000000000..7f92e1e6f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackReuseItem.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseItem extends ABItemCallback { + + private ABStringCallback name; + + @Override + public CItem callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABItemCallback) { + return ((ABItemCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseItemCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseItemCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackReuseItemWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackReuseItemWithArguments.java new file mode 100644 index 000000000..f4637601a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABCallbackReuseItemWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseItemWithArguments extends ABItemCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CItem callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABItemCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABItemCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseItemCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseItemCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABItemCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABItemCallback.java new file mode 100644 index 000000000..439b2032e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/item/ABItemCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABItemCallback implements ABCallback { + + abstract public CItem callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackArgumentList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackArgumentList.java new file mode 100644 index 000000000..5f20b97d3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackArgumentList.java @@ -0,0 +1,36 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentList extends ABListCallback { + + private ABStringCallback name; + + @SuppressWarnings("unchecked") + @Override + public List callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABListCallback) { + return ((ABListCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ArgumentLocationCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackArgumentSortableList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackArgumentSortableList.java new file mode 100644 index 000000000..392337f8a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackArgumentSortableList.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentSortableList> extends ABSortableListCallback { + + private ABStringCallback name; + + @SuppressWarnings("unchecked") + @Override + public List callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABListCallback) { + return ((ABListCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ArgumentLocationCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackGetStoredListByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackGetStoredListByKey.java new file mode 100644 index 000000000..2c5016274 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackGetStoredListByKey.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredListByKey extends ABListCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @SuppressWarnings("unchecked") + @Override + public List callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return (List) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId)); + } else { + return (List) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackGetStoredSortableListByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackGetStoredSortableListByKey.java new file mode 100644 index 000000000..05266c734 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackGetStoredSortableListByKey.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredSortableListByKey> extends ABSortableListCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @SuppressWarnings("unchecked") + @Override + public List callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return (List) localStore.get(ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId)); + } else { + return (List) localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackInlineConditionList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackInlineConditionList.java new file mode 100644 index 000000000..1f0df3ff4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackInlineConditionList.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionList extends ABListCallback { + + private ABBooleanCallback condition; + private ABListCallback pass; + private ABListCallback fail; + + @Override + public List callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackInlineConditionSortableList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackInlineConditionSortableList.java new file mode 100644 index 000000000..368092828 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackInlineConditionSortableList.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionSortableList> extends ABSortableListCallback { + + private ABBooleanCallback condition; + private ABListCallback pass; + private ABListCallback fail; + + @Override + public List callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackListSorted.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackListSorted.java new file mode 100644 index 000000000..42c91abcb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackListSorted.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.Collections; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackListSorted> extends ABSortableListCallback { + + private ABSortableListCallback list; + private ABListSortType sort; + + @Override + public List callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + List theList = list.callback(caster, localStore, castId); + switch(sort){ + case DSC: + theList.sort(Collections.reverseOrder()); + break; + case RAND: + Collections.shuffle(theList, localStore.game.getSeededRandom()); + break; + default: + case ASC: + Collections.sort(theList); + break; + } + return theList; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseList.java new file mode 100644 index 000000000..34d974d14 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseList.java @@ -0,0 +1,41 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseList extends ABListCallback { + + private ABStringCallback name; + + @SuppressWarnings("unchecked") + @Override + public List callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABListCallback) { + return ((ABListCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseLocationCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseLocationCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseListWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseListWithArguments.java new file mode 100644 index 000000000..2893d8db1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseListWithArguments.java @@ -0,0 +1,50 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseListWithArguments extends ABListCallback { + + private ABStringCallback name; + private Map arguments; + + @SuppressWarnings("unchecked") + @Override + public List callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABListCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABListCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseLocationCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseLocationCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseSortableList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseSortableList.java new file mode 100644 index 000000000..e174abdb2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseSortableList.java @@ -0,0 +1,42 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseSortableList> extends ABSortableListCallback { + + private ABStringCallback name; + + @SuppressWarnings("unchecked") + @Override + public List callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABListCallback) { + return ((ABListCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseLocationCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseLocationCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseSortableListWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseSortableListWithArguments.java new file mode 100644 index 000000000..3b1621693 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABCallbackReuseSortableListWithArguments.java @@ -0,0 +1,51 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseSortableListWithArguments> + extends ABSortableListCallback { + + private ABStringCallback name; + private Map arguments; + + @SuppressWarnings("unchecked") + @Override + public List callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABListCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABListCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseLocationCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseLocationCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABListCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABListCallback.java new file mode 100644 index 000000000..9f7bad66a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABListCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABListCallback implements ABCallback { + + abstract public List callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABListSortType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABListSortType.java new file mode 100644 index 000000000..632461348 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABListSortType.java @@ -0,0 +1,7 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +public enum ABListSortType { + ASC, + DSC, + RAND; +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABSortableListCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABSortableListCallback.java new file mode 100644 index 000000000..59ee7d3b1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/ABSortableListCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABSortableListCallback> implements ABCallback { + + abstract public List callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABCallbackEmptyIntegerList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABCallbackEmptyIntegerList.java new file mode 100644 index 000000000..28ae5745f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABCallbackEmptyIntegerList.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.integer; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackEmptyIntegerList extends ABIntegerListCallback { + + @Override + public List callback(CUnit caster, ABLocalDataStore localStore, int castId) { + return new ArrayList<>(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABCallbackIntegerListOfRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABCallbackIntegerListOfRange.java new file mode 100644 index 000000000..6c277e91c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABCallbackIntegerListOfRange.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.integer; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIntegerListOfRange extends ABIntegerListCallback { + + private ABIntegerCallback start; + private ABIntegerCallback end; + + private ABBooleanCallback inclusiveEnd; + + @Override + public List callback(CUnit caster, ABLocalDataStore localStore, int castId) { + int theStart = 0; + if (start != null) { + theStart = start.callback(caster, localStore, castId); + } + if (inclusiveEnd != null && inclusiveEnd.callback(caster, localStore, castId)) { + return IntStream.rangeClosed(theStart, end.callback(caster, localStore, castId)).boxed() + .collect(Collectors.toList()); + } + return IntStream.range(theStart, end.callback(caster, localStore, castId)).boxed() + .collect(Collectors.toList()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABIntegerListCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABIntegerListCallback.java new file mode 100644 index 000000000..2e906056d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/integer/ABIntegerListCallback.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.integer; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABSortableListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABIntegerListCallback extends ABSortableListCallback { + + abstract public List callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/location/ABCallbackEmptyLocationList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/location/ABCallbackEmptyLocationList.java new file mode 100644 index 000000000..c3fd93cf2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/location/ABCallbackEmptyLocationList.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.location; + +import java.util.ArrayList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackEmptyLocationList extends ABLocationListCallback { + + @Override + public List callback(CUnit caster, ABLocalDataStore localStore, int castId) { + return new ArrayList<>(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/location/ABLocationListCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/location/ABLocationListCallback.java new file mode 100644 index 000000000..44f0175de --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/list/location/ABLocationListCallback.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.location; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABLocationListCallback extends ABListCallback { + + abstract public List callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAbilityEffectReactionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAbilityEffectReactionListenerCallback.java new file mode 100644 index 000000000..ab7612ab9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAbilityEffectReactionListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityEffectReactionListener; + +public abstract class ABAbilityEffectReactionListenerCallback implements ABCallback { + + abstract public ABAbilityEffectReactionListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAbilityProjReactionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAbilityProjReactionListenerCallback.java new file mode 100644 index 000000000..f25ab1f70 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAbilityProjReactionListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityProjReactionListener; + +public abstract class ABAbilityProjReactionListenerCallback implements ABCallback { + + abstract public ABAbilityProjReactionListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackPostDamageListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackPostDamageListenerCallback.java new file mode 100644 index 000000000..d6caea0ef --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackPostDamageListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPostDamageListener; + +public abstract class ABAttackPostDamageListenerCallback implements ABCallback { + + abstract public ABAttackPostDamageListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackPreDamageListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackPreDamageListenerCallback.java new file mode 100644 index 000000000..64716eb9c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackPreDamageListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPreDamageListener; + +public abstract class ABAttackPreDamageListenerCallback implements ABCallback { + + abstract public ABAttackPreDamageListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackProjReactionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackProjReactionListenerCallback.java new file mode 100644 index 000000000..99f4e45c4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABAttackProjReactionListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackProjReactionListener; + +public abstract class ABAttackProjReactionListenerCallback implements ABCallback { + + abstract public ABAttackProjReactionListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABBehaviorChangeListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABBehaviorChangeListenerCallback.java new file mode 100644 index 000000000..02f8399f0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABBehaviorChangeListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABBehaviorChangeListener; + +public abstract class ABBehaviorChangeListenerCallback implements ABCallback { + + abstract public ABBehaviorChangeListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAbilityEffectReactionListener.java new file mode 100644 index 000000000..dcd4de01c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAbilityEffectReactionListener.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityEffectReactionListener; + +public class ABCallbackGetLastCreatedAbilityEffectReactionListener extends ABAbilityEffectReactionListenerCallback { + + @Override + public ABAbilityEffectReactionListener callback(CUnit caster, ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDAbERL, ABAbilityEffectReactionListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAbilityProjReactionListener.java new file mode 100644 index 000000000..6dc9a54ad --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAbilityProjReactionListener.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityProjReactionListener; + +public class ABCallbackGetLastCreatedAbilityProjReactionListener extends ABAbilityProjReactionListenerCallback { + + @Override + public ABAbilityProjReactionListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDAbPRL, ABAbilityProjReactionListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackPostDamageListener.java new file mode 100644 index 000000000..9852d283c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackPostDamageListener.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPostDamageListener; + +public class ABCallbackGetLastCreatedAttackPostDamageListener extends ABAttackPostDamageListenerCallback { + + @Override + public ABAttackPostDamageListener callback(CUnit caster, ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDAPoDL, ABAttackPostDamageListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackPreDamageListener.java new file mode 100644 index 000000000..6977fb2f4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackPreDamageListener.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPreDamageListener; + +public class ABCallbackGetLastCreatedAttackPreDamageListener extends ABAttackPreDamageListenerCallback { + + @Override + public ABAttackPreDamageListener callback(CUnit caster, ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDAPrDL, ABAttackPreDamageListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackProjReactionListener.java new file mode 100644 index 000000000..59c9f6283 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedAttackProjReactionListener.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackProjReactionListener; + +public class ABCallbackGetLastCreatedAttackProjReactionListener extends ABAttackProjReactionListenerCallback { + + @Override + public ABAttackProjReactionListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDAtkPRL, ABAttackProjReactionListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedBehaviorChangeListener.java new file mode 100644 index 000000000..ab6d9e28b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedBehaviorChangeListener.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABBehaviorChangeListener; + +public class ABCallbackGetLastCreatedBehaviorChangeListener extends ABBehaviorChangeListenerCallback { + + @Override + public ABBehaviorChangeListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDBCL, ABBehaviorChangeListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDamageTakenListener.java new file mode 100644 index 000000000..0f45e88cb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDamageTakenListener.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenListener; + +public class ABCallbackGetLastCreatedDamageTakenListener extends ABDamageTakenListenerCallback { + + @Override + public ABDamageTakenListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDDTL, ABDamageTakenListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDamageTakenModificationListener.java new file mode 100644 index 000000000..46a1957f6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDamageTakenModificationListener.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenModificationListener; + +public class ABCallbackGetLastCreatedDamageTakenModificationListener extends ABDamageTakenModificationListenerCallback { + + @Override + public ABDamageTakenModificationListener callback(CUnit caster, ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDDTML, ABDamageTakenModificationListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDeathReplacement.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDeathReplacement.java new file mode 100644 index 000000000..af6f41c96 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedDeathReplacement.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDeathReplacementEffect; + +public class ABCallbackGetLastCreatedDeathReplacement extends ABDeathReplacementCallback { + + @Override + public ABDeathReplacementEffect callback(CUnit caster, ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDDRE, ABDeathReplacementEffect.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedEvasionListener.java new file mode 100644 index 000000000..cafc473e6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedEvasionListener.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackEvasionListener; + +public class ABCallbackGetLastCreatedEvasionListener extends ABEvasionListenerCallback { + + @Override + public ABAttackEvasionListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDAEL, ABAttackEvasionListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedUnitStateListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedUnitStateListener.java new file mode 100644 index 000000000..5f3bc06b1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetLastCreatedUnitStateListener.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABUnitStateListener; + +public class ABCallbackGetLastCreatedUnitStateListener extends ABUnitStateListenerCallback { + + @Override + public ABUnitStateListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDUSL, ABUnitStateListener.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAbilityEffectReactionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAbilityEffectReactionListenerByKey.java new file mode 100644 index 000000000..b9fc6ca85 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAbilityEffectReactionListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityEffectReactionListener; + +public class ABCallbackGetStoredAbilityEffectReactionListenerByKey extends ABAbilityEffectReactionListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABAbilityEffectReactionListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABAbilityEffectReactionListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABAbilityEffectReactionListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAbilityProjReactionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAbilityProjReactionListenerByKey.java new file mode 100644 index 000000000..f7fa3c066 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAbilityProjReactionListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAbilityProjReactionListener; + +public class ABCallbackGetStoredAbilityProjReactionListenerByKey extends ABAbilityProjReactionListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABAbilityProjReactionListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABAbilityProjReactionListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABAbilityProjReactionListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackPostDamageListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackPostDamageListenerByKey.java new file mode 100644 index 000000000..9369cca6a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackPostDamageListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPostDamageListener; + +public class ABCallbackGetStoredAttackPostDamageListenerByKey extends ABAttackPostDamageListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABAttackPostDamageListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABAttackPostDamageListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABAttackPostDamageListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackPreDamageListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackPreDamageListenerByKey.java new file mode 100644 index 000000000..26d0ebbe9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackPreDamageListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackPreDamageListener; + +public class ABCallbackGetStoredAttackPreDamageListenerByKey extends ABAttackPreDamageListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABAttackPreDamageListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABAttackPreDamageListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABAttackPreDamageListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackProjReactionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackProjReactionListenerByKey.java new file mode 100644 index 000000000..9cd782ce0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredAttackProjReactionListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackProjReactionListener; + +public class ABCallbackGetStoredAttackProjReactionListenerByKey extends ABAttackProjReactionListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABAttackProjReactionListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABAttackProjReactionListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABAttackProjReactionListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredBehaviorChangeListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredBehaviorChangeListenerByKey.java new file mode 100644 index 000000000..8bdbab7c5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredBehaviorChangeListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABBehaviorChangeListener; + +public class ABCallbackGetStoredBehaviorChangeListenerByKey extends ABBehaviorChangeListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABBehaviorChangeListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABBehaviorChangeListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABBehaviorChangeListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDamageTakenListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDamageTakenListenerByKey.java new file mode 100644 index 000000000..c55ed2d63 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDamageTakenListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenListener; + +public class ABCallbackGetStoredDamageTakenListenerByKey extends ABDamageTakenListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABDamageTakenListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABDamageTakenListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABDamageTakenListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDamageTakenModificationListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDamageTakenModificationListenerByKey.java new file mode 100644 index 000000000..d19d1f5b5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDamageTakenModificationListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenModificationListener; + +public class ABCallbackGetStoredDamageTakenModificationListenerByKey extends ABDamageTakenModificationListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABDamageTakenModificationListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABDamageTakenModificationListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABDamageTakenModificationListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDeathReplacementByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDeathReplacementByKey.java new file mode 100644 index 000000000..a6f403841 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredDeathReplacementByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDeathReplacementEffect; + +public class ABCallbackGetStoredDeathReplacementByKey extends ABDeathReplacementCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABDeathReplacementEffect callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABDeathReplacementEffect.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABDeathReplacementEffect.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredEvasionListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredEvasionListenerByKey.java new file mode 100644 index 000000000..f7b3634d1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredEvasionListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackEvasionListener; + +public class ABCallbackGetStoredEvasionListenerByKey extends ABEvasionListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABAttackEvasionListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABAttackEvasionListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABAttackEvasionListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredUnitStateListenerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredUnitStateListenerByKey.java new file mode 100644 index 000000000..dcd86bb95 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABCallbackGetStoredUnitStateListenerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABUnitStateListener; + +public class ABCallbackGetStoredUnitStateListenerByKey extends ABUnitStateListenerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public ABUnitStateListener callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + ABUnitStateListener.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + ABUnitStateListener.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDamageTakenListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDamageTakenListenerCallback.java new file mode 100644 index 000000000..17a34666f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDamageTakenListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenListener; + +public abstract class ABDamageTakenListenerCallback implements ABCallback { + + abstract public ABDamageTakenListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDamageTakenModificationListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDamageTakenModificationListenerCallback.java new file mode 100644 index 000000000..1393449ce --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDamageTakenModificationListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDamageTakenModificationListener; + +public abstract class ABDamageTakenModificationListenerCallback implements ABCallback { + + abstract public ABDamageTakenModificationListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDeathReplacementCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDeathReplacementCallback.java new file mode 100644 index 000000000..9980c7c7a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABDeathReplacementCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABDeathReplacementEffect; + +public abstract class ABDeathReplacementCallback implements ABCallback { + + abstract public ABDeathReplacementEffect callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABEvasionListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABEvasionListenerCallback.java new file mode 100644 index 000000000..b1895d0cd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABEvasionListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABAttackEvasionListener; + +public abstract class ABEvasionListenerCallback implements ABCallback { + + abstract public ABAttackEvasionListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABUnitStateListenerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABUnitStateListenerCallback.java new file mode 100644 index 000000000..0967d18f3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/listener/ABUnitStateListenerCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener.ABUnitStateListener; + +public abstract class ABUnitStateListenerCallback implements ABCallback { + + abstract public ABUnitStateListener callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackArgumentLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackArgumentLocation.java new file mode 100644 index 000000000..3b85e5eea --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackArgumentLocation.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentLocation extends ABLocationCallback { + + private ABStringCallback name; + + @Override + public AbilityPointTarget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABLocationCallback) { + return ((ABLocationCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ArgumentLocationCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromOffset.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromOffset.java new file mode 100644 index 000000000..05716367c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromOffset.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCreateLocationFromOffset extends ABLocationCallback { + + private ABLocationCallback origin; + private ABFloatCallback dist; + private ABFloatCallback angle; + + private ABBooleanCallback angleInDegrees; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget orig = this.origin.callback(caster, localStore, castId); + final float d = this.dist.callback(caster, localStore, castId); + final float a = this.angle.callback(caster, localStore, castId); + + if (angleInDegrees != null && angleInDegrees.callback(caster, localStore, castId)) { + return new AbilityPointTarget((float) (orig.x + (d * Math.cos(Math.toRadians(a)))), (float) (orig.y + (d * Math.sin(Math.toRadians(a))))); + } + return new AbilityPointTarget((float) (orig.x + (d * Math.cos(a))), (float) (orig.y + (d * Math.sin(a)))); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "PolarProjectionAU(" + this.origin.generateJassEquivalent(jassTextGenerator) + ", " + + this.dist.generateJassEquivalent(jassTextGenerator) + ", " + + this.angle.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromTarget.java new file mode 100644 index 000000000..b937c2e6b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromTarget.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target.ABTargetCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCreateLocationFromTarget extends ABLocationCallback { + + private ABTargetCallback target; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityTarget tar = target.callback(caster, localStore, castId); + return new AbilityPointTarget(tar.getX(), tar.getY()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromXY.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromXY.java new file mode 100644 index 000000000..9e6e65dab --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromXY.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCreateLocationFromXY extends ABLocationCallback { + + private ABFloatCallback x; + private ABFloatCallback y; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return new AbilityPointTarget(x.callback(caster, localStore, castId), y.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromXYOffset.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromXYOffset.java new file mode 100644 index 000000000..829f72cad --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackCreateLocationFromXYOffset.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCreateLocationFromXYOffset extends ABLocationCallback { + + private ABLocationCallback origin; + private ABFloatCallback xdist; + private ABFloatCallback ydist; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget orig = this.origin.callback(caster, localStore, castId); + return new AbilityPointTarget((float) (orig.x + xdist.callback(caster, localStore, castId)), + (float) (orig.y + ydist.callback(caster, localStore, castId))); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetAttackImpactLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetAttackImpactLocation.java new file mode 100644 index 000000000..481cf205f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetAttackImpactLocation.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAttackImpactLocation extends ABLocationCallback { + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKIMPACTLOCATION, castId), + AbilityPointTarget.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetAttackTargetLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetAttackTargetLocation.java new file mode 100644 index 000000000..f15b98d1b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetAttackTargetLocation.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAttackTargetLocation extends ABLocationCallback { + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityTarget tar = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, castId), + AbilityTarget.class); + if (tar.visit(AbilityTargetVisitor.POINT) != null) { + return tar.visit(AbilityTargetVisitor.POINT); + } + return new AbilityPointTarget(tar.getX(), tar.getY()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetGroundAttackedLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetGroundAttackedLocation.java new file mode 100644 index 000000000..2034edba9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetGroundAttackedLocation.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetGroundAttackedLocation extends ABLocationCallback { + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityTarget tar = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, castId), + AbilityTarget.class); + return tar.visit(AbilityTargetVisitor.POINT); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetLocationFromList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetLocationFromList.java new file mode 100644 index 000000000..45a6dfa31 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetLocationFromList.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.ABListCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetLocationFromList extends ABLocationCallback { + + private ABListCallback list; + private ABIntegerCallback index; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return list.callback(caster, localStore, castId).get(index.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetProjectileCurrentLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetProjectileCurrentLocation.java new file mode 100644 index 000000000..b4df7c90d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetProjectileCurrentLocation.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetProjectileCurrentLocation extends ABLocationCallback { + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId), + AbilityPointTarget.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetStoredLocationByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetStoredLocationByKey.java new file mode 100644 index 000000000..a06c40b4c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetStoredLocationByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredLocationByKey extends ABLocationCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + AbilityPointTarget.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + AbilityPointTarget.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetTargetedLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetTargetedLocation.java new file mode 100644 index 000000000..095ca1b99 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetTargetedLocation.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetTargetedLocation extends ABLocationCallback { + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget target = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, castId), + AbilityPointTarget.class); + + return target; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_ABILITYTARGETEDLOCATION + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.LocationHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetUnitLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetUnitLocation.java new file mode 100644 index 000000000..c3add6737 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackGetUnitLocation.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitLocation extends ABLocationCallback { + + private ABUnitCallback unit; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CUnit theUnit = this.unit.callback(caster, localStore, castId); + + return new AbilityPointTarget(theUnit.getX(), theUnit.getY()); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GetUnitLoc(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackInlineConditionLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackInlineConditionLocation.java new file mode 100644 index 000000000..72c194b2f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackInlineConditionLocation.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionLocation extends ABLocationCallback { + + private ABBooleanCallback condition; + private ABLocationCallback pass; + private ABLocationCallback fail; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackModifyLocationWithOffset.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackModifyLocationWithOffset.java new file mode 100644 index 000000000..7b15d415e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackModifyLocationWithOffset.java @@ -0,0 +1,31 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackModifyLocationWithOffset extends ABLocationCallback { + + private ABLocationCallback origin; + private ABFloatCallback dist; + private ABFloatCallback angle; + + private ABBooleanCallback angleInDegrees; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget orig = this.origin.callback(caster, localStore, castId); + final float d = this.dist.callback(caster, localStore, castId); + final float a = this.angle.callback(caster, localStore, castId); + + if (angleInDegrees != null && angleInDegrees.callback(caster, localStore, castId)) { + orig.add((float)(d * Math.cos(Math.toRadians(a))), (float)(d * Math.sin(Math.toRadians(a)))); + return orig; + } + orig.add((float)(d * Math.cos(a)), (float)(d * Math.sin(a))); + return orig; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackModifyLocationWithXYOffset.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackModifyLocationWithXYOffset.java new file mode 100644 index 000000000..8f4b60eec --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackModifyLocationWithXYOffset.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackModifyLocationWithXYOffset extends ABLocationCallback { + + private ABLocationCallback origin; + private ABFloatCallback xdist; + private ABFloatCallback ydist; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget orig = this.origin.callback(caster, localStore, castId); + orig.add(xdist.callback(caster, localStore, castId), ydist.callback(caster, localStore, castId)); + return orig; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackRandomLocationInRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackRandomLocationInRange.java new file mode 100644 index 000000000..848c711fb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackRandomLocationInRange.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRandomLocationInRange extends ABLocationCallback { + + private ABLocationCallback origin; + private ABFloatCallback range; + + @Override + public AbilityPointTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final AbilityPointTarget orig = this.origin.callback(caster, localStore, castId); + final float d = this.range.callback(caster, localStore, castId) * localStore.game.getSeededRandom().nextFloat(); + final float a = (float) (Math.PI * 2 * localStore.game.getSeededRandom().nextFloat()); + + orig.add((float) (d * Math.cos(a)), (float) (d * Math.sin(a))); + return orig; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackReuseLocation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackReuseLocation.java new file mode 100644 index 000000000..39916aa0e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackReuseLocation.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseLocation extends ABLocationCallback { + + private ABStringCallback name; + + @Override + public AbilityPointTarget callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABLocationCallback) { + return ((ABLocationCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseLocationCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseLocationCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackReuseLocationWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackReuseLocationWithArguments.java new file mode 100644 index 000000000..56c872176 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABCallbackReuseLocationWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseLocationWithArguments extends ABLocationCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public AbilityPointTarget callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABLocationCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABLocationCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseLocationCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseLocationCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABLocationCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABLocationCallback.java new file mode 100644 index 000000000..83c15e347 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/location/ABLocationCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABLocationCallback implements ABCallback { + + abstract public AbilityPointTarget callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackAddLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackAddLong.java new file mode 100644 index 000000000..0779b8cce --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackAddLong.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackAddLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) + value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackAndLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackAndLong.java new file mode 100644 index 000000000..73644424f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackAndLong.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackAndLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) & value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackArgumentLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackArgumentLong.java new file mode 100644 index 000000000..fc7b11ea9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackArgumentLong.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentLong extends ABLongCallback { + + private ABStringCallback name; + + @Override + public Long callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABLongCallback) { + return ((ABLongCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseLongCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateDetectedData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateDetectedData.java new file mode 100644 index 000000000..859095096 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateDetectedData.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCreateDetectedData extends ABLongCallback { + + private ABIntegerCallback detectionLevel; + private ABIntegerCallback playerDetectedData; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + long ply = playerDetectedData.callback(caster, localStore, castId); + byte val = detectionLevel.callback(caster, localStore, castId).byteValue(); + return val + (ply<<8); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateDetectorData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateDetectorData.java new file mode 100644 index 000000000..3284bcbd1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateDetectorData.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCreateDetectorData extends ABLongCallback { + + private ABIntegerCallback detectionLevel; + private ABFloatCallback range; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + long rng = Math.min(PathingGrid.getFogOfWarDistance(range.callback(caster, localStore, castId)), 8388607); + byte val = detectionLevel.callback(caster, localStore, castId).byteValue(); + return val + (rng<<8); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateOwnershipData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateOwnershipData.java new file mode 100644 index 000000000..dc4692160 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackCreateOwnershipData.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCreateOwnershipData extends ABLongCallback { + + private ABIntegerCallback priority; + private ABIntegerCallback playerId; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + long ply = playerId.callback(caster, localStore, castId); + int val = Math.min(priority.callback(caster, localStore, castId), 15) & 0b1111; + return val + (ply << 4); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackDivideLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackDivideLong.java new file mode 100644 index 000000000..1b3c237b2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackDivideLong.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackDivideLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) / value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetAbilityDataAsLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetAbilityDataAsLong.java new file mode 100644 index 000000000..82a86cc6b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetAbilityDataAsLong.java @@ -0,0 +1,36 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsLong extends ABLongCallback { + + private ABDataFieldLetter dataField; + + @SuppressWarnings("unchecked") + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + final String data = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData() + .get(this.dataField.getIndex()); + if ("-".equals(data)) { + return 0l; + } + return Long.parseLong(data); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityDataAsLongAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" + + this.dataField.name() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetAbilityUniqueValueLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetAbilityUniqueValueLong.java new file mode 100644 index 000000000..b2a1e6106 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetAbilityUniqueValueLong.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityUniqueValueLong extends ABLongCallback { + + private ABAbilityCallback ability; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Long callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CAbility theAbility = ability.callback(caster, localStore, castId); + Long theVal = theAbility.getUniqueValue(keyS, Long.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return 0l; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetBuffUniqueValueLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetBuffUniqueValueLong.java new file mode 100644 index 000000000..8bd90ce7f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetBuffUniqueValueLong.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffUniqueValueLong extends ABLongCallback { + + private ABBuffCallback buff; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Long callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CBuff theBuff = buff.callback(caster, localStore, castId); + Long theVal = theBuff.getUniqueValue(keyS, Long.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return 0l; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetStoredLongByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetStoredLongByKey.java new file mode 100644 index 000000000..526b13c7a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackGetStoredLongByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredLongByKey extends ABLongCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + Long.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + Long.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackInlineConditionLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackInlineConditionLong.java new file mode 100644 index 000000000..a2e8168a6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackInlineConditionLong.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionLong extends ABLongCallback { + + private ABBooleanCallback condition; + private ABLongCallback pass; + private ABLongCallback fail; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMaxLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMaxLong.java new file mode 100644 index 000000000..87ed615b5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMaxLong.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMaxLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return Math.max(value1.callback(caster, localStore, castId), + value2.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMinLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMinLong.java new file mode 100644 index 000000000..aefead1a3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMinLong.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMinLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return Math.min(value1.callback(caster, localStore, castId), + value2.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMultiplyLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMultiplyLong.java new file mode 100644 index 000000000..3c7866ea6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackMultiplyLong.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackMultiplyLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) * value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackOrLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackOrLong.java new file mode 100644 index 000000000..1e6b8327b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackOrLong.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackOrLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) | value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskAllPlayers.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskAllPlayers.java new file mode 100644 index 000000000..d62942408 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskAllPlayers.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackPlayerMaskAllPlayers extends ABLongCallback { + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + long dat = 0; + for (int i = 0; i < WarsmashConstants.MAX_PLAYERS; i++) { + dat |= 1 << i; + } + + return dat; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskExcludePlayers.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskExcludePlayers.java new file mode 100644 index 000000000..a2bfe9bff --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskExcludePlayers.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackPlayerMaskExcludePlayers extends ABLongCallback { + + List players; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + long dat = 0; + for (ABPlayerCallback player : players) { + dat |= 1 << player.callback(caster, localStore, castId).getId(); + } + + return ~dat; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskIncludePlayers.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskIncludePlayers.java new file mode 100644 index 000000000..d1de3a8a1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackPlayerMaskIncludePlayers.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackPlayerMaskIncludePlayers extends ABLongCallback { + + List players; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + long dat = 0; + for (ABPlayerCallback player : players) { + dat |= 1 << player.callback(caster, localStore, castId).getId(); + } + + return dat; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackRawLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackRawLong.java new file mode 100644 index 000000000..8db0409fb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackRawLong.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRawLong extends ABLongCallback { + + private Long value; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackReuseLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackReuseLong.java new file mode 100644 index 000000000..d88226ac7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackReuseLong.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseLong extends ABLongCallback { + + private ABStringCallback name; + + @Override + public Long callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABLongCallback) { + return ((ABLongCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseLongCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseLongCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackReuseLongWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackReuseLongWithArguments.java new file mode 100644 index 000000000..09d20c25b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackReuseLongWithArguments.java @@ -0,0 +1,47 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseLongWithArguments extends ABLongCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public Long callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABLongCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABLongCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseLongCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseLongCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackSubtractLong.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackSubtractLong.java new file mode 100644 index 000000000..be4bf39fa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABCallbackSubtractLong.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackSubtractLong extends ABLongCallback { + + private ABLongCallback value1; + private ABLongCallback value2; + + @Override + public Long callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value1.callback(caster, localStore, castId) - value2.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABLongCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABLongCallback.java new file mode 100644 index 000000000..02d85ff74 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/longs/ABLongCallback.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABLongCallback implements ABCallback { + + abstract public Long callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackArgumentOrderId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackArgumentOrderId.java new file mode 100644 index 000000000..5801119c8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackArgumentOrderId.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentOrderId extends ABOrderIdCallback { + + private ABStringCallback name; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABOrderIdCallback) { + return ((ABOrderIdCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseOrderIdCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackGetStoredOrderIdByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackGetStoredOrderIdByKey.java new file mode 100644 index 000000000..583bdcd87 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackGetStoredOrderIdByKey.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredOrderIdByKey extends ABOrderIdCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + Integer.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + Integer.class); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackIdString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackIdString.java new file mode 100644 index 000000000..774b30561 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackIdString.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIdUtils; + +public class ABCallbackIdString extends ABOrderIdCallback { + + private ABStringCallback idString; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return OrderIdUtils.getOrderId(idString.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackInlineConditionOrderId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackInlineConditionOrderId.java new file mode 100644 index 000000000..c1b691e02 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackInlineConditionOrderId.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionOrderId extends ABOrderIdCallback { + + private ABBooleanCallback condition; + private ABOrderIdCallback pass; + private ABOrderIdCallback fail; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackRawID.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackRawID.java new file mode 100644 index 000000000..17e2a2088 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackRawID.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRawID extends ABOrderIdCallback { + + private Integer id; + + @Override + public Integer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return id; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackReuseOrderId.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackReuseOrderId.java new file mode 100644 index 000000000..fac23155c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackReuseOrderId.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseOrderId extends ABOrderIdCallback { + + private ABStringCallback name; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABOrderIdCallback) { + return ((ABOrderIdCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseOrderIdCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseOrderIdCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackReuseOrderIdWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackReuseOrderIdWithArguments.java new file mode 100644 index 000000000..5e5bb3112 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABCallbackReuseOrderIdWithArguments.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseOrderIdWithArguments extends ABOrderIdCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public Integer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABOrderIdCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABOrderIdCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseOrderIdCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseOrderIdCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABOrderIdCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABOrderIdCallback.java new file mode 100644 index 000000000..01164ddb5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/orderid/ABOrderIdCallback.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABOrderIdCallback implements ABCallback { + + abstract public Integer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackArgumentPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackArgumentPlayer.java new file mode 100644 index 000000000..5cf824ef8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackArgumentPlayer.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackArgumentPlayer extends ABPlayerCallback { + + private ABStringCallback name; + + @Override + public CPlayer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABPlayerCallback) { + return ((ABPlayerCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReusePlayerCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetCastingPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetCastingPlayer.java new file mode 100644 index 000000000..42ce21579 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetCastingPlayer.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackGetCastingPlayer extends ABPlayerCallback { + + @Override + public CPlayer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.originPlayer; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetOwnerOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetOwnerOfUnit.java new file mode 100644 index 000000000..8c721644b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetOwnerOfUnit.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackGetOwnerOfUnit extends ABPlayerCallback { + + private ABUnitCallback unit; + + @Override + public CPlayer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getPlayer(unit.callback(caster, localStore, castId).getPlayerIndex()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetPlayerById.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetPlayerById.java new file mode 100644 index 000000000..3a92694c1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetPlayerById.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackGetPlayerById extends ABPlayerCallback { + + private ABIntegerCallback id; + + @Override + public CPlayer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getPlayer(id.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetStoredPlayerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetStoredPlayerByKey.java new file mode 100644 index 000000000..350321d39 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackGetStoredPlayerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackGetStoredPlayerByKey extends ABPlayerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CPlayer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CPlayer.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CPlayer.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackInlineConditionPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackInlineConditionPlayer.java new file mode 100644 index 000000000..7cca22d63 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackInlineConditionPlayer.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackInlineConditionPlayer extends ABPlayerCallback { + + private ABBooleanCallback condition; + private ABPlayerCallback pass; + private ABPlayerCallback fail; + + @Override + public CPlayer callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackReusePlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackReusePlayer.java new file mode 100644 index 000000000..d4c943b28 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackReusePlayer.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackReusePlayer extends ABPlayerCallback { + + private ABStringCallback name; + + @Override + public CPlayer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABPlayerCallback) { + return ((ABPlayerCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReusePlayerCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReusePlayerCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackReusePlayerWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackReusePlayerWithArguments.java new file mode 100644 index 000000000..258960494 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABCallbackReusePlayerWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABCallbackReusePlayerWithArguments extends ABPlayerCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CPlayer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABPlayerCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABPlayerCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReusePlayerCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReusePlayerCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABPlayerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABPlayerCallback.java new file mode 100644 index 000000000..3e52f8020 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/player/ABPlayerCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public abstract class ABPlayerCallback implements ABCallback { + + abstract public CPlayer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackArgumentProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackArgumentProjectile.java new file mode 100644 index 000000000..a34363015 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackArgumentProjectile.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackArgumentProjectile extends ABProjectileCallback { + + private ABStringCallback name; + + @Override + public CProjectile callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABProjectileCallback) { + return ((ABProjectileCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseProjectileCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetLastCreatedProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetLastCreatedProjectile.java new file mode 100644 index 000000000..a44f2d311 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetLastCreatedProjectile.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackGetLastCreatedProjectile extends ABProjectileCallback { + + @Override + public CProjectile callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDPROJECTILE, CProjectile.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetReactionAbilityProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetReactionAbilityProjectile.java new file mode 100644 index 000000000..c3efad72e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetReactionAbilityProjectile.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackGetReactionAbilityProjectile extends ABProjectileCallback { + + @Override + public CProjectile callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.ABILITYPROJ, CProjectile.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITYPROJ", JassTextGeneratorType.ProjectileHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetReactionAttackProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetReactionAttackProjectile.java new file mode 100644 index 000000000..708095381 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetReactionAttackProjectile.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackGetReactionAttackProjectile extends ABProjectileCallback { + + @Override + public CProjectile callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKPROJ, castId), CProjectile.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetStoredProjectileByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetStoredProjectileByKey.java new file mode 100644 index 000000000..238bfa1d1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetStoredProjectileByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackGetStoredProjectileByKey extends ABProjectileCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CProjectile callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CProjectile.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CProjectile.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetThisProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetThisProjectile.java new file mode 100644 index 000000000..5e2cdcf2f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackGetThisProjectile.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackGetThisProjectile extends ABProjectileCallback { + + @Override + public CProjectile callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), CProjectile.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackInlineConditionProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackInlineConditionProjectile.java new file mode 100644 index 000000000..365c61b13 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackInlineConditionProjectile.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackInlineConditionProjectile extends ABProjectileCallback { + + private ABBooleanCallback condition; + private ABProjectileCallback pass; + private ABProjectileCallback fail; + + @Override + public CProjectile callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackReuseProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackReuseProjectile.java new file mode 100644 index 000000000..3f5bbf406 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackReuseProjectile.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackReuseProjectile extends ABProjectileCallback { + + private ABStringCallback name; + + @Override + public CProjectile callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABProjectileCallback) { + return ((ABProjectileCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseProjectileCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseProjectileCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackReuseProjectileWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackReuseProjectileWithArguments.java new file mode 100644 index 000000000..9e7b8fa35 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABCallbackReuseProjectileWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackReuseProjectileWithArguments extends ABProjectileCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CProjectile callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABProjectileCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABProjectileCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseProjectileCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseProjectileCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABProjectileCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABProjectileCallback.java new file mode 100644 index 000000000..cfccc65b0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/projectile/ABProjectileCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public abstract class ABProjectileCallback implements ABCallback { + + abstract public CProjectile callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackArgumentNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackArgumentNonStackingStatBuff.java new file mode 100644 index 000000000..59b23918b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackArgumentNonStackingStatBuff.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABCallbackArgumentNonStackingStatBuff extends ABNonStackingStatBuffCallback { + + private ABStringCallback name; + + @Override + public NonStackingStatBuff callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABNonStackingStatBuffCallback) { + return ((ABNonStackingStatBuffCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseNonStackingStatBuffCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackGetLastCreatedNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackGetLastCreatedNonStackingStatBuff.java new file mode 100644 index 000000000..6170e1010 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackGetLastCreatedNonStackingStatBuff.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABCallbackGetLastCreatedNonStackingStatBuff extends ABNonStackingStatBuffCallback { + + @Override + public NonStackingStatBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDNSSB, NonStackingStatBuff.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDNSSB", + JassTextGeneratorType.NonStackingStatBuffHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackGetStoredNonStackingStatBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackGetStoredNonStackingStatBuffByKey.java new file mode 100644 index 000000000..787213f86 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackGetStoredNonStackingStatBuffByKey.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABCallbackGetStoredNonStackingStatBuffByKey extends ABNonStackingStatBuffCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public NonStackingStatBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + NonStackingStatBuff.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + NonStackingStatBuff.class); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + if (this.instanceValue == null) { + return "GetLocalStoreUserCastNonStackingStatBuffHandleAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; + } + return "GetStoredNonStackingStatBuffAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackInlineConditionNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackInlineConditionNonStackingStatBuff.java new file mode 100644 index 000000000..a3934865d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackInlineConditionNonStackingStatBuff.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABCallbackInlineConditionNonStackingStatBuff extends ABNonStackingStatBuffCallback { + + private ABBooleanCallback condition; + private ABNonStackingStatBuffCallback pass; + private ABNonStackingStatBuffCallback fail; + + @Override + public NonStackingStatBuff callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackReuseNonStackingStatBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackReuseNonStackingStatBuff.java new file mode 100644 index 000000000..0d3b950d9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackReuseNonStackingStatBuff.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABCallbackReuseNonStackingStatBuff extends ABNonStackingStatBuffCallback { + + private ABStringCallback name; + + @Override + public NonStackingStatBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABNonStackingStatBuffCallback) { + return ((ABNonStackingStatBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseNonStackingStatBuffCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseNonStackingStatBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackReuseNonStackingStatBuffWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackReuseNonStackingStatBuffWithArguments.java new file mode 100644 index 000000000..c69b8a2cb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABCallbackReuseNonStackingStatBuffWithArguments.java @@ -0,0 +1,50 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABCallbackReuseNonStackingStatBuffWithArguments extends ABNonStackingStatBuffCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public NonStackingStatBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABNonStackingStatBuffCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABNonStackingStatBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseNonStackingStatBuffCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseNonStackingStatBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABNonStackingStatBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABNonStackingStatBuffCallback.java new file mode 100644 index 000000000..70bac6b25 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statbuff/ABNonStackingStatBuffCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public abstract class ABNonStackingStatBuffCallback implements ABCallback { + + abstract public NonStackingStatBuff callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackArgumentStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackArgumentStateModBuff.java new file mode 100644 index 000000000..5744c50e2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackArgumentStateModBuff.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABCallbackArgumentStateModBuff extends ABStateModBuffCallback { + + private ABStringCallback name; + + @Override + public StateModBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABStateModBuffCallback) { + return ((ABStateModBuffCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseStateModBuffCallback, but key is missing or callback was the wrong type: " + + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackGetLastCreatedStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackGetLastCreatedStateModBuff.java new file mode 100644 index 000000000..84e8792a0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackGetLastCreatedStateModBuff.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABCallbackGetLastCreatedStateModBuff extends ABStateModBuffCallback { + + @Override + public StateModBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDSMB, StateModBuff.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackGetStoredStateModBuffByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackGetStoredStateModBuffByKey.java new file mode 100644 index 000000000..9196cb8e3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackGetStoredStateModBuffByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABCallbackGetStoredStateModBuffByKey extends ABStateModBuffCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public StateModBuff callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + StateModBuff.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + StateModBuff.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackInlineConditionStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackInlineConditionStateModBuff.java new file mode 100644 index 000000000..7b208cda4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackInlineConditionStateModBuff.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABCallbackInlineConditionStateModBuff extends ABStateModBuffCallback { + + private ABBooleanCallback condition; + private ABStateModBuffCallback pass; + private ABStateModBuffCallback fail; + + @Override + public StateModBuff callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackReuseStateModBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackReuseStateModBuff.java new file mode 100644 index 000000000..6068d38b0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackReuseStateModBuff.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABCallbackReuseStateModBuff extends ABStateModBuffCallback { + + private ABStringCallback name; + + @Override + public StateModBuff callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABStateModBuffCallback) { + return ((ABStateModBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseStateModBuffCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseStateModBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackReuseStateModBuffWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackReuseStateModBuffWithArguments.java new file mode 100644 index 000000000..6518e5a34 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABCallbackReuseStateModBuffWithArguments.java @@ -0,0 +1,51 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public class ABCallbackReuseStateModBuffWithArguments extends ABStateModBuffCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public StateModBuff callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABStateModBuffCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABStateModBuffCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseStateModBuffCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseStateModBuffCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABStateModBuffCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABStateModBuffCallback.java new file mode 100644 index 000000000..5ca0a1d8d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/statemod/ABStateModBuffCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; + +public abstract class ABStateModBuffCallback implements ABCallback { + + abstract public StateModBuff callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackArgumentString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackArgumentString.java new file mode 100644 index 000000000..8cbec43e6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackArgumentString.java @@ -0,0 +1,31 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentString extends ABStringCallback { + + private ABStringCallback name; + + @Override + public String callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABStringCallback) { + return ((ABStringCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseStringCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackBooleanToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackBooleanToString.java new file mode 100644 index 000000000..63e25af78 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackBooleanToString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackBooleanToString extends ABStringCallback { + + private ABBooleanCallback value; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return "" + value.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackCatStrings.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackCatStrings.java new file mode 100644 index 000000000..afb554528 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackCatStrings.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackCatStrings extends ABStringCallback { + + private List stringList; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + String output = ""; + for (ABStringCallback callB : stringList) { + output += callB.callback(caster, localStore, castId); + } + return output; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackFloatToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackFloatToString.java new file mode 100644 index 000000000..8fb108b40 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackFloatToString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackFloatToString extends ABStringCallback { + + private ABFloatCallback value; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return "" + value.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityDataAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityDataAsString.java new file mode 100644 index 000000000..e1276f423 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityDataAsString.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsString extends ABStringCallback { + + private ABDataFieldLetter dataField; + + @SuppressWarnings("unchecked") + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + return levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData().get(dataField.getIndex()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityHandleAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityHandleAsString.java new file mode 100644 index 000000000..2606b5a2b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityHandleAsString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityHandleAsString extends ABStringCallback { + + private ABAbilityCallback ability; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return "" + ability.callback(caster, localStore, castId).getHandleId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityUniqueValueString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityUniqueValueString.java new file mode 100644 index 000000000..0f073b5e5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAbilityUniqueValueString.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityUniqueValueString extends ABStringCallback { + + private ABAbilityCallback ability; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public String callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CAbility theAbility = ability.callback(caster, localStore, castId); + String theVal = theAbility.getUniqueValue(keyS, String.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return ""; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAliasAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAliasAsString.java new file mode 100644 index 000000000..9393c3cbe --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAliasAsString.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAliasAsString extends ABStringCallback { + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.ALIAS, War3ID.class)).asStringValue(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAllowStackingKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAllowStackingKey.java new file mode 100644 index 000000000..27c2f712b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetAllowStackingKey.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; + +public class ABCallbackGetAllowStackingKey extends ABStringCallback { + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return NonStackingStatBuff.ALLOW_STACKING_KEY; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "\"" + NonStackingStatBuff.ALLOW_STACKING_KEY + "\""; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetBuffHandleAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetBuffHandleAsString.java new file mode 100644 index 000000000..2f860a332 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetBuffHandleAsString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffHandleAsString extends ABStringCallback { + + private ABBuffCallback buff; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return "" + buff.callback(caster, localStore, castId).getHandleId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetBuffUniqueValueString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetBuffUniqueValueString.java new file mode 100644 index 000000000..4b8cd0981 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetBuffUniqueValueString.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffUniqueValueString extends ABStringCallback { + + private ABBuffCallback buff; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public String callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CBuff theBuff = buff.callback(caster, localStore, castId); + String theVal = theBuff.getUniqueValue(keyS, String.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return ""; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetCodeAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetCodeAsString.java new file mode 100644 index 000000000..6b4133e25 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetCodeAsString.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetCodeAsString extends ABStringCallback { + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.CODE, War3ID.class)).asStringValue(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetStoredStringByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetStoredStringByKey.java new file mode 100644 index 000000000..72387e495 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetStoredStringByKey.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredStringByKey extends ABStringCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public String callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + String.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + String.class); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetUnitHandleAsString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetUnitHandleAsString.java new file mode 100644 index 000000000..d0c357b55 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackGetUnitHandleAsString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitHandleAsString extends ABStringCallback { + + private ABUnitCallback unit; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return "" + unit.callback(caster, localStore, castId).getHandleId(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackIdToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackIdToString.java new file mode 100644 index 000000000..65f4785fc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackIdToString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIdToString extends ABStringCallback { + + private ABIDCallback value; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value.callback(caster, localStore, castId).asStringValue(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackInlineConditionString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackInlineConditionString.java new file mode 100644 index 000000000..52312c866 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackInlineConditionString.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionString extends ABStringCallback { + + private ABBooleanCallback condition; + private ABStringCallback pass; + private ABStringCallback fail; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackIntegerToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackIntegerToString.java new file mode 100644 index 000000000..cd3821b53 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackIntegerToString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIntegerToString extends ABStringCallback { + + private ABIntegerCallback value; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return "" + value.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackLongToString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackLongToString.java new file mode 100644 index 000000000..247d25d95 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackLongToString.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs.ABLongCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackLongToString extends ABStringCallback { + + private ABLongCallback value; + + @Override + public String callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return "" + value.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackRawString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackRawString.java new file mode 100644 index 000000000..66d491113 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackRawString.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRawString extends ABStringCallback { + + private String value; + + @Override + public String callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return this.value; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "\"" + this.value + "\""; + } + + public String getValue() { + return this.value; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackReuseString.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackReuseString.java new file mode 100644 index 000000000..ce1488430 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackReuseString.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseString extends ABStringCallback { + + private ABStringCallback name; + + @Override + public String callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABStringCallback) { + return ((ABStringCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseStringCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseStringCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackReuseStringWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackReuseStringWithArguments.java new file mode 100644 index 000000000..fb3dcb4d8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABCallbackReuseStringWithArguments.java @@ -0,0 +1,47 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseStringWithArguments extends ABStringCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public String callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABStringCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABStringCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseStringCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseStringCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABStringCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABStringCallback.java new file mode 100644 index 000000000..0bfc0b137 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/strings/ABStringCallback.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABStringCallback implements ABCallback { + + abstract public String callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackArgumentTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackArgumentTarget.java new file mode 100644 index 000000000..6fcfea894 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackArgumentTarget.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentTarget extends ABTargetCallback { + + private ABStringCallback name; + + @Override + public AbilityTarget callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABTargetCallback) { + return ((ABTargetCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseTargetCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackGetAbilityTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackGetAbilityTarget.java new file mode 100644 index 000000000..09545789d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackGetAbilityTarget.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAbilityTarget extends ABTargetCallback { + + @Override + public AbilityTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget target = localStore.get( + ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDLOCATION, castId), + AbilityPointTarget.class); + if (target != null) { + return target; + } + CUnit taru = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), + CUnit.class); + if (taru != null) { + return taru; + } + return null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackGetStoredTargetByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackGetStoredTargetByKey.java new file mode 100644 index 000000000..3d76f7fe9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackGetStoredTargetByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredTargetByKey extends ABTargetCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public AbilityTarget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + AbilityTarget.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + AbilityTarget.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackInlineConditionTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackInlineConditionTarget.java new file mode 100644 index 000000000..3270a0b07 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackInlineConditionTarget.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionTarget extends ABTargetCallback { + + private ABBooleanCallback condition; + private ABTargetCallback pass; + private ABTargetCallback fail; + + @Override + public AbilityTarget callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackReuseTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackReuseTarget.java new file mode 100644 index 000000000..a1e630a03 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackReuseTarget.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseTarget extends ABTargetCallback { + + private ABStringCallback name; + + @Override + public AbilityTarget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABTargetCallback) { + return ((ABTargetCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseTargetCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseTargetCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackReuseTargetWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackReuseTargetWithArguments.java new file mode 100644 index 000000000..1c03e2024 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABCallbackReuseTargetWithArguments.java @@ -0,0 +1,50 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseTargetWithArguments extends ABTargetCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public AbilityTarget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABTargetCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABTargetCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseTargetCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseTargetCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABTargetCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABTargetCallback.java new file mode 100644 index 000000000..5a5937b4d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/target/ABTargetCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABTargetCallback implements ABCallback { + + abstract public AbilityTarget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackArgumentTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackArgumentTimer.java new file mode 100644 index 000000000..0cc27b0dc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackArgumentTimer.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackArgumentTimer extends ABTimerCallback { + + private ABStringCallback name; + + @Override + public CTimer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABTimerCallback) { + return ((ABTimerCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseTimerCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetFiringTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetFiringTimer.java new file mode 100644 index 000000000..d351a5251 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetFiringTimer.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackGetFiringTimer extends ABTimerCallback { + + @Override + public CTimer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.FIRINGTIMER, CTimer.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetLastCreatedTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetLastCreatedTimer.java new file mode 100644 index 000000000..c32a8f814 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetLastCreatedTimer.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackGetLastCreatedTimer extends ABTimerCallback { + + @Override + public CTimer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDTIMER, CTimer.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetLastStartedTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetLastStartedTimer.java new file mode 100644 index 000000000..6488b3319 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetLastStartedTimer.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackGetLastStartedTimer extends ABTimerCallback { + + @Override + public CTimer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTSTARTEDTIMER, CTimer.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetStoredTimerByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetStoredTimerByKey.java new file mode 100644 index 000000000..3aa5fcf9c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackGetStoredTimerByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackGetStoredTimerByKey extends ABTimerCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CTimer callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CTimer.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CTimer.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackInlineConditionTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackInlineConditionTimer.java new file mode 100644 index 000000000..44272e5f3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackInlineConditionTimer.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackInlineConditionTimer extends ABTimerCallback { + + private ABBooleanCallback condition; + private ABTimerCallback pass; + private ABTimerCallback fail; + + @Override + public CTimer callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackReuseTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackReuseTimer.java new file mode 100644 index 000000000..582d0dad2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackReuseTimer.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackReuseTimer extends ABTimerCallback { + + private ABStringCallback name; + + @Override + public CTimer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABTimerCallback) { + return ((ABTimerCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseTimerCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseTimerCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackReuseTimerWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackReuseTimerWithArguments.java new file mode 100644 index 000000000..ae12c9b19 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABCallbackReuseTimerWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABCallbackReuseTimerWithArguments extends ABTimerCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CTimer callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABTimerCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABTimerCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseTimerCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseTimerCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABTimerCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABTimerCallback.java new file mode 100644 index 000000000..e3fd3612e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/timer/ABTimerCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public abstract class ABTimerCallback implements ABCallback { + + abstract public CTimer callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackArgumentUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackArgumentUnit.java new file mode 100644 index 000000000..4cdbe4544 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackArgumentUnit.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentUnit extends ABUnitCallback { + + private ABStringCallback name; + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABUnitCallback) { + return ((ABUnitCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAbilityPairedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAbilityPairedUnit.java new file mode 100644 index 000000000..f8b52fa8c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAbilityPairedUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAbilityPairedUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYPAIREDUNIT, castId), CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_ABILITYPAIREDUNIT + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAbilityTargetedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAbilityTargetedUnit.java new file mode 100644 index 000000000..cd3a79f35 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAbilityTargetedUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAbilityTargetedUnit extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYTARGETEDUNIT, castId), CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_ABILITYTARGETEDUNIT + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAttackedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAttackedUnit.java new file mode 100644 index 000000000..110c71b2d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAttackedUnit.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAttackedUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityTarget tar = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, castId), + AbilityTarget.class); + return tar.visit(AbilityTargetVisitor.UNIT); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAttackingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAttackingUnit.java new file mode 100644 index 000000000..35e72fc97 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetAttackingUnit.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetAttackingUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, castId), CUnit.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetBuffCastingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetBuffCastingUnit.java new file mode 100644 index 000000000..f6effe0c0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetBuffCastingUnit.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetBuffCastingUnit extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return localStore.get(ABLocalStoreKeys.BUFFCASTINGUNIT, CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_BUFFCASTINGUNIT", JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetBuffedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetBuffedUnit.java new file mode 100644 index 000000000..167b0dfa9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetBuffedUnit.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffedUnit extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return caster; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getCaster(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCastingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCastingUnit.java new file mode 100644 index 000000000..6d949906a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCastingUnit.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetCastingUnit extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + return localStore.originUnit; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getCaster(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetChainUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetChainUnit.java new file mode 100644 index 000000000..29f6acc8e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetChainUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetChainUnit extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CHAINUNIT, castId), CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_CHAINUNIT + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCompUnit1.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCompUnit1.java new file mode 100644 index 000000000..82a653e53 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCompUnit1.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetCompUnit1 extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.COMPUNIT1, CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_COMPUNIT1", JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCompUnit2.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCompUnit2.java new file mode 100644 index 000000000..a980c4b37 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetCompUnit2.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetCompUnit2 extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.COMPUNIT2, CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_COMPUNIT2", JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDamagedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDamagedUnit.java new file mode 100644 index 000000000..f671a98b8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDamagedUnit.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetDamagedUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, castId), CUnit.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDamagingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDamagingUnit.java new file mode 100644 index 000000000..ec50f1cd1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDamagingUnit.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetDamagingUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, castId), CUnit.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDyingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDyingUnit.java new file mode 100644 index 000000000..ebb046b42 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetDyingUnit.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetDyingUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DYINGUNIT, castId), CUnit.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetEnumUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetEnumUnit.java new file mode 100644 index 000000000..a15fd0c48 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetEnumUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetEnumUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ENUMUNIT, castId), CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_ENUMUNIT + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetKillingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetKillingUnit.java new file mode 100644 index 000000000..3f25145ba --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetKillingUnit.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetKillingUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.KILLINGUNIT, castId), CUnit.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetLastCreatedUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetLastCreatedUnit.java new file mode 100644 index 000000000..719ca92ca --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetLastCreatedUnit.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDUNIT, CUnit.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_LASTCREATEDUNIT", + JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetListenerUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetListenerUnit.java new file mode 100644 index 000000000..48a19cb4e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetListenerUnit.java @@ -0,0 +1,13 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetListenerUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return caster; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetMatchingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetMatchingUnit.java new file mode 100644 index 000000000..089a341f8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetMatchingUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetMatchingUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), CUnit.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_MATCHINGUNIT + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetNearestCorpseInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetNearestCorpseInRangeOfUnit.java new file mode 100644 index 000000000..5fe9db892 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetNearestCorpseInRangeOfUnit.java @@ -0,0 +1,60 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitAndRangeComparator; + +public class ABCallbackGetNearestCorpseInRangeOfUnit extends ABUnitCallback { + private static final Rectangle recycleRect = new Rectangle(); + + private ABUnitCallback originUnit; + private ABFloatCallback range; + private List conditions; + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit originUnitTarget = originUnit.callback(caster, localStore, castId); + Float rangeVal = range.callback(caster, localStore, castId); + + final ABUnitAndRangeComparator ur = new ABUnitAndRangeComparator(); + + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumCorpsesInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal)) { + double dist = originUnitTarget.distance(enumUnit); + if (ur.getUnit() == null || ur.getRange() > dist) { + if (conditions != null) { + boolean result = true; + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), + enumUnit); + for (ABBooleanCallback condition : conditions) { + result = result && condition.callback(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + if (result) { + ur.setRange(dist); + ur.setUnit(enumUnit); + } + } else { + ur.setRange(dist); + ur.setUnit(enumUnit); + } + } + } + return false; + } + }); + return ur.getUnit(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetNearestUnitInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetNearestUnitInRangeOfUnit.java new file mode 100644 index 000000000..f90319dff --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetNearestUnitInRangeOfUnit.java @@ -0,0 +1,60 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitAndRangeComparator; + +public class ABCallbackGetNearestUnitInRangeOfUnit extends ABUnitCallback { + private static final Rectangle recycleRect = new Rectangle(); + + private ABUnitCallback originUnit; + private ABFloatCallback range; + private List conditions; + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit originUnitTarget = originUnit.callback(caster, localStore, castId); + Float rangeVal = range.callback(caster, localStore, castId); + + final ABUnitAndRangeComparator ur = new ABUnitAndRangeComparator(); + + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal)) { + double dist = originUnitTarget.distance(enumUnit); + if (ur.getUnit() == null || ur.getRange() > dist) { + if (conditions != null) { + boolean result = true; + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), + enumUnit); + for (ABBooleanCallback condition : conditions) { + result = result && condition.callback(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + if (result) { + ur.setRange(dist); + ur.setUnit(enumUnit); + } + } else { + ur.setRange(dist); + ur.setUnit(enumUnit); + } + } + } + return false; + } + }); + return ur.getUnit(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetProjectileHitUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetProjectileHitUnit.java new file mode 100644 index 000000000..60e794eed --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetProjectileHitUnit.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetProjectileHitUnit extends ABUnitCallback { + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId), CUnit.class); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr( + "AB_LOCAL_STORE_KEY_PROJECTILEHITUNIT + I2S(" + jassTextGenerator.getCastId() + ")", + JassTextGeneratorType.UnitHandle); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetProjectileSourceUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetProjectileSourceUnit.java new file mode 100644 index 000000000..fd87fc786 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetProjectileSourceUnit.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCallbackGetProjectileSourceUnit extends ABUnitCallback { + + private ABProjectileCallback proj; + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + CProjectile p = proj.callback(caster, localStore, castId); + return p.getSource(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetReactionAbilityCastingUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetReactionAbilityCastingUnit.java new file mode 100644 index 000000000..83c16d387 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetReactionAbilityCastingUnit.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetReactionAbilityCastingUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYCASTER, castId), CUnit.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetReactionAbilityTargetUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetReactionAbilityTargetUnit.java new file mode 100644 index 000000000..f2400fab3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetReactionAbilityTargetUnit.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetReactionAbilityTargetUnit extends ABUnitCallback { + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityTarget tar = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYCASTER, castId), + AbilityTarget.class); + return tar.visit(AbilityTargetVisitor.UNIT); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetStoredUnitByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetStoredUnitByKey.java new file mode 100644 index 000000000..52ad806bc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackGetStoredUnitByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredUnitByKey extends ABUnitCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CUnit.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CUnit.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackInlineConditionUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackInlineConditionUnit.java new file mode 100644 index 000000000..36a7d02ab --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackInlineConditionUnit.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionUnit extends ABUnitCallback { + + private ABBooleanCallback condition; + private ABUnitCallback pass; + private ABUnitCallback fail; + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackPollUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackPollUnitQueue.java new file mode 100644 index 000000000..4307c7722 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackPollUnitQueue.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue.ABUnitQueueCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackPollUnitQueue extends ABUnitCallback { + + private ABUnitQueueCallback queue; + + @Override + public CUnit callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return queue.callback(caster, localStore, castId).poll(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackReuseUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackReuseUnit.java new file mode 100644 index 000000000..e0bd5027f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackReuseUnit.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseUnit extends ABUnitCallback { + + private ABStringCallback name; + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABUnitCallback) { + return ((ABUnitCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseUnitCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackReuseUnitWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackReuseUnitWithArguments.java new file mode 100644 index 000000000..785e554f8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABCallbackReuseUnitWithArguments.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseUnitWithArguments extends ABUnitCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABUnitCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABUnitCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseUnitCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABUnitCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABUnitCallback.java new file mode 100644 index 000000000..9e71f000e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unit/ABUnitCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABUnitCallback implements ABCallback { + + @Override + abstract public CUnit callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackArgumentUnitGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackArgumentUnitGroup.java new file mode 100644 index 000000000..82bb86a36 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackArgumentUnitGroup.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentUnitGroup extends ABUnitGroupCallback { + + private ABStringCallback name; + + @Override + public Set callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABUnitGroupCallback) { + return ((ABUnitGroupCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitGroupCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetLastCreatedUnitGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetLastCreatedUnitGroup.java new file mode 100644 index 000000000..ec8097a82 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetLastCreatedUnitGroup.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedUnitGroup extends ABUnitGroupCallback { + + @SuppressWarnings("unchecked") + @Override + public Set callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (Set) localStore.get(ABLocalStoreKeys.LASTCREATEDUNITGROUP); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetStoredUnitGroupByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetStoredUnitGroupByKey.java new file mode 100644 index 000000000..602abeba8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetStoredUnitGroupByKey.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredUnitGroupByKey extends ABUnitGroupCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @SuppressWarnings("unchecked") + @Override + public Set callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return (Set) localStore.get(ABLocalStoreKeys + .combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId)); + } else { + return (Set) localStore + .get(ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetUnitGroupByName.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetUnitGroupByName.java new file mode 100644 index 000000000..c6c9083d8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackGetUnitGroupByName.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitGroupByName extends ABUnitGroupCallback { + + private String name; + + @SuppressWarnings("unchecked") + @Override + public Set callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (Set) localStore.get("_unitgroup_" + name); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackInlineConditionUnitGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackInlineConditionUnitGroup.java new file mode 100644 index 000000000..747d404e9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackInlineConditionUnitGroup.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionUnitGroup extends ABUnitGroupCallback { + + private ABBooleanCallback condition; + private ABUnitGroupCallback pass; + private ABUnitGroupCallback fail; + + @Override + public Set callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackReuseUnitGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackReuseUnitGroup.java new file mode 100644 index 000000000..e87b4975c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackReuseUnitGroup.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseUnitGroup extends ABUnitGroupCallback { + + private ABStringCallback name; + + @Override + public Set callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABUnitGroupCallback) { + return ((ABUnitGroupCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitGroupCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseUnitGroupCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackReuseUnitGroupWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackReuseUnitGroupWithArguments.java new file mode 100644 index 000000000..9fe21ad34 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABCallbackReuseUnitGroupWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Map; +import java.util.Set; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseUnitGroupWithArguments extends ABUnitGroupCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public Set callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABUnitGroupCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABUnitGroupCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitGroupCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseUnitGroupCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABUnitGroupCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABUnitGroupCallback.java new file mode 100644 index 000000000..174897de5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitgroup/ABUnitGroupCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup; + +import java.util.Set; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABUnitGroupCallback implements ABCallback { + + abstract public Set callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackArgumentUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackArgumentUnitQueue.java new file mode 100644 index 000000000..8a08ec793 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackArgumentUnitQueue.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentUnitQueue extends ABUnitQueueCallback { + + private ABStringCallback name; + + @Override + public Queue callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABUnitQueueCallback) { + return ((ABUnitQueueCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitQueueCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetLastCreatedUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetLastCreatedUnitQueue.java new file mode 100644 index 000000000..c943a3029 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetLastCreatedUnitQueue.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetLastCreatedUnitQueue extends ABUnitQueueCallback { + + @SuppressWarnings("unchecked") + @Override + public Queue callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (Queue) localStore.get(ABLocalStoreKeys.LASTCREATEDUNITQUEUE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetStoredUnitQueueByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetStoredUnitQueueByKey.java new file mode 100644 index 000000000..d7742a4aa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetStoredUnitQueueByKey.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredUnitQueueByKey extends ABUnitQueueCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @SuppressWarnings("unchecked") + @Override + public Queue callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return (Queue) localStore.get(ABLocalStoreKeys + .combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId)); + } else { + return (Queue) localStore + .get(ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId)); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetUnitQueueByName.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetUnitQueueByName.java new file mode 100644 index 000000000..40a38c9d8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackGetUnitQueueByName.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetUnitQueueByName extends ABUnitQueueCallback { + + private String name; + + @SuppressWarnings("unchecked") + @Override + public Queue callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (Queue) localStore.get("_unitqueue_" + name); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackInlineConditionUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackInlineConditionUnitQueue.java new file mode 100644 index 000000000..b2614ca4f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackInlineConditionUnitQueue.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionUnitQueue extends ABUnitQueueCallback { + + private ABBooleanCallback condition; + private ABUnitQueueCallback pass; + private ABUnitQueueCallback fail; + + @Override + public Queue callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackReuseUnitQueue.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackReuseUnitQueue.java new file mode 100644 index 000000000..ace638072 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackReuseUnitQueue.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseUnitQueue extends ABUnitQueueCallback { + + private ABStringCallback name; + + @Override + public Queue callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABUnitQueueCallback) { + return ((ABUnitQueueCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseUnitQueueCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseUnitQueueCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackReuseUnitQueueWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackReuseUnitQueueWithArguments.java new file mode 100644 index 000000000..f2972f842 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABCallbackReuseUnitQueueWithArguments.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Map; +import java.util.Queue; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseUnitQueueWithArguments extends ABUnitQueueCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public Queue callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABUnitQueueCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABUnitQueueCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseUnitQueueCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseUnitQueueCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABUnitQueueCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABUnitQueueCallback.java new file mode 100644 index 000000000..e81c6c7b5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/unitqueue/ABUnitQueueCallback.java @@ -0,0 +1,12 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue; + +import java.util.Queue; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABUnitQueueCallback implements ABCallback { + + abstract public Queue callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackArgumentVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackArgumentVisionModifier.java new file mode 100644 index 000000000..a3b89ac3c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackArgumentVisionModifier.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; + +public class ABCallbackArgumentVisionModifier extends ABVisionModifierCallback { + + private ABStringCallback name; + + @Override + public CFogModifier callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABVisionModifierCallback) { + return ((ABVisionModifierCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseVisionModifierCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackGetLastCreatedVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackGetLastCreatedVisionModifier.java new file mode 100644 index 000000000..4feac7dba --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackGetLastCreatedVisionModifier.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; + +public class ABCallbackGetLastCreatedVisionModifier extends ABVisionModifierCallback { + + @Override + public CFogModifier callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.LASTCREATEDVISIONMODIFIER, CFogModifier.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackGetStoredVisionModifierByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackGetStoredVisionModifierByKey.java new file mode 100644 index 000000000..b5a2fa9cc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackGetStoredVisionModifierByKey.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; + +public class ABCallbackGetStoredVisionModifierByKey extends ABVisionModifierCallback { + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CFogModifier callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (instanceValue == null || instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(key.callback(caster, localStore, castId), castId), + CFogModifier.class); + } else { + return localStore.get(ABLocalStoreKeys.combineUserKey(key.callback(caster, localStore, castId), castId), + CFogModifier.class); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackInlineConditionVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackInlineConditionVisionModifier.java new file mode 100644 index 000000000..731b6752b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackInlineConditionVisionModifier.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; + +public class ABCallbackInlineConditionVisionModifier extends ABVisionModifierCallback { + + private ABBooleanCallback condition; + private ABVisionModifierCallback pass; + private ABVisionModifierCallback fail; + + @Override + public CFogModifier callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackReuseVisionModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackReuseVisionModifier.java new file mode 100644 index 000000000..e273d8d7c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackReuseVisionModifier.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; + +public class ABCallbackReuseVisionModifier extends ABVisionModifierCallback { + + private ABStringCallback name; + + @Override + public CFogModifier callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABVisionModifierCallback) { + return ((ABVisionModifierCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseVisionModifierCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseVisionModifierCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackReuseVisionModifierWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackReuseVisionModifierWithArguments.java new file mode 100644 index 000000000..7543fb06d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABCallbackReuseVisionModifierWithArguments.java @@ -0,0 +1,50 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; + +public class ABCallbackReuseVisionModifierWithArguments extends ABVisionModifierCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CFogModifier callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABVisionModifierCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABVisionModifierCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseVisionModifierCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseVisionModifierCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABVisionModifierCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABVisionModifierCallback.java new file mode 100644 index 000000000..e6a8ad99e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/visionmodifier/ABVisionModifierCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision.CFogModifier; + +public abstract class ABVisionModifierCallback implements ABCallback { + + abstract public CFogModifier callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackArgumentWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackArgumentWidget.java new file mode 100644 index 000000000..fe3e5aa47 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackArgumentWidget.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentWidget extends ABWidgetCallback { + + private ABStringCallback name; + + @Override + public CWidget callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABWidgetCallback) { + return ((ABWidgetCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseWidgetCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackDestructableToWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackDestructableToWidget.java new file mode 100644 index 000000000..c7175c0c7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackDestructableToWidget.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackDestructableToWidget extends ABWidgetCallback { + + private ABDestructableCallback destructable; + + @Override + public CWidget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return destructable.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackGetProjectileHitWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackGetProjectileHitWidget.java new file mode 100644 index 000000000..b2550c233 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackGetProjectileHitWidget.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetProjectileHitWidget extends ABWidgetCallback { + + @Override + public CWidget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CWidget unit = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId), + CWidget.class); + final CWidget dest = localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId), + CWidget.class); + if (unit != null) { + return unit; + } else { + return dest; + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "GetProjectileHitWidgetAU()"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackGetStoredWidgetByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackGetStoredWidgetByKey.java new file mode 100644 index 000000000..13971f802 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackGetStoredWidgetByKey.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredWidgetByKey extends ABWidgetCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public CWidget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + CWidget.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + CWidget.class); + } + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackInlineConditionWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackInlineConditionWidget.java new file mode 100644 index 000000000..f2c23cac3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackInlineConditionWidget.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionWidget extends ABWidgetCallback { + + private ABBooleanCallback condition; + private ABWidgetCallback pass; + private ABWidgetCallback fail; + + @Override + public CWidget callback(CUnit caster, ABLocalDataStore localStore, int castId) { + if (condition != null && condition.callback(caster, localStore, castId)) { + return pass.callback(caster, localStore, castId); + } + return fail.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackItemToWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackItemToWidget.java new file mode 100644 index 000000000..56ac8a248 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackItemToWidget.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackItemToWidget extends ABWidgetCallback { + + private ABItemCallback item; + + @Override + public CWidget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return item.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackReuseWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackReuseWidget.java new file mode 100644 index 000000000..23ca31787 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackReuseWidget.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseWidget extends ABWidgetCallback { + + private ABStringCallback name; + + @Override + public CWidget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABWidgetCallback) { + return ((ABWidgetCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println("Trying to run ReuseWidgetCallback, but key is missing or callback was the wrong type: " + keyS); + } + } else { + System.err.println("Trying to run ReuseWidgetCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackReuseWidgetWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackReuseWidgetWithArguments.java new file mode 100644 index 000000000..ca3a345b4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackReuseWidgetWithArguments.java @@ -0,0 +1,50 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseWidgetWithArguments extends ABWidgetCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public CWidget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility) + .getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABWidgetCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABWidgetCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseWidgetCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseWidgetCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackUnitToWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackUnitToWidget.java new file mode 100644 index 000000000..e9b88f6e5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABCallbackUnitToWidget.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackUnitToWidget extends ABWidgetCallback { + + private ABUnitCallback unit; + + @Override + public CWidget callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return unit.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABWidgetCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABWidgetCallback.java new file mode 100644 index 000000000..951d95a7c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/callback/widget/ABWidgetCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABWidgetCallback implements ABCallback { + + abstract public CWidget callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABBooleanCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABBooleanCallback.java new file mode 100644 index 000000000..b90c4a271 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABBooleanCallback.java @@ -0,0 +1,11 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition; + +import com.etheller.warsmash.parsers.jass.JassTextGeneratorExpr; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABBooleanCallback implements ABCallback, JassTextGeneratorExpr { + + abstract public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackArgumentBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackArgumentBoolean.java new file mode 100644 index 000000000..dab94d809 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackArgumentBoolean.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackArgumentBoolean extends ABBooleanCallback { + + private ABStringCallback name; + + @Override + public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = name.callback(caster, localStore, castId); + ABCallback cbck = localStore.get(ABLocalStoreKeys.combineArgumentKey(keyS), ABCallback.class); + if (cbck != null && cbck instanceof ABBooleanCallback) { + return ((ABBooleanCallback) cbck).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseBooleanCallback, but key is missing or callback was the wrong type: " + keyS); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackReuseBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackReuseBoolean.java new file mode 100644 index 000000000..53b5007c1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackReuseBoolean.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseBoolean extends ABBooleanCallback { + + private ABStringCallback name; + + @Override + public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABBooleanCallback) { + return ((ABBooleanCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseBooleanCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseBooleanCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackReuseBooleanWithArguments.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackReuseBooleanWithArguments.java new file mode 100644 index 000000000..1ef6a413d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABCallbackReuseBooleanWithArguments.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition; + +import java.util.Map; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABCallbackReuseBooleanWithArguments extends ABBooleanCallback { + + private ABStringCallback name; + private Map arguments; + + @Override + public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final ABAbilityBuilderConfiguration config = (localStore.originAbility).getConfig(); + final String keyS = name.callback(caster, localStore, castId); + if (config.getReuseCallbacks() != null) { + ABCallback callback = config.getReuseCallbacks().get(keyS); + if (callback != null && callback instanceof ABBooleanCallback) { + if (arguments != null && !arguments.isEmpty()) { + for (String argKey : arguments.keySet()) { + localStore.put(ABLocalStoreKeys.combineArgumentKey(argKey), arguments.get(argKey)); + } + } + + return ((ABBooleanCallback) callback).callback(caster, localStore, castId); + } else { + System.err.println( + "Trying to run ReuseBooleanCallback, but key is missing or callback was the wrong type: " + + keyS); + } + } else { + System.err.println("Trying to run ReuseBooleanCallback, but none defined"); + } + return null; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "TODOJASS"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABConditionSetCantUseReasonOnFailure.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABConditionSetCantUseReasonOnFailure.java new file mode 100644 index 000000000..81a20e4c6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ABConditionSetCantUseReasonOnFailure.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeysEnum; + +public class ABConditionSetCantUseReasonOnFailure extends ABBooleanCallback { + + private ABBooleanCallback condition; + private CommandStringErrorKeysEnum reason; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean result = condition.callback(caster, localStore, castId); + if (!result) { + localStore.put(ABLocalStoreKeys.CANTUSEREASON, reason.getKey()); + } + return result; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsAutoCastCurrentlyActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsAutoCastCurrentlyActive.java new file mode 100644 index 000000000..8ebf755fc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsAutoCastCurrentlyActive.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionIsAutoCastCurrentlyActive extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.ISAUTOCASTON, Boolean.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ISAUTOCASTON", JassTextGeneratorType.Boolean); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsAutoCastTargeting.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsAutoCastTargeting.java new file mode 100644 index 000000000..9c1c292da --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsAutoCastTargeting.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionIsAutoCastTargeting extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.ISAUTOCASTTARGETING, Boolean.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ISAUTOCAST", JassTextGeneratorType.Boolean); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsDisabled.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsDisabled.java new file mode 100644 index 000000000..72f4e275c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsDisabled.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsDisabled extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderAbility ability = localStore.originAbility; + return ability.isDisabled(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityNonPointTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityNonPointTarget.java new file mode 100644 index 000000000..af648516b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityNonPointTarget.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveFlexTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionIsFlexAbilityNonPointTarget extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderActiveFlexTarget ability = localStore.get(ABLocalStoreKeys.ISFLEXABILITY, ABAbilityBuilderActiveFlexTarget.class); + + return !ability.isPointTarget(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityNonTargeted.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityNonTargeted.java new file mode 100644 index 000000000..b85e0ff4d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityNonTargeted.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveFlexTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionIsFlexAbilityNonTargeted extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderActiveFlexTarget ability = localStore.get(ABLocalStoreKeys.ISFLEXABILITY, ABAbilityBuilderActiveFlexTarget.class); + + return !ability.isTargetedSpell(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityPointTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityPointTarget.java new file mode 100644 index 000000000..0d663a215 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityPointTarget.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveFlexTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionIsFlexAbilityPointTarget extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderActiveFlexTarget ability = localStore.get(ABLocalStoreKeys.ISFLEXABILITY, ABAbilityBuilderActiveFlexTarget.class); + + return ability.isPointTarget(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityTargeted.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityTargeted.java new file mode 100644 index 000000000..a90fe98f8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsFlexAbilityTargeted.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveFlexTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionIsFlexAbilityTargeted extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderActiveFlexTarget ability = localStore.get(ABLocalStoreKeys.ISFLEXABILITY, + ABAbilityBuilderActiveFlexTarget.class); + + return ability.isTargetedSpell(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsOnCooldown.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsOnCooldown.java new file mode 100644 index 000000000..8d0c0d03e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsOnCooldown.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsOnCooldown extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderAbility ability = localStore.originAbility; + + return ability.getCooldownRemainingTicks(localStore.game, caster) > 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsToggleAbilityActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsToggleAbilityActive.java new file mode 100644 index 000000000..029b4b653 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsToggleAbilityActive.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsToggleAbilityActive extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderActiveAbility ability = (ABAbilityBuilderActiveAbility) localStore.originAbility; + return ability.isActive(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "IsToggleAbilityActive(" + + jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ABILITY", JassTextGeneratorType.AbilityHandle) + + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsTransformingToAlternate.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsTransformingToAlternate.java new file mode 100644 index 000000000..5c4e8b9db --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionIsTransformingToAlternate.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionIsTransformingToAlternate extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.TRANSFORMINGTOALT, castId), Boolean.class); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasAutoCast.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasAutoCast.java new file mode 100644 index 000000000..72ef590ea --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasAutoCast.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionWasAutoCast extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), Boolean.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_ISAUTOCAST", JassTextGeneratorType.Boolean); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasAutoCastPreviouslyActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasAutoCastPreviouslyActive.java new file mode 100644 index 000000000..767298eae --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasAutoCastPreviouslyActive.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionWasAutoCastPreviouslyActive extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.WASAUTOCASTON, Boolean.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_WASAUTOCASTON", JassTextGeneratorType.Boolean); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasCastingInterrupted.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasCastingInterrupted.java new file mode 100644 index 000000000..0e5125cae --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/ability/ABConditionWasCastingInterrupted.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.JassTextGeneratorType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionWasCastingInterrupted extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.get(ABLocalStoreKeys.INTERRUPTED, Boolean.class); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return jassTextGenerator.getUserDataExpr("AB_LOCAL_STORE_KEY_INTERRUPTED", JassTextGeneratorType.Boolean); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/attack/ABConditionIsAttackProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/attack/ABConditionIsAttackProjectile.java new file mode 100644 index 000000000..e78310936 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/attack/ABConditionIsAttackProjectile.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; + +public class ABConditionIsAttackProjectile extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class)) + .getWeaponType().isProjectile(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/attack/ABConditionIsAttackRanged.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/attack/ABConditionIsAttackRanged.java new file mode 100644 index 000000000..12b3efe5d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/attack/ABConditionIsAttackRanged.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.attack; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; + +public class ABConditionIsAttackRanged extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, castId), CUnitAttack.class)) + .getWeaponType().isRanged(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetAbilityDataAsBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetAbilityDataAsBoolean.java new file mode 100644 index 000000000..f1fd9af6f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetAbilityDataAsBoolean.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; + +public class ABCallbackGetAbilityDataAsBoolean extends ABBooleanCallback { + + private ABDataFieldLetter dataField; + + @SuppressWarnings("unchecked") + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + + final String data = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getData() + .get(this.dataField.getIndex()); + if (data.equals("-")) { + return false; + } + return Integer.parseInt(data) == 1; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return "GetAbilityDataAsFloatAU(" + jassTextGenerator.getTriggerLocalStore() + ", DATA_FIELD_LETTER_" + + this.dataField.name() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetAbilityUniqueValueBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetAbilityUniqueValueBoolean.java new file mode 100644 index 000000000..8876987f8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetAbilityUniqueValueBoolean.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetAbilityUniqueValueBoolean extends ABBooleanCallback { + + private ABAbilityCallback ability; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, + final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CAbility theAbility = ability.callback(caster, localStore, castId); + Boolean theVal = theAbility.getUniqueValue(keyS, Boolean.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetBuffUniqueValueBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetBuffUniqueValueBoolean.java new file mode 100644 index 000000000..789cd4834 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetBuffUniqueValueBoolean.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackGetBuffUniqueValueBoolean extends ABBooleanCallback { + + private ABBuffCallback buff; + private ABStringCallback key; + + private ABBooleanCallback allowNull; + + @Override + public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final String keyS = key.callback(caster, localStore, castId); + final CBuff theBuff = buff.callback(caster, localStore, castId); + Boolean theVal = theBuff.getUniqueValue(keyS, Boolean.class); + if (theVal != null || (allowNull != null && allowNull.callback(caster, localStore, castId))) { + return theVal; + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetStoredBooleanByKey.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetStoredBooleanByKey.java new file mode 100644 index 000000000..16535bab4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackGetStoredBooleanByKey.java @@ -0,0 +1,38 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABCallbackGetStoredBooleanByKey extends ABBooleanCallback { + + private ABStringCallback key; + private ABBooleanCallback instanceValue; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if ((this.instanceValue == null) || this.instanceValue.callback(caster, localStore, castId)) { + return localStore.get( + ABLocalStoreKeys.combineUserInstanceKey(this.key.callback(caster, localStore, castId), castId), + Boolean.class); + } else { + return localStore.get( + ABLocalStoreKeys.combineUserKey(this.key.callback(caster, localStore, castId), castId), + Boolean.class); + } + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + if (this.instanceValue == null) { + return "GetLocalStoreUserCastBooleanAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ")"; + } + return "GetStoredBooleanAU(" + jassTextGenerator.getTriggerLocalStore() + ", " + + this.key.generateJassEquivalent(jassTextGenerator) + ", " + jassTextGenerator.getCastId() + ", " + + this.instanceValue.generateJassEquivalent(jassTextGenerator) + ")"; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackInlineConditionBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackInlineConditionBoolean.java new file mode 100644 index 000000000..c5fed0457 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackInlineConditionBoolean.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackInlineConditionBoolean extends ABBooleanCallback { + + private ABBooleanCallback condition; + private ABBooleanCallback pass; + private ABBooleanCallback fail; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, int castBoolean) { + if (condition != null && condition.callback(caster, localStore, castBoolean)) { + return pass.callback(caster, localStore, castBoolean); + } + return fail.callback(caster, localStore, castBoolean); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackIntegerToBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackIntegerToBoolean.java new file mode 100644 index 000000000..bd8cdeb8d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackIntegerToBoolean.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackIntegerToBoolean extends ABBooleanCallback { + + private ABIntegerCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return this.value.callback(caster, localStore, castId) != 0; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return this.value.generateJassEquivalent(jassTextGenerator) + " != 0"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackRawBoolean.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackRawBoolean.java new file mode 100644 index 000000000..f4e92db02 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/booleans/ABCallbackRawBoolean.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABCallbackRawBoolean extends ABBooleanCallback { + + private Boolean value; + + @Override + public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return this.value; + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return this.value.toString(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffAlly.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffAlly.java new file mode 100644 index 000000000..11eea609e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffAlly.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; + +public class ABConditionIsBuffAlly extends ABBooleanCallback { + + ABBuffCallback buff; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CBuff theBuff = buff.callback(caster, localStore, castId); + return localStore.game.getPlayer(caster.getPlayerIndex()).hasAlliance(theBuff.getSourceUnit().getPlayerIndex(), + CAllianceType.SHARED_SPELLS); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffEnemy.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffEnemy.java new file mode 100644 index 000000000..2c2cded75 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffEnemy.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; + +public class ABConditionIsBuffEnemy extends ABBooleanCallback { + + ABBuffCallback buff; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CBuff theBuff = buff.callback(caster, localStore, castId); + return !localStore.game.getPlayer(caster.getPlayerIndex()).hasAlliance(theBuff.getSourceUnit().getPlayerIndex(), + CAllianceType.PASSIVE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffMagic.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffMagic.java new file mode 100644 index 000000000..90d08dbda --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffMagic.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsBuffMagic extends ABBooleanCallback { + + ABBuffCallback buff; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CBuff theBuff = buff.callback(caster, localStore, castId); + return theBuff.isMagic(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffNegative.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffNegative.java new file mode 100644 index 000000000..2afd8bee4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffNegative.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsBuffNegative extends ABBooleanCallback { + + ABBuffCallback buff; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CBuff theBuff = buff.callback(caster, localStore, castId); + return !theBuff.isPositive(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffPositive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffPositive.java new file mode 100644 index 000000000..e8d8e956a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/buff/ABConditionIsBuffPositive.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsBuffPositive extends ABBooleanCallback { + + ABBuffCallback buff; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CBuff theBuff = buff.callback(caster, localStore, castId); + return theBuff.isPositive(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsAttackTypeEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsAttackTypeEqual.java new file mode 100644 index 000000000..5e57c5d14 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsAttackTypeEqual.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAttackTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; + +public class ABConditionIsAttackTypeEqual extends ABBooleanCallback { + + private ABAttackTypeCallback attackType1; + private ABAttackTypeCallback attackType2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CAttackType lA = attackType1.callback(caster, localStore, castId); + CAttackType rA = attackType2.callback(caster, localStore, castId); + if (lA == null) { + if (rA == null) { + return true; + } + return false; + } + return lA.equals(rA); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDamageTypeEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDamageTypeEqual.java new file mode 100644 index 000000000..b7b0ce1df --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDamageTypeEqual.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDamageTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; + +public class ABConditionIsDamageTypeEqual extends ABBooleanCallback { + + private ABDamageTypeCallback damageType1; + private ABDamageTypeCallback damageType2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CDamageType lD = damageType1.callback(caster, localStore, castId); + CDamageType rD = damageType2.callback(caster, localStore, castId); + if (lD == null) { + if (rD == null) { + return true; + } + return false; + } + return lD.equals(rD); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDefenseTypeEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDefenseTypeEqual.java new file mode 100644 index 000000000..77ee39e2a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDefenseTypeEqual.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDefenseTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; + +public class ABConditionIsDefenseTypeEqual extends ABBooleanCallback { + + private ABDefenseTypeCallback defenseType1; + private ABDefenseTypeCallback defenseType2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CDefenseType lD = defenseType1.callback(caster, localStore, castId); + CDefenseType rD = defenseType2.callback(caster, localStore, castId); + if (lD == null) { + if (rD == null) { + return true; + } + return false; + } + return lD.equals(rD); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDefenseTypeInList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDefenseTypeInList.java new file mode 100644 index 000000000..b74e80600 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsDefenseTypeInList.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABDefenseTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; + +public class ABConditionIsDefenseTypeInList extends ABBooleanCallback { + + private ABDefenseTypeCallback defenseType; + private List list; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, int castId) { + CDefenseType theType = defenseType.callback(caster, localStore, castId); + for (ABDefenseTypeCallback lType : list) { + if (theType == lType.callback(caster, localStore, castId)) { + return true; + } + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsIdEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsIdEqual.java new file mode 100644 index 000000000..1f952d150 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsIdEqual.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsIdEqual extends ABBooleanCallback { + + private ABIDCallback id1; + private ABIDCallback id2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + War3ID lA = id1.callback(caster, localStore, castId); + War3ID rA = id2.callback(caster, localStore, castId); + if (lA == null) { + if (rA == null) { + return true; + } + return false; + } + return lA.equals(rA); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsMovementTypeEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsMovementTypeEqual.java new file mode 100644 index 000000000..e1618636f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsMovementTypeEqual.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABMovementTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsMovementTypeEqual extends ABBooleanCallback { + + private ABMovementTypeCallback movementType1; + private ABMovementTypeCallback movementType2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + MovementType lD = movementType1.callback(caster, localStore, castId); + MovementType rD = movementType2.callback(caster, localStore, castId); + if (lD == null) { + if (rD == null) { + return true; + } + return false; + } + return lD.equals(rD); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsUnitEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsUnitEqual.java new file mode 100644 index 000000000..68d5d77e9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsUnitEqual.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitEqual extends ABBooleanCallback { + + private ABUnitCallback unit1; + private ABUnitCallback unit2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit lUnit = unit1.callback(caster, localStore, castId); + CUnit rUnit = unit2.callback(caster, localStore, castId); + if (lUnit == null) { + if (rUnit == null) { + return true; + } + return false; + } + return lUnit.equals(rUnit); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsWeaponTypeEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsWeaponTypeEqual.java new file mode 100644 index 000000000..fd572625e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/comparison/ABConditionIsWeaponTypeEqual.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABWeaponTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; + +public class ABConditionIsWeaponTypeEqual extends ABBooleanCallback { + + private ABWeaponTypeCallback weaponType1; + private ABWeaponTypeCallback weaponType2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CWeaponType lD = weaponType1.callback(caster, localStore, castId); + CWeaponType rD = weaponType2.callback(caster, localStore, castId); + if (lD == null) { + if (rD == null) { + return true; + } + return false; + } + return lD.equals(rD); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/cost/ABConditionSuccessfullyChargeResources.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/cost/ABConditionSuccessfullyChargeResources.java new file mode 100644 index 000000000..bbcf9046f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/cost/ABConditionSuccessfullyChargeResources.java @@ -0,0 +1,64 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.cost; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.ABPlayerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; + +public class ABConditionSuccessfullyChargeResources extends ABBooleanCallback { + + private ABUnitCallback unit; + private ABPlayerCallback player; + + private ABIntegerCallback mana; + private ABIntegerCallback gold; + private ABIntegerCallback lumber; + private ABIntegerCallback food; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + CPlayer thePlayer = localStore.game.getPlayer(theUnit.getPlayerIndex()); + if (player != null) { + thePlayer = player.callback(caster, localStore, castId); + } + + int manaCost = 0; + int goldCost = 0; + int lumberCost = 0; + int foodCost = 0; + if (mana != null) { + manaCost = mana.callback(caster, localStore, castId); + } + if (gold != null) { + goldCost = gold.callback(caster, localStore, castId); + } + if (lumber != null) { + lumberCost = lumber.callback(caster, localStore, castId); + } + if (food != null) { + foodCost = food.callback(caster, localStore, castId); + } + + if ((manaCost > 0 && manaCost > theUnit.getMana()) || (goldCost > 0 && goldCost > thePlayer.getGold()) + || (lumberCost > 0 && lumberCost > thePlayer.getLumber()) + || (foodCost > 0 && foodCost > (thePlayer.getFoodCap() - thePlayer.getFoodUsed()))) { + return false; + } + + if (manaCost > 0) + theUnit.chargeMana(manaCost); + theUnit.notifyAbilitiesChanged(); + if (goldCost > 0 || lumberCost > 0) + thePlayer.charge(goldCost, lumberCost); + if (foodCost > 0) + thePlayer.setFoodUsed(thePlayer.getFoodUsed() + foodCost); + return true; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionDoesDestructableHaveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionDoesDestructableHaveBuff.java new file mode 100644 index 000000000..3b005ebec --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionDoesDestructableHaveBuff.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionDoesDestructableHaveBuff extends ABBooleanCallback { + + private ABDestructableCallback dest; + private ABIDCallback id; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CDestructable theDestructable = dest.callback(caster, localStore, castId); + if (theDestructable != null) { + for (CDestructableBuff ability : theDestructable.getBuffs()) { + if ((ability).getAlias() == id.callback(caster, localStore, castId)) { + return true; + } + } + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionDoesDestructableHaveBuffMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionDoesDestructableHaveBuffMatchingCondition.java new file mode 100644 index 000000000..a338db171 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionDoesDestructableHaveBuffMatchingCondition.java @@ -0,0 +1,32 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.destructable; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionDoesDestructableHaveBuffMatchingCondition extends ABBooleanCallback { + + private ABDestructableCallback dest; + private ABBooleanCallback condition; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CDestructable theDestructable = dest.callback(caster, localStore, castId); + if (theDestructable != null) { + for (CDestructableBuff ability : theDestructable.getBuffs()) { + localStore.put(ABLocalStoreKeys.MATCHINGDESTBUFF, ability); + if (condition.callback(caster, localStore, castId)) { + localStore.remove(ABLocalStoreKeys.MATCHINGDESTBUFF); + return true; + } + localStore.remove(ABLocalStoreKeys.MATCHINGDESTBUFF); + } + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionIsTree.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionIsTree.java new file mode 100644 index 000000000..4bd87cc96 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructable/ABConditionIsTree.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.destructable; + +import java.util.EnumSet; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABConditionIsTree extends ABBooleanCallback { + + private ABDestructableCallback dest; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CDestructable theDestructable = dest.callback(caster, localStore, castId); + if (theDestructable != null) { + return theDestructable.canBeTargetedBy(localStore.game, caster, EnumSet.of(CTargetType.TREE)); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructablebuff/ABConditionIsDestructableBuffMagic.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructablebuff/ABConditionIsDestructableBuffMagic.java new file mode 100644 index 000000000..8b99b5b0b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/destructablebuff/ABConditionIsDestructableBuffMagic.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.destructablebuff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff.ABDestructableBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsDestructableBuffMagic extends ABBooleanCallback { + + ABDestructableBuffCallback buff; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CDestructableBuff theBuff = buff.callback(caster, localStore, castId); + return theBuff.isMagic(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantCanDisableDivineShield.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantCanDisableDivineShield.java new file mode 100644 index 000000000..9cc1c2570 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantCanDisableDivineShield.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.game; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionGameplayConstantCanDisableDivineShield extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getGameplayConstants().isCanDisableDivineShield(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantIsDefendCanDeflect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantIsDefendCanDeflect.java new file mode 100644 index 000000000..39ed9871a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantIsDefendCanDeflect.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.game; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionGameplayConstantIsDefendCanDeflect extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getGameplayConstants().isDefendDeflection(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantIsRelativeUpgradeCosts.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantIsRelativeUpgradeCosts.java new file mode 100644 index 000000000..4489563ee --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantIsRelativeUpgradeCosts.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.game; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionGameplayConstantIsRelativeUpgradeCosts extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getGameplayConstants().isRelativeUpgradeCosts(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantSmartAbolishMagic.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantSmartAbolishMagic.java new file mode 100644 index 000000000..8cc26dce2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionGameplayConstantSmartAbolishMagic.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.game; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionGameplayConstantSmartAbolishMagic extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return localStore.game.getGameplayConstants().isAbolishMagicSmartDispel(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionIsTimeOfDayInRange.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionIsTimeOfDayInRange.java new file mode 100644 index 000000000..502b74c81 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/game/ABConditionIsTimeOfDayInRange.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.game; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsTimeOfDayInRange extends ABBooleanCallback { + + private ABFloatCallback startTime; + private ABFloatCallback endTime; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + float st = 0; + float et = Float.MAX_VALUE; + if (startTime != null) { + st = startTime.callback(caster, localStore, castId); + } + if (endTime != null) { + et = endTime.callback(caster, localStore, castId); + } + return st <= et ? localStore.game.getGameTimeOfDay() >= st && localStore.game.getGameTimeOfDay() < et + : localStore.game.getGameTimeOfDay() >= st || localStore.game.getGameTimeOfDay() < et; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionIsItemAbility.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionIsItemAbility.java new file mode 100644 index 000000000..91c1e2deb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionIsItemAbility.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsItemAbility extends ABBooleanCallback { + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + ABAbilityBuilderAbility ability = localStore.originAbility; + + return ability.getItem() != null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionItemHasCharges.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionItemHasCharges.java new file mode 100644 index 000000000..fa9e22fb7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionItemHasCharges.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionItemHasCharges extends ABBooleanCallback { + + private ABItemCallback item; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (item == null) { + ABAbilityBuilderAbility ability = localStore.originAbility; + + return ability.getItem().getCharges() > 0; + } else { + return item.callback(caster, localStore, castId).getCharges() > 0; + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionItemIsCharged.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionItemIsCharged.java new file mode 100644 index 000000000..65a0fea74 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/item/ABConditionItemIsCharged.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.item; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.ABItemCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionItemIsCharged extends ABBooleanCallback { + + private ABItemCallback item; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + if (item == null) { + ABAbilityBuilderAbility ability = localStore.originAbility; + + return ability.getItem().getItemType().getNumberOfCharges() > 0; + } else { + return item.callback(caster, localStore, castId).getItemType().getNumberOfCharges() > 0; + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationDeepWater.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationDeepWater.java new file mode 100644 index 000000000..13f5c51d2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationDeepWater.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.PathingType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsLocationDeepWater extends ABBooleanCallback { + + private ABLocationCallback location; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + return localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.SWIMMABLE) + && !localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.WALKABLE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationFlyingOnly.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationFlyingOnly.java new file mode 100644 index 000000000..4fc115d0a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationFlyingOnly.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.PathingType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsLocationFlyingOnly extends ABBooleanCallback { + + private ABLocationCallback location; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + return localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.FLYABLE) + && !localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.SWIMMABLE) + && !localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.WALKABLE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationPathableForUnitType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationPathableForUnitType.java new file mode 100644 index 000000000..f0c4a3416 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationPathableForUnitType.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.location; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsLocationPathableForUnitType extends ABBooleanCallback { + + ABLocationCallback location; + ABIDCallback unitType; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, int castId) { + War3ID uType = unitType.callback(caster, localStore, castId); + AbilityPointTarget loc = location.callback(caster, localStore, castId); + return localStore.game.getPathingGrid().isPathable(loc.x, loc.y, + localStore.game.getUnitData().getUnitType(uType).getMovementType()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationShallowWater.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationShallowWater.java new file mode 100644 index 000000000..f02aa8720 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationShallowWater.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.PathingType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsLocationShallowWater extends ABBooleanCallback { + + private ABLocationCallback location; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + return localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.SWIMMABLE) + && localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.WALKABLE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationWalkable.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationWalkable.java new file mode 100644 index 000000000..2d3f99d84 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationWalkable.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.PathingType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsLocationWalkable extends ABBooleanCallback { + + private ABLocationCallback location; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + return localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.WALKABLE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationWalkableNonWater.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationWalkableNonWater.java new file mode 100644 index 000000000..1caaa74cb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/location/ABConditionIsLocationWalkableNonWater.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.location; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.PathingType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.ABLocationCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsLocationWalkableNonWater extends ABBooleanCallback { + + private ABLocationCallback location; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + AbilityPointTarget loc = location.callback(caster, localStore, castId); + return !localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.SWIMMABLE) + && localStore.game.getPathingGrid().isPathable(loc.x, loc.y, PathingType.WALKABLE); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionAnd.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionAnd.java new file mode 100644 index 000000000..89b9cc923 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionAnd.java @@ -0,0 +1,39 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.logical; + +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionAnd extends ABBooleanCallback { + + private List conditions; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean result = true; + if (conditions != null) { + for (ABBooleanCallback cond : conditions) { + if (result) { + result = result && cond.callback(caster, localStore, castId); + } + } + } + return result; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String result = ""; + for (int i = 0; i < conditions.size(); i++) { + result += conditions.get(i).generateJassEquivalent(jassTextGenerator); + if (i < (conditions.size() - 1)) { + result += " and "; + } + } + return result; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionBool.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionBool.java new file mode 100644 index 000000000..341b9a610 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionBool.java @@ -0,0 +1,16 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.logical; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionBool extends ABBooleanCallback { + + private ABBooleanCallback bool; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return bool.callback(caster, localStore, castId); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionIsNull.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionIsNull.java new file mode 100644 index 000000000..b575812a1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionIsNull.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.logical; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsNull extends ABBooleanCallback { + + private ABCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value.callback(caster, localStore, castId) == null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionNot.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionNot.java new file mode 100644 index 000000000..9a1d9b5cb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionNot.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.logical; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionNot extends ABBooleanCallback { + + private ABBooleanCallback condition; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return !condition.callback(caster, localStore, castId); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "not " + this.condition.generateJassEquivalent(jassTextGenerator); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionNotNull.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionNotNull.java new file mode 100644 index 000000000..84abaa6e0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionNotNull.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.logical; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionNotNull extends ABBooleanCallback { + + private ABCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return value.callback(caster, localStore, castId) != null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionOr.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionOr.java new file mode 100644 index 000000000..0cd08e850 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/logical/ABConditionOr.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.logical; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionOr extends ABBooleanCallback { + + private List conditions; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + boolean result = false; + if (conditions != null) { + for (ABBooleanCallback cond : conditions) { + if (!result) { + result = result || cond.callback(caster, localStore, castId); + } + } + } + return result; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionIsUnitInGroup.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionIsUnitInGroup.java new file mode 100644 index 000000000..05294d641 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionIsUnitInGroup.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.membership; + +import java.util.Set; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup.ABUnitGroupCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitInGroup extends ABBooleanCallback { + + private ABUnitGroupCallback group; + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Set groupSet = group.callback(caster, localStore, castId); + CUnit rUnit = unit.callback(caster, localStore, castId); + return groupSet.contains(rUnit); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionIsUnitInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionIsUnitInRangeOfUnit.java new file mode 100644 index 000000000..4b67b7d4b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionIsUnitInRangeOfUnit.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.membership; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitInRangeOfUnit extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABUnitCallback target; + private ABFloatCallback range; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + return caster.callback(casterUnit, localStore, castId).canReach( + target.callback(casterUnit, localStore, castId), + range.callback(casterUnit, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionMatchingCorpseExistsInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionMatchingCorpseExistsInRangeOfUnit.java new file mode 100644 index 000000000..30badba79 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionMatchingCorpseExistsInRangeOfUnit.java @@ -0,0 +1,58 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.membership; + +import java.util.List; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitAndRangeComparator; + +public class ABConditionMatchingCorpseExistsInRangeOfUnit extends ABBooleanCallback { + private static final Rectangle recycleRect = new Rectangle(); + + private ABUnitCallback originUnit; + private ABFloatCallback range; + private List conditions; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit originUnitTarget = originUnit.callback(caster, localStore, castId); + Float rangeVal = range.callback(caster, localStore, castId); + + final ABUnitAndRangeComparator ur = new ABUnitAndRangeComparator(); + + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumCorpsesInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal)) { + if (ur.getUnit() == null) { + if (conditions != null) { + boolean result = true; + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), + enumUnit); + for (ABBooleanCallback condition : conditions) { + result = result && condition.callback(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + if (result) { + ur.setUnit(enumUnit); + } + } else { + ur.setUnit(enumUnit); + } + } + } + return false; + } + }); + return ur.getUnit() != null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionMatchingUnitExistsInRangeOfUnit.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionMatchingUnitExistsInRangeOfUnit.java new file mode 100644 index 000000000..ae8f65aec --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/membership/ABConditionMatchingUnitExistsInRangeOfUnit.java @@ -0,0 +1,53 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.membership; + +import com.badlogic.gdx.math.Rectangle; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs.ABUnitAndRangeComparator; + +public class ABConditionMatchingUnitExistsInRangeOfUnit extends ABBooleanCallback { + private static final Rectangle recycleRect = new Rectangle(); + + private ABUnitCallback originUnit; + private ABFloatCallback range; + private ABBooleanCallback condition; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit originUnitTarget = originUnit.callback(caster, localStore, castId); + Float rangeVal = range.callback(caster, localStore, castId); + + final ABUnitAndRangeComparator ur = new ABUnitAndRangeComparator(); + + recycleRect.set(originUnitTarget.getX() - rangeVal, originUnitTarget.getY() - rangeVal, rangeVal * 2, + rangeVal * 2); + localStore.game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (originUnitTarget.canReach(enumUnit, rangeVal)) { + if (ur.getUnit() == null) { + if (condition != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId), + enumUnit); + boolean result = condition.callback(caster, localStore, castId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.MATCHINGUNIT, castId)); + if (result) { + ur.setUnit(enumUnit); + } + } else { + ur.setUnit(enumUnit); + } + } + } + return false; + } + }); + return ur.getUnit() != null; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatEq0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatEq0.java new file mode 100644 index 000000000..5658fb510 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatEq0.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatEq0 extends ABBooleanCallback { + + private ABFloatCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v = value.callback(caster, localStore, castId); + + return v==0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatEqual.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatEqual.java new file mode 100644 index 000000000..c28823d16 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatEqual.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatEqual extends ABBooleanCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v1 = value1.callback(caster, localStore, castId); + Float v2 = value2.callback(caster, localStore, castId); + + return v1.equals(v2); + } + + @Override + public String generateJassEquivalent(final JassTextGenerator jassTextGenerator) { + return this.value1.generateJassEquivalent(jassTextGenerator) + " == " + + this.value2.generateJassEquivalent(jassTextGenerator); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGt.java new file mode 100644 index 000000000..cc67b617f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGt.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatGt extends ABBooleanCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v1 = value1.callback(caster, localStore, castId); + Float v2 = value2.callback(caster, localStore, castId); + + return v1 > v2; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return this.value1.generateJassEquivalent(jassTextGenerator) + " > " + + this.value2.generateJassEquivalent(jassTextGenerator); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGt0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGt0.java new file mode 100644 index 000000000..d63fc5056 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGt0.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatGt0 extends ABBooleanCallback { + + private ABFloatCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v = value.callback(caster, localStore, castId); + return v > 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGte.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGte.java new file mode 100644 index 000000000..2cb6ab749 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatGte.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatGte extends ABBooleanCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v1 = value1.callback(caster, localStore, castId); + Float v2 = value2.callback(caster, localStore, castId); + + return v1 >= v2; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatLt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatLt.java new file mode 100644 index 000000000..44f94bf52 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatLt.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatLt extends ABBooleanCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v1 = value1.callback(caster, localStore, castId); + Float v2 = value2.callback(caster, localStore, castId); + + return v1 < v2; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatLte.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatLte.java new file mode 100644 index 000000000..40ae39bbb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatLte.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatLte extends ABBooleanCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v1 = value1.callback(caster, localStore, castId); + Float v2 = value2.callback(caster, localStore, castId); + + return v1 <= v2; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatNe.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatNe.java new file mode 100644 index 000000000..5c6cde128 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatNe.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatNe extends ABBooleanCallback { + + private ABFloatCallback value1; + private ABFloatCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v1 = value1.callback(caster, localStore, castId); + Float v2 = value2.callback(caster, localStore, castId); + + return !v1.equals(v2); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatNe0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatNe0.java new file mode 100644 index 000000000..154c7b12a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionFloatNe0.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionFloatNe0 extends ABBooleanCallback { + + private ABFloatCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Float v = value.callback(caster, localStore, castId); + + return v!=0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerEq.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerEq.java new file mode 100644 index 000000000..dcbc46baf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerEq.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerEq extends ABBooleanCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value1.callback(caster, localStore, castId); + Integer v2 = value2.callback(caster, localStore, castId); + + return v1.equals(v2); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerEq0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerEq0.java new file mode 100644 index 000000000..83223eb48 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerEq0.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerEq0 extends ABBooleanCallback { + + private ABIntegerCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value.callback(caster, localStore, castId); + return v1 == 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGt.java new file mode 100644 index 000000000..c77a6cc9f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGt.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerGt extends ABBooleanCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value1.callback(caster, localStore, castId); + Integer v2 = value2.callback(caster, localStore, castId); + return v1 > v2; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGt0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGt0.java new file mode 100644 index 000000000..3e75de924 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGt0.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerGt0 extends ABBooleanCallback { + + private ABIntegerCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value.callback(caster, localStore, castId); + return v1 > 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGte.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGte.java new file mode 100644 index 000000000..acccc7887 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerGte.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerGte extends ABBooleanCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value1.callback(caster, localStore, castId); + Integer v2 = value2.callback(caster, localStore, castId); + return v1 >= v2; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerIsEven.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerIsEven.java new file mode 100644 index 000000000..4c9ffc9af --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerIsEven.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerIsEven extends ABBooleanCallback { + + private ABIntegerCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value.callback(caster, localStore, castId); + + return (v1 % 2) == 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerIsOdd.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerIsOdd.java new file mode 100644 index 000000000..de9d55cb6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerIsOdd.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerIsOdd extends ABBooleanCallback { + + private ABIntegerCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value.callback(caster, localStore, castId); + + return (v1 % 2) == 1; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerLt.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerLt.java new file mode 100644 index 000000000..25ec36d38 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerLt.java @@ -0,0 +1,27 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerLt extends ABBooleanCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value1.callback(caster, localStore, castId); + Integer v2 = value2.callback(caster, localStore, castId); + return v1 < v2; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return this.value1.generateJassEquivalent(jassTextGenerator) + " < " + + this.value2.generateJassEquivalent(jassTextGenerator); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerLte.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerLte.java new file mode 100644 index 000000000..357652e9d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerLte.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerLte extends ABBooleanCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value1.callback(caster, localStore, castId); + Integer v2 = value2.callback(caster, localStore, castId); + return v1 <= v2; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerNe.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerNe.java new file mode 100644 index 000000000..83b88f8f9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerNe.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerNe extends ABBooleanCallback { + + private ABIntegerCallback value1; + private ABIntegerCallback value2; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value1.callback(caster, localStore, castId); + Integer v2 = value2.callback(caster, localStore, castId); + return !v1.equals(v2); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerNe0.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerNe0.java new file mode 100644 index 000000000..1c32fd403 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/numeric/ABConditionIntegerNe0.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIntegerNe0 extends ABBooleanCallback { + + private ABIntegerCallback value; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + Integer v1 = value.callback(caster, localStore, castId); + return v1 != 0; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/projectile/ABConditionIsProjectileReflected.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/projectile/ABConditionIsProjectileReflected.java new file mode 100644 index 000000000..ef09e039a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/projectile/ABConditionIsProjectileReflected.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.projectile; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.ABProjectileCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABConditionIsProjectileReflected extends ABBooleanCallback { + + private ABProjectileCallback projectile; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + final CProjectile proj = this.projectile.callback(caster, localStore, castId); + return proj.isReflected(); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "IsProjectileReflected(" + this.projectile.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsDestructableValidTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsDestructableValidTarget.java new file mode 100644 index 000000000..fe0a56edd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsDestructableValidTarget.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.targeting; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.ABDestructableCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABConditionIsDestructableValidTarget extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABDestructableCallback target; + + @SuppressWarnings("unchecked") + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = casterUnit; + + EnumSet targetsAllowed = null; + ABAbilityBuilderAbility ability = localStore.originAbility; + if (ability != null && ability instanceof ABAbilityBuilderActiveAbility) { + targetsAllowed = ((ABAbilityBuilderActiveAbility) ability).getTargetsAllowed(); + } else { + List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + targetsAllowed = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getTargetsAllowed(); + } + + if (targetsAllowed.isEmpty()) { + return true; + } + if (caster != null) { + theCaster = caster.callback(casterUnit, localStore, castId); + } + + return target.callback(casterUnit, localStore, castId).canBeTargetedBy(localStore.game, theCaster, + targetsAllowed); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsPassAllAbilityTargetChecks.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsPassAllAbilityTargetChecks.java new file mode 100644 index 000000000..e7a309acb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsPassAllAbilityTargetChecks.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.targeting; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget.ABWidgetCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; + +public class ABConditionIsPassAllAbilityTargetChecks extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABWidgetCallback target; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = casterUnit; + + if (caster != null) { + theCaster = caster.callback(casterUnit, localStore, castId); + } + + ABAbilityBuilderActiveAbility abil = (ABAbilityBuilderActiveAbility) localStore.originAbility; + final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver + .getInstance().reset(); + + abil.checkCanTarget(localStore.game, theCaster, abil.getBaseOrderId(), + (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), Boolean.class)), + target.callback(casterUnit, localStore, castId), booleanTargetReceiver); + + if (booleanTargetReceiver.isTargetable()) { + return true; + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsUnitPassAllAbilityTargetChecks.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsUnitPassAllAbilityTargetChecks.java new file mode 100644 index 000000000..af6d15bc7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsUnitPassAllAbilityTargetChecks.java @@ -0,0 +1,42 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.targeting; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; + +public class ABConditionIsUnitPassAllAbilityTargetChecks extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABUnitCallback target; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = casterUnit; + CUnit theTarget = target.callback(casterUnit, localStore, castId); + if (theTarget == null) { + return false; + } + if (caster != null) { + theCaster = caster.callback(casterUnit, localStore, castId); + } + + ABAbilityBuilderActiveAbility abil = (ABAbilityBuilderActiveAbility) localStore.originAbility; + final BooleanAbilityTargetCheckReceiver booleanTargetReceiver = BooleanAbilityTargetCheckReceiver + .getInstance().reset(); + + abil.checkCanTarget(localStore.game, theCaster, abil.getBaseOrderId(), + (localStore.get(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ISAUTOCAST, castId), Boolean.class)), theTarget, + booleanTargetReceiver); + + if (booleanTargetReceiver.isTargetable()) { + return true; + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsUnitValidTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsUnitValidTarget.java new file mode 100644 index 000000000..2bee0fb2f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsUnitValidTarget.java @@ -0,0 +1,75 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.targeting; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; + +public class ABConditionIsUnitValidTarget extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABUnitCallback target; + private ABBooleanCallback targetedEffect; + + @SuppressWarnings("unchecked") + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = casterUnit; + + EnumSet targetsAllowed = null; + ABAbilityBuilderAbility ability = localStore.originAbility; + if (ability != null && ability instanceof ABAbilityBuilderActiveAbility) { + targetsAllowed = ((ABAbilityBuilderActiveAbility) ability).getTargetsAllowed(); + } else { + List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + targetsAllowed = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getTargetsAllowed(); + } + + if (targetsAllowed.isEmpty()) { + return true; + } + final CUnit theUnit = this.target.callback(casterUnit, localStore, castId); + if (theUnit == null) { + return false; + } + boolean te = false; + if (this.caster != null) { + theCaster = this.caster.callback(casterUnit, localStore, castId); + } + if (this.targetedEffect != null) { + te = this.targetedEffect.callback(theCaster, localStore, castId); + } + + return theUnit.canBeTargetedBy(localStore.game, theCaster, te, targetsAllowed, + BooleanAbilityTargetCheckReceiver.getInstance().reset()); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String casterExpr; + if (this.caster == null) { + casterExpr = jassTextGenerator.getCaster(); + } else { + casterExpr = this.caster.generateJassEquivalent(jassTextGenerator); + } + String targetedEffectExpr = "false"; + if (this.targetedEffect != null) { + targetedEffectExpr = this.targetedEffect.generateJassEquivalent(jassTextGenerator); + } + return "IsUnitValidTargetAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + casterExpr + ", " + + targetedEffectExpr + ", " + jassTextGenerator.getTriggerLocalStore() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsValidTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsValidTarget.java new file mode 100644 index 000000000..c836d9a4b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/targeting/ABConditionIsValidTarget.java @@ -0,0 +1,66 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.targeting; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget.ABWidgetCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABConditionIsValidTarget extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABWidgetCallback target; + + @SuppressWarnings("unchecked") + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theCaster = casterUnit; + + EnumSet targetsAllowed = null; + ABAbilityBuilderAbility ability = localStore.originAbility; + if (ability != null && ability instanceof ABAbilityBuilderActiveAbility) { + targetsAllowed = ((ABAbilityBuilderActiveAbility) ability).getTargetsAllowed(); + } else { + List levelData = (List) localStore + .get(ABLocalStoreKeys.LEVELDATA); + targetsAllowed = levelData.get(localStore.getLevelDataInstanceLevel(castId)).getTargetsAllowed(); + } + + if (targetsAllowed.isEmpty()) { + return true; + } + if (this.caster != null) { + theCaster = this.caster.callback(casterUnit, localStore, castId); + } + + CWidget widget = this.target.callback(casterUnit, localStore, castId); + if (widget == null) { + return false; + } + + return widget.canBeTargetedBy(localStore.game, theCaster, targetsAllowed); + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String casterExpr; + if (this.caster == null) { + casterExpr = jassTextGenerator.getCaster(); + } else { + casterExpr = this.caster.generateJassEquivalent(jassTextGenerator); + } + return "IsValidTargetAU(" + this.target.generateJassEquivalent(jassTextGenerator) + ", " + casterExpr + ", " + + jassTextGenerator.getTriggerLocalStore() + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/timer/ABConditionIsTimerActive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/timer/ABConditionIsTimerActive.java new file mode 100644 index 000000000..0c87f8926 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/timer/ABConditionIsTimerActive.java @@ -0,0 +1,17 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer.ABTimerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsTimerActive extends ABBooleanCallback { + + private ABTimerCallback timer; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + return timer.callback(caster, localStore, castId).isRunning(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/uniqueflag/ABConditionDoesAbilityHaveUniqueFlag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/uniqueflag/ABConditionDoesAbilityHaveUniqueFlag.java new file mode 100644 index 000000000..e8af31c2e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/uniqueflag/ABConditionDoesAbilityHaveUniqueFlag.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.uniqueflag; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.ABAbilityCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionDoesAbilityHaveUniqueFlag extends ABBooleanCallback { + + ABAbilityCallback ability; + ABStringCallback flag; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CAbility theAbility = ability.callback(caster, localStore, castId); + return theAbility.hasUniqueFlag(flag.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/uniqueflag/ABConditionDoesBuffHaveUniqueFlag.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/uniqueflag/ABConditionDoesBuffHaveUniqueFlag.java new file mode 100644 index 000000000..0b8f55379 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/uniqueflag/ABConditionDoesBuffHaveUniqueFlag.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.uniqueflag; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.ABBuffCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionDoesBuffHaveUniqueFlag extends ABBooleanCallback { + + ABBuffCallback buff; + ABStringCallback flag; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CBuff theBuff = buff.callback(caster, localStore, castId); + return theBuff.hasUniqueFlag(flag.callback(caster, localStore, castId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/ABConditionIsUnitType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/ABConditionIsUnitType.java new file mode 100644 index 000000000..d189c158b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/ABConditionIsUnitType.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitType extends ABBooleanCallback { + + private ABUnitCallback unit; + private ABIDCallback unitType; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.getTypeId().equals(unitType.callback(caster, localStore, castId)); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/ability/ABConditionDoesUnitHaveAbilityMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/ability/ABConditionDoesUnitHaveAbilityMatchingCondition.java new file mode 100644 index 000000000..233ebc176 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/ability/ABConditionDoesUnitHaveAbilityMatchingCondition.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.ability; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionDoesUnitHaveAbilityMatchingCondition extends ABBooleanCallback { + + private ABUnitCallback unit; + private ABBooleanCallback condition; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + for (CAbility ability : theUnit.getAbilities()) { + if (CAbilityCategory.BUFF != ability.getAbilityCategory()) { + localStore.put(ABLocalStoreKeys.MATCHINGABILITY, ability); + if (condition.callback(caster, localStore, castId)) { + localStore.remove(ABLocalStoreKeys.MATCHINGABILITY); + return true; + } + } + } + } + localStore.remove(ABLocalStoreKeys.MATCHINGABILITY); + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitEnemy.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitEnemy.java new file mode 100644 index 000000000..6c0bc421e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitEnemy.java @@ -0,0 +1,42 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.alliance; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; + +public class ABConditionIsUnitEnemy extends ABBooleanCallback { + + private ABUnitCallback self; + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = unit.callback(casterUnit, localStore, castId); + CUnit theCaster = casterUnit; + if (this.self != null) { + theCaster = this.self.callback(casterUnit, localStore, castId); + } + + if (theUnit != null) { + return !localStore.game.getPlayer(theUnit.getPlayerIndex()).hasAlliance(theCaster.getPlayerIndex(), + CAllianceType.PASSIVE); + } + return false; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String casterExpr; + if (this.self == null) { + casterExpr = jassTextGenerator.getCaster(); + } else { + casterExpr = this.self.generateJassEquivalent(jassTextGenerator); + } + return "IsUnitEnemy(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", GetOwningPlayer(" + casterExpr + + "))"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitFriend.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitFriend.java new file mode 100644 index 000000000..b864821be --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitFriend.java @@ -0,0 +1,42 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.alliance; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; + +public class ABConditionIsUnitFriend extends ABBooleanCallback { + + private ABUnitCallback self; + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = unit.callback(casterUnit, localStore, castId); + CUnit theCaster = casterUnit; + if (this.self != null) { + theCaster = this.self.callback(casterUnit, localStore, castId); + } + + if (theUnit != null) { + return localStore.game.getPlayer(theUnit.getPlayerIndex()).hasAlliance(theCaster.getPlayerIndex(), + CAllianceType.SHARED_SPELLS); + } + return false; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String casterExpr; + if (this.self == null) { + casterExpr = jassTextGenerator.getCaster(); + } else { + casterExpr = this.self.generateJassEquivalent(jassTextGenerator); + } + return "IsUnitEnemy(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", GetOwningPlayer(" + casterExpr + + "))"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitShareSpells.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitShareSpells.java new file mode 100644 index 000000000..8f542268a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/alliance/ABConditionIsUnitShareSpells.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.alliance; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; + +public class ABConditionIsUnitShareSpells extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = unit.callback(casterUnit, localStore, castId); + CUnit theCaster = casterUnit; + if (caster != null) { + theCaster = caster.callback(casterUnit, localStore, castId); + } + + if (theUnit != null) { + return localStore.game.getPlayer(theUnit.getPlayerIndex()).hasAlliance(theCaster.getPlayerIndex(), CAllianceType.SHARED_SPELLS); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/behavior/ABConditionIsCurrentBehaviorCategoryInList.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/behavior/ABConditionIsCurrentBehaviorCategoryInList.java new file mode 100644 index 000000000..124d3ba78 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/behavior/ABConditionIsCurrentBehaviorCategoryInList.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.behavior; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; + +public class ABConditionIsCurrentBehaviorCategoryInList extends ABBooleanCallback { + + private ABUnitCallback unit; + private List list; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + CBehavior beh = theUnit.getCurrentBehavior(); + CBehaviorCategory cat = CBehaviorCategory.IDLE; + if (beh != null) { + cat = beh.getBehaviorCategory(); + } + return list.contains(cat); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/buff/ABConditionDoesUnitHaveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/buff/ABConditionDoesUnitHaveBuff.java new file mode 100644 index 000000000..e1bcd6f1b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/buff/ABConditionDoesUnitHaveBuff.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionDoesUnitHaveBuff extends ABBooleanCallback { + + private ABUnitCallback unit; + private ABIDCallback id; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + for (CAbility ability : theUnit.getAbilities()) { + if (ability instanceof CBuff) { + if (((CBuff) ability).getAlias() == id.callback(caster, localStore, castId)) { + return true; + } + } + } + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/buff/ABConditionDoesUnitHaveBuffMatchingCondition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/buff/ABConditionDoesUnitHaveBuffMatchingCondition.java new file mode 100644 index 000000000..9b1e06f88 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/buff/ABConditionDoesUnitHaveBuffMatchingCondition.java @@ -0,0 +1,37 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABConditionDoesUnitHaveBuffMatchingCondition extends ABBooleanCallback { + + private ABUnitCallback unit; + private ABBooleanCallback condition; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + for (CAbility ability : theUnit.getAbilities()) { + if (ability instanceof CBuff) { + localStore.put(ABLocalStoreKeys.MATCHINGBUFF, ability); + if (condition.callback(caster, localStore, castId)) { + localStore.remove(ABLocalStoreKeys.MATCHINGBUFF); + return true; + } + localStore.remove(ABLocalStoreKeys.MATCHINGBUFF); + } + } + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitBuilding.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitBuilding.java new file mode 100644 index 000000000..3b0c85030 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitBuilding.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitBuilding extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isBuilding(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHero.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHero.java new file mode 100644 index 000000000..b958d764d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHero.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitHero extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isHero(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHeroDuration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHeroDuration.java new file mode 100644 index 000000000..9343b3734 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHeroDuration.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; + +public class ABConditionIsUnitHeroDuration extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = unit.callback(caster, localStore, castId); + if (theUnit != null && (theUnit.isHero() || theUnit.isUnitType(CUnitTypeJass.RESISTANT))) { + return true; + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHidden.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHidden.java new file mode 100644 index 000000000..4dc9db924 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitHidden.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitHidden extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isHidden(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitMagicImmune.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitMagicImmune.java new file mode 100644 index 000000000..1a0e1f293 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitMagicImmune.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitMagicImmune extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isMagicImmune(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitMorphImmune.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitMorphImmune.java new file mode 100644 index 000000000..090131ba2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitMorphImmune.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitMorphImmune extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isMorphImmune(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitSummoned.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitSummoned.java new file mode 100644 index 000000000..449dea158 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/classification/ABConditionIsUnitSummoned.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; + +public class ABConditionIsUnitSummoned extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isUnitType(CUnitTypeJass.SUMMONED); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitAlive.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitAlive.java new file mode 100644 index 000000000..f48963473 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitAlive.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitAlive extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return !theUnit.isDead(); + } + return true; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitDead.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitDead.java new file mode 100644 index 000000000..c0face8e4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitDead.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitDead extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isDead(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitMaxHp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitMaxHp.java new file mode 100644 index 000000000..f3b01693d --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitMaxHp.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitMaxHp extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.getLife() >= theUnit.getMaximumLife(); + } + return false; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "IsUnitMaxHpAU(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitMaxMp.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitMaxMp.java new file mode 100644 index 000000000..7ae790978 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitMaxMp.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitMaxMp extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.getMana() >= theUnit.getMaximumMana(); + } + return false; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + return "IsUnitMaxMpAU(" + this.unit.generateJassEquivalent(jassTextGenerator) + ")"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitPolymorphed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitPolymorphed.java new file mode 100644 index 000000000..2e152f014 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitPolymorphed.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; + +public class ABConditionIsUnitPolymorphed extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isUnitType(CUnitTypeJass.POLYMORPHED); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitSleeping.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitSleeping.java new file mode 100644 index 000000000..7001f678f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitSleeping.java @@ -0,0 +1,25 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; + +public class ABConditionIsUnitSleeping extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isUnitType(CUnitTypeJass.SLEEPING); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitUpgrading.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitUpgrading.java new file mode 100644 index 000000000..e0b5bf71f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitUpgrading.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitUpgrading extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isUpgrading(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitVisible.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitVisible.java new file mode 100644 index 000000000..30ba0d75a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/state/ABConditionIsUnitVisible.java @@ -0,0 +1,40 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state; + +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitVisible extends ABBooleanCallback { + + private ABUnitCallback caster; + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit casterUnit, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = unit.callback(casterUnit, localStore, castId); + CUnit theCaster = casterUnit; + if (this.caster != null) { + theCaster = this.caster.callback(casterUnit, localStore, castId); + } + + if (theUnit != null) { + return theUnit.isVisible(localStore.game, theCaster.getPlayerIndex()); + } + return false; + } + + @Override + public String generateJassEquivalent(JassTextGenerator jassTextGenerator) { + String casterExpr; + if (this.caster == null) { + casterExpr = jassTextGenerator.getCaster(); + } else { + casterExpr = this.caster.generateJassEquivalent(jassTextGenerator); + } + return "IsUnitEnemy(" + this.unit.generateJassEquivalent(jassTextGenerator) + ", GetOwningPlayer(" + casterExpr + + "))"; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitConstructing.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitConstructing.java new file mode 100644 index 000000000..f6201b8dc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitConstructing.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.tech; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitConstructing extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isConstructing(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitConstructingOrUpgrading.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitConstructingOrUpgrading.java new file mode 100644 index 000000000..281b46763 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitConstructingOrUpgrading.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.tech; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitConstructingOrUpgrading extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isConstructingOrUpgrading(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitTraining.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitTraining.java new file mode 100644 index 000000000..3d1d496f9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionIsUnitTraining.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.tech; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionIsUnitTraining extends ABBooleanCallback { + + private ABUnitCallback unit; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.isBuildQueueActive(); + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionUnitHasResearch.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionUnitHasResearch.java new file mode 100644 index 000000000..2bdbd8b8c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/behavior/condition/unit/tech/ABConditionUnitHasResearch.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.tech; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.ABUnitCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionUnitHasResearch extends ABBooleanCallback { + + private ABUnitCallback unit; + private ABIDCallback researchId; + + @Override + public Boolean callback(CUnit caster, ABLocalDataStore localStore, final int castId) { + CUnit theUnit = caster; + if (unit != null) { + theUnit = unit.callback(caster, localStore, castId); + } + if (theUnit != null) { + return theUnit.getLevelOfAppliedUpgrade(researchId.callback(caster, localStore, castId)) > 0; + } + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABBuff.java new file mode 100644 index 000000000..76dbc775a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABBuff.java @@ -0,0 +1,246 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractCBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityActivationReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.AbilityTargetCheckReceiver; + +public abstract class ABBuff extends AbstractCBuff { + protected final static int TIMEDLIFE = 0b1; + protected final static int NEGATIVE = 0b10; + protected final static int DISPELLABLE = 0b100; + protected final static int LEVELED = 0b1000; + protected final static int HERO = 0b10000; + protected final static int PHYSICAL = 0b100000; + protected final static int MAGIC = 0b1000000; + protected final static int AURA = 0b10000000; + protected final static int STACKS = 0b100000000; + + protected int flags = DISPELLABLE; + + protected ABLocalDataStore localStore; + protected List uniqueFlags = null; + private String visibilityGroup = null; + private CAbility sourceAbil; + protected CUnit sourceUnit; + + public ABBuff(int handleId, War3ID code, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit) { + super(handleId, code, alias); + this.localStore = localStore; + this.sourceAbil = sourceAbility; + this.sourceUnit = sourceUnit; + } + + @Override + public void onCancelFromQueue(final CSimulation game, final CUnit unit, final int orderId) { + } + + @Override + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, + final CWidget target) { + return null; + } + + @Override + public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder, + final AbilityPointTarget point) { + return null; + } + + @Override + public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId, boolean autoOrder) { + return null; + } + + @Override + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final CWidget target, final AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + } + + @Override + public void checkCanTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final AbilityPointTarget target, final AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + } + + @Override + public void checkCanTargetNoTarget(final CSimulation game, final CUnit unit, final int orderId, boolean autoOrder, + final AbilityTargetCheckReceiver receiver) { + receiver.orderIdNotAccepted(); + } + + @Override + protected void innerCheckCanUse(final CSimulation game, final CUnit unit, final int orderId, + final AbilityActivationReceiver receiver) { + receiver.notAnActiveAbility(); + } + + @Override + public T visit(final CAbilityVisitor visitor) { + return visitor.accept(this); + } + + @Override + public boolean hasUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + return this.uniqueFlags.contains(flag); + } + return false; + } + + public void addUniqueFlag(String flag) { + if (this.uniqueFlags == null) { + this.uniqueFlags = new ArrayList<>(); + } + this.uniqueFlags.add(flag); + } + + public void removeUniqueFlag(String flag) { + if (this.uniqueFlags != null) { + this.uniqueFlags.remove(flag); + } + } + + @SuppressWarnings("unchecked") + @Override + public T getUniqueValue(String key, Class cls) { + Object o = this.localStore.get(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + if (o != null && o.getClass() == cls) { + return (T) o; + } + return null; + } + + public void addUniqueValue(Object item, String key) { + this.localStore.put(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId()), item); + } + + public void removeUniqueValue(String key) { + this.localStore.remove(ABLocalStoreKeys.combineUniqueValueKey(key, this.getHandleId())); + } + + public void cleanUpUniqueValues() { + final Set keySet = new HashSet<>(localStore.keySet()); + String search = ABLocalStoreKeys.combineUniqueValueKey("", this.getHandleId()); + for (final String key : keySet) { + if (key.contains(search)) { + localStore.remove(key); + } + } + } + + public void setVisibilityGroup(String visibilityGroup) { + this.visibilityGroup = visibilityGroup; + } + + @Override + public String getVisibilityGroup() { + return this.visibilityGroup; + } + + public void setTimedLifeBar(boolean timedLife) { + this.flags = timedLife ? this.flags | TIMEDLIFE : this.flags & ~TIMEDLIFE; + } + + @Override + public boolean isTimedLifeBar() { + return ((this.flags & TIMEDLIFE) != 0); + } + + public void setPositive(boolean positive) { + this.flags = positive ? this.flags & ~NEGATIVE : this.flags | NEGATIVE; + } + + @Override + public boolean isPositive() { + return ((this.flags & NEGATIVE) == 0); + } + + public void setLeveled(boolean leveled) { + this.flags = leveled ? this.flags | LEVELED : this.flags & ~LEVELED; + } + + @Override + public boolean isLeveled() { + return ((this.flags & LEVELED) != 0); + } + + public void setDispellable(boolean dispellable) { + this.flags = dispellable ? this.flags | DISPELLABLE : this.flags & ~DISPELLABLE; + } + + @Override + public boolean isDispellable() { + return ((this.flags & DISPELLABLE) != 0); + } + + public void setHero(boolean hero) { + this.flags = hero ? this.flags | HERO : this.flags & ~HERO; + } + + @Override + public boolean isHero() { + return ((this.flags & HERO) != 0); + } + + public void setPhysical(boolean physical) { + this.flags = physical ? this.flags | PHYSICAL : this.flags & ~PHYSICAL; + } + + @Override + public boolean isPhysical() { + return ((this.flags & PHYSICAL) != 0); + } + + public void setMagic(boolean magic) { + this.flags = magic ? this.flags | MAGIC : this.flags & ~MAGIC; + } + + @Override + public boolean isMagic() { + return ((this.flags & MAGIC) != 0); + } + + public void setAura(boolean aura) { + this.flags = aura ? this.flags | AURA : this.flags & ~AURA; + } + + @Override + public boolean isAura() { + return ((this.flags & AURA) != 0); + } + + public void setStacks(boolean stacks) { + this.flags = stacks ? this.flags | STACKS : this.flags & ~STACKS; + } + + public boolean isStacks() { + return ((this.flags & STACKS) != 0); + } + + @Override + public CAbility getSourceAbility() { + return this.sourceAbil; + } + + @Override + public CUnit getSourceUnit() { + return this.sourceUnit; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABDestructableBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABDestructableBuff.java new file mode 100644 index 000000000..0828c769c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABDestructableBuff.java @@ -0,0 +1,169 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CDestructableBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABDestructableBuff implements CDestructableBuff { + + protected static int TIMEDLIFE = 0b1; + protected static int NEGATIVE = 0b10; + protected static int DISPELLABLE = 0b100; + protected static int HERO = 0b1000; + protected static int MAGIC = 0b10000; + protected static int PHYSICAL = 0b100000; + protected static int AURA = 0b1000000; + protected int flags = 0b0; + + private int handleId; + private War3ID alias; + private int level; + + protected ABLocalDataStore localStore; + protected int castId = 0; + private CUnit caster; + + private List onAddActions; + private List onRemoveActions; + private List onDeathActions; + + public ABDestructableBuff(int handleId, War3ID alias, int level, ABLocalDataStore localStore, + List onAddActions, List onRemoveActions, List onDeathActions, + final int castId, CUnit caster, boolean dispellable) { + this.handleId = handleId; + this.alias = alias; + this.level = level; + this.castId = castId; + this.localStore = localStore; + this.onAddActions = onAddActions; + this.onRemoveActions = onRemoveActions; + this.onDeathActions = onDeathActions; + this.caster = caster; + this.setDispellable(dispellable); + this.setHero(caster.isHero()); + } + + @Override + public int getHandleId() { + return this.handleId; + } + + @Override + public War3ID getAlias() { + return this.alias; + } + + @Override + public void onAdd(CSimulation game, CDestructable dest) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BUFFEDDEST, castId), this); + if (onAddActions != null) { + for (ABAction action : onAddActions) { + action.runAction(this.caster, localStore, castId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BUFFEDDEST, castId)); + } + + @Override + public void onRemove(CSimulation game, CDestructable dest) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BUFFEDDEST, castId), this); + if (onRemoveActions != null) { + for (ABAction action : onRemoveActions) { + action.runAction(this.caster, localStore, castId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BUFFEDDEST, castId)); + } + + @Override + public void onDeath(CSimulation game, CDestructable dest) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BUFFEDDEST, castId), this); + if (onDeathActions != null) { + for (ABAction action : onDeathActions) { + action.runAction(this.caster, localStore, castId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BUFFEDDEST, castId)); + } + + @Override + public int getLevel() { + return this.level; + } + + @Override + public void setLevel(int level) { + this.level = level; + } + + public void setTimedLife(boolean timedLife) { + this.flags = timedLife ? this.flags | TIMEDLIFE : this.flags & ~TIMEDLIFE; + } + + @Override + public boolean isTimedLife() { + return ((this.flags & TIMEDLIFE) != 0); + } + + public void setPositive(boolean positive) { + this.flags = positive ? this.flags & ~NEGATIVE : this.flags | NEGATIVE; + } + + @Override + public boolean isPositive() { + return ((this.flags & NEGATIVE) == 0); + } + + public void setDispellable(boolean dispellable) { + this.flags = dispellable ? this.flags | DISPELLABLE : this.flags & ~DISPELLABLE; + } + + @Override + public boolean isDispellable() { + return ((this.flags & DISPELLABLE) != 0); + } + + public void setHero(boolean hero) { + this.flags = hero ? this.flags | HERO : this.flags & ~HERO; + } + + @Override + public boolean isHero() { + return ((this.flags & HERO) != 0); + } + + public void setMagic(boolean magic) { + this.flags = magic ? this.flags | MAGIC : this.flags & ~MAGIC; + } + + @Override + public boolean isMagic() { + return ((this.flags & MAGIC) != 0); + } + + public void setPhysical(boolean physical) { + this.flags = physical ? this.flags | PHYSICAL : this.flags & ~PHYSICAL; + } + + @Override + public boolean isPhysical() { + return ((this.flags & PHYSICAL) != 0); + } + + public void setAura(boolean aura) { + this.flags = aura ? this.flags | AURA : this.flags & ~AURA; + } + + @Override + public boolean isAura() { + return ((this.flags & AURA) != 0); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericArtBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericArtBuff.java similarity index 75% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericArtBuff.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericArtBuff.java index 471f72803..30a39953e 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/buff/ABGenericArtBuff.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericArtBuff.java @@ -1,8 +1,10 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.buff; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; import com.etheller.warsmash.util.War3ID; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; @@ -11,8 +13,9 @@ public class ABGenericArtBuff extends ABBuff { private SimulationRenderComponent sfx; private SimulationRenderComponent lsfx; - public ABGenericArtBuff(int handleId, War3ID alias) { - super(handleId, alias, alias); + public ABGenericArtBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit) { + super(handleId, alias, alias, localStore, sourceAbility, sourceUnit); this.setIconShowing(false); } @@ -48,11 +51,6 @@ public float getDurationMax() { return 0; } - @Override - public boolean isTimedLifeBar() { - return false; - } - @Override public void onTick(CSimulation game, CUnit unit) { } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericAuraBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericAuraBuff.java new file mode 100644 index 000000000..970df22f0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericAuraBuff.java @@ -0,0 +1,65 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.HashMap; +import java.util.Map; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; + +public class ABGenericAuraBuff extends ABBuff { + private Map fx; + + private CUnit caster; + + public ABGenericAuraBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit caster, boolean leveled, boolean positive) { + super(handleId, alias, alias, localStore, sourceAbility, caster); + this.caster = caster; + this.fx = new HashMap<>(); + this.setHero(caster.isHero()); + this.setLeveled(leveled); + this.setPositive(positive); + this.setAura(true); + this.setLevel(null, null, 1); + } + + @Override + public void onAdd(final CSimulation game, final CUnit unit) { + if (unit != this.caster) { + this.fx.put(unit.getHandleId(), unit.addNonStackingFx(game, "aura", getAlias(), CEffectType.TARGET)); + } + } + + @Override + public void onRemove(final CSimulation game, final CUnit unit) { + NonStackingFx theFx = this.fx.get(unit.getHandleId()); + if (theFx != null) { + this.fx.remove(unit.getHandleId()); + unit.removeNonStackingFx(game, theFx); + } + } + + @Override + public float getDurationRemaining(CSimulation game, final CUnit unit) { + return 0; + } + + @Override + public float getDurationMax() { + return 0; + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + } + + @Override + public void onDeath(CSimulation game, CUnit cUnit) { + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericPermanentBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericPermanentBuff.java new file mode 100644 index 000000000..ca466158b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericPermanentBuff.java @@ -0,0 +1,58 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABGenericPermanentBuff extends ABBuff { + + public ABGenericPermanentBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, boolean showIcon, boolean leveled, boolean positive) { + super(handleId, alias, alias, localStore, sourceAbility, sourceUnit); + this.setIconShowing(showIcon); + this.setLeveled(leveled); + this.setPositive(positive); + } + + public ABGenericPermanentBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, boolean leveled, boolean positive) { + super(handleId, alias, alias, localStore, sourceAbility, sourceUnit); + this.setLeveled(leveled); + this.setPositive(positive); + } + + protected abstract void onBuffAdd(CSimulation game, CUnit unit); + + @Override + public void onAdd(final CSimulation game, final CUnit unit) { + this.onBuffAdd(game, unit); + } + + protected abstract void onBuffRemove(CSimulation game, CUnit unit); + + @Override + public void onRemove(final CSimulation game, final CUnit unit) { + this.onBuffRemove(game, unit); + } + + @Override + public float getDurationRemaining(CSimulation game, final CUnit unit) { + return 0; + } + + @Override + public float getDurationMax() { + return 0; + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + } + + @Override + public void onDeath(CSimulation game, CUnit cUnit) { + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericTimedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericTimedBuff.java new file mode 100644 index 000000000..a0c8f88a1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABGenericTimedBuff.java @@ -0,0 +1,90 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public abstract class ABGenericTimedBuff extends ABBuff { + private final float duration; + private int currentTick = 0; + private int expireTick; + + public ABGenericTimedBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, boolean leveled, boolean positive, + boolean dispellable) { + super(handleId, alias, alias, localStore, sourceAbility, sourceUnit); + this.setTimedLifeBar(showTimedLifeBar); + this.duration = duration; + this.setLeveled(leveled); + this.setPositive(positive); + this.setDispellable(dispellable); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ABGenericTimedBuff other = (ABGenericTimedBuff) obj; + return this.getAlias() == other.getAlias() && this.getLevel() == other.getLevel() && !this.isStacks() + && !other.isStacks(); + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + this.onBuffAdd(game, unit); + if (this.duration == 0) { + expireTick = Integer.MAX_VALUE; + } else { + final int durationTicks = (int) (this.duration / WarsmashConstants.SIMULATION_STEP_TIME); + expireTick = durationTicks; + } + } + + protected abstract void onBuffAdd(CSimulation game, CUnit unit); + + @Override + public void onRemove(CSimulation game, CUnit unit) { + this.onBuffRemove(game, unit); + this.cleanUpUniqueValues(); + } + + protected abstract void onBuffRemove(CSimulation game, CUnit unit); + + protected abstract void onBuffExpire(CSimulation game, CUnit unit); + + @Override + public float getDurationMax() { + return this.duration; + } + + @Override + public float getDurationRemaining(final CSimulation game, final CUnit unit) { + final int remaining = Math.max(0, this.expireTick - this.currentTick); + return remaining * WarsmashConstants.SIMULATION_STEP_TIME; + } + + @Override + public void onTick(final CSimulation game, final CUnit caster) { + this.currentTick++; + if (this.currentTick > this.expireTick) { + this.onBuffExpire(game, caster); + caster.remove(game, this); + } + } + + @Override + public void onDeath(final CSimulation game, final CUnit cUnit) { + cUnit.remove(game, this); + } + + public void updateExpiration(final CSimulation game, final CUnit unit) { + this.currentTick = 0; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABPermanentPassiveBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABPermanentPassiveBuff.java new file mode 100644 index 000000000..c2101b29a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABPermanentPassiveBuff.java @@ -0,0 +1,98 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABPermanentPassiveBuff extends ABGenericPermanentBuff { + + private List onAddActions; + private List onRemoveActions; + + private boolean showFx = true; + private boolean playSfx = false; + + private CEffectType artType = CEffectType.TARGET; + private NonStackingFx fx; + private SimulationRenderComponent sfx; + private SimulationRenderComponent lsfx; + + protected int castId = 0; + + public ABPermanentPassiveBuff(int handleId, War3ID alias, CAbility sourceAbility, CUnit sourceUnit, + ABLocalDataStore localStore, List onAddActions, List onRemoveActions, boolean showIcon, + final int castId, boolean leveled, boolean positive) { + this(handleId, alias, sourceAbility, sourceUnit, localStore, onAddActions, onRemoveActions, castId, leveled, + positive); + this.setIconShowing(showIcon); + } + + public ABPermanentPassiveBuff(int handleId, War3ID alias, CAbility sourceAbility, CUnit sourceUnit, + ABLocalDataStore localStore, List onAddActions, List onRemoveActions, final int castId, + boolean leveled, boolean positive) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, leveled, positive); + this.onAddActions = onAddActions; + this.onRemoveActions = onRemoveActions; + this.castId = castId; + } + + public void setArtType(CEffectType artType) { + this.artType = artType; + } + + public void setShowFx(boolean showFx) { + this.showFx = showFx; + } + + public void setPlaySfx(boolean playSfx) { + this.playSfx = playSfx; + } + + @Override + protected void onBuffAdd(CSimulation game, CUnit unit) { + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.getAlias() != null) { + if (showFx) { + this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), artType); + } + if (playSfx) { + this.sfx = game.unitSoundEffectEvent(unit, getAlias()); + this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); + } + } + if (onAddActions != null) { + for (ABAction action : onAddActions) { + action.runAction(unit, localStore, castId); + } + } + } + + @Override + protected void onBuffRemove(CSimulation game, CUnit unit) { + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.sfx != null) { + this.sfx.remove(); + } + if (this.lsfx != null) { + this.lsfx.remove(); + } + if (onRemoveActions != null) { + for (ABAction action : onRemoveActions) { + action.runAction(unit, localStore, castId); + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTargetingBuff.java new file mode 100644 index 000000000..7d9b38742 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTargetingBuff.java @@ -0,0 +1,42 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABTargetingBuff extends ABBuff { + public ABTargetingBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit) { + super(handleId, alias, alias, localStore, sourceAbility, sourceUnit); + this.setIconShowing(false); + } + + @Override + public float getDurationRemaining(CSimulation game, CUnit unit) { + return 0; + } + + @Override + public float getDurationMax() { + return 0; + } + + @Override + public void onAdd(CSimulation game, CUnit unit) { + } + + @Override + public void onRemove(CSimulation game, CUnit unit) { + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + } + + @Override + public void onDeath(CSimulation game, CUnit cUnit) { + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedArtBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedArtBuff.java new file mode 100644 index 000000000..698d1449c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedArtBuff.java @@ -0,0 +1,64 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABTimedArtBuff extends ABGenericTimedBuff { + private NonStackingFx fx; + private SimulationRenderComponent sfx; + private SimulationRenderComponent lsfx; + private CEffectType artType = CEffectType.TARGET; + + public ABTimedArtBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showIcon, boolean leveled, boolean positive, + boolean dispellable) { + this(handleId, alias, localStore, sourceAbility, sourceUnit, duration, leveled, positive, dispellable); + this.setIconShowing(showIcon); + } + + public ABTimedArtBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean leveled, boolean positive, boolean dispellable) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, false, leveled, positive, dispellable); + } + + public void setArtType(CEffectType artType) { + this.artType = artType; + } + + @Override + protected void onBuffAdd(CSimulation game, CUnit unit) { + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + this.fx = null; + } + if (this.getAlias() != null) { + this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), artType); + this.sfx = game.unitSoundEffectEvent(unit, getAlias()); + this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); + } + } + + @Override + protected void onBuffRemove(CSimulation game, CUnit unit) { + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.sfx != null) { + this.sfx.remove(); + } + if (this.lsfx != null) { + this.lsfx.remove(); + } + } + + @Override + protected void onBuffExpire(CSimulation game, CUnit unit) { + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedBuff.java new file mode 100644 index 000000000..84982bafb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedBuff.java @@ -0,0 +1,146 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.List; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABTimedBuff extends ABGenericTimedBuff { + + private List onAddActions; + private List onRemoveActions; + private List onExpireActions; + + private CEffectType artType = CEffectType.TARGET; + private NonStackingFx fx; + private SimulationRenderComponent sfx; + private SimulationRenderComponent lsfx; + + protected int castId = 0; + + private List stateMods = null; + private List statBuffs = null; + + public ABTimedBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, boolean showIcon, final int castId, + final boolean leveled, final boolean positive, final boolean dispellable) { + this(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, castId, leveled, positive, dispellable); + this.setIconShowing(showIcon); + } + + public ABTimedBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, final int castId, final boolean leveled, + final boolean positive, final boolean dispellable) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, leveled, positive, + dispellable); + this.onAddActions = onAddActions; + this.onRemoveActions = onRemoveActions; + this.onExpireActions = onExpireActions; + this.castId = castId; + + if (localStore.originAbility != null) { + this.setLevel(null, null, localStore.originAbility.getLevel()); + } else { + this.setLevel(null, null, 1); + } + } + + public void setArtType(CEffectType artType) { + this.artType = artType; + } + + @Override + protected void onBuffAdd(CSimulation game, CUnit unit) { + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.getAlias() != null) { + if (artType != null) { + this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), artType); + } + this.sfx = game.unitSoundEffectEvent(unit, getAlias()); + this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); + } + if (this.statBuffs != null) { + for (NonStackingStatBuff buff : this.statBuffs) { + unit.addNonStackingStatBuff(game, buff); + } + } + if (this.stateMods != null) { + for (StateModBuff mod : this.stateMods) { + unit.addStateModBuff(mod); + unit.computeUnitState(game, mod.getBuffType()); + } + } + if (onAddActions != null) { + localStore.put(ABLocalStoreKeys.BUFF, this); + for (ABAction action : onAddActions) { + action.runAction(unit, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.BUFF); + } + } + + @Override + protected void onBuffRemove(CSimulation game, CUnit unit) { + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.sfx != null) { + this.sfx.remove(); + } + if (this.lsfx != null) { + this.lsfx.remove(); + } + if (onRemoveActions != null) { + localStore.put(ABLocalStoreKeys.BUFF, this); + for (ABAction action : onRemoveActions) { + action.runAction(unit, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.BUFF); + } + if (this.statBuffs != null) { + for (NonStackingStatBuff buff : this.statBuffs) { + unit.removeNonStackingStatBuff(game, buff); + } + } + if (this.stateMods != null) { + for (StateModBuff mod : this.stateMods) { + unit.removeStateModBuff(mod); + unit.computeUnitState(game, mod.getBuffType()); + } + } + } + + @Override + protected void onBuffExpire(CSimulation game, CUnit unit) { + if (onExpireActions != null) { + localStore.put(ABLocalStoreKeys.BUFF, this); + for (ABAction action : onExpireActions) { + action.runAction(unit, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.BUFF); + } + } + + public void setStateMods(List stateMods) { + this.stateMods = stateMods; + } + + public void setStatBuffs(List statBuffs) { + this.statBuffs = statBuffs; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedInstantTransformationBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedInstantTransformationBuff.java new file mode 100644 index 000000000..9a5bb637f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedInstantTransformationBuff.java @@ -0,0 +1,72 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABDelayInstantTransformationTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABTimedInstantTransformationBuff extends ABGenericTimedBuff { + + private OnTransformationActions actions; + private ABAbilityBuilderPassiveAbility abil; + private CUnitType targetType; + private boolean keepRatios; + private boolean addAlternateTagAfter; + private boolean perm; + private float dur; + private float transTime; + + public ABTimedInstantTransformationBuff(int handleId, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, OnTransformationActions actions, War3ID alias, float duration, + ABAbilityBuilderPassiveAbility ability, CUnitType newType, final boolean keepRatios, + boolean addAlternateTagAfter, boolean permanent, float transformationDuration) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, true, false, true, false); + this.setIconShowing(false); + this.actions = actions; + this.abil = ability; + this.targetType = newType; + this.keepRatios = keepRatios; + this.addAlternateTagAfter = addAlternateTagAfter; + this.perm = permanent; + this.dur = transformationDuration; + } + + @Override + protected void onBuffAdd(CSimulation game, CUnit unit) { + } + + @Override + protected void onBuffRemove(CSimulation game, CUnit unit) { + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + if (unit.isHero()) { + ABTransformationHandler.instantTransformation(localStore, unit, targetType, keepRatios, actions, abil, + addAlternateTagAfter, perm, true); + unit.remove(game, this); + } + } + + @Override + protected void onBuffExpire(CSimulation game, CUnit unit) { + if (dur > 0) { + ABTransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); + new ABDelayInstantTransformationTimer(sourceUnit, localStore, unit, actions, addAlternateTagAfter, + transTime, null, targetType, keepRatios, abil, null, transTime, 0).start(game); + } else { + ABTransformationHandler.instantTransformation(localStore, unit, targetType, keepRatios, actions, abil, + addAlternateTagAfter, perm, true); + } + unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this.abil, null); + unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this.abil, null); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedPausedExpirationBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedPausedExpirationBuff.java new file mode 100644 index 000000000..7221a3cf8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedPausedExpirationBuff.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.List; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABTimedPausedExpirationBuff extends ABTimedBuff implements CPausedTickingBuff { + + public ABTimedPausedExpirationBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, boolean showIcon, final int castId, + final boolean leveled, final boolean positive, final boolean dispellable) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, showIcon, castId, leveled, positive, dispellable); + } + + public ABTimedPausedExpirationBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, final int castId, final boolean leveled, + final boolean positive, final boolean dispellable) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, castId, leveled, positive, dispellable); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTargetingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTargetingBuff.java new file mode 100644 index 000000000..b253857eb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTargetingBuff.java @@ -0,0 +1,28 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABTimedTargetingBuff extends ABGenericTimedBuff { + public ABTimedTargetingBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, false, false, true, false); + this.setIconShowing(false); + } + + @Override + protected void onBuffAdd(CSimulation game, CUnit unit) { + } + + @Override + protected void onBuffRemove(CSimulation game, CUnit unit) { + } + + @Override + protected void onBuffExpire(CSimulation game, CUnit unit) { + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingBuff.java new file mode 100644 index 000000000..8f59e77e2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingBuff.java @@ -0,0 +1,48 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABTimedTickingBuff extends ABTimedBuff { + + private List onTickActions; + + public ABTimedTickingBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, List onTickActions, + boolean showIcon, final int castId, final boolean leveled, final boolean positive, + final boolean dispellable) { + this(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, onTickActions, castId, leveled, positive, dispellable); + this.setIconShowing(showIcon); + } + + public ABTimedTickingBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, List onTickActions, + final int castId, final boolean leveled, final boolean positive, final boolean dispellable) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, castId, leveled, positive, dispellable); + this.onTickActions = onTickActions; + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + if (onTickActions != null) { + localStore.put(ABLocalStoreKeys.BUFF, this); + for (ABAction action : onTickActions) { + action.runAction(unit, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.BUFF); + } + super.onTick(game, unit); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingPausedBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingPausedBuff.java new file mode 100644 index 000000000..51d45e2aa --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingPausedBuff.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABTimedTickingPausedBuff extends ABTimedBuff implements CPausedTickingBuff { + + private List onTickActions; + + public ABTimedTickingPausedBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, List onTickActions, + boolean showIcon, final int castId, final boolean leveled, final boolean positive, + final boolean dispellable) { + this(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, onTickActions, castId, leveled, positive, dispellable); + this.setIconShowing(showIcon); + } + + public ABTimedTickingPausedBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, List onTickActions, + final int castId, final boolean leveled, final boolean positive, final boolean dispellable) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, castId, leveled, positive, dispellable); + this.onTickActions = onTickActions; + } + + @Override + public void onTick(CSimulation game, CUnit unit) { + if (onTickActions != null) { + localStore.put(ABLocalStoreKeys.BUFF, this); + for (ABAction action : onTickActions) { + action.runAction(unit, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.BUFF); + } + if (!unit.isPaused()) { + super.onTick(game, unit); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingPostDeathBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingPostDeathBuff.java new file mode 100644 index 000000000..5c4bd7683 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTickingPostDeathBuff.java @@ -0,0 +1,36 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABTimedTickingPostDeathBuff extends ABTimedTickingBuff { + + public ABTimedTickingPostDeathBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, List onTickActions, + boolean showIcon, final int castId, final boolean leveled, final boolean positive, + final boolean dispellable) { + this(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, onTickActions, castId, leveled, positive, dispellable); + this.setIconShowing(showIcon); + } + + public ABTimedTickingPostDeathBuff(int handleId, War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, float duration, boolean showTimedLifeBar, List onAddActions, + List onRemoveActions, List onExpireActions, List onTickActions, + final int castId, final boolean leveled, final boolean positive, final boolean dispellable) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, showTimedLifeBar, onAddActions, + onRemoveActions, onExpireActions, onTickActions, castId, leveled, positive, dispellable); + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTransformationBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTransformationBuff.java new file mode 100644 index 000000000..b6fe85ee6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/ABTimedTransformationBuff.java @@ -0,0 +1,126 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorFinishTransformation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABOrderStartTransformation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABDelayInstantTransformationTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABTimedTransformationBuff extends ABGenericTimedBuff { + + private OnTransformationActions actions; + private ABAbilityBuilderAbility abil; + private CUnitType targetType; + private boolean keepRatios; + private boolean addAlternateTagAfter; + private boolean perm; + private float dur; + private float transTime; + private float landTime; + private float atlAdDelay; + private float altAdTime; + private boolean imLand; + private boolean imTakeOff; + private boolean instantTransformation; + + public ABTimedTransformationBuff(int handleId, ABLocalDataStore localStore, CAbility sourceAbility, CUnit sourceUnit, + OnTransformationActions actions, War3ID alias, float duration, ABAbilityBuilderAbility ability, + CUnitType newType, final boolean keepRatios, boolean addAlternateTagAfter, boolean permanent, + float transformationDuration, float transformationTime, float landingDelay, float altitudeAdjustmentDelay, + float altitudeAdjustmentDuration, boolean immediateLanding, boolean immediateTakeoff) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, true, false, true, false); + this.setIconShowing(false); + this.actions = actions; + this.abil = ability; + this.targetType = newType; + this.keepRatios = keepRatios; + this.addAlternateTagAfter = addAlternateTagAfter; + this.perm = permanent; + this.dur = transformationDuration; + this.transTime = transformationTime; + this.landTime = landingDelay; + this.atlAdDelay = altitudeAdjustmentDelay; + this.altAdTime = altitudeAdjustmentDuration; + this.imLand = immediateLanding; + this.imTakeOff = immediateTakeoff; + this.instantTransformation = false; + } + + public ABTimedTransformationBuff(int handleId, ABLocalDataStore localStore, CAbility sourceAbility, CUnit sourceUnit, + OnTransformationActions actions, War3ID alias, float duration, ABAbilityBuilderAbility ability, + CUnitType newType, boolean addAlternateTagAfter, boolean permanent, float transformationDuration) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, true, false, true, false); + this.setIconShowing(false); + this.actions = actions; + this.abil = ability; + this.targetType = newType; + this.addAlternateTagAfter = addAlternateTagAfter; + this.perm = permanent; + this.dur = transformationDuration; + this.instantTransformation = true; + } + + @Override + protected void onBuffAdd(CSimulation game, CUnit unit) { + } + + @Override + protected void onBuffRemove(CSimulation game, CUnit unit) { + } + + @Override + public void onDeath(CSimulation game, CUnit unit) { + if (unit.isHero()) { + ABTransformationHandler.instantTransformation(localStore, unit, targetType, keepRatios, actions, abil, + addAlternateTagAfter, perm, true); + unit.remove(game, this); + } + } + + @Override + protected void onBuffExpire(CSimulation game, CUnit unit) { + int visibleOrderId = -1; + int transformId = -1; + if (abil instanceof ABAbilityBuilderActiveAbility) { + ABAbilityBuilderActiveAbility actabil = (ABAbilityBuilderActiveAbility) abil; + if (actabil.isToggleOn()) { + actabil.deactivate(game, unit); + } + visibleOrderId = addAlternateTagAfter ? actabil.getBaseOrderId() : actabil.getOffOrderId(); + transformId = actabil.getBaseOrderId(); + } + unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CHANNEL, this.abil, null); + unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_CAST, this.abil, null); + unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_EFFECT, this.abil, null); + if (instantTransformation) { + if (dur > 0) { + ABTransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); + new ABDelayInstantTransformationTimer(sourceUnit, localStore, unit, actions, addAlternateTagAfter, + transTime, null, targetType, keepRatios, abil, null, transTime, 0).start(game); + } else { + ABTransformationHandler.instantTransformation(localStore, unit, targetType, keepRatios, actions, abil, + addAlternateTagAfter, perm, true); + } + unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_FINISH, this.abil, null); + unit.fireSpellEvents(game, JassGameEventsWar3.EVENT_UNIT_SPELL_ENDCAST, this.abil, null); + } else { + this.localStore.put(ABLocalStoreKeys.PREVIOUSBEHAVIOR, unit.getCurrentBehavior()); + unit.order(game, new ABOrderStartTransformation( + new ABBehaviorFinishTransformation(sourceUnit, localStore, unit, abil, targetType, keepRatios, + actions, addAlternateTagAfter, visibleOrderId, perm, dur, transTime, landTime, atlAdDelay, + altAdTime, imLand, imTakeOff, this.getAlias(), targetType, instantTransformation), + transformId), false); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/CPausedTickingBuff.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/CPausedTickingBuff.java new file mode 100644 index 000000000..b056f3006 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/CPausedTickingBuff.java @@ -0,0 +1,8 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; + +public interface CPausedTickingBuff { + public void onTick(CSimulation game, CUnit unit); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/defaultbuffs/ABBuffSlow.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/defaultbuffs/ABBuffSlow.java new file mode 100644 index 000000000..c0ba64fc6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/defaultbuffs/ABBuffSlow.java @@ -0,0 +1,104 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.defaultbuffs; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABGenericTimedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABBuffSlow extends ABGenericTimedBuff { + private static NonStackingStatBuff STANDARD_ATTACK_DEBUFF; + private static NonStackingStatBuff STANDARD_MOVE_DEBUFF; + + private NonStackingStatBuff attackSpeedDebuff; + private NonStackingStatBuff moveSpeedDebuff; + + private NonStackingFx fx; + private SimulationRenderComponent sfx; + private SimulationRenderComponent lsfx; + + public ABBuffSlow(final CSimulation game, final int handleId, final War3ID alias, ABLocalDataStore localStore, + CAbility sourceAbility, CUnit sourceUnit, final float duration, boolean leveled) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, false, leveled, false, false); + if (STANDARD_ATTACK_DEBUFF == null) { + STANDARD_ATTACK_DEBUFF = new NonStackingStatBuff(NonStackingStatBuffType.ATKSPD, "genericSlow", + -1 * game.getGameplayConstants().getFrostAttackSpeedDecrease()); + } + if (STANDARD_MOVE_DEBUFF == null) { + STANDARD_MOVE_DEBUFF = new NonStackingStatBuff(NonStackingStatBuffType.MVSPDPCT, "genericSlow", + -1 * game.getGameplayConstants().getFrostMoveSpeedDecrease()); + } + this.attackSpeedDebuff = STANDARD_ATTACK_DEBUFF; + this.moveSpeedDebuff = STANDARD_MOVE_DEBUFF; + } + + public ABBuffSlow(final int handleId, final War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, final float duration, final float attackSpeedReductionPercent, + final float moveSpeedReductionPercent, boolean leveled) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, false, leveled, false, false); + this.attackSpeedDebuff = new NonStackingStatBuff(NonStackingStatBuffType.ATKSPD, "genericSlow", + -1 * attackSpeedReductionPercent); + this.moveSpeedDebuff = new NonStackingStatBuff(NonStackingStatBuffType.MVSPDPCT, "genericSlow", + -1 * moveSpeedReductionPercent); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ABBuffSlow other = (ABBuffSlow) obj; + return this.attackSpeedDebuff.getValue() == other.attackSpeedDebuff.getValue() + && this.moveSpeedDebuff.getValue() == other.moveSpeedDebuff.getValue(); + } + + @Override + protected void onBuffAdd(final CSimulation game, final CUnit unit) { + unit.addNonStackingStatBuff(game, attackSpeedDebuff); + unit.addNonStackingStatBuff(game, moveSpeedDebuff); + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.getAlias() != null) { + this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), CEffectType.TARGET); + this.sfx = game.unitSoundEffectEvent(unit, getAlias()); + this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); + } + + float[] color = game.getUnitVertexColor(unit); + color[0] *= 0.6; + color[1] *= 0.6; + game.changeUnitVertexColor(unit, color[0], color[1], color[2]); + } + + @Override + protected void onBuffRemove(final CSimulation game, final CUnit unit) { + unit.removeNonStackingStatBuff(game, attackSpeedDebuff); + unit.removeNonStackingStatBuff(game, moveSpeedDebuff); + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.sfx != null) { + this.sfx.remove(); + } + if (this.lsfx != null) { + this.lsfx.remove(); + } + game.changeUnitVertexColor(unit, 1, 1, 1); + } + + @Override + protected void onBuffExpire(CSimulation game, CUnit unit) { + // Do Nothing + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/defaultbuffs/ABBuffStun.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/defaultbuffs/ABBuffStun.java new file mode 100644 index 000000000..f4f75ffa0 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/buff/defaultbuffs/ABBuffStun.java @@ -0,0 +1,72 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.defaultbuffs; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABGenericTimedBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingFx; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuffType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABBuffStun extends ABGenericTimedBuff { + private static StateModBuff stunBuff = new StateModBuff(StateModBuffType.STUN, 1); + + private NonStackingFx fx; + private SimulationRenderComponent sfx; + private SimulationRenderComponent lsfx; + + public ABBuffStun(final int handleId, final War3ID alias, ABLocalDataStore localStore, CAbility sourceAbility, + CUnit sourceUnit, final float duration, final boolean leveled) { + super(handleId, alias, localStore, sourceAbility, sourceUnit, duration, false, leveled, false, false); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + return true; + } + + @Override + protected void onBuffAdd(final CSimulation game, final CUnit unit) { + unit.addStateModBuff(stunBuff); + unit.computeUnitState(game, stunBuff.getBuffType()); + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.getAlias() != null) { + this.fx = unit.addNonStackingFx(game, getAlias().asStringValue(), getAlias(), CEffectType.TARGET); + this.sfx = game.unitSoundEffectEvent(unit, getAlias()); + this.lsfx = game.unitLoopSoundEffectEvent(unit, getAlias()); + } + } + + @Override + protected void onBuffRemove(final CSimulation game, final CUnit unit) { + unit.removeStateModBuff(stunBuff); + unit.computeUnitState(game, stunBuff.getBuffType()); + if (this.fx != null) { + unit.removeNonStackingFx(game, this.fx); + } + if (this.sfx != null) { + this.sfx.remove(); + } + if (this.lsfx != null) { + this.lsfx.remove(); + } + } + + @Override + protected void onBuffExpire(CSimulation game, CUnit unit) { + // Do Nothing + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABAbilityBuilderGsonBuilder.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABAbilityBuilderGsonBuilder.java new file mode 100644 index 000000000..843b576a2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABAbilityBuilderGsonBuilder.java @@ -0,0 +1,1691 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.ability.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.abilitydata.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.attackmodifier.internal.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.behavior.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.buff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.damage.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.datastore.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructable.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.destructablebuff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.timeofday.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.events.widget.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.floatingtext.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.group.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.lightning.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.sound.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.splat.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.fx.terrain.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.gamestate.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.item.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.destructable.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.iterator.unit.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.list.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.order.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.player.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.projectile.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.reaction.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.stats.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.structural.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.timer.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniqueflag.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.uniquevalue.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.animation.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.art.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.movement.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.stats.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.transformation.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unit.worker.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitgroup.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalaction.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcallback.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.attack.internalcondition.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior.internalcallback.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.behavior.internalcondition.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken.internalaction.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.damagetaken.internalcondition.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.death.internalaction.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.evasion.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction.internalaction.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.reaction.internalcallback.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.sharedinternalactions.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.sharedinternalcallbacks.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitlisteners.state.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitqueue.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.unitstate.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.action.vision.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.ability.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attack.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.attacksettings.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.buff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructable.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.destructablebuff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.timeevent.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.event.widgetevent.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.fx.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.item.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.integer.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.list.location.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.listener.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.location.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.longs.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.player.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.projectile.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statbuff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.statemod.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.target.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.timer.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unit.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitgroup.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.unitqueue.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.visionmodifier.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.widget.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ability.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.attack.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.booleans.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.buff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.comparison.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.cost.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.destructable.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.destructablebuff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.game.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.item.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.location.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.logical.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.membership.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.numeric.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.projectile.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.targeting.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.timer.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.uniqueflag.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.ability.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.alliance.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.behavior.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.buff.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.classification.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.state.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.unit.tech.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.typeadapters.RuntimeTypeAdapterFactory; + +@SuppressWarnings({ "unchecked", "rawtypes" }) +public abstract class ABAbilityBuilderGsonBuilder { + + private static void registerAbilityCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetStoredAbilityByKey.class, "getStoredAbilityByKey") + .registerSubtype(ABCallbackInlineConditionAbility.class, "inlineConditionAbility") + .registerSubtype(ABCallbackGetPartnerAbility.class, "getPartnerAbility") + .registerSubtype(ABCallbackGetReactionAbility.class, "getReactionAbility") + .registerSubtype(ABCallbackGetLastCreatedAbility.class, "getLastCreatedAbility") + .registerSubtype(ABCallbackGetMatchingAbility.class, "getMatchingAbility") + .registerSubtype(ABCallbackGetThisAbility.class, "getThisAbility") + .registerSubtype(ABCallbackGetAbilityById.class, "getAbilityById") + + .registerSubtype(ABCallbackGetBuffSourceAbility.class, "getBuffSourceAbility") + + .registerSubtype(ABCallbackArgumentAbility.class, "argumentAbility") + .registerSubtype(ABCallbackReuseAbility.class, "reuseAbility") + .registerSubtype(ABCallbackReuseAbilityWithArguments.class, "reuseAbilityWithArguments"); + + } + + private static void registerAttackModifierCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedAttackModifier.class, + "getLastCreatedAttackModifier") + .registerSubtype(ABCallbackGetStoredAttackModifierByKey.class, + "getStoredAttackModifierByKey"); + } + + private static void registerAttackSettingsCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedAttackSettings.class, + "getLastCreatedAttackSettings") + .registerSubtype(ABCallbackGetStoredAttackSettingsByKey.class, + "getStoredAttackSettingsByKey") + .registerSubtype(ABCallbackGetCurrentAttackSettings.class, + "getCurrentAttackSettings"); + } + + private static void registerAbilityEffectReactionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedAbilityEffectReactionListener.class, + "getLastCreatedAbilityEffectReactionListener") + .registerSubtype(ABCallbackGetStoredAbilityEffectReactionListenerByKey.class, + "getStoredAbilityEffectReactionListenerByKey"); + } + + private static void registerAbilityProjReactionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedAbilityProjReactionListener.class, + "getLastCreatedAbilityProjReactionListener") + .registerSubtype(ABCallbackGetStoredAbilityProjReactionListenerByKey.class, + "getStoredAbilityProjReactionListenerByKey"); + } + + private static void registerAttackProjReactionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedAttackProjReactionListener.class, + "getLastCreatedAttackProjReactionListener") + .registerSubtype(ABCallbackGetStoredAttackProjReactionListenerByKey.class, + "getStoredAttackProjReactionListenerByKey"); + } + + private static void registerAttackPostDamageListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedAttackPostDamageListener.class, + "getLastCreatedAttackPostDamageListener") + .registerSubtype(ABCallbackGetStoredAttackPostDamageListenerByKey.class, + "getStoredAttackPostDamageListenerByKey"); + } + + private static void registerAttackPreDamageListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedAttackPreDamageListener.class, + "getLastCreatedAttackPreDamageListener") + .registerSubtype(ABCallbackGetStoredAttackPreDamageListenerByKey.class, + "getStoredAttackPreDamageListenerByKey"); + } + + private static void registerBehaviorChangeListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedBehaviorChangeListener.class, + "getLastCreatedBehaviorChangeListener") + .registerSubtype(ABCallbackGetStoredBehaviorChangeListenerByKey.class, + "getStoredBehaviorChangeListenerByKey"); + } + + private static void registerBooleanCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackRawBoolean.class, "rawBoolean") + .registerSubtype(ABCallbackGetStoredBooleanByKey.class, "getStoredBooleanByKey") + .registerSubtype(ABCallbackInlineConditionBoolean.class, "inlineConditionBoolean") + .registerSubtype(ABCallbackGetAbilityDataAsBoolean.class, "getAbilityDataAsBoolean") + .registerSubtype(ABCallbackGetAbilityUniqueValueBoolean.class, "getAbilityUniqueValueBoolean") + .registerSubtype(ABCallbackGetBuffUniqueValueBoolean.class, "getBuffUniqueValueBoolean") + + .registerSubtype(ABCallbackIntegerToBoolean.class, "i2b") + + .registerSubtype(ABCallbackArgumentBoolean.class, "argumentBoolean") + .registerSubtype(ABCallbackReuseBoolean.class, "reuseBoolean") + .registerSubtype(ABCallbackReuseBooleanWithArguments.class, "reuseBooleanWithArguments") + ; + } + + private static void registerBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetStoredBuffByKey.class, "getStoredBuffByKey") + .registerSubtype(ABCallbackInlineConditionBuff.class, "inlineConditionBuff") + .registerSubtype(ABCallbackThisBuff.class, "thisBuff") + .registerSubtype(ABCallbackGetLastCreatedBuff.class, "getLastCreatedBuff") + .registerSubtype(ABCallbackEnumBuff.class, "enumBuff") + .registerSubtype(ABCallbackGetMatchingBuff.class, "getMatchingBuff") + + .registerSubtype(ABCallbackGetBuffById.class, "getBuffById") + + .registerSubtype(ABCallbackArgumentBuff.class, "argumentBuff") + .registerSubtype(ABCallbackReuseBuff.class, "reuseBuff") + .registerSubtype(ABCallbackReuseBuffWithArguments.class, "reuseBuffWithArguments"); + } + + private static void registerDamageTakenListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedDamageTakenListener.class, "getLastCreatedDamageTakenListener") + .registerSubtype(ABCallbackGetStoredDamageTakenListenerByKey.class, + "getStoredDamageTakenListenerByKey"); + } + + private static void registerDamageTakenModificationListenerCallbacks( + RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedDamageTakenModificationListener.class, + "getLastCreatedDamageTakenModificationListener") + .registerSubtype(ABCallbackGetStoredDamageTakenModificationListenerByKey.class, + "getStoredDamageTakenModificationListenerByKey"); + } + + private static void registerDeathReplacementEffectCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedDeathReplacement.class, "getLastCreatedDeathReplacement") + .registerSubtype(ABCallbackGetStoredDeathReplacementByKey.class, "getStoredDeathReplacementByKey"); + } + + private static void registerDestructableCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetStoredDestructableByKey.class, "getStoredDestructableByKey") + .registerSubtype(ABCallbackInlineConditionDestructable.class, "inlineConditionDestructable") + .registerSubtype(ABCallbackGetLastCreatedDestructable.class, "getLastCreatedDestructable") + .registerSubtype(ABCallbackGetEnumDestructable.class, "getEnumDestructable") + .registerSubtype(ABCallbackGetAbilityTargetedDestructable.class, "getAbilityTargetedDestructable") + .registerSubtype(ABCallbackGetAttackedDestructable.class, "getAttackedDestructable") + .registerSubtype(ABCallbackGetProjectileHitDestructable.class, "getProjectileHitDestructable") + + .registerSubtype(ABCallbackArgumentDestructable.class, "argumentDestructable") + .registerSubtype(ABCallbackReuseDestructable.class, "reuseDestructable") + .registerSubtype(ABCallbackReuseDestructableWithArguments.class, "reuseDestructableWithArguments"); + } + + private static void registerDestructableBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedDestructableBuff.class, "getLastCreatedDestructableBuff") + .registerSubtype(ABCallbackGetStoredDestructableBuffByKey.class, "getStoredDestructableBuffByKey") + .registerSubtype(ABCallbackInlineConditionDestructableBuff.class, "inlineConditionDestructableBuff") + + .registerSubtype(ABCallbackEnumDestructableBuff.class, "enumDestructableBuff") + .registerSubtype(ABCallbackMatchingDestructableBuff.class, "matchingDestructableBuff") + .registerSubtype(ABCallbackArgumentDestructableBuff.class, "argumentDestructableBuff") + .registerSubtype(ABCallbackReuseDestructableBuff.class, "reuseDestructableBuff") + .registerSubtype(ABCallbackReuseDestructableBuffWithArguments.class, "reuseDestructableBuffWithArguments"); + } + + private static void registerEvasionListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedEvasionListener.class, "getLastCreatedEvasionListener") + .registerSubtype(ABCallbackGetStoredEvasionListenerByKey.class, "getStoredEvasionListenerByKey"); + } + + private static void registerFloatCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetAbilityArea.class, "getAbilityArea") + .registerSubtype(ABCallbackGetAbilityDuration.class, "getAbilityDuration") + .registerSubtype(ABCallbackGetAbilityCastTime.class, "getAbilityCastTime") + .registerSubtype(ABCallbackGetAbilityCastRange.class, "getAbilityCastRange") + .registerSubtype(ABCallbackGetAbilityHeroDuration.class, "getAbilityHeroDuration") + .registerSubtype(ABCallbackGetAbilityCooldown.class, "getAbilityCooldown") + .registerSubtype(ABCallbackGetAbilityProjectileSpeed.class, "getAbilityProjectileSpeed") + + .registerSubtype(ABCallbackGetBuffDurationElapsed.class, "getBuffDurationElapsed") + + .registerSubtype(ABCallbackOneGameTick.class, "oneGameTick") + + .registerSubtype(ABCallbackRawFloat.class, "rawFloat") + .registerSubtype(ABCallbackIntToFloat.class, "i2f") + .registerSubtype(ABCallbackNegativeFloat.class, "negativeFloat") + .registerSubtype(ABCallbackPi.class, "pi").registerSubtype(ABCallbackCos.class, "cos") + .registerSubtype(ABCallbackSin.class, "sin") + .registerSubtype(ABCallbackTan.class, "tan") + .registerSubtype(ABCallbackDegToRad.class, "degToRad") + + .registerSubtype(ABCallbackFMaxValue.class, "fMaxValue") + + .registerSubtype(ABCallbackGetStoredFloatByKey.class, "getStoredFloatByKey") + .registerSubtype(ABCallbackInlineConditionFloat.class, "inlineConditionFloat") + .registerSubtype(ABCallbackGetAbilityDataAsFloat.class, "getAbilityDataAsFloat") + .registerSubtype(ABCallbackGetAbilityUniqueValueFloat.class, "getAbilityUniqueValueFloat") + .registerSubtype(ABCallbackGetBuffUniqueValueFloat.class, "getBuffUniqueValueFloat") + + .registerSubtype(ABCallbackRandomFloat.class, "randomFloat") + .registerSubtype(ABCallbackRandomBoundedFloat.class, "randomBoundedFloat") + .registerSubtype(ABCallbackGetUnitLocationX.class, "getUnitLocationX") + .registerSubtype(ABCallbackGetUnitLocationY.class, "getUnitLocationY") + .registerSubtype(ABCallbackGetLocationX.class, "getLocationX") + .registerSubtype(ABCallbackGetLocationY.class, "getLocationY") + .registerSubtype(ABCallbackGetUnitFacing.class, "getUnitFacing") + .registerSubtype(ABCallbackGetUnitAcquisitionRange.class, "getUnitAcquisitionRange") + .registerSubtype(ABCallbackGetUnitCastPoint.class, "getUnitCastPoint") + .registerSubtype(ABCallbackGetUnitCurrentMana.class, "getUnitCurrentMana") + .registerSubtype(ABCallbackGetUnitInitialMana.class, "getUnitInitialMana") + .registerSubtype(ABCallbackGetUnitCurrentHp.class, "getUnitCurrentHp") + + .registerSubtype(ABCallbackGetAngleBetweenLocations.class, "getAngleBetweenLocations") + .registerSubtype(ABCallbackGetDistanceBetweenLocations.class, "getDistanceBetweenLocations") + .registerSubtype(ABCallbackGetDistanceBetweenUnits.class, "getDistanceBetweenUnits") + .registerSubtype(ABCallbackTicksForDuration.class, "ticksForDuration") + + .registerSubtype(ABCallbackGetRawTotalDamageDealt.class, "getRawTotalDamageDealt") + .registerSubtype(ABCallbackGetFinalTotalDamageDealt.class, "getFinalTotalDamageDealt") + .registerSubtype(ABCallbackGetAttackBaseDamage.class, "getAttackBaseDamage") + .registerSubtype(ABCallbackGetReactionAttackProjectileDamage.class, "getReactionAttackProjectileDamage") + + .registerSubtype(ABCallbackArgumentFloat.class, "argumentFloat") + .registerSubtype(ABCallbackReuseFloat.class, "reuseFloat") + .registerSubtype(ABCallbackReuseFloatWithArguments.class, "reuseFloatWithArguments") + + ; + } + + private static void registerGenericFloatCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackAddFloat.class, "f+") + .registerSubtype(ABCallbackSubtractFloat.class, "f-") + .registerSubtype(ABCallbackMultiplyFloat.class, "f*") + .registerSubtype(ABCallbackDivideFloat.class, "f/") + .registerSubtype(ABCallbackMinFloat.class, "fMin") + .registerSubtype(ABCallbackMaxFloat.class, "fMax") + .registerSubtype(ABCallbackCeilFloat.class, "ceil") + .registerSubtype(ABCallbackFloorFloat.class, "floor"); + } + + private static void registerSpecialFloatCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackAddFloat.class, "f+") + .registerSubtype(ABCallbackSubtractFloat.class, "f-").registerSubtype(ABCallbackMultiplyFloat.class, "f*") + .registerSubtype(ABCallbackDivideFloat.class, "f/") + .registerSubtype(ABCallbackMinFloat.class, "fMin").registerSubtype(ABCallbackMaxFloat.class, "fMax") + .registerSubtype(ABCallbackCeilFloat.class, "ceil") + .registerSubtype(ABCallbackFloorFloat.class, "floor"); + } + + private static void registerFxCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedFX.class, "getLastCreatedFX") + .registerSubtype(ABCallbackGetStoredFXByKey.class, "getStoredFXByKey") + .registerSubtype(ABCallbackInlineConditionFX.class, "inlineConditionFX") + + .registerSubtype(ABCallbackArgumentFX.class, "argumentFX") + .registerSubtype(ABCallbackReuseFX.class, "reuseFX") + .registerSubtype(ABCallbackReuseFXWithArguments.class, "reuseFXWithArguments"); + } + + private static void registerIdCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetStoredIDByKey.class, "getStoredIDByKey") + .registerSubtype(ABCallbackInlineConditionID.class, "inlineConditionID") + .registerSubtype(ABCallbackGetAbilityUniqueValueId.class, "getAbilityUniqueValueId") + .registerSubtype(ABCallbackGetAbilityDataAsID.class, "getAbilityDataAsID") + .registerSubtype(ABCallbackGetAbilityDataAsIDFromList.class, "getAbilityDataAsIDFromList") + .registerSubtype(ABCallbackGetAbilityDataAsRandomIDFromList.class, "getAbilityDataAsRandomIDFromList") + .registerSubtype(ABCallbackGetAbilityUnitId.class, "getAbilityUnitId") + .registerSubtype(ABCallbackGetWar3IDFromString.class, "getWar3IDFromString") + .registerSubtype(ABCallbackGetAlias.class, "getAlias") + .registerSubtype(ABCallbackGetCode.class, "getCode") + .registerSubtype(ABCallbackGetBuffIdFromCode.class, "getBuffIdFromCode") + .registerSubtype(ABCallbackGetFirstBuffId.class, "getFirstBuffId") + .registerSubtype(ABCallbackGetSecondBuffId.class, "getSecondBuffId") + .registerSubtype(ABCallbackGetFirstEffectId.class, "getFirstEffectId") + + .registerSubtype(ABCallbackGetBuffAlias.class, "getBuffAlias") + + .registerSubtype(ABCallbackGetUnitType.class, "getUnitType") + .registerSubtype(ABCallbackGetNonCurrentTransformType.class, "getNonCurrentTransformType") + + .registerSubtype(ABCallbackGetItemType.class, "getItemType") + + .registerSubtype(ABCallbackRandomMechanicalCritterId.class, "randomMechanicalCritterId") + .registerSubtype(ABCallbackRandomItemId.class, "randomItemId") + + .registerSubtype(ABCallbackNullIfFalse.class, "nullIfFalse") + + .registerSubtype(ABCallbackArgumentID.class, "argumentID") + .registerSubtype(ABCallbackReuseID.class, "reuseID") + .registerSubtype(ABCallbackReuseIDWithArguments.class, "reuseIDWithArguments"); + } + + private static void registerIntegerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackRawInteger.class, "rawInteger") + .registerSubtype(ABCallbackGetStoredIntegerByKey.class, "getStoredIntegerByKey") + .registerSubtype(ABCallbackGetCastId.class, "getCastId") + .registerSubtype(ABCallbackGetAbilityUniqueValueInteger.class, "getAbilityUniqueValueInteger") + .registerSubtype(ABCallbackGetBuffUniqueValueInteger.class, "getBuffUniqueValueInteger") + + .registerSubtype(ABCallbackInlineConditionInteger.class, "inlineConditionInteger") + .registerSubtype(ABCallbackIterator.class, "iterator") + + .registerSubtype(ABCallbackGetAbilityDataAsInteger.class, "getAbilityDataAsInteger") + .registerSubtype(ABCallbackGetAbilityManaCost.class, "getAbilityManaCost") + .registerSubtype(ABCallbackGetAbilityCastTimeAsInteger.class, "getAbilityCastTimeAsInteger") + .registerSubtype(ABCallbackGetAbilityTargetAttachmentPoints.class, "getAbilityTargetAttachmentPoints") + + .registerSubtype(ABCallbackGetUnitMaximumHp.class, "getUnitMaximumHp") + .registerSubtype(ABCallbackGetUnitMaximumMp.class, "getUnitMaximumMp") + + .registerSubtype(ABCallbackCountBuffsOnUnitMatchingCondition.class, "countBuffsOnUnitMatchingCondition") + + .registerSubtype(ABCallbackGetUnitHandleAsInteger.class, "getUnitHandleAsInteger") + .registerSubtype(ABCallbackGetAbilityHandleAsInteger.class, "getAbilityHandleAsInteger") + .registerSubtype(ABCallbackGetBuffHandleAsInteger.class, "getBuffHandleAsInteger") + + .registerSubtype(ABCallbackCountUnitsInRangeOfUnit.class, "countUnitsInRangeOfUnit") + .registerSubtype(ABCallbackCountUnitsInRangeOfLocation.class, "countUnitsInRangeOfLocation") + .registerSubtype(ABCallbackGetSpellLevel.class, "getSpellLevel") + .registerSubtype(ABCallbackGetProjectileUnitTargets.class, "getProjectileUnitTargets") + .registerSubtype(ABCallbackGetProjectileDestructableTargets.class, "getProjectileDestructableTargets") + + .registerSubtype(ABCallbackGetUnitTypeGoldCost.class, "getUnitTypeGoldCost") + .registerSubtype(ABCallbackGetUnitTypeLumberCost.class, "getUnitTypeLumberCost") + .registerSubtype(ABCallbackGetUnitTypeFoodCost.class, "getUnitTypeFoodCost") + .registerSubtype(ABCallbackGetUnitTypeSpeed.class, "getUnitTypeSpeed") + + .registerSubtype(ABCallbackGetAttackMaximumSplashRadius.class, "getAttackMaximumSplashRadius") + + .registerSubtype(ABCallbackRandomInteger.class, "randomInteger") + + .registerSubtype(ABCallbackAddInteger.class, "i+") + .registerSubtype(ABCallbackSubtractInteger.class, "i-") + .registerSubtype(ABCallbackMultiplyInteger.class, "i*") + .registerSubtype(ABCallbackDivideInteger.class, "i/") + .registerSubtype(ABCallbackAndInteger.class, "i&") + .registerSubtype(ABCallbackOrInteger.class, "i|") + .registerSubtype(ABCallbackMinInteger.class, "iMin") + .registerSubtype(ABCallbackMaxInteger.class, "iMax") + + .registerSubtype(ABCallbackTruncateFloatToInteger.class, "f2i") + + .registerSubtype(ABCallbackIntegerIf.class, "iIf") + .registerSubtype(ABCallbackIntegerZeroIfFalse.class, "i0IfFalse") + .registerSubtype(ABCallbackIntegerZeroIfNull.class, "i0IfNull") + + .registerSubtype(ABCallbackGetIntegerFromList.class, "getIntegerFromList") + + .registerSubtype(ABCallbackGetListSize.class, "getListSize") + .registerSubtype(ABCallbackGetSortableListSize.class, "getSortableListSize") + .registerSubtype(ABCallbackGetUnitGroupSize.class, "getUnitGroupSize") + .registerSubtype(ABCallbackGetUnitQueueSize.class, "getUnitQueueSize") + + .registerSubtype(ABCallbackGetPlayerId.class, "getPlayerId") + .registerSubtype(ABCallbackGetNeutralHostilePlayerId.class, "getNeutralHostilePlayerId") + .registerSubtype(ABCallbackGetNeutralPassivePlayerId.class, "getNeutralPassivePlayerId") + + .registerSubtype(ABCallbackGetItemSlot.class, "getItemSlot") + .registerSubtype(ABCallbackGetItemLevel.class, "getItemLevel") + .registerSubtype(ABCallbackGetItemCharges.class, "getItemCharges") + .registerSubtype(ABCallbackGetItemMaxCharges.class, "getItemMaxCharges") + + .registerSubtype(ABCallbackPlayerToStateModValue.class, "playerToStateModValue") + .registerSubtype(ABCallbackDetectionDropdownConversion.class, "detectionDropdownConversion") + + .registerSubtype(ABCallbackArgumentInteger.class, "argumentInteger") + .registerSubtype(ABCallbackReuseInteger.class, "reuseInteger") + .registerSubtype(ABCallbackReuseIntegerWithArguments.class, "reuseIntegerWithArguments"); + } + + private static void registerItemCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackArgumentItem.class, "argumentItem") + .registerSubtype(ABCallbackInlineConditionItem.class, "inlineConditionItem") + .registerSubtype(ABCallbackReuseItem.class, "reuseItem") + .registerSubtype(ABCallbackReuseItemWithArguments.class, "reuseItemWithArguments") + .registerSubtype(ABCallbackGetStoredItemByKey.class, "getStoredItemByKey") + .registerSubtype(ABCallbackGetAbilityTargetedItem.class, "getAbilityTargetedItem") + .registerSubtype(ABCallbackGetLastCreatedItem.class, "getLastCreatedItem") + .registerSubtype(ABCallbackGetAttackedItem.class, "getAttackedItem"); + } + + private static void registerLightningCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedLightningEffect.class, "getLastCreatedLightningEffect") + .registerSubtype(ABCallbackGetStoredLightningByKey.class, "getStoredLightningByKey"); + } + + private static void registerListCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackArgumentList.class, "argumentList") + .registerSubtype(ABCallbackGetStoredListByKey.class, "getStoredListByKey") + .registerSubtype(ABCallbackInlineConditionList.class, "inlineConditionList") + .registerSubtype(ABCallbackReuseList.class, "reuseList") + .registerSubtype(ABCallbackReuseListWithArguments.class, "reuseListWithArguments"); + } + + private static void registerSortableListCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackArgumentSortableList.class, "argumentSortableList") + .registerSubtype(ABCallbackGetStoredSortableListByKey.class, "getStoredSortableListByKey") + .registerSubtype(ABCallbackInlineConditionSortableList.class, "inlineConditionSortableList") + .registerSubtype(ABCallbackListSorted.class, "listSorted") + .registerSubtype(ABCallbackReuseSortableList.class, "reuseSortableList") + .registerSubtype(ABCallbackReuseSortableListWithArguments.class, "reuseSortableListWithArguments"); + } + + private static void registerIntegerListCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackIntegerListOfRange.class, "integerListOfRange") + .registerSubtype(ABCallbackEmptyIntegerList.class, "emptyIntegerList"); + } + + private static void registerLocationListCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackEmptyLocationList.class, "emptyLocationList"); + } + + private static void registerLocationCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackCreateLocationFromXY.class, "createLocationFromXY") + .registerSubtype(ABCallbackCreateLocationFromOffset.class, "createLocationFromOffset") + .registerSubtype(ABCallbackCreateLocationFromXYOffset.class, "createLocationFromXYOffset") + .registerSubtype(ABCallbackModifyLocationWithOffset.class, "modifyLocationWithOffset") + .registerSubtype(ABCallbackModifyLocationWithXYOffset.class, "modifyLocationWithXYOffset") + .registerSubtype(ABCallbackRandomLocationInRange.class, "randomLocationInRange") + .registerSubtype(ABCallbackGetStoredLocationByKey.class, "getStoredLocationByKey") + .registerSubtype(ABCallbackInlineConditionLocation.class, "inlineConditionLocation") + .registerSubtype(ABCallbackGetTargetedLocation.class, "getTargetedLocation") + .registerSubtype(ABCallbackGetGroundAttackedLocation.class, "getGroundAttackedLocation") + .registerSubtype(ABCallbackGetAttackTargetLocation.class, "getAttackTargetLocation") + .registerSubtype(ABCallbackGetAttackImpactLocation.class, "getAttackImpactLocation") + .registerSubtype(ABCallbackCreateLocationFromTarget.class, "createLocationFromTarget") + .registerSubtype(ABCallbackGetProjectileCurrentLocation.class, "getProjectileCurrentLocation") + .registerSubtype(ABCallbackGetUnitLocation.class, "getUnitLocation") + + .registerSubtype(ABCallbackGetLocationFromList.class, "getLocationFromList") + .registerSubtype(ABCallbackArgumentLocation.class, "argumentLocation") + .registerSubtype(ABCallbackReuseLocation.class, "reuseLocation") + .registerSubtype(ABCallbackReuseLocationWithArguments.class, "reuseLocationWithArguments"); + } + + private static void registerLongCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackRawLong.class, "rawLong") + .registerSubtype(ABCallbackGetAbilityDataAsLong.class, "getAbilityDataAsLong") + .registerSubtype(ABCallbackGetStoredLongByKey.class, "getStoredLongByKey") + .registerSubtype(ABCallbackInlineConditionLong.class, "inlineConditionLong") + .registerSubtype(ABCallbackGetAbilityUniqueValueLong.class, "getAbilityUniqueValueLong") + .registerSubtype(ABCallbackGetBuffUniqueValueLong.class, "getBuffUniqueValueLong") + + .registerSubtype(ABCallbackAddLong.class, "l+") + .registerSubtype(ABCallbackSubtractLong.class, "l-") + .registerSubtype(ABCallbackMultiplyLong.class, "l*") + .registerSubtype(ABCallbackDivideLong.class, "l/") + .registerSubtype(ABCallbackAndLong.class, "l&") + .registerSubtype(ABCallbackOrLong.class, "l|") + .registerSubtype(ABCallbackMinLong.class, "lMin") + .registerSubtype(ABCallbackMaxLong.class, "lMax") + + .registerSubtype(ABCallbackCreateDetectorData.class, "createDetectorData") + .registerSubtype(ABCallbackCreateDetectedData.class, "createDetectedData") + + .registerSubtype(ABCallbackCreateOwnershipData.class, "createOwnershipData") + + .registerSubtype(ABCallbackPlayerMaskIncludePlayers.class, "playerMaskIncludePlayers") + .registerSubtype(ABCallbackPlayerMaskExcludePlayers.class, "playerMaskExcludePlayers") + .registerSubtype(ABCallbackPlayerMaskAllPlayers.class, "playerMaskAllPlayers") + + .registerSubtype(ABCallbackArgumentLong.class, "argumentLong") + .registerSubtype(ABCallbackReuseLong.class, "reuseLong") + .registerSubtype(ABCallbackReuseLongWithArguments.class, "reuseLongWithArguments"); + } + + private static void registerOrderIdCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackRawID.class, "rawId") + .registerSubtype(ABCallbackIdString.class, "idString") + .registerSubtype(ABCallbackGetStoredOrderIdByKey.class, "getStoredOrderIdByKey") + .registerSubtype(ABCallbackInlineConditionOrderId.class, "inlineConditionOrderId") + + .registerSubtype(ABCallbackArgumentOrderId.class, "argumentOrderId") + .registerSubtype(ABCallbackReuseOrderId.class, "reuseOrderId") + .registerSubtype(ABCallbackReuseOrderIdWithArguments.class, "reuseOrderIdWithArguments"); + } + + private static void registerPlayerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetPlayerById.class, "getPlayerById") + .registerSubtype(ABCallbackGetCastingPlayer.class, "getCastingPlayer") + .registerSubtype(ABCallbackGetStoredPlayerByKey.class, "getStoredPlayerByKey") + .registerSubtype(ABCallbackInlineConditionPlayer.class, "inlineConditionPlayer") + .registerSubtype(ABCallbackGetOwnerOfUnit.class, "getOwnerOfUnit") + + .registerSubtype(ABCallbackArgumentPlayer.class, "argumentPlayer") + .registerSubtype(ABCallbackReusePlayer.class, "reusePlayer") + .registerSubtype(ABCallbackReusePlayerWithArguments.class, "reusePlayerWithArguments"); + } + + private static void registerProjectileCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedProjectile.class, "getLastCreatedProjectile") + .registerSubtype(ABCallbackGetStoredProjectileByKey.class, "getStoredProjectileByKey") + .registerSubtype(ABCallbackInlineConditionProjectile.class, "inlineConditionProjectile") + .registerSubtype(ABCallbackGetThisProjectile.class, "getThisProjectile") + + + .registerSubtype(ABCallbackGetReactionAttackProjectile.class, "getReactionAttackProjectile") + .registerSubtype(ABCallbackGetReactionAbilityProjectile.class, "getReactionAbilityProjectile") + + .registerSubtype(ABCallbackArgumentProjectile.class, "argumentProjectile") + .registerSubtype(ABCallbackReuseProjectile.class, "reuseProjectile") + .registerSubtype(ABCallbackReuseProjectileWithArguments.class, "reuseProjectileWithArguments") + ; + } + + private static void registerStatBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedNonStackingStatBuff.class, "getLastCreatedNonStackingStatBuff") + .registerSubtype(ABCallbackGetStoredNonStackingStatBuffByKey.class, + "getStoredNonStackingStatBuffByKey") + .registerSubtype(ABCallbackInlineConditionNonStackingStatBuff.class, "inlineConditionNonStackingStatBuff") + + .registerSubtype(ABCallbackArgumentNonStackingStatBuff.class, "argumentNonStackingStatBuff") + .registerSubtype(ABCallbackReuseNonStackingStatBuff.class, "reuseNonStackingStatBuff") + .registerSubtype(ABCallbackReuseNonStackingStatBuffWithArguments.class, "reuseNonStackingStatBuffWithArguments"); + } + + private static void registerStateModBuffCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedStateModBuff.class, "getLastCreatedStateModBuff") + .registerSubtype(ABCallbackGetStoredStateModBuffByKey.class, + "getStoredStateModBuffByKey") + .registerSubtype(ABCallbackInlineConditionStateModBuff.class, "inlineConditionStateModBuff") + + .registerSubtype(ABCallbackArgumentStateModBuff.class, "argumentStateModBuff") + .registerSubtype(ABCallbackReuseStateModBuff.class, "reuseStateModBuff") + .registerSubtype(ABCallbackReuseStateModBuffWithArguments.class, "reuseStateModBuffWithArguments"); + } + + private static void registerStringCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackRawString.class, "rawString") + .registerSubtype(ABCallbackGetStoredStringByKey.class, "getStoredStringByKey") + .registerSubtype(ABCallbackInlineConditionString.class, "inlineConditionString") + .registerSubtype(ABCallbackGetAbilityDataAsString.class, "getAbilityDataAsString") + .registerSubtype(ABCallbackGetAbilityUniqueValueString.class, "getAbilityUniqueValueString") + .registerSubtype(ABCallbackGetBuffUniqueValueString.class, "getBuffUniqueValueString") + + .registerSubtype(ABCallbackCatStrings.class, "catStrings") + .registerSubtype(ABCallbackGetAliasAsString.class, "getAliasAsString") + .registerSubtype(ABCallbackGetCodeAsString.class, "getCodeAsString") + .registerSubtype(ABCallbackGetUnitHandleAsString.class, "getUnitHandleAsString") + .registerSubtype(ABCallbackGetAbilityHandleAsString.class, "getAbilityHandleAsString") + .registerSubtype(ABCallbackGetBuffHandleAsString.class, "getBuffHandleAsString") + .registerSubtype(ABCallbackGetAllowStackingKey.class, "getAllowStackingKey") + + + + .registerSubtype(ABCallbackBooleanToString.class, "b2s") + .registerSubtype(ABCallbackFloatToString.class, "f2s") + .registerSubtype(ABCallbackIntegerToString.class, "i2s") + .registerSubtype(ABCallbackLongToString.class, "l2s") + .registerSubtype(ABCallbackIdToString.class, "id2s") + + .registerSubtype(ABCallbackArgumentString.class, "argumentString") + .registerSubtype(ABCallbackReuseString.class, "reuseString") + .registerSubtype(ABCallbackReuseStringWithArguments.class, "reuseStringWithArguments") + ; + } + + private static void registerTargetCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetAbilityTarget.class, "getAbilityTarget") + .registerSubtype(ABCallbackGetNewBehaviorTarget.class, "getNewBehaviorTarget") + .registerSubtype(ABCallbackGetStoredTargetByKey.class, "getStoredTargetByKey") + .registerSubtype(ABCallbackInlineConditionTarget.class, "inlineConditionTarget") + + .registerSubtype(ABCallbackArgumentTarget.class, "argumentTarget") + .registerSubtype(ABCallbackReuseTarget.class, "reuseTarget") + .registerSubtype(ABCallbackReuseTargetWithArguments.class, "reuseTargetWithArguments"); + } + + private static void registerTimeOfDayEventCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedTimeOfDayEvent.class, "getLastCreatedTimeOfDayEvent") + .registerSubtype(ABCallbackGetStoredTimeOfDayEventByKey.class, "getStoredTimeOfDayEventByKey") + .registerSubtype(ABCallbackInlineConditionTimeOfDayEvent.class, "inlineConditionTimeOfDayEvent") + + .registerSubtype(ABCallbackArgumentTimeOfDayEvent.class, "argumentTimeOfDayEvent") + .registerSubtype(ABCallbackReuseTimeOfDayEvent.class, "reuseTimeOfDayEvent") + .registerSubtype(ABCallbackReuseTimeOfDayEventWithArguments.class, "reuseTimeOfDayEventWithArguments"); + } + + private static void registerTimerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedTimer.class, "getLastCreatedTimer") + .registerSubtype(ABCallbackGetLastStartedTimer.class, "getLastStartedTimer") + .registerSubtype(ABCallbackGetFiringTimer.class, "getFiringTimer") + .registerSubtype(ABCallbackGetStoredTimerByKey.class, "getStoredTimerByKey") + .registerSubtype(ABCallbackInlineConditionTimer.class, "inlineConditionTimer") + + .registerSubtype(ABCallbackArgumentTimer.class, "argumentTimer") + .registerSubtype(ABCallbackReuseTimer.class, "reuseTimer") + .registerSubtype(ABCallbackReuseTimerWithArguments.class, "reuseTimerWithArguments"); + } + + private static void registerUnitCallbacks(RuntimeTypeAdapterFactory unitCallbackTypeFactory) { + unitCallbackTypeFactory.registerSubtype(ABCallbackGetCastingUnit.class, "getCastingUnit") + .registerSubtype(ABCallbackGetBuffCastingUnit.class, "getBuffCastingUnit") + .registerSubtype(ABCallbackGetBuffedUnit.class, "getBuffedUnit") + .registerSubtype(ABCallbackGetListenerUnit.class, "getListenerUnit") + .registerSubtype(ABCallbackGetEnumUnit.class, "getEnumUnit") + .registerSubtype(ABCallbackGetCompUnit1.class, "getCompUnit1") + .registerSubtype(ABCallbackGetCompUnit2.class, "getCompUnit2") + .registerSubtype(ABCallbackGetMatchingUnit.class, "getMatchingUnit") + .registerSubtype(ABCallbackGetAttackedUnit.class, "getAttackedUnit") + .registerSubtype(ABCallbackGetAttackingUnit.class, "getAttackingUnit") + .registerSubtype(ABCallbackGetDamagedUnit.class, "getDamagedUnit") + .registerSubtype(ABCallbackGetDamagingUnit.class, "getDamagingUnit") + .registerSubtype(ABCallbackGetDyingUnit.class, "getDyingUnit") + .registerSubtype(ABCallbackGetKillingUnit.class, "getKillingUnit") + .registerSubtype(ABCallbackGetAbilityTargetedUnit.class, "getAbilityTargetedUnit") + .registerSubtype(ABCallbackGetAbilityPairedUnit.class, "getAbilityPairedUnit") + .registerSubtype(ABCallbackGetStoredUnitByKey.class, "getStoredUnitByKey") + .registerSubtype(ABCallbackInlineConditionUnit.class, "inlineConditionUnit") + .registerSubtype(ABCallbackGetProjectileSourceUnit.class, "getProjectileSourceUnit") + .registerSubtype(ABCallbackGetProjectileHitUnit.class, "getProjectileHitUnit") + .registerSubtype(ABCallbackGetChainUnit.class, "getChainUnit") + .registerSubtype(ABCallbackGetLastCreatedUnit.class, "getLastCreatedUnit") + + .registerSubtype(ABCallbackGetReactionAbilityCastingUnit.class, "getReactionAbilityCastingUnit") + .registerSubtype(ABCallbackGetReactionAbilityTargetUnit.class, "getReactionAbilityTargetUnit") + + .registerSubtype(ABCallbackPollUnitQueue.class, "pollUnitQueue") + + .registerSubtype(ABCallbackGetNearestUnitInRangeOfUnit.class, "getNearestUnitInRangeOfUnit") + .registerSubtype(ABCallbackGetNearestCorpseInRangeOfUnit.class, "getNearestCorpseInRangeOfUnit") + + .registerSubtype(ABCallbackArgumentUnit.class, "argumentUnit") + .registerSubtype(ABCallbackReuseUnit.class, "reuseUnit") + .registerSubtype(ABCallbackReuseUnitWithArguments.class, "reuseUnitWithArguments"); + } + + private static void registerUnitGroupCallbacks(RuntimeTypeAdapterFactory unitGroupCallbackTypeFactory) { + unitGroupCallbackTypeFactory.registerSubtype(ABCallbackGetUnitGroupByName.class, "getUnitGroupByName") + .registerSubtype(ABCallbackGetLastCreatedUnitGroup.class, "getLastCreatedUnitGroup") + .registerSubtype(ABCallbackGetStoredUnitGroupByKey.class, "getStoredUnitGroupByKey") + .registerSubtype(ABCallbackInlineConditionUnitGroup.class, "inlineConditionUnitGroup") + + .registerSubtype(ABCallbackArgumentUnitGroup.class, "argumentUnitGroup") + .registerSubtype(ABCallbackReuseUnitGroup.class, "reuseUnitGroup") + .registerSubtype(ABCallbackReuseUnitGroupWithArguments.class, "reuseUnitGroupWithArguments"); + } + + private static void registerUnitQueueCallbacks(RuntimeTypeAdapterFactory unitGroupCallbackTypeFactory) { + unitGroupCallbackTypeFactory.registerSubtype(ABCallbackGetUnitQueueByName.class, "getUnitQueueByName") + .registerSubtype(ABCallbackGetLastCreatedUnitQueue.class, "getLastCreatedUnitQueue") + .registerSubtype(ABCallbackGetStoredUnitQueueByKey.class, "getStoredUnitQueueByKey") + .registerSubtype(ABCallbackInlineConditionUnitQueue.class, "inlineConditionUnitQueue") + + .registerSubtype(ABCallbackArgumentUnitQueue.class, "argumentUnitQueue") + .registerSubtype(ABCallbackReuseUnitQueue.class, "reuseUnitQueue") + .registerSubtype(ABCallbackReuseUnitQueueWithArguments.class, "reuseUnitQueueWithArguments"); + } + + private static void registerUnitStateListenerCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetLastCreatedUnitStateListener.class, + "getLastCreatedUnitStateListener") + .registerSubtype(ABCallbackGetStoredUnitStateListenerByKey.class, + "getStoredUnitStateListenerByKey"); + } + + private static void registerVisionModifierCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetStoredVisionModifierByKey.class, "getStoredVisionModifierByKey") + .registerSubtype(ABCallbackInlineConditionVisionModifier.class, "inlineConditionVisionModifier") + .registerSubtype(ABCallbackGetLastCreatedVisionModifier.class, "getLastCreatedVisionModifier") + + .registerSubtype(ABCallbackArgumentVisionModifier.class, "argumentVisionModifier") + .registerSubtype(ABCallbackReuseVisionModifier.class, "reuseVisionModifier") + .registerSubtype(ABCallbackReuseVisionModifierWithArguments.class, "reuseVisionModifierWithArguments") + ; + } + + private static void registerWidgetCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory + .registerSubtype(ABCallbackGetProjectileHitWidget.class, "getProjectileHitWidget") + .registerSubtype(ABCallbackUnitToWidget.class, "u2w") + .registerSubtype(ABCallbackItemToWidget.class, "i2w") + .registerSubtype(ABCallbackDestructableToWidget.class, "d2w") + .registerSubtype(ABCallbackGetStoredWidgetByKey.class, "getStoredWidgetByKey") + .registerSubtype(ABCallbackInlineConditionWidget.class, "inlineConditionWidget") + + .registerSubtype(ABCallbackArgumentWidget.class, "argumentWidget") + .registerSubtype(ABCallbackReuseWidget.class, "reuseWidget") + .registerSubtype(ABCallbackReuseWidgetWithArguments.class, "reuseWidgetWithArguments") + ; + } + + private static void registerWidgetEventCallbacks(RuntimeTypeAdapterFactory callbackTypeFactory) { + callbackTypeFactory.registerSubtype(ABCallbackGetLastCreatedWidgetEvent.class, "getLastCreatedWidgetEvent") + .registerSubtype(ABCallbackGetStoredWidgetEventByKey.class, "getStoredWidgetEventByKey") + .registerSubtype(ABCallbackInlineConditionWidgetEvent.class, "inlineConditionWidgetEvent") + + .registerSubtype(ABCallbackArgumentWidgetEvent.class, "argumentWidgetEvent") + .registerSubtype(ABCallbackReuseWidgetEvent.class, "reuseWidgetEvent") + .registerSubtype(ABCallbackReuseWidgetEventWithArguments.class, "reuseWidgetEventWithArguments"); + } + + private static void registerConditions(RuntimeTypeAdapterFactory conditionTypeFactory) { + conditionTypeFactory.registerSubtype(ABConditionAnd.class, "and").registerSubtype(ABConditionOr.class, "or") + .registerSubtype(ABConditionNot.class, "not").registerSubtype(ABConditionBool.class, "bool") + .registerSubtype(ABConditionNotNull.class, "notNull") + .registerSubtype(ABConditionIsNull.class, "isNull") + + .registerSubtype(ABConditionFloatEqual.class, "f=") + .registerSubtype(ABConditionFloatEq0.class, "f=0") + .registerSubtype(ABConditionFloatGte.class, "f>=") + .registerSubtype(ABConditionFloatGt.class, "f>") + .registerSubtype(ABConditionFloatGt0.class, "f>0") + .registerSubtype(ABConditionFloatLte.class, "f<=") + .registerSubtype(ABConditionFloatLt.class, "f<") + .registerSubtype(ABConditionFloatNe.class, "f!=") + .registerSubtype(ABConditionFloatNe0.class, "f!=0") + + .registerSubtype(ABConditionIntegerEq.class, "i=") + .registerSubtype(ABConditionIntegerNe.class, "i!=") + .registerSubtype(ABConditionIntegerGt.class, "i>") + .registerSubtype(ABConditionIntegerGt0.class, "i>0") + .registerSubtype(ABConditionIntegerGte.class, "i>=") + .registerSubtype(ABConditionIntegerLt.class, "i<") + .registerSubtype(ABConditionIntegerLte.class, "i<=") + .registerSubtype(ABConditionIntegerNe0.class, "i!=0") + .registerSubtype(ABConditionIntegerEq0.class, "i=0") + .registerSubtype(ABConditionIntegerIsOdd.class, "iOdd") + .registerSubtype(ABConditionIntegerIsEven.class, "iEven") + + .registerSubtype(ABConditionSetCantUseReasonOnFailure.class, "setCantUseReasonOnFailure") + + .registerSubtype(ABConditionIsValidTarget.class, "isValidTarget") + .registerSubtype(ABConditionIsUnitValidTarget.class, "isUnitValidTarget") + .registerSubtype(ABConditionIsUnitValidSplashDamageTarget.class, "isUnitValidSplashDamageTarget") + .registerSubtype(ABConditionIsPassAllAbilityTargetChecks.class, "isPassAllAbilityTargetChecks") + .registerSubtype(ABConditionIsUnitPassAllAbilityTargetChecks.class, "isUnitPassAllAbilityTargetChecks") + .registerSubtype(ABConditionIsDestructableValidTarget.class, "isDestructableValidTarget") + + .registerSubtype(ABConditionIsUnitInRangeOfUnit.class, "isUnitInRangeOfUnit") + .registerSubtype(ABConditionMatchingUnitExistsInRangeOfUnit.class, "matchingUnitExistsInRangeOfUnit") + .registerSubtype(ABConditionMatchingCorpseExistsInRangeOfUnit.class, "matchingCorpseExistsInRangeOfUnit") + + .registerSubtype(ABConditionIsUnitInGroup.class, "isUnitInGroup") + .registerSubtype(ABConditionIsUnitEqual.class, "isUnitEqual") + .registerSubtype(ABConditionIsAttackTypeEqual.class, "isAttackTypeEqual") + .registerSubtype(ABConditionIsDamageTypeEqual.class, "isDamageTypeEqual") + .registerSubtype(ABConditionIsWeaponTypeEqual.class, "isWeaponTypeEqual") + .registerSubtype(ABConditionIsMovementTypeEqual.class, "isMovementTypeEqual") + .registerSubtype(ABConditionIsIdEqual.class, "isIdEqual") + .registerSubtype(ABConditionIsDefenseTypeEqual.class, "isDefenseTypeEqual") + .registerSubtype(ABConditionIsDefenseTypeInList.class, "isDefenseTypeInList") + + .registerSubtype(ABConditionIsOnCooldown.class, "isOnCooldown") + .registerSubtype(ABConditionIsDisabled.class, "isDisabled") + .registerSubtype(ABConditionIsAutoCastCurrentlyActive.class, "isAutoCastCurrentlyActive") + .registerSubtype(ABConditionWasAutoCastPreviouslyActive.class, "wasAutoCastPreviouslyActive") + .registerSubtype(ABConditionDoesAbilityHaveUniqueFlag.class, "doesAbilityHaveUniqueFlag") + .registerSubtype(ABConditionIsFlexAbilityTargeted.class, "isFlexAbilityTargeted") + .registerSubtype(ABConditionIsFlexAbilityNonTargeted.class, "isFlexAbilityNonTargeted") + .registerSubtype(ABConditionIsFlexAbilityPointTarget.class, "isFlexAbilityPointTarget") + .registerSubtype(ABConditionIsFlexAbilityNonPointTarget.class, "isFlexAbilityNonPointTarget") + .registerSubtype(ABConditionIsToggleAbilityActive.class, "isToggleAbilityActive") + .registerSubtype(ABConditionIsTransformingToAlternate.class, "isTransformingToAlternate") + .registerSubtype(ABConditionIsAutoCastTargeting.class, "isAutoCastTargeting") + .registerSubtype(ABConditionWasAutoCast.class, "wasAutoCast") + + + .registerSubtype(ABConditionIsUnitType.class, "isUnitType") + .registerSubtype(ABConditionDoesUnitHaveAbilityMatchingCondition.class, "doesUnitHaveAbilityMatchingCondition") + .registerSubtype(ABConditionDoesUnitHaveBuff.class, "doesUnitHaveBuff") + .registerSubtype(ABConditionDoesUnitHaveBuffMatchingCondition.class, "doesUnitHaveBuffMatchingCondition") + .registerSubtype(ABConditionIsUnitMaxHp.class, "isUnitMaxHp") + .registerSubtype(ABConditionIsUnitMaxMp.class, "isUnitMaxMp") + .registerSubtype(ABConditionIsUnitBuilding.class, "isUnitBuilding") + .registerSubtype(ABConditionIsUnitHero.class, "isUnitHero") + .registerSubtype(ABConditionIsUnitSummoned.class, "isUnitSummoned") + .registerSubtype(ABConditionIsUnitVisible.class, "isUnitVisible") + .registerSubtype(ABConditionIsUnitEnemy.class, "isUnitEnemy") + .registerSubtype(ABConditionIsUnitFriend.class, "isUnitFriend") + .registerSubtype(ABConditionIsUnitAlive.class, "isUnitAlive") + .registerSubtype(ABConditionIsUnitDead.class, "isUnitDead") + .registerSubtype(ABConditionIsUnitHidden.class, "isUnitHidden") + .registerSubtype(ABConditionUnitHasResearch.class, "unitHasResearch") + .registerSubtype(ABConditionIsUnitTraining.class, "isUnitTraining") + .registerSubtype(ABConditionIsUnitConstructing.class, "isUnitConstructing") + .registerSubtype(ABConditionIsUnitUpgrading.class, "isUnitUpgrading") + .registerSubtype(ABConditionIsUnitConstructingOrUpgrading.class, "isUnitConstructingOrUpgrading") + .registerSubtype(ABConditionIsUnitMagicImmune.class, "isUnitMagicImmune") + .registerSubtype(ABConditionIsUnitSleeping.class, "isUnitSleeping") + .registerSubtype(ABConditionIsUnitMorphImmune.class, "isUnitMorphImmune") + .registerSubtype(ABConditionIsUnitPolymorphed.class, "isUnitPolymorphed") + .registerSubtype(ABConditionIsUnitShareSpells.class, "isUnitShareSpells") + .registerSubtype(ABConditionIsUnitHeroDuration.class, "isUnitHeroDuration") + .registerSubtype(ABConditionIsCurrentBehaviorCategoryInList.class, "isCurrentBehaviorCategoryInList") + + .registerSubtype(ABConditionIsItemAbility.class, "isItemAbility") + .registerSubtype(ABConditionItemHasCharges.class, "itemHasCharges") + .registerSubtype(ABConditionItemIsCharged.class, "itemIsCharged") + + .registerSubtype(ABConditionIsTree.class, "isTree") + .registerSubtype(ABConditionDoesDestructableHaveBuff.class, "doesDestructableHaveBuff") + .registerSubtype(ABConditionDoesDestructableHaveBuffMatchingCondition.class, "doesDestructableHaveBuffMatchingCondition") + + .registerSubtype(ABConditionIsTimerActive.class, "isTimerActive") + + .registerSubtype(ABConditionIsLocationDeepWater.class, "isLocationDeepWater") + .registerSubtype(ABConditionIsLocationShallowWater.class, "isLocationShallowWater") + .registerSubtype(ABConditionIsLocationWalkable.class, "isLocationWalkable") + .registerSubtype(ABConditionIsLocationWalkableNonWater.class, "isLocationWalkableNonWater") + .registerSubtype(ABConditionIsLocationFlyingOnly.class, "isLocationFlyingOnly") + + .registerSubtype(ABConditionIsLocationPathableForUnitType.class, "isLocationPathableForUnitType") + + .registerSubtype(ABConditionWasCastingInterrupted.class, "wasCastingInterrupted") + .registerSubtype(ABConditionIsTriggeringDamageAnAttack.class, "isTriggeringDamageAnAttack") + .registerSubtype(ABConditionIsTriggeringDamageRanged.class, "isTriggeringDamageRanged") + .registerSubtype(ABConditionIsAttackRanged.class, "isAttackRanged") + .registerSubtype(ABConditionIsAttackProjectile.class, "isAttackProjectile") + .registerSubtype(ABConditionIsAttackHoming.class, "isAttackHoming") + .registerSubtype(ABConditionIsAttackArtillery.class, "isAttackArtillery") + + .registerSubtype(ABConditionIsProjectileReflected.class, "isProjectileReflected") + + .registerSubtype(ABConditionDoesBuffHaveUniqueFlag.class, "doesBuffHaveUniqueFlag") + .registerSubtype(ABConditionIsBuffMagic.class, "isBuffMagic") + .registerSubtype(ABConditionIsBuffPositive.class, "isBuffPositive") + .registerSubtype(ABConditionIsBuffNegative.class, "isBuffNegative") + .registerSubtype(ABConditionIsBuffAlly.class, "isBuffAlly") + .registerSubtype(ABConditionIsBuffEnemy.class, "isBuffEnemy") + + .registerSubtype(ABConditionIsDestructableBuffMagic.class, "isDestructableBuffMagic") + + + .registerSubtype(ABConditionGameplayConstantSmartAbolishMagic.class, "gameplayConstantSmartAbolishMagic") + .registerSubtype(ABConditionGameplayConstantCanDisableDivineShield.class, "gameplayConstantCanDisableDivineShield") + .registerSubtype(ABConditionIsTimeOfDayInRange.class, "isTimeOfDayInRange") + .registerSubtype(ABConditionGameplayConstantIsRelativeUpgradeCosts.class, "gameplayConstantIsRelativeUpgradeCosts") + .registerSubtype(ABConditionGameplayConstantIsDefendCanDeflect.class, "gameplayConstantIsDefendCanDeflect") + + .registerSubtype(ABConditionIsNewBehaviorCategoryInList.class, "isNewBehaviorCategoryInList") + + .registerSubtype(ABConditionSuccessfullyChargeResources.class, "successfullyChargeResources") + ; + } + + private static void registerActions(RuntimeTypeAdapterFactory factory) { + factory.registerSubtype(ABActionIf.class, "if") + .registerSubtype(ABActionWhile.class, "while") + .registerSubtype(ABActionFor.class, "for") + .registerSubtype(ABActionBreak.class, "break") + .registerSubtype(ABActionIterateUnitsInRangeOfUnitMatchingCondition.class, "iterateUnitsInRangeOfUnitMatchingCondition") + .registerSubtype(ABActionIterateUnitsInRangeOfLocationMatchingCondition.class, "iterateUnitsInRangeOfLocationMatchingCondition") + .registerSubtype(ABActionIterateUnitsInRangeOfUnitMatchingConditionWithSort.class, "iterateUnitsInRangeOfUnitMatchingConditionWithSort") + .registerSubtype(ABActionIterateUnitsInRangeOfLocationMatchingConditionWithSort.class, "iterateUnitsInRangeOfLocationMatchingConditionWithSort") + .registerSubtype(ABActionIterateUnitsInRect.class, "iterateUnitsInRect") + .registerSubtype(ABActionPeriodicExecute.class, "periodicExecute") + .registerSubtype(ABActionResetPeriodicExecute.class, "resetPeriodicExecute") + .registerSubtype(ABActionCleanUpCastInstance.class, "cleanUpCastInstance") + + .registerSubtype(ABActionCheckAbilityEffectReaction.class, "checkAbilityEffectReaction") + .registerSubtype(ABActionCheckAbilityProjReaction.class, "checkAbilityProjReaction") + + .registerSubtype(ABActionCreateSpellEffectOnUnit.class, "createSpellEffectOnUnit") + .registerSubtype(ABActionCreateTemporarySpellEffectOnUnit.class, "createTemporarySpellEffectOnUnit") + .registerSubtype(ABActionCreateSpellEffectAtLocation.class, "createSpellEffectAtLocation") + .registerSubtype(ABActionCreateTemporarySpellEffectAtLocation.class, + "createTemporarySpellEffectAtLocation") + .registerSubtype(ABActionCreateSpellEffectAtPoint.class, "createSpellEffectAtPoint") + .registerSubtype(ABActionCreateTemporarySpellEffectAtPoint.class, "createTemporarySpellEffectAtPoint") + .registerSubtype(ABActionCreateSoundEffectOnUnit.class, "createSoundEffectOnUnit") + .registerSubtype(ABActionCreateLoopingSoundEffectOnUnit.class, "createLoopingSoundEffectOnUnit") + .registerSubtype(ABActionCreateSoundEffectAtLocation.class, "createSoundEffectAtLocation") + .registerSubtype(ABActionCreateLoopingSoundEffectAtLocation.class, "createLoopingSoundEffectAtLocation") + .registerSubtype(ABActionCreateLightningEffect.class, "createLightningEffect") + .registerSubtype(ABActionRemoveLightningEffect.class, "removeLightningEffect") + .registerSubtype(ABActionCreateGroupEffectAtLocation.class, "createGroupEffectAtLocation") + .registerSubtype(ABActionCreateUberSplat.class, "createUberSplat") + + .registerSubtype(ABActionChainEffect.class, "chainEffect") + + .registerSubtype(ABActionCreateUnitTargetedProjectile.class, "createUnitTargetedProjectile") + .registerSubtype(ABActionCreateUnitTargetedBouncingProjectile.class, "createUnitTargetedBouncingProjectile") + .registerSubtype(ABActionCreateLocationTargetedProjectile.class, "createLocationTargetedProjectile") + .registerSubtype(ABActionCreateUnitTargetedCollisionProjectile.class, "createUnitTargetedCollisionProjectile") + .registerSubtype(ABActionCreateLocationTargetedCollisionProjectile.class, "createLocationTargetedCollisionProjectile") + .registerSubtype(ABActionCreateUnitTargetedPseudoProjectile.class, "createUnitTargetedPseudoProjectile") + .registerSubtype(ABActionCreateLocationTargetedPseudoProjectile.class, "createLocationTargetedPseudoProjectile") + + .registerSubtype(ABActionSetProjectileDone.class, "setProjectileDone") + .registerSubtype(ABActionSetProjectileReflected.class, "setProjectileReflected") + .registerSubtype(ABActionSetProjectileTarget.class, "setProjectileTarget") + .registerSubtype(ABActionSetAttackProjectileDamage.class, "setAttackProjectileDamage") + + + .registerSubtype(ABActionAddAbility.class, "addAbility") + .registerSubtype(ABActionAddNewAbility.class, "addNewAbility") + .registerSubtype(ABActionRemoveAbility.class, "removeAbility") + .registerSubtype(ABActionStoreValueLocally.class, "storeValueLocally") + .registerSubtype(ABActionDeleteStoredKey.class, "deleteStoredKey") + .registerSubtype(ABActionRemoveEffect.class, "removeEffect") + .registerSubtype(ABActionCreateAbilityFromId.class, "createAbilityFromId") + .registerSubtype(ABActionPrepUnownedAbilityForUse.class, "prepUnownedAbilityForUse") + .registerSubtype(ABActionAddDefenseBonus.class, "addDefenseBonus") + .registerSubtype(ABActionRemoveDefenseBonus.class, "removeDefenseBonus") + .registerSubtype(ABActionAddRallyAbility.class, "addRallyAbility") + + .registerSubtype(ABActionCreateUnitGroup.class, "createUnitGroup") + .registerSubtype(ABActionIterateUnitsInGroup.class, "iterateUnitsInGroup") + .registerSubtype(ABActionAddUnitToGroup.class, "addUnitToGroup") + .registerSubtype(ABActionRemoveUnitFromGroup.class, "removeUnitFromGroup") + + .registerSubtype(ABActionCreateUnitQueue.class, "createUnitQueue") + .registerSubtype(ABActionIterateUnitsInQueue.class, "iterateUnitsInQueue") + .registerSubtype(ABActionAddUnitToQueue.class, "addUnitToQueue") + .registerSubtype(ABActionRemoveUnitFromQueue.class, "removeUnitFromQueue") + .registerSubtype(ABActionClearUnitQueue.class, "clearUnitQueue") + + .registerSubtype(ABActionCreateUnit.class, "createUnit") + .registerSubtype(ABActionDamageTarget.class, "damageTarget") + .registerSubtype(ABActionDamageArea.class, "damageArea") + .registerSubtype(ABActionDamageBurst.class, "damageBurst") + .registerSubtype(ABActionDamageSplash.class, "damageSplash") + .registerSubtype(ABActionDamageAttackSplash.class, "damageAttackSplash") + .registerSubtype(ABActionHeal.class, "heal") + .registerSubtype(ABActionSetHp.class, "setHp").registerSubtype(ABActionResurrect.class, "resurrect") + .registerSubtype(ABActionSetMp.class, "setMp") + .registerSubtype(ABActionAddMp.class, "addMp") + .registerSubtype(ABActionSubtractMp.class, "subtractMp") + .registerSubtype(ABActionSetSpeed.class, "setSpeed") + .registerSubtype(ABActionMultiplyUnitScale.class, "multiplyUnitScale") + .registerSubtype(ABActionAddStunBuff.class, "addStunBuff") + .registerSubtype(ABActionAddSlowBuff.class, "addSlowBuff") + .registerSubtype(ABActionKillUnit.class, "killUnit") + .registerSubtype(ABActionRemoveUnit.class, "removeUnit") + .registerSubtype(ABActionHideUnit.class, "hideUnit") + .registerSubtype(ABActionUnhideUnit.class, "unhideUnit") + .registerSubtype(ABActionMergeUnits.class, "mergeUnits") + .registerSubtype(ABActionTransformUnit.class, "transformUnit") + .registerSubtype(ABActionTransformUnitInstant.class, "transformUnitInstant") + .registerSubtype(ABActionTransformedUnitAbilityAdd.class, "transformedUnitAbilityAdd") + .registerSubtype(ABActionTransformedUnitAbilityRemove.class, "transformedUnitAbilityRemove") + .registerSubtype(ABActionTransformUnitAppearance.class, "transformUnitAppearance") + .registerSubtype(ABActionSetExplodesOnDeath.class, "setExplodesOnDeath") + .registerSubtype(ABActionIssueStopOrder.class, "issueStopOrder") + .registerSubtype(ABActionSendUnitBackToWork.class, "sendUnitBackToWork") + .registerSubtype(ABActionStartTrainingUnit.class, "startTrainingUnit") + .registerSubtype(ABActionStartSacrificingUnit.class, "startSacrificingUnit") + .registerSubtype(ABActionForceBeginCreatedBehavior.class, "forceBeginCreatedBehavior") + .registerSubtype(ABActionChangeAttackActionToMovement.class, "changeAttackActionToMovement") + .registerSubtype(ABActionStartModifiedAttack.class, "startModifiedAttack") + .registerSubtype(ABActionFireModifiedAttack.class, "fireModifiedAttack") + + .registerSubtype(ABActionSetUnitFlyHeight.class, "setUnitFlyHeight") + .registerSubtype(ABActionSetUnitMovementTypeNoCollision.class, "setUnitMovementTypeNoCollision") + + .registerSubtype(ABActionPlayAnimation.class, "playAnimation") + .registerSubtype(ABActionQueueAnimation.class, "queueAnimation") + .registerSubtype(ABActionAddSecondaryAnimationTag.class, "addSecondaryAnimationTag") + .registerSubtype(ABActionRemoveSecondaryAnimationTag.class, "removeSecondaryAnimationTag") + + .registerSubtype(ABActionSetUnitAlpha.class, "setUnitAlpha") + .registerSubtype(ABActionMultiplyUnitAlpha.class, "multiplyUnitAlpha") + .registerSubtype(ABActionDivideUnitAlpha.class, "divideUnitAlpha") + + .registerSubtype(ABActionInstantReturnResources.class, "instantReturnResources") + .registerSubtype(ABActionEnableWorkerAbilities.class, "enableWorkerAbilities") + .registerSubtype(ABActionDisableWorkerAbilities.class, "disableWorkerAbilities") + + + + .registerSubtype(ABActionStartCooldown.class, "startCooldown") + .registerSubtype(ABActionResetCooldown.class, "resetCooldown") + .registerSubtype(ABActionActivateToggledAbility.class, "activateToggledAbility") + .registerSubtype(ABActionDeactivateToggledAbility.class, "deactivateToggledAbility") + .registerSubtype(ABActionEnableAbility.class, "enableAbility") + .registerSubtype(ABActionDisableAbility.class, "disableAbility") + .registerSubtype(ABActionEnableAbilityById.class, "enableAbilityById") + .registerSubtype(ABActionDisableAbilityById.class, "disableAbilityById") + .registerSubtype(ABActionClickEnableAbility.class, "clickEnableAbility") + .registerSubtype(ABActionClickDisableAbility.class, "clickDisableAbility") + .registerSubtype(ABActionBeginChanneling.class, "beginChanneling") + .registerSubtype(ABActionFinishChanneling.class, "finishChanneling") + .registerSubtype(ABActionSetAbilityCastRange.class, "setAbilityCastRange") + .registerSubtype(ABActionAddTargetAllowed.class, "addTargetAllowed") + .registerSubtype(ABActionRemoveTargetAllowed.class, "removeTargetAllowed") + .registerSubtype(ABActionAbilityAttemptToApplyEffect.class, "abilityAttemptToApplyEffect") + .registerSubtype(ABActionAbilityRunEndCastingActions.class, "abilityRunEndCastingActions") + .registerSubtype(ABActionSendStartCastingEvents.class, "sendStartCastingEvents") + .registerSubtype(ABActionSetPreventEndEvents.class, "setPreventEndEvents") + + + .registerSubtype(ABActionCreateTimer.class, "createTimer") + .registerSubtype(ABActionStartTimer.class, "startTimer") + .registerSubtype(ABActionUpdateTimerTimeout.class, "updateTimerTimeout") + .registerSubtype(ABActionRemoveTimer.class, "removeTimer") + .registerSubtype(ABActionKillTimer.class, "killTimer") + + .registerSubtype(ABActionAddBuff.class, "addBuff") + .registerSubtype(ABActionAddNonStackingDisplayBuff.class, "addNonStackingDisplayBuff") + .registerSubtype(ABActionRemoveBuff.class, "removeBuff") + .registerSubtype(ABActionDispelBuffs.class, "dispelBuffs") + .registerSubtype(ABActionRemoveNonStackingDisplayBuff.class, "removeNonStackingDisplayBuff") + .registerSubtype(ABActionCreatePassiveBuff.class, "createPassiveBuff") + .registerSubtype(ABActionCreateTargetingBuff.class, "createTargetingBuff") + .registerSubtype(ABActionCreateTimedBuff.class, "createTimedBuff") + .registerSubtype(ABActionCreateTimedTargetingBuff.class, "createTimedTargetingBuff") + .registerSubtype(ABActionCreateTimedArtBuff.class, "createTimedArtBuff") + .registerSubtype(ABActionCreateTimedPausedExpirationBuff.class, "createTimedPausedExpirationBuff") + .registerSubtype(ABActionCreateTimedTickingBuff.class, "createTimedTickingBuff") + .registerSubtype(ABActionCreateTimedTickingPausedBuff.class, "createTimedTickingPausedBuff") + .registerSubtype(ABActionCreateTimedTickingPostDeathBuff.class, "createTimedTickingPostDeathBuff") + .registerSubtype(ABActionCreateTimedLifeBuff.class, "createTimedLifeBuff") + + .registerSubtype(ABActionBuffAddUniqueFlag.class, "buffAddUniqueFlag") + .registerSubtype(ABActionBuffRemoveUniqueFlag.class, "buffRemoveUniqueFlag") + .registerSubtype(ABActionBuffStoreUniqueValue.class, "buffStoreUniqueValue") + .registerSubtype(ABActionBuffRemoveUniqueValue.class, "buffRemoveUniqueValue") + + .registerSubtype(ABActionCreateStateModBuff.class, "createStateModBuff") + .registerSubtype(ABActionAddStateModBuff.class, "addStateModBuff") + .registerSubtype(ABActionRemoveStateModBuff.class, "removeStateModBuff") + .registerSubtype(ABActionUpdateStateModBuff.class, "updateStateModBuff") + .registerSubtype(ABActionSetUnitFadeTimer.class, "setUnitFadeTimer") + + .registerSubtype(ABActionCreateNonStackingStatBuff.class, "createNonStackingStatBuff") + .registerSubtype(ABActionAddNonStackingStatBuff.class, "addNonStackingStatBuff") + .registerSubtype(ABActionRemoveNonStackingStatBuff.class, "removeNonStackingStatBuff") + .registerSubtype(ABActionUpdateNonStackingStatBuff.class, "updateNonStackingStatBuff") + .registerSubtype(ABActionRecomputeStatBuffsOnUnit.class, "recomputeStatBuffsOnUnit") + + .registerSubtype(ABActionCreateAttackModifier.class, "createAttackModifier") + .registerSubtype(ABActionAddAttackModifier.class, "addAttackModifier") + .registerSubtype(ABActionRemoveAttackModifier.class, "removeAttackModifier") + .registerSubtype(ABActionCreateAttackPostDamageListener.class, "createAttackPostDamageListener") + .registerSubtype(ABActionAddAttackPostDamageListener.class, "addAttackPostDamageListener") + .registerSubtype(ABActionRemoveAttackPostDamageListener.class, "removeAttackPostDamageListener") + .registerSubtype(ABActionCreateAttackPreDamageListener.class, "createAttackPreDamageListener") + .registerSubtype(ABActionAddAttackPreDamageListener.class, "addAttackPreDamageListener") + .registerSubtype(ABActionRemoveAttackPreDamageListener.class, "removeAttackPreDamageListener") + .registerSubtype(ABActionCreateDamageTakenListener.class, "createDamageTakenListener") + .registerSubtype(ABActionAddDamageTakenListener.class, "addDamageTakenListener") + .registerSubtype(ABActionRemoveDamageTakenListener.class, "removeDamageTakenListener") + .registerSubtype(ABActionCreateDamageTakenModificationListener.class, + "createDamageTakenModificationListener") + .registerSubtype(ABActionAddDamageTakenModificationListener.class, "addDamageTakenModificationListener") + .registerSubtype(ABActionRemoveDamageTakenModificationListener.class, + "removeDamageTakenModificationListener") + .registerSubtype(ABActionCreateEvasionListener.class, "createEvasionListener") + .registerSubtype(ABActionAddEvasionListener.class, "addEvasionListener") + .registerSubtype(ABActionRemoveEvasionListener.class, "removeEvasionListener") + .registerSubtype(ABActionCreateDeathReplacementEffect.class, "createDeathReplacementEffect") + .registerSubtype(ABActionAddDeathReplacementEffect.class, "addDeathReplacementEffect") + .registerSubtype(ABActionRemoveDeathReplacementEffect.class, "removeDeathReplacementEffect") + .registerSubtype(ABActionCreateBehaviorChangeListener.class, "createBehaviorChangeListener") + .registerSubtype(ABActionAddBehaviorChangeListener.class, "addBehaviorChangeListener") + .registerSubtype(ABActionRemoveBehaviorChangeListener.class, "removeBehaviorChangeListener") + + .registerSubtype(ABActionCreateAbilityEffectReactionListener.class, "createAbilityEffectReactionListener") + .registerSubtype(ABActionAddAbilityEffectReactionListener.class, "addAbilityEffectReactionListener") + .registerSubtype(ABActionRemoveAbilityEffectReactionListener.class, "removeAbilityEffectReactionListener") + .registerSubtype(ABActionCreateAbilityProjReactionListener.class, "createAbilityProjReactionListener") + .registerSubtype(ABActionAddAbilityProjReactionListener.class, "addAbilityProjReactionListener") + .registerSubtype(ABActionRemoveAbilityProjReactionListener.class, "removeAbilityProjReactionListener") + .registerSubtype(ABActionCreateAttackProjReactionListener.class, "createAttackProjReactionListener") + .registerSubtype(ABActionAddAttackProjReactionListener.class, "addAttackProjReactionListener") + .registerSubtype(ABActionRemoveAttackProjReactionListener.class, "removeAttackProjReactionListener") + + .registerSubtype(ABActionDamageTakenModificationSetDamageMultiplier.class, "setDamageTakenMultiplier") + .registerSubtype(ABActionDamageTakenModificationMultiplyDamageMultiplier.class, + "multiplyDamageTakenMultiplier") + .registerSubtype(ABActionPreDamageListenerAddDamageMultiplier.class, "addDamageDealtMultiplier") + .registerSubtype(ABActionPreDamageListenerAddBonusDamage.class, "addBonusDamageDealt") + .registerSubtype(ABActionPreDamageListenerLockDamageModifications.class, "lockDamageModifications") + .registerSubtype(ABActionPreDamageListenerSetMiss.class, "preDamageListenerSetMiss") + .registerSubtype(ABActionSetPreDamageStacking.class, "setStacking") + .registerSubtype(ABActionDeathReplacementSetReviving.class, "setReviving") + .registerSubtype(ABActionDeathReplacementSetReincarnating.class, "setReincarnating") + .registerSubtype(ABActionDeathReplacementFinishReincarnating.class, "finishReincarnating") + .registerSubtype(ABActionSubtractTotalDamageDealt.class, "subtractTotalDamageDealt") + .registerSubtype(ABActionReactionPreventHit.class, "reactionPreventHit") + + .registerSubtype(ABActionCreateUnitStateListener.class, "createUnitStateListener") + .registerSubtype(ABActionAddUnitStateListener.class, "addUnitStateListener") + .registerSubtype(ABActionRemoveUnitStateListener.class, "removeUnitStateListener") + + .registerSubtype(ABActionAttackModifierPreventOtherSamePriorityModifications.class, "attackModifierPreventOtherSamePriorityModifications") + .registerSubtype(ABActionAttackModifierPreventOtherModifications.class, "attackModifierPreventOtherModifications") + .registerSubtype(ABActionAttackModifierApplyArt.class, "attackModifierApplyArt") + .registerSubtype(ABActionAttackModifierApplyArtAndSpeed.class, "attackModifierApplyArtAndSpeed") + .registerSubtype(ABActionAttackModifierApplyAllArtFields.class, "attackModifierApplyAllArtFields") + .registerSubtype(ABActionAttackModifierApplyDefaultSpeed.class, "attackModifierApplyDefaultSpeed") + .registerSubtype(ABActionAttackModifierSetAttackArc.class, "attackModifierSetAttackArc") + .registerSubtype(ABActionAttackModifierSetAttackHoming.class, "attackModifierSetAttackHoming") + .registerSubtype(ABActionAttackModifierSetSplashFields.class, "attackModifierSetSplashFields") + .registerSubtype(ABActionAttackModifierSetAttackStartZ.class, "attackModifierSetAttackStartZ") + .registerSubtype(ABActionAttackModifierSetAttackImpactZ.class, "attackModifierSetAttackImpactZ") + .registerSubtype(ABActionAttackModifierSetAttackDeathTime.class, "attackModifierSetAttackDeathTime") + .registerSubtype(ABActionAttackModifierAddPreDamageListener.class, "attackModifierAddPreDamageListener") + .registerSubtype(ABActionAttackModifierRemovePreDamageListener.class, "attackModifierRemovePreDamageListener") + .registerSubtype(ABActionAttackModifierAddPostDamageListener.class, "attackModifierAddPostDamageListener") + .registerSubtype(ABActionAttackModifierRemovePostDamageListener.class, "attackModifierRemovePostDamageListener") + .registerSubtype(ABActionAttackModifierAddAnimationTag.class, "attackModifierAddAnimationTag") + .registerSubtype(ABActionAttackModifierRemoveAnimationTag.class, "attackModifierRemoveAnimationTag") + + .registerSubtype(ABActionCreateDestructable.class, "createDestructable") + .registerSubtype(ABActionDamageDestructable.class, "damageDestructable") + .registerSubtype(ABActionKillDestructable.class, "killDestructable") + .registerSubtype(ABActionRemoveDestructable.class, "removeDestructable") + .registerSubtype(ABActionIterateDestructablesInRangeOfLocation.class, "iterateDestructablesInRangeOfLocation") + + .registerSubtype(ABActionAddDestructableBuff.class, "addDestructableBuff") + .registerSubtype(ABActionCreateDestructableBuff.class, "createDestructableBuff") + .registerSubtype(ABActionRemoveDestructableBuff.class, "removeDestructableBuff") + .registerSubtype(ABActionDispelDestructableBuffs.class, "dispelDestructableBuffs") + + .registerSubtype(ABActionCreateFloatingTextOnUnit.class, "createFloatingTextOnUnit") + .registerSubtype(ABActionCreateNumericFloatingTextOnUnit.class, "createNumericFloatingTextOnUnit") + + .registerSubtype(ABActionSetAutoTargetUnit.class, "setAutoTargetUnit") + .registerSubtype(ABActionSetAutoTargetDestructable.class, "setAutoTargetDestructable") + + + + .registerSubtype(ABActionChargeItem.class, "chargeItem") + .registerSubtype(ABActionTransformItem.class, "transformItem") + + + + + .registerSubtype(ABActionGiveResourcesToPlayer.class, "giveResourcesToPlayer") + .registerSubtype(ABActionSetAbilityEnabledForPlayer.class, "setAbilityEnabledForPlayer") + + .registerSubtype(ABActionCreateUnitVisionModifier.class, "createUnitVisionModifier") + .registerSubtype(ABActionCreateLocationVisionModifier.class, "createLocationVisionModifier") + .registerSubtype(ABActionCreateProjectileVisionModifier.class, "createProjectileVisionModifier") + .registerSubtype(ABActionRemoveVisionModifier.class, "removeVisionModifier") + + + .registerSubtype(ABActionAbilitySetShowIcon.class, "abilitySetShowIcon") + .registerSubtype(ABActionAbilityAddUniqueFlag.class, "abilityAddUniqueFlag") + .registerSubtype(ABActionAbilityRemoveUniqueFlag.class, "abilityRemoveUniqueFlag") + .registerSubtype(ABActionAbilityStoreUniqueValue.class, "abilityStoreUniqueValue") + .registerSubtype(ABActionAbilityRemoveUniqueValue.class, "abilityRemoveUniqueValue") + + + .registerSubtype(ABActionCreateTimeOfDayEvent.class, "createTimeOfDayEvent") + .registerSubtype(ABActionRegisterTimeOfDayEvent.class, "registerTimeOfDayEvent") + .registerSubtype(ABActionRegisterUniqueTimeOfDayEvent.class, "registerUniqueTimeOfDayEvent") + .registerSubtype(ABActionUnregisterTimeOfDayEvent.class, "unregisterTimeOfDayEvent") + + .registerSubtype(ABActionCreateWidgetEvent.class, "createWidgetEvent") + .registerSubtype(ABActionRegisterWidgetEvent.class, "registerWidgetEvent") + .registerSubtype(ABActionUnregisterWidgetEvent.class, "unregisterWidgetEvent") + + + .registerSubtype(ABActionListRemove.class, "listRemove") + .registerSubtype(ABActionSortableListRemove.class, "sortableListRemove") + .registerSubtype(ABActionLocationListAdd.class, "locationListAdd") + + + .registerSubtype(ABActionCreateSubroutine.class, "createSubroutine") + .registerSubtype(ABActionRunSubroutine.class, "runSubroutine") + + .registerSubtype(ABActionRunReuseAction.class, "runReuseAction") + .registerSubtype(ABActionRunReuseActionWithArguments.class, "runReuseActionWithArguments") + + .registerSubtype(ABActionSetFalseTimeOfDay.class, "setFalseTimeOfDay") + + .registerSubtype(ABActionAttemptToReOrderPreviousBehavior.class, "attemptToReOrderPreviousBehavior") + .registerSubtype(ABActionAttemptToResumePreviousBehavior.class, "attemptToResumePreviousBehavior") + + .registerSubtype(ABActionModifyTerrainVertex.class, "modifyTerrainVertex") + .registerSubtype(ABActionCreateTerrainRippleAtLocation.class, "createTerrainRippleAtLocation") + .registerSubtype(ABActionCreateTerrainBowlAtLocation.class, "createTerrainBowlAtLocation") + .registerSubtype(ABActionCreateTerrainWaveAtLocation.class, "createTerrainWaveAtLocation") + ; + } + + public static Gson create() { + GsonBuilder gsonBuilder = new GsonBuilder(); + + final RuntimeTypeAdapterFactory actionTypeFactory = RuntimeTypeAdapterFactory.of(ABAction.class, + "type"); + registerActions(actionTypeFactory); + gsonBuilder.registerTypeAdapterFactory(actionTypeFactory); + + final RuntimeTypeAdapterFactory callbackTypeFactory = RuntimeTypeAdapterFactory.of(ABCallback.class, + "type"); + registerAbilityCallbacks(callbackTypeFactory); + registerAttackModifierCallbacks(callbackTypeFactory); + registerAttackSettingsCallbacks(callbackTypeFactory); + registerAbilityEffectReactionListenerCallbacks(callbackTypeFactory); + registerAbilityProjReactionListenerCallbacks(callbackTypeFactory); + registerAttackProjReactionListenerCallbacks(callbackTypeFactory); + registerAttackPostDamageListenerCallbacks(callbackTypeFactory); + registerAttackPreDamageListenerCallbacks(callbackTypeFactory); + registerBehaviorChangeListenerCallbacks(callbackTypeFactory); + registerBooleanCallbacks(callbackTypeFactory); + registerConditions(callbackTypeFactory); // conditions are boolean callbacks now + registerBuffCallbacks(callbackTypeFactory); + registerDamageTakenListenerCallbacks(callbackTypeFactory); + registerDamageTakenModificationListenerCallbacks(callbackTypeFactory); + registerDeathReplacementEffectCallbacks(callbackTypeFactory); + registerDestructableCallbacks(callbackTypeFactory); + registerDestructableBuffCallbacks(callbackTypeFactory); + registerEvasionListenerCallbacks(callbackTypeFactory); + registerFloatCallbacks(callbackTypeFactory); + registerGenericFloatCallbacks(callbackTypeFactory); + registerFxCallbacks(callbackTypeFactory); + registerIdCallbacks(callbackTypeFactory); + registerIntegerCallbacks(callbackTypeFactory); + registerItemCallbacks(callbackTypeFactory); + registerListCallbacks(callbackTypeFactory); + registerSortableListCallbacks(callbackTypeFactory); + registerIntegerListCallbacks(callbackTypeFactory); + registerLocationListCallbacks(callbackTypeFactory); + registerLightningCallbacks(callbackTypeFactory); + registerLocationCallbacks(callbackTypeFactory); + registerLongCallbacks(callbackTypeFactory); + registerOrderIdCallbacks(callbackTypeFactory); + registerPlayerCallbacks(callbackTypeFactory); + registerProjectileCallbacks(callbackTypeFactory); + registerStatBuffCallbacks(callbackTypeFactory); + registerStateModBuffCallbacks(callbackTypeFactory); + registerStringCallbacks(callbackTypeFactory); + registerTargetCallbacks(callbackTypeFactory); + registerTimeOfDayEventCallbacks(callbackTypeFactory); + registerTimerCallbacks(callbackTypeFactory); + registerUnitCallbacks(callbackTypeFactory); + registerUnitGroupCallbacks(callbackTypeFactory); + registerUnitQueueCallbacks(callbackTypeFactory); + registerUnitStateListenerCallbacks(callbackTypeFactory); + registerVisionModifierCallbacks(callbackTypeFactory); + registerWidgetCallbacks(callbackTypeFactory); + registerWidgetEventCallbacks(callbackTypeFactory); + callbackTypeFactory.registerSubtype(ABCallbackNull.class, "null"); + gsonBuilder.registerTypeAdapterFactory(callbackTypeFactory); + + final RuntimeTypeAdapterFactory abilityCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAbilityCallback.class, "type"); + registerAbilityCallbacks(abilityCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(abilityCallbackTypeFactory); + + + + final RuntimeTypeAdapterFactory attackModifierCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAttackModifierCallback.class, "type"); + registerAttackModifierCallbacks(attackModifierCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(attackModifierCallbackTypeFactory); + + final RuntimeTypeAdapterFactory attackSettingsCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAttackSettingsCallback.class, "type"); + registerAttackSettingsCallbacks(attackSettingsCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(attackSettingsCallbackTypeFactory); + + final RuntimeTypeAdapterFactory abilityEffectReactionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAbilityEffectReactionListenerCallback.class, "type"); + registerAbilityEffectReactionListenerCallbacks(abilityEffectReactionListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(abilityEffectReactionListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory abilityProjReactionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAbilityProjReactionListenerCallback.class, "type"); + registerAbilityProjReactionListenerCallbacks(abilityProjReactionListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(abilityProjReactionListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory attackProjReactionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAttackProjReactionListenerCallback.class, "type"); + registerAttackProjReactionListenerCallbacks(attackProjReactionListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(attackProjReactionListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory attackPostDamageListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAttackPostDamageListenerCallback.class, "type"); + registerAttackPostDamageListenerCallbacks(attackPostDamageListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(attackPostDamageListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory attackPreDamageListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABAttackPreDamageListenerCallback.class, "type"); + registerAttackPreDamageListenerCallbacks(attackPreDamageListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(attackPreDamageListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory behaviorChangeListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABBehaviorChangeListenerCallback.class, "type"); + registerBehaviorChangeListenerCallbacks(behaviorChangeListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(behaviorChangeListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory booleanCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABBooleanCallback.class, "type"); + registerBooleanCallbacks(booleanCallbackTypeFactory); + registerConditions(booleanCallbackTypeFactory); // conditions are boolean callbacks now + gsonBuilder.registerTypeAdapterFactory(booleanCallbackTypeFactory); + + final RuntimeTypeAdapterFactory buffCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABBuffCallback.class, "type"); + registerBuffCallbacks(buffCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(buffCallbackTypeFactory); + + final RuntimeTypeAdapterFactory damageTakenListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABDamageTakenListenerCallback.class, "type"); + registerDamageTakenListenerCallbacks(damageTakenListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(damageTakenListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory damageTakenModificationListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABDamageTakenModificationListenerCallback.class, "type"); + registerDamageTakenModificationListenerCallbacks(damageTakenModificationListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(damageTakenModificationListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory deathReplacementEffectCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABDeathReplacementCallback.class, "type"); + registerDeathReplacementEffectCallbacks(deathReplacementEffectCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(deathReplacementEffectCallbackTypeFactory); + + final RuntimeTypeAdapterFactory destructableCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABDestructableCallback.class, "type"); + registerDestructableCallbacks(destructableCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(destructableCallbackTypeFactory); + + final RuntimeTypeAdapterFactory destructableBuffCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABDestructableBuffCallback.class, "type"); + registerDestructableBuffCallbacks(destructableBuffCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(destructableBuffCallbackTypeFactory); + + final RuntimeTypeAdapterFactory evasionListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABEvasionListenerCallback.class, "type"); + registerEvasionListenerCallbacks(evasionListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(evasionListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory floatCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABFloatCallback.class, "type"); + registerFloatCallbacks(floatCallbackTypeFactory); + registerSpecialFloatCallbacks(floatCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(floatCallbackTypeFactory); + + final RuntimeTypeAdapterFactory fxCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABFXCallback.class, "type"); + registerFxCallbacks(fxCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(fxCallbackTypeFactory); + + final RuntimeTypeAdapterFactory idCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABIDCallback.class, "type"); + registerIdCallbacks(idCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(idCallbackTypeFactory); + + final RuntimeTypeAdapterFactory integerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABIntegerCallback.class, "type"); + registerIntegerCallbacks(integerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(integerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory itemCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABItemCallback.class, "type"); + registerItemCallbacks(itemCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(itemCallbackTypeFactory); + + final RuntimeTypeAdapterFactory lightningCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABLightningCallback.class, "type"); + registerLightningCallbacks(lightningCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(lightningCallbackTypeFactory); + + final RuntimeTypeAdapterFactory listCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABListCallback.class, "type"); + registerListCallbacks(listCallbackTypeFactory); + registerLocationListCallbacks(listCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(listCallbackTypeFactory); + + final RuntimeTypeAdapterFactory sortableListCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABSortableListCallback.class, "type"); + registerSortableListCallbacks(sortableListCallbackTypeFactory); + registerIntegerListCallbacks(sortableListCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(sortableListCallbackTypeFactory); + + final RuntimeTypeAdapterFactory locationListCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABLocationListCallback.class, "type"); + registerListCallbacks(locationListCallbackTypeFactory); + registerLocationListCallbacks(locationListCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(locationListCallbackTypeFactory); + + final RuntimeTypeAdapterFactory integerListCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABIntegerListCallback.class, "type"); + registerSortableListCallbacks(integerListCallbackTypeFactory); + registerIntegerListCallbacks(integerListCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(integerListCallbackTypeFactory); + + final RuntimeTypeAdapterFactory locationCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABLocationCallback.class, "type"); + registerLocationCallbacks(locationCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(locationCallbackTypeFactory); + + final RuntimeTypeAdapterFactory longCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABLongCallback.class, "type"); + registerLongCallbacks(longCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(longCallbackTypeFactory); + + final RuntimeTypeAdapterFactory orderIdCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABOrderIdCallback.class, "type"); + registerOrderIdCallbacks(orderIdCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(orderIdCallbackTypeFactory); + + + final RuntimeTypeAdapterFactory playerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABPlayerCallback.class, "type"); + registerPlayerCallbacks(playerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(playerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory projectileCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABProjectileCallback.class, "type"); + registerProjectileCallbacks(projectileCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(projectileCallbackTypeFactory); + + final RuntimeTypeAdapterFactory statBuffCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABNonStackingStatBuffCallback.class, "type"); + registerStatBuffCallbacks(statBuffCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(statBuffCallbackTypeFactory); + + final RuntimeTypeAdapterFactory stateModBuffCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABStateModBuffCallback.class, "type"); + registerStateModBuffCallbacks(stateModBuffCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(stateModBuffCallbackTypeFactory); + + final RuntimeTypeAdapterFactory stringCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABStringCallback.class, "type"); + registerStringCallbacks(stringCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(stringCallbackTypeFactory); + + final RuntimeTypeAdapterFactory targetCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABTargetCallback.class, "type"); + registerTargetCallbacks(targetCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(targetCallbackTypeFactory); + + final RuntimeTypeAdapterFactory timeOfDayEventCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABTimeOfDayEventCallback.class, "type"); + registerTimeOfDayEventCallbacks(timeOfDayEventCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(timeOfDayEventCallbackTypeFactory); + + final RuntimeTypeAdapterFactory timerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABTimerCallback.class, "type"); + registerTimerCallbacks(timerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(timerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory unitCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABUnitCallback.class, "type"); + registerUnitCallbacks(unitCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(unitCallbackTypeFactory); + + final RuntimeTypeAdapterFactory unitGroupCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABUnitGroupCallback.class, "type"); + registerUnitGroupCallbacks(unitGroupCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(unitGroupCallbackTypeFactory); + + final RuntimeTypeAdapterFactory unitQueueCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABUnitQueueCallback.class, "type"); + registerUnitQueueCallbacks(unitQueueCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(unitQueueCallbackTypeFactory); + + final RuntimeTypeAdapterFactory unitStateListenerCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABUnitStateListenerCallback.class, "type"); + registerUnitStateListenerCallbacks(unitStateListenerCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(unitStateListenerCallbackTypeFactory); + + final RuntimeTypeAdapterFactory visionModifierCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABVisionModifierCallback.class, "type"); + registerVisionModifierCallbacks(visionModifierCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(visionModifierCallbackTypeFactory); + + + final RuntimeTypeAdapterFactory widgetCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABWidgetCallback.class, "type"); + registerWidgetCallbacks(widgetCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(widgetCallbackTypeFactory); + + final RuntimeTypeAdapterFactory widgetEventCallbackTypeFactory = RuntimeTypeAdapterFactory + .of(ABWidgetEventCallback.class, "type"); + registerWidgetEventCallbacks(widgetEventCallbackTypeFactory); + gsonBuilder.registerTypeAdapterFactory(widgetEventCallbackTypeFactory); + + final RuntimeTypeAdapterFactory conditionTypeFactory = RuntimeTypeAdapterFactory + .of(ABBooleanCallback.class, "type"); + registerConditions(conditionTypeFactory); + registerBooleanCallbacks(conditionTypeFactory); + gsonBuilder.registerTypeAdapterFactory(conditionTypeFactory); + + // ENUM CALLBACKS + final RuntimeTypeAdapterFactory nssbtTypeFactory = RuntimeTypeAdapterFactory + .of(ABNonStackingStatBuffTypeCallback.class, "type"); + nssbtTypeFactory.registerSubtype(ABCallbackGetNonStackingStatBuffTypeFromString.class, + "getNonStackingStatBuffTypeFromString"); + gsonBuilder.registerTypeAdapterFactory(nssbtTypeFactory); + + final RuntimeTypeAdapterFactory atTypeFactory = RuntimeTypeAdapterFactory + .of(ABAttackTypeCallback.class, "type"); + atTypeFactory.registerSubtype(ABCallbackGetAttackTypeFromString.class, "getAttackTypeFromString") + .registerSubtype(ABCallbackGetStoredAttackTypeByKey.class, "getStoredAttackTypeByKey") + .registerSubtype(ABCallbackGetAttackType.class, "getAttackType") + .registerSubtype(ABCallbackGetTriggeringAttackType.class, "getTriggeringAttackType") + .registerSubtype(ABCallbackGetModifiedAttackAttackType.class, "getModifiedAttackAttackType") + .registerSubtype(ABCallbackGetReactionAttackProjectileAttackType.class, "getReactionAttackProjectileAttackType"); + gsonBuilder.registerTypeAdapterFactory(atTypeFactory); + callbackTypeFactory.registerSubtype(ABCallbackGetAttackType.class, "getAttackType"); + + final RuntimeTypeAdapterFactory dtTypeFactory = RuntimeTypeAdapterFactory + .of(ABDamageTypeCallback.class, "type"); + dtTypeFactory.registerSubtype(ABCallbackGetDamageTypeFromString.class, "getDamageTypeFromString") + .registerSubtype(ABCallbackGetStoredDamageTypeByKey.class, "getStoredDamageTypeByKey") + .registerSubtype(ABCallbackGetAttackDamageType.class, "getAttackDamageType") + .registerSubtype(ABCallbackGetTriggeringDamageType.class, "getTriggeringDamageType") + .registerSubtype(ABCallbackGetModifiedAttackDamageType.class, "getModifiedAttackDamageType"); + gsonBuilder.registerTypeAdapterFactory(dtTypeFactory); + callbackTypeFactory.registerSubtype(ABCallbackGetAttackDamageType.class, "getAttackDamageType"); + + final RuntimeTypeAdapterFactory defTypeFactory = RuntimeTypeAdapterFactory + .of(ABDefenseTypeCallback.class, "type"); + defTypeFactory.registerSubtype(ABCallbackGetDefenseTypeFromString.class, "getDefenseTypeFromString") + .registerSubtype(ABCallbackGetStoredDefenseTypeByKey.class, "getStoredDefenseTypeByKey") + .registerSubtype(ABCallbackGetUnitDefenseType.class, "getUnitDefenseType"); + gsonBuilder.registerTypeAdapterFactory(defTypeFactory); + + final RuntimeTypeAdapterFactory wtTypeFactory = RuntimeTypeAdapterFactory + .of(ABWeaponTypeCallback.class, "type"); + wtTypeFactory.registerSubtype(ABCallbackGetWeaponTypeFromString.class, "getWeaponTypeFromString") + .registerSubtype(ABCallbackGetStoredWeaponTypeByKey.class, "getStoredWeaponTypeByKey") + .registerSubtype(ABCallbackGetAttackWeaponType.class, "getAttackWeaponType") + .registerSubtype(ABCallbackRawWeaponType.class, "rawWeaponType") + .registerSubtype(ABCallbackGetModifiedAttackWeaponType.class, "getModifiedAttackWeaponType"); + gsonBuilder.registerTypeAdapterFactory(wtTypeFactory); + + final RuntimeTypeAdapterFactory ttTypeFactory = RuntimeTypeAdapterFactory + .of(ABTargetTypeCallback.class, "type"); + ttTypeFactory.registerSubtype(ABCallbackGetTargetTypeFromString.class, "getTargetTypeFromString") + .registerSubtype(ABCallbackGetStoredTargetTypeByKey.class, "getStoredTargetTypeByKey") + .registerSubtype(ABCallbackRawTargetType.class, "rawTargetType"); + gsonBuilder.registerTypeAdapterFactory(ttTypeFactory); + + final RuntimeTypeAdapterFactory moveTypeFactory = RuntimeTypeAdapterFactory + .of(ABMovementTypeCallback.class, "type"); + moveTypeFactory.registerSubtype(ABCallbackGetMovementTypeFromString.class, "getMovementTypeFromString") + .registerSubtype(ABCallbackGetStoredMovementTypeByKey.class, "getStoredMovementTypeByKey") + .registerSubtype(ABCallbackGetUnitMovementType.class, "getUnitMovementType") + .registerSubtype(ABCallbackGetUnitTypeMovementType.class, "getUnitTypeMovementType"); + gsonBuilder.registerTypeAdapterFactory(moveTypeFactory); + + final RuntimeTypeAdapterFactory pdlpTypeFactory = RuntimeTypeAdapterFactory + .of(ABAttackPreDamageListenerPriorityCallback.class, "type"); + pdlpTypeFactory.registerSubtype(ABCallbackRawPreDamageListenerPriority.class, "rawPriority"); + gsonBuilder.registerTypeAdapterFactory(pdlpTypeFactory); + + final RuntimeTypeAdapterFactory drepTypeFactory = RuntimeTypeAdapterFactory + .of(ABDeathReplacementPriorityCallback.class, "type"); + drepTypeFactory.registerSubtype(ABCallbackRawDeathEffectPriority.class, "rawPriority"); + gsonBuilder.registerTypeAdapterFactory(drepTypeFactory); + + final RuntimeTypeAdapterFactory autocastTypeFactory = RuntimeTypeAdapterFactory + .of(ABAutocastTypeCallback.class, "type"); + autocastTypeFactory.registerSubtype(ABCallbackConditionalAutocastType.class, + "conditionalAutocastType"); + autocastTypeFactory.registerSubtype(ABCallbackGetAutocastTypeFromString.class, + "getAutocastTypeFromString"); + gsonBuilder.registerTypeAdapterFactory(autocastTypeFactory); + + + return gsonBuilder.create(); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABAction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABAction.java new file mode 100644 index 000000000..5f5685518 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABAction.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core; + +import com.etheller.warsmash.parsers.jass.JassTextGeneratorStmt; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public interface ABAction extends JassTextGeneratorStmt { + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABCallback.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABCallback.java new file mode 100644 index 000000000..6d7c6d0b7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABCallback.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core; + +import com.etheller.warsmash.parsers.jass.JassTextGeneratorExpr; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public interface ABCallback extends JassTextGeneratorExpr { + + public Object callback(final CUnit caster, final ABLocalDataStore localStore, final int castId); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABConstants.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABConstants.java new file mode 100644 index 000000000..6ebf02537 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABConstants.java @@ -0,0 +1,19 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core; + +public class ABConstants { + public static int NO_CAST_ID = 0; + public static int STARTING_CAST_ID = 0; + public static int STARTING_TRIGGER_ID = 0; + public static int STARTING_TRIGGER_PRIORITY_ID = 1; + + public static int incrementCastId(int castId) { + if (castId + 1 == NO_CAST_ID) { + return castId+2; + } + return castId+1; + } + + public static int incrementTriggerId(int castId) { + return incrementCastId(castId); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABSingleAction.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABSingleAction.java new file mode 100644 index 000000000..4fe3f4787 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/core/ABSingleAction.java @@ -0,0 +1,7 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core; + +import com.etheller.warsmash.parsers.jass.JassTextGeneratorCallStmt; + +public interface ABSingleAction extends ABAction, JassTextGeneratorCallStmt { + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABDataStore.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABDataStore.java new file mode 100644 index 000000000..31bf548a1 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABDataStore.java @@ -0,0 +1,42 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore; + +import java.util.Collection; +import java.util.Set; + +public interface ABDataStore { + + public boolean containsKey(String key); + + public boolean containsValue(Object value); + + public Object get(String key); + + public Object getOrDefault(String key, Object def); + + public T get(String key, Class D); + + public T getOrDefault(String key, T def, Class D); + + public Object put(String key, Object value); + + public Object remove(String key); + + public void clear(); + + public Set keySet(); + + public Collection values(); + + int getInt(String key); + + int getIntOrDefault(String key, int def); + + boolean getBoolean(String key); + + boolean getBooleanOrDefault(String key, boolean def); + + float getFloat(String key); + + float getFloatOrDefault(String key, float def); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABGlobalDataStore.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABGlobalDataStore.java new file mode 100644 index 000000000..d4d2c39e6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABGlobalDataStore.java @@ -0,0 +1,136 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class ABGlobalDataStore implements ABDataStore { + public static ABGlobalDataStore INSTANCE = new ABGlobalDataStore(); + + private Map store; + + private ABGlobalDataStore() { + this.store = new HashMap<>(); + } + + @Override + public boolean containsKey(String key) { + return store.containsKey(key); + } + + @Override + public boolean containsValue(Object value) { + return store.containsValue(value); + } + + @Override + public Object get(String key) { + return store.get(key); + } + + @Override + public Object getOrDefault(String key, Object def) { + return store.getOrDefault(key, def); + } + + @SuppressWarnings("unchecked") + @Override + public T get(String key, Class D) { + Object val = store.get(key); + if (val != null && D.isAssignableFrom(val.getClass())) { + return (T) val; + } + return null; + } + + @SuppressWarnings("unchecked") + @Override + public T getOrDefault(String key, T def, Class D) { + Object val = store.getOrDefault(key, def); + if (val != null && D.isAssignableFrom(val.getClass())) { + return (T) val; + } + return null; + } + + @Override + public int getInt(String key) { + Object val = store.get(key); + if (val != null && val instanceof Integer) { + return (int) val; + } + return 0; + } + + @Override + public int getIntOrDefault(String key, int def) { + Object val = store.getOrDefault(key, def); + if (val != null && val instanceof Integer) { + return (int) val; + } + return 0; + } + + @Override + public boolean getBoolean(String key) { + Object val = store.get(key); + if (val != null && val instanceof Boolean) { + return (boolean) val; + } + return false; + } + + @Override + public boolean getBooleanOrDefault(String key, boolean def) { + Object val = store.getOrDefault(key, def); + if (val != null && val instanceof Boolean) { + return (boolean) val; + } + return false; + } + + @Override + public float getFloat(String key) { + Object val = store.get(key); + if (val != null && val instanceof Float) { + return (float) val; + } + return 0f; + } + + @Override + public float getFloatOrDefault(String key, float def) { + Object val = store.getOrDefault(key, def); + if (val != null && val instanceof Float) { + return (float) val; + } + return 0f; + } + + @Override + public Object put(String key, Object value) { + return store.put(key, value); + } + + @Override + public Object remove(String key) { + return store.remove(key); + } + + @Override + public void clear() { + store.clear(); + } + + @Override + public Set keySet() { + return store.keySet(); + } + + @Override + public Collection values() { + return store.values(); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABLocalDataStore.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABLocalDataStore.java new file mode 100644 index 000000000..4c0c7f814 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABLocalDataStore.java @@ -0,0 +1,29 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItem; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.upgrade.CUpgradeEffect; + +public abstract class ABLocalDataStore implements ABDataStore { + + public CSimulation game = null; + public CUnit originUnit = null; + public ABAbilityBuilderAbility originAbility = null; + public CItem originItem = null; + public CPlayer originPlayer = null; + public CUpgradeEffect originUpgrade = null; + + public int getLevelDataInstanceLevel(int castId) { + if (castId != ABConstants.NO_CAST_ID) { + return this.getInt(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, castId)) - 1; + } + if (this.originAbility != null) { + return this.originAbility.getLevel() - 1; + } + return 0; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABLocalStoreKeys.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABLocalStoreKeys.java new file mode 100644 index 000000000..25a015095 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABLocalStoreKeys.java @@ -0,0 +1,232 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore; + +public class ABLocalStoreKeys { + // Core values + public static final String ABILITYEDITORDATA = "_abilityEditorData"; + public static final String LEVELDATA = "_levelData"; + public static final String ALIAS = "_alias"; + public static final String CODE = "_code"; + public static final String BUFF = "_buff"; + public static final String ITEMSLOT = "_itemSlot"; + public static final String ITERATORCOUNT = "_i"; + public static final String BREAK = "_break"; + public static final String BUFFCASTINGUNIT = "_buffCastingUnit"; + + public static final String PREVIOUSBEHAVIOR = "_previousBehavior"; + public static final String NEWBEHAVIOR = "_newBehavior"; + + public static final String CASTINSTANCELEVEL = "_castInLvl#"; + + public static final String FAILEDTOCAST = "_failedToCast#"; + public static final String TRANSFORMINGTOALT = "_transformingToAlt#"; + public static final String CHANNELING = "_channeling#"; + public static final String INTERRUPTED = "_interrupted#"; + public static final String PERIODICNEXTTICK = "_periodicNextTick#"; + public static final String PREVENTENDEVENTS = "_preventEndEvents#"; + + public static final String CANTUSEREASON = "_cantUseReason"; + + public static final String ISAUTOCASTTARGETING = "_isAutoCastTar"; + public static final String ISAUTOCAST = "_isAutoCast#"; + + public static final String ISTOGGLEDABILITY = "_toggledAbility"; + public static final String ISFLEXABILITY = "_flexAbility"; + public static final String ISPAIRABILITY = "_pairAbility"; + public static final String ISABILITYLEVELED = "_isAbilityLeveld"; + + + // Aura Template + public static final String AURAGROUP = "_auraGroup"; + + // FX names + public static final String LASTCREATEDFX = "_lastCreatedFx"; + public static final String LASTCREATEDLIGHTNING = "_lastCreatedLtng"; + + // Unit Names + public static final String ENUMUNIT = "_enumUnit#"; + public static final String MATCHINGUNIT = "_matchingUnit#"; + public static final String LASTCREATEDUNIT = "_lastCreatedUnit"; + public static final String LASTADDEDUNIT = "_lastAddedUnit"; + public static final String LASTREMOVEDDUNIT = "_lastRemovedUnit"; + public static final String CHAINUNIT = "_chainUnit#"; + public static final String COMPUNIT1 = "_compUnit1"; + public static final String COMPUNIT2 = "_compUnit2"; + + // Item Names + public static final String LASTCREATEDITEM = "_lastCreatedItem"; + + // Destructable Names + public static final String LASTCREATEDDESTRUCTABLE = "_lastCreatedDest"; + + // Ability Names + public static final String LASTCREATEDABILITY = "_lastCreatedAbility"; + public static final String LASTADDEDABILITY = "_lastAddedAbility"; + public static final String MATCHINGABILITY = "_matchingAbility"; + + public static final String LASTCREATEDUNITGROUP = "_lastCreatedUnitGroup"; + public static final String LASTCREATEDUNITQUEUE = "_lastCreatedUnitQueue"; + + public static final String LASTCREATEDDESTBUFF = "_lastCreatedDestBuff"; + public static final String ENUMDESTBUFF = "_enumDestBuff"; + public static final String MATCHINGDESTBUFF = "_matchingDestBuff"; + + // Buff Names + public static final String LASTCREATEDBUFF = "_lastCreatedBuff"; + public static final String LASTADDEDBUFF = "_lastAddedBuff"; + + public static final String ENUMBUFF = "_enumBuff"; + public static final String MATCHINGBUFF = "_matchingBuff"; + + //Generic Targeting + public static final String ATTACKINGUNIT = "_attackingUnit#"; + public static final String ATTACKTARGET = "_attackTarget#"; + public static final String DAMAGINGUNIT = "_damagingUnit#"; + public static final String DAMAGEDUNIT = "_damagedUnit#"; + public static final String ATTACKIMPACTLOCATION = "_attackImpactLocation#"; + public static final String ABILITYTARGETEDUNIT = "_abilityTargetedUnit#"; + public static final String ABILITYTARGETEDDESTRUCTABLE = "_abilityTargetedDestructable#"; + public static final String ABILITYTARGETEDITEM = "_abilityTargetedItem#"; + public static final String ABILITYTARGETEDLOCATION = "_abilityTargetedLocation#"; + + //Event Targeting + public static final String EVENTABILITY = "_eventAbility#"; + public static final String EVENTABILITYID = "_eventAbilityId#"; + public static final String EVENTCASTINGUNIT = "_eventCastingUnit#"; + public static final String EVENTTARGETEDUNIT = "_eventTargetedUnit#"; + public static final String EVENTTARGETEDDESTRUCTABLE = "_eventTargetedDestructable#"; + public static final String EVENTTARGETEDITEM = "_eventTargetedItem#"; + public static final String EVENTTARGETEDLOCATION = "_eventTargetedLocation#"; + + //Generic Attacks + public static final String DAMAGECALC = "_damageCalc#"; + + //Timers + public static final String LASTCREATEDTIMER = "_lastCreatedTimer"; + public static final String LASTSTARTEDTIMER = "_lastStartedTimer"; + public static final String FIRINGTIMER = "_firingTimer"; + + //Events + public static final String LASTCREATEDTODEVENT = "_lastCreatedToDEvent"; + public static final String LASTCREATEDWIDEVENT = "_lastCreatedWidEvent"; + + + // Dest Names + public static final String BUFFEDDEST = "_buffedDest#"; + public static final String ENUMDESTRUCTABLE = "_enumDest#"; + + //Projectiles + public static final String LASTCREATEDPROJECTILE = "_lastCreatedProjectile"; + public static final String THISPROJECTILE = "_thisProjectile#"; + public static final String PROJECTILEUNITTARGETS = "_projUnitTargets#"; + public static final String PROJECTILEDESTTARGETS = "_projDestTargets#"; + public static final String PROJECTILECURRENTLOC = "_projCurrentLoc#"; + public static final String PROJECTILEHITUNIT = "_projHitUnit#"; + public static final String PROJECTILEHITDEST = "_projHitDest#"; + + //vision + public static final String LASTCREATEDVISIONMODIFIER = "_lastCreatedVisionMod"; + + + // Pairing + public static final String ABILITYPAIREDUNIT = "_abilityPairedUnit#"; + public static final String LASTPARTNERABILITY = "_lastPartnerAbility"; + + // Transforming + public static final String ACTIVE_ALTITUDE_ADJUSTMENT = "_activeAltAdj"; + public static final String WAITING_ANIMATION = "_morphTimer"; + + + + // NonStackingStatBuff Names + public static final String LASTCREATEDNSSB = "_lastCreatedNSSB"; + + // StateModBuff Names + public static final String LASTCREATEDSMB = "_lastCreatedSMB"; + + // AttackEvasionListener Names + public static final String LASTCREATEDAEL = "_lastCreatedAEL"; + + // AttackPostDamageListener Names + public static final String LASTCREATEDAPoDL = "_lastCreatedAPoDL"; + + // AttackPreDamageListener Names + public static final String LASTCREATEDAPrDL = "_lastCreatedAPrDL"; + + // DamageTakenListener Names + public static final String LASTCREATEDDTL = "_lastCreatedDTL"; + + // DamageTakenModificationListener Names + public static final String LASTCREATEDDTML = "_lastCreatedDTML"; + + // DamageTakenModificationListener Names + public static final String LASTCREATEDFDTML = "_lastCreatedFDTML"; + + // DeathReplacementEffect Names + public static final String LASTCREATEDDRE = "_lastCreatedDRE"; + public static final String KILLINGUNIT = "_killingUnit#"; + public static final String DYINGUNIT = "_dyingUnit#"; + public static final String DEATHRESULT = "_deathResult#"; + public static final String DEATHSTACKING = "_deathStacking#"; + + // Reaction Names + public static final String LASTCREATEDAtkPRL = "_lastCreatedAtkPRL"; + public static final String LASTCREATEDAbPRL = "_lastCreatedAbPRL"; + public static final String LASTCREATEDAbERL = "_lastCreatedAbERL"; + public static final String REACTIONALLOWHIT = "_reactionAllowHit#"; + public static final String ATTACKPROJ = "_attackProj#"; + public static final String ABILITYPROJ = "_abilityProj#"; + public static final String REACTIONABILITY = "_reactionAbility#"; + public static final String REACTIONABILITYCASTER = "_reactionAbilityCaster#"; + public static final String REACTIONABILITYTARGET = "_reactionAbilityTarget#"; + + // Behavior Change Names + public static final String LASTCREATEDBCL = "_lastCreatedBCL"; + public static final String PRECHANGEBEHAVIOR = "_preChangeBehavior#"; + public static final String POSTCHANGEBEHAVIOR = "_postChangeBehaviorj#"; + public static final String BEHAVIORONGOING = "_behaviorOngoing#"; + + // Autocast on/off actions + public static final String WASAUTOCASTON = "_wasAutocastOn"; + public static final String ISAUTOCASTON = "_isAutocastOn"; + + // Attack Modifier Names + public static final String LASTCREATEDAMod = "_lastCreatedAMod"; + public static final String ATTACKSETTINGS = "_attackSettings#"; + public static final String ATTACKMODLOOP = "_attackModLoop#"; + public static final String THEATTACK = "_theAttack#"; + + // Attack Settings + public static final String LASTCREATEDASettings = "_lastCreatedASettings"; + + //Unit State Listener + public static final String LASTCREATEDUSL = "_lastCreatedUSL"; + public static final String LASTSTATELISTENERADDEDUNIT = "_lastStateListenerAddedUnit"; + + public static String combineKey(String key, int castId) { + return key + castId; + } + + public static String combineUserKey(String key, int castId) { + return "__" + key; + } + + public static String combineUserInstanceKey(String key, int castId) { + return "__" + key + "#" + castId; + } + + public static String combineSubroutineKey(String key, int castId) { + return "_!" + key; + } + + public static String combineSubroutineInstanceKey(String key, int castId) { + return "_!" + key + "#" + castId; + } + + public static String combineArgumentKey(String key) { + return "_$" + key; + } + + public static String combineUniqueValueKey(String key, int handleId) { + return "_*" + handleId +"#" + key; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABMapLocalDataStore.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABMapLocalDataStore.java new file mode 100644 index 000000000..f5e538adc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/datastore/ABMapLocalDataStore.java @@ -0,0 +1,140 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; + +public class ABMapLocalDataStore extends ABLocalDataStore { + private Map store; + + public ABMapLocalDataStore() { + this.store = new HashMap<>(); + } + + public ABMapLocalDataStore(CSimulation game) { + this.store = new HashMap<>(); + this.game = game; + } + + @Override + public boolean containsKey(String key) { + return store.containsKey(key); + } + + @Override + public boolean containsValue(Object value) { + return store.containsValue(value); + } + + @Override + public Object get(String key) { + return store.get(key); + } + + @Override + public Object getOrDefault(String key, Object def) { + return store.getOrDefault(key, def); + } + + @SuppressWarnings("unchecked") + @Override + public T get(String key, Class D) { + Object val = store.get(key); + if (val != null && D.isAssignableFrom(val.getClass())) { + return (T) val; + } + return null; + } + + @SuppressWarnings("unchecked") + @Override + public T getOrDefault(String key, T def, Class D) { + Object val = store.getOrDefault(key, def); + if (val != null && D.isAssignableFrom(val.getClass())) { + return (T) val; + } + return null; + } + + @Override + public int getInt(String key) { + Object val = store.get(key); + if (val != null && val instanceof Integer) { + return (int) val; + } + return 0; + } + + @Override + public int getIntOrDefault(String key, int def) { + Object val = store.getOrDefault(key, def); + if (val != null && val instanceof Integer) { + return (int) val; + } + return 0; + } + + @Override + public boolean getBoolean(String key) { + Object val = store.get(key); + if (val != null && val instanceof Boolean) { + return (boolean) val; + } + return false; + } + + @Override + public boolean getBooleanOrDefault(String key, boolean def) { + Object val = store.getOrDefault(key, def); + if (val != null && val instanceof Boolean) { + return (boolean) val; + } + return false; + } + + @Override + public float getFloat(String key) { + Object val = store.get(key); + if (val != null && val instanceof Float) { + return (float) val; + } + return 0f; + } + + @Override + public float getFloatOrDefault(String key, float def) { + Object val = store.getOrDefault(key, def); + if (val != null && val instanceof Float) { + return (float) val; + } + return 0f; + } + + @Override + public Object put(String key, Object value) { + return store.put(key, value); + } + + @Override + public Object remove(String key) { + return store.remove(key); + } + + @Override + public void clear() { + store.clear(); + } + + @Override + public Set keySet() { + return store.keySet(); + } + + @Override + public Collection values() { + return store.values(); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABGroupEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABGroupEffect.java new file mode 100644 index 000000000..9d0c1d811 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABGroupEffect.java @@ -0,0 +1,67 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public class ABGroupEffect extends CTimer implements SimulationRenderComponent { + + private AbilityPointTarget loc; + private War3ID id; + private CEffectType effectType; + + private float inRad; + private float jitter; + + private boolean removing = false; + + public ABGroupEffect(AbilityPointTarget loc, float rad, War3ID id, CEffectType effectType) { + this.loc = loc; + this.id = id; + this.effectType = effectType; + + this.inRad = rad / 2; + this.jitter = rad * 0.4f; + this.setRepeats(true); + } + + @Override + public void remove() { + this.removing = true; + } + + private float getJitter(CSimulation game) { + return this.jitter * (game.getSeededRandom().nextFloat() - 0.5f); + } + + @Override + public void onFire(CSimulation game) { + if (this.removing) { + this.setRepeats(false); + game.unregisterTimer(this); + return; + } + + int total = 2 + game.getSeededRandom().nextInt(19); + if (total > 5) { + total--; + game.spawnTemporarySpellEffectOnPoint(loc.x + this.getJitter(game), loc.y + this.getJitter(game), 0, id, + effectType, 0); + } + double angleDelta = (Math.PI * 2 / total); + double startAngle = (Math.PI * 2 * game.getSeededRandom().nextFloat()); + while (total > 0) { + total--; + double iAngle = startAngle + angleDelta * total; + double iX = inRad * Math.cos(iAngle); + double iY = inRad * Math.sin(iAngle); + game.spawnTemporarySpellEffectOnPoint((float) (loc.x + this.getJitter(game) + iX), + (float) (loc.y + this.getJitter(game) + iY), 0, id, effectType, 0); + } + this.setTimeoutTime(game.getSeededRandom().nextFloat()); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainBowlEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainBowlEffect.java new file mode 100644 index 000000000..aa919a121 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainBowlEffect.java @@ -0,0 +1,98 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.Terrain; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; + +public class ABTerrainBowlEffect extends ABTerrainEffect { + + private int[] rect; + private int rectW; + private int rectH; + private float cx; + private float cy; + + private float[] inverseTotalModBuffer; + + private boolean permanent; + + private float depth; + + private float terrainRadius; + private float terrainRadiusSq; + + private float sinkTime; + private float fillTime; + private float startDepth; + + public ABTerrainBowlEffect(CSimulation game, AbilityPointTarget loc, float radius, float depth, float sinkTime, + float staticTime, float fillTime, float stopDuration, float startDepth) { + super(sinkTime + staticTime + fillTime, 1); + this.depth = depth; + this.sinkTime = sinkTime / (sinkTime + staticTime + fillTime); + this.fillTime = (sinkTime + staticTime) / (sinkTime + staticTime + fillTime); + this.startDepth = startDepth; + + this.stopDuration = stopDuration; + + this.terrainRadius = radius / Terrain.CELL_SIZE; + this.terrainRadiusSq = this.terrainRadius * this.terrainRadius; + + this.rect = game.getTerrainModBufferSize(loc.x, loc.y, radius); + this.rectW = (this.rect[2] - this.rect[0] + 1); + this.rectH = (this.rect[3] - this.rect[1] + 1); + this.cx = game.getTerrainSpaceX(loc.x) - rect[0]; + this.cy = game.getTerrainSpaceY(loc.y) - rect[1]; + this.inverseTotalModBuffer = new float[this.rectW * this.rectH]; + } + + @Override + protected void onTick(CSimulation game, float timeRatio, float stopRatio) { + if (this.stopping || timeRatio <= this.sinkTime || timeRatio >= this.fillTime) { + boolean changed = false; + float[] terrainModBuffer = new float[this.inverseTotalModBuffer.length]; + for (int x = 0; x < this.rectW; x++) { + for (int y = 0; y < this.rectH; y++) { + float dz = 0; + float dsq = (x - cx) * (x - cx) + (y - cy) * (y - cy); + if (dsq <= this.terrainRadiusSq) { + float d = Math.min(Math.max((float) Math.sqrt(dsq) / this.terrainRadius, 0.0f), 1.0f); + float timeFraction = 1; + if (this.sinkTime <= timeRatio) { + if (timeRatio > this.fillTime) { + timeFraction = 1 - ((timeRatio - this.fillTime) / (1 - this.fillTime)); + } + } else { + timeFraction = timeRatio / this.sinkTime; + } + dz = (float) ((this.startDepth + timeFraction * this.depth) * Math.cos(d * 0.5 * Math.PI)); + if (this.stopping) { + dz *= stopRatio; + } + dz += this.inverseTotalModBuffer[x + y * this.rectW]; + } + + if (dz != 0) { + terrainModBuffer[x + y * this.rectW] = dz; + changed = true; + } + } + } + + if (changed) { + game.adjustTerrain(rect, terrainModBuffer); + for (int i = 0; i < terrainModBuffer.length; i++) { + this.inverseTotalModBuffer[i] -= terrainModBuffer[i]; + } + } + } + } + + @Override + protected void onRemove(CSimulation game) { + if (!permanent) { + game.adjustTerrain(rect, inverseTotalModBuffer); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainEffect.java new file mode 100644 index 000000000..23e92df16 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainEffect.java @@ -0,0 +1,109 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.SimulationRenderComponent; + +public abstract class ABTerrainEffect extends CTimer implements SimulationRenderComponent { + + private boolean removing = false; + + private float period; + protected int totalCount; + + private float elapsedTime; + private float startTime; + protected int count; + private boolean loop; + + protected boolean stopping; + protected float stopDuration; + private float stopBegan; + + public ABTerrainEffect(float period, int totalCount) { + this.period = period; + this.totalCount = Math.max(totalCount, 1); + + this.setRepeats(true); + this.setTimeoutTime(0); + this.startTime = 0; + this.elapsedTime = 0; + this.count = 0; + this.loop = period < 0; + + this.stopping = false; + this.stopDuration = 0; + this.stopBegan = 0; + } + + @Override + public void remove() { + if (this.stopDuration > 0) { + this.stopBegan = this.elapsedTime; + this.stopping = true; + } else { + this.removing = true; + } + } + + public void remove(float stopDuration) { + if (stopDuration > 0) { + this.stopDuration = stopDuration; + this.stopBegan = this.elapsedTime; + this.stopping = true; + } else { + this.removing = true; + } + } + + @Override + public void onFire(CSimulation game) { + if (this.removing) { + this.onRemove(game); + this.setRepeats(false); + game.unregisterTimer(this); + return; + } + + this.elapsedTime += WarsmashConstants.SIMULATION_STEP_TIME * 1000; + + float timeRatio = 1; + if (this.period != 0) { + timeRatio = (this.elapsedTime - this.startTime) / this.period; + } + boolean rolledOver = false; + if(timeRatio > 1) { + this.count += (int) timeRatio; + timeRatio = timeRatio % 1; + rolledOver = true; + } + if (rolledOver) { + this.startTime = this.elapsedTime - (timeRatio * this.period); + } + boolean ending = !this.loop && this.count >= this.totalCount; + if (ending) { + timeRatio = 1; + } + + float stopRatio = 1; + if (this.stopping) { + float stopFraction = Math.min((this.elapsedTime - this.stopBegan) / this.stopDuration, 1); + if (stopFraction >= 1) { + this.removing = true; + return; + } + stopRatio = 1 - stopFraction; + } + this.onTick(game, timeRatio, stopRatio); + + if (ending) { + this.removing = true; + } + } + + protected abstract void onTick(CSimulation game, float timeRatio, float stopRatio); + + protected abstract void onRemove(CSimulation game); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainRippleEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainRippleEffect.java new file mode 100644 index 000000000..deab79faf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainRippleEffect.java @@ -0,0 +1,106 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.Terrain; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; + +public class ABTerrainRippleEffect extends ABTerrainEffect { + + private float startRadius; + private float radius; + + private int[] rect; + private int rectW; + private int rectH; + private float cx; + private float cy; + + private float[] inverseTotalModBuffer; + + private boolean permanent; + + private float depth; + private float spaceWaves; + private float timeWaves; + private boolean onlyNegative; + private boolean radChanges; + + private float terrainRadius; + private float terrainRadiusSq; + + public ABTerrainRippleEffect(CSimulation game, AbilityPointTarget loc, float startRadius, float endRadius, + float depth, float period, int totalPeriodCount, int spaceWaves, int timeWaves, boolean onlyNegative) { + super(period, totalPeriodCount); + this.radius = endRadius; + this.depth = depth; + this.spaceWaves = (float) (spaceWaves * Math.PI); + this.timeWaves = (float) (timeWaves * Math.PI); + this.startRadius = startRadius; + this.onlyNegative = onlyNegative; + + this.radChanges = this.startRadius != this.radius; + this.terrainRadius = startRadius / Terrain.CELL_SIZE; + this.terrainRadiusSq = this.terrainRadius * this.terrainRadius; + + this.rect = game.getTerrainModBufferSize(loc.x, loc.y, Math.max(startRadius, endRadius)); + this.rectW = (this.rect[2] - this.rect[0] + 1); + this.rectH = (this.rect[3] - this.rect[1] + 1); + this.cx = game.getTerrainSpaceX(loc.x) - rect[0]; + this.cy = game.getTerrainSpaceY(loc.y) - rect[1]; + this.inverseTotalModBuffer = new float[this.rectW * this.rectH]; + } + + @Override + protected void onTick(CSimulation game, float timeRatio, float stopRatio) { + float timeFactorRepetitions = (this.count + timeRatio) / this.totalCount; + if (this.radChanges) { + float currentRadiusSq = (this.startRadius + (this.radius - this.startRadius) * timeFactorRepetitions); + currentRadiusSq /= Terrain.CELL_SIZE; + this.terrainRadius = currentRadiusSq; + this.terrainRadiusSq = currentRadiusSq * currentRadiusSq; + } + + boolean changed = false; + float[] terrainModBuffer = new float[this.inverseTotalModBuffer.length]; + + for (int x = 0; x < this.rectW; x++) { + for (int y = 0; y < this.rectH; y++) { + float dz = 0; + float dsq = (x - cx) * (x - cx) + (y - cy) * (y - cy); + if (dsq <= this.terrainRadiusSq) { + float d = Math.min(Math.max((float) Math.sqrt(dsq) / this.terrainRadius, 0.0f), 1.0f); + dz = (float) ((this.depth * (Math.sin(d * this.spaceWaves + this.timeWaves * timeRatio))) * (1 - timeFactorRepetitions)); + if (this.stopping) { + dz *= stopRatio; + } + dz += this.inverseTotalModBuffer[x + y * this.rectW]; + if (this.onlyNegative && (dz - this.inverseTotalModBuffer[x + y * this.rectW]) > 0) { + dz = this.inverseTotalModBuffer[x + y * this.rectW]; + } + } else if (this.inverseTotalModBuffer[x + y * this.rectW] != 0) { + dz = this.inverseTotalModBuffer[x + y * this.rectW]; + } + + if (dz != 0) { + terrainModBuffer[x + y * this.rectW] = dz; + changed = true; + } + } + } + + if (changed) { + game.adjustTerrain(rect, terrainModBuffer); + for (int i = 0; i < terrainModBuffer.length; i++) { + this.inverseTotalModBuffer[i] -= terrainModBuffer[i]; + } + } + } + + @Override + protected void onRemove(CSimulation game) { + if (!permanent) { + game.adjustTerrain(rect, inverseTotalModBuffer); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainWaveEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainWaveEffect.java new file mode 100644 index 000000000..451422a43 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/effects/ABTerrainWaveEffect.java @@ -0,0 +1,137 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.effects; + +import com.badlogic.gdx.math.Vector2; +import com.etheller.warsmash.viewer5.handlers.w3x.environment.Terrain; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; + +public class ABTerrainWaveEffect extends ABTerrainEffect { + + private AbilityPointTarget targetLoc; + + private float trailStart; + private float leadEnd; + + private int[] rect; + private int rectW; + private int rectH; + private float distX; + private float distY; + private float slope; + + private float[] inverseTotalModBuffer; + + private boolean permanent; + + private float depth; + + private float terrainRadius; + private float terrainRadiusSq; + + private float terrainStartX; + private float terrainStartY; + private float terrainTargetX; + + public ABTerrainWaveEffect(CSimulation game, AbilityPointTarget start, AbilityPointTarget target, float radius, + float depth, float distance, float speed, int trailTime, int count) { + super((distance / speed) * 1000 + trailTime, count); + + Vector2 v = new Vector2(target.x - start.x, target.y - start.y); + v = v.nor(); + this.targetLoc = new AbilityPointTarget(start.x + v.x * distance, start.y + v.y * distance); + this.depth = depth; + + float travelTime = (distance / speed) * 1000; + this.trailStart = trailTime / (travelTime + trailTime); + this.leadEnd = travelTime / (travelTime + trailTime); + + this.terrainRadius = radius / Terrain.CELL_SIZE; + this.terrainRadiusSq = this.terrainRadius * this.terrainRadius; + + this.rect = game.getTerrainModBufferSize(Math.min(start.x, targetLoc.x) - radius, + Math.min(start.y, targetLoc.y) - radius, + Math.max(start.x, targetLoc.x) - Math.min(start.x, targetLoc.x) + radius, + Math.max(start.y, targetLoc.y) - Math.min(start.y, targetLoc.y) + radius); + this.rectW = (this.rect[2] - this.rect[0] + 1); + this.rectH = (this.rect[3] - this.rect[1] + 1); + + this.terrainStartX = game.getTerrainSpaceX(start.x) - this.rect[0]; + this.terrainStartY = game.getTerrainSpaceY(start.y) - this.rect[1]; + this.terrainTargetX = game.getTerrainSpaceX(targetLoc.x) - this.rect[0]; + float terrainTargetY = game.getTerrainSpaceY(targetLoc.y) - this.rect[1]; + this.distX = terrainTargetX - terrainStartX; + this.distY = terrainTargetY - terrainStartY; + this.slope = this.distY / this.distX; + + this.inverseTotalModBuffer = new float[this.rectW * this.rectH]; + } + + @Override + protected void onTick(CSimulation game, float timeRatio, float stopRatio) { + boolean changed = false; + float[] terrainModBuffer = new float[this.inverseTotalModBuffer.length]; + + final float leadX = timeRatio <= this.leadEnd ? terrainStartX + ((timeRatio / this.leadEnd) * this.distX) + : terrainTargetX; + final float tailX = this.trailStart <= timeRatio + ? terrainStartX + (((timeRatio - this.trailStart) / (1 - this.trailStart)) * this.distX) + : terrainStartX; + final float projX = this.terrainStartX + this.distX * timeRatio; + final float dpx; + final float dpy; + if ((projX <= leadX || terrainTargetX <= terrainStartX) + && (leadX <= projX || terrainStartX <= terrainTargetX)) { + if ((tailX <= projX || terrainTargetX <= terrainStartX) + && (projX <= tailX || terrainStartX <= terrainTargetX)) { + dpx = projX; + dpy = this.terrainStartY + this.distY * timeRatio; + } else { + dpx = tailX; + dpy = (terrainStartY + ((tailX - terrainStartX) * slope)); + } + } else { + dpx = leadX; + dpy = (terrainStartY + ((leadX - terrainStartX) * slope)); + } + + for (int x = 0; x < this.rectW; x++) { + for (int y = 0; y < this.rectH; y++) { + float dz = 0; + float dsq = (x - dpx) * (x - dpx) + (y - dpy) * (y - dpy); + if (dsq <= this.terrainRadiusSq) { + float d = Math.min(Math.max((float) Math.sqrt(dsq) / this.terrainRadius, 0.0f), 1.0f); + dz = (float) (-0.5 * this.depth * (Math.cos(d * Math.PI) + 1)); + if (timeRatio > 0.89999998) { + dz *= (1.0 - ((timeRatio - 0.89999998) / 0.10000002)); + } + if (this.stopping) { + dz *= stopRatio; + } + dz += this.inverseTotalModBuffer[x + y * this.rectW]; + } else { + dz = this.inverseTotalModBuffer[x + y * this.rectW]; + } + + if (dz != 0) { + terrainModBuffer[x + y * this.rectW] = dz; + changed = true; + } + } + } + + if (changed) { + game.adjustTerrain(rect, terrainModBuffer); + for (int i = 0; i < terrainModBuffer.length; i++) { + this.inverseTotalModBuffer[i] -= terrainModBuffer[i]; + } + } + } + + @Override + protected void onRemove(CSimulation game) { + if (!permanent) { + game.adjustTerrain(rect, inverseTotalModBuffer); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABGlobalWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABGlobalWidgetEvent.java new file mode 100644 index 000000000..a10f3d9df --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABGlobalWidgetEvent.java @@ -0,0 +1,70 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event; + +import java.util.List; + +import com.etheller.interpreter.ast.scope.TriggerExecutionScope; +import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CGlobalWidgetEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABGlobalWidgetEvent extends CGlobalWidgetEvent { + + private CUnit caster; + private ABLocalDataStore localStore; + private int castId; + + private ABBooleanCallback condition; + private List actions; + + public ABGlobalWidgetEvent(CUnit caster, ABLocalDataStore localStore, int castId, CWidget widget, + JassGameEventsWar3 eventType, ABBooleanCallback condition, List actions) { + super(localStore.game, localStore.game.getGlobalScope(), null, eventType, null); + this.caster = caster; + this.localStore = localStore; + this.castId = castId; + + this.condition = condition; + this.actions = actions; + } + + @Override + public void fire(final CWidget triggerWidget, final TriggerExecutionScope scope) { + if (condition == null || condition.callback(caster, localStore, castId)) { + if (scope instanceof CommonTriggerExecutionScope) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDUNIT, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetUnit()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDLOCATION, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetPoint()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDITEM, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetItem()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetDestructable()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTCASTINGUNIT, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbilityUnit()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITYID, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbilityId()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITY, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbility()); + } + if (actions != null) { + for (ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDLOCATION, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDITEM, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTCASTINGUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITYID, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITY, castId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABPlayerEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABPlayerEvent.java new file mode 100644 index 000000000..90a479677 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABPlayerEvent.java @@ -0,0 +1,80 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event; + +import java.util.List; + +import com.etheller.interpreter.ast.scope.TriggerExecutionScope; +import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayerEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayerJass; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; + +public class ABPlayerEvent extends CPlayerEvent { + + private CUnit caster; + private ABLocalDataStore localStore; + private int castId; + + private ABBooleanCallback condition; + private List actions; + + public ABPlayerEvent(CUnit caster, ABLocalDataStore localStore, int castId, CPlayerJass player, + JassGameEventsWar3 eventType, ABBooleanCallback condition, List actions) { + super(localStore.game.getGlobalScope(), player, null, eventType, null); + this.caster = caster; + this.localStore = localStore; + this.castId = castId; + + this.condition = condition; + this.actions = actions; + } + + public void fire(final CUnit hero, final TriggerExecutionScope scope) { + if (condition == null || condition.callback(caster, localStore, castId)) { + if (scope instanceof CommonTriggerExecutionScope) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDUNIT, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetUnit()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDLOCATION, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetPoint()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDITEM, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetItem()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetDestructable()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTCASTINGUNIT, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbilityUnit()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITYID, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbilityId()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITY, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbility()); + } + if (actions != null) { + for (ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDLOCATION, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDITEM, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTCASTINGUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITYID, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITY, castId)); + } + } + + public void fire(final CPlayer player, final TriggerExecutionScope scope) { + if (condition == null || condition.callback(caster, localStore, castId)) { + if (actions != null) { + for (ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABTimeOfDayEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABTimeOfDayEvent.java similarity index 77% rename from core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABTimeOfDayEvent.java rename to core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABTimeOfDayEvent.java index d1973bb1b..141205014 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/abilitybuilder/event/ABTimeOfDayEvent.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABTimeOfDayEvent.java @@ -1,19 +1,19 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.event; +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event; import java.util.List; -import java.util.Map; import java.util.Objects; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation.TimeOfDayEvent; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; public class ABTimeOfDayEvent implements TimeOfDayEvent { private CSimulation game; private CUnit caster; - private Map localStore; + private ABLocalDataStore localStore; private int castId; private List actions; @@ -22,10 +22,10 @@ public class ABTimeOfDayEvent implements TimeOfDayEvent { private String equalityId; - public ABTimeOfDayEvent(CSimulation game, CUnit caster, Map localStore, int castId, - List actions, float startTime, float endTime, String equalityId) { + public ABTimeOfDayEvent(CUnit caster, ABLocalDataStore localStore, int castId, List actions, + float startTime, float endTime, String equalityId) { super(); - this.game = game; + this.game = localStore.game; this.caster = caster; this.localStore = localStore; this.castId = castId; @@ -39,7 +39,7 @@ public ABTimeOfDayEvent(CSimulation game, CUnit caster, Map loca public void fire() { if (actions != null) { for (ABAction eventAction : actions) { - eventAction.runAction(game, caster, localStore, castId); + eventAction.runAction(caster, localStore, castId); } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABWidgetEvent.java new file mode 100644 index 000000000..db1bf884e --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/event/ABWidgetEvent.java @@ -0,0 +1,70 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.event; + +import java.util.List; + +import com.etheller.interpreter.ast.scope.TriggerExecutionScope; +import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.JassGameEventsWar3; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CWidgetEvent; + +public class ABWidgetEvent extends CWidgetEvent { + + private CUnit caster; + private ABLocalDataStore localStore; + private int castId; + + private ABBooleanCallback condition; + private List actions; + + public ABWidgetEvent(CUnit caster, ABLocalDataStore localStore, int castId, CWidget widget, + JassGameEventsWar3 eventType, ABBooleanCallback condition, List actions) { + super(localStore.game.getGlobalScope(), widget, null, eventType, null); + this.caster = caster; + this.localStore = localStore; + this.castId = castId; + + this.condition = condition; + this.actions = actions; + } + + @Override + public void fire(final CWidget triggerWidget, final TriggerExecutionScope scope) { + if (condition == null || condition.callback(caster, localStore, castId)) { + if (scope instanceof CommonTriggerExecutionScope) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDUNIT, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetUnit()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDLOCATION, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetPoint()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDITEM, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetItem()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE, castId), + ((CommonTriggerExecutionScope) scope).getSpellTargetDestructable()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTCASTINGUNIT, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbilityUnit()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITYID, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbilityId()); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITY, castId), + ((CommonTriggerExecutionScope) scope).getSpellAbility()); + } + if (actions != null) { + for (ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDLOCATION, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDITEM, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTTARGETEDDESTRUCTABLE, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTCASTINGUNIT, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITYID, castId)); + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.EVENTABILITY, castId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/handler/ABRandomTypeHandler.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/handler/ABRandomTypeHandler.java new file mode 100644 index 000000000..9b99b16d4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/handler/ABRandomTypeHandler.java @@ -0,0 +1,108 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CItemType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.data.CUnitRace; + +public class ABRandomTypeHandler { + private static List landCritters = null; + private static List airCritters = null; + private static List seaCritters = null; + + private static List randomItems = null; + + private static void loadCritterLists(CSimulation game) { + landCritters = new ArrayList<>(); + airCritters = new ArrayList<>(); + seaCritters = new ArrayList<>(); + Collection types = game.getUnitData().getAllUnitTypesLightweight(); + String tileset = ("" + game.getTileset()).toUpperCase(); + + for (CUnitType type : types) { + if (type.getRace() == CUnitRace.CRITTERS + && ("*".equals(type.getTilesets()) || type.getTilesets().indexOf(tileset) >= 0) + && !type.isSpecial()) { + switch (type.getMovementType()) { + case AMPHIBIOUS: + seaCritters.add(type); + break; + case FLY: + airCritters.add(type); + break; + case FOOT: + case FOOT_NO_COLLISION: + case HORSE: + case HOVER: + landCritters.add(type); + break; + case FLOAT: + case DISABLED: + default: + break; + + } + } + } + } + + private static void loadItemLists(CSimulation game) { + randomItems = new ArrayList<>(); + Collection types = game.getItemData().getAllItemTypes(); + + for (CItemType type : types) { + if (type.isIncludeAsRandomChoice()) { + randomItems.add(type); + } + } + } + + public static CUnitType getRandomMechanicalCritterType(CSimulation game) { + if (landCritters == null) { + loadCritterLists(game); + } + if (landCritters.size() > 0 || seaCritters.size() > 0) { + int i = game.getSeededRandom().nextInt(landCritters.size() + seaCritters.size()); + if (i >= landCritters.size()) { + return seaCritters.get(i - landCritters.size()); + } else { + return landCritters.get(i); + } + } else if (airCritters.size() > 0) { + int i = game.getSeededRandom().nextInt(airCritters.size()); + return airCritters.get(i); + } + return null; + } + + public static CItemType getRandomItemType(CSimulation game) { + if (randomItems == null) { + loadItemLists(game); + } + int i = game.getSeededRandom().nextInt(randomItems.size()); + return randomItems.get(i); + } + + public static CItemType getRandomItemType(CSimulation game, War3ID previousType, int level, + boolean ignoreValidTargetField, boolean ignoreRandomPoolField) { + List filtered = new ArrayList<>(); + for (CItemType type : game.getItemData().getAllItemTypes()) { + if (!type.getTypeId().equals(previousType) && (level == -1 || level == type.getLevel()) + && (ignoreValidTargetField || type.isValidTargetForTransformation()) + && (ignoreRandomPoolField || type.isIncludeAsRandomChoice())) { + filtered.add(type); + } + } + if (filtered.size() == 0) { + return null; + } + int i = game.getSeededRandom().nextInt(filtered.size()); + return filtered.get(i); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/handler/ABTransformationHandler.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/handler/ABTransformationHandler.java new file mode 100644 index 000000000..d6037e4d5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/handler/ABTransformationHandler.java @@ -0,0 +1,267 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTransformationBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABAltitudeAdjustmentTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABDelayTimerTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer.ABTransformationMorphAnimationTimer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor.ABGetInstantTransformationBuffVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABTransformationHandler { + + public static void setUnitID(final ABLocalDataStore localStore, final CUnit unit, final CUnitType newType, + final boolean keepRatios, final boolean addAlternateTagAfter, final OnTransformationActions actions, + final CAbility ability) { + setUnitID(localStore, unit, newType, keepRatios, addAlternateTagAfter, actions, ability, false); + } + + public static void setUnitID(final ABLocalDataStore localStore, final CUnit unit, final CUnitType newType, + final boolean keepRatios, final boolean addAlternateTagAfter, final OnTransformationActions actions, + final CAbility ability, final boolean updateArt) { + final CPlayer pl = localStore.game.getPlayer(unit.getPlayerIndex()); + if (actions != null) { + pl.setGold(Math.max(pl.getGold() - actions.goldCost, 0)); + pl.setLumber(Math.max(pl.getLumber() - actions.lumberCost, 0)); + + if (!addAlternateTagAfter) { + if (actions.onUntransformActions != null) { + for (final ABAction action : actions.onUntransformActions) { + action.runAction(unit, localStore, actions.castId); + } + } + } + } + + unit.setTypeId(localStore.game, newType.getTypeId(), keepRatios, updateArt); + pl.setUnitFoodUsed(unit, newType.getFoodUsed()); + pl.setUnitFoodMade(unit, newType.getFoodMade()); + if (addAlternateTagAfter) { + if (unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE)) { + unit.getUnitAnimationListener().forceResetCurrentAnimation(); + } + } else { + if (unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE)) { + unit.getUnitAnimationListener().forceResetCurrentAnimation(); + } + } + localStore.game.unitSoundEffectEvent(unit, ability.getAlias()); + + if (addAlternateTagAfter && (actions != null)) { + if (actions.onTransformActions != null) { + for (final ABAction action : actions.onTransformActions) { + action.runAction(unit, localStore, actions.castId); + } + } + } + } + + public static void playMorphAnimation(final CUnit unit, final boolean addAlternateTagAfter) { + if (addAlternateTagAfter) { + unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); + unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, SequenceUtils.EMPTY, 1.0f, true); + } else { + unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, EnumSet.of(SecondaryTag.ALTERNATE), + 1.0f, true); + } + unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, + addAlternateTagAfter ? EnumSet.of(SecondaryTag.ALTERNATE) : SequenceUtils.EMPTY, true); + if (addAlternateTagAfter) { + unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE); + } else { + unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); + } + } + + public static void setTags(final CUnit unit, final boolean addAlternateTagAfter) { + if (addAlternateTagAfter) { + unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE); + } else { + unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); + } + unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, + addAlternateTagAfter ? EnumSet.of(SecondaryTag.ALTERNATE) : SequenceUtils.EMPTY, 1.0f, true); + } + + public static void beginTakingOff(final ABLocalDataStore localStore, final CUnit unit, final CUnitType newType, + final boolean keepRatios, final OnTransformationActions actions, final CAbility ability, + final boolean addAlternateTagAfter, final boolean immediateTakeoff, final float altitudeAdjustmentDelay, + final float altitudeAdjustmentDuration) { + CTimer timer = localStore.get(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, CTimer.class); + if (timer != null) { + localStore.game.unregisterTimer(timer); + } + timer = (new ABDelayTimerTimer( + new ABAltitudeAdjustmentTimer(unit, newType.getDefaultFlyingHeight(), altitudeAdjustmentDuration), + localStore, altitudeAdjustmentDelay)); + timer.start(localStore.game); + localStore.put(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, timer); + ABTransformationHandler.setUnitID(localStore, unit, newType, keepRatios, addAlternateTagAfter, actions, ability); + if (immediateTakeoff) { + ABTransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); + } else { + final CTimer t2 = new ABTransformationMorphAnimationTimer(unit, addAlternateTagAfter, + altitudeAdjustmentDelay); + t2.start(localStore.game); + localStore.put(ABLocalStoreKeys.WAITING_ANIMATION, t2); + } + } + + public static void beginLanding(final ABLocalDataStore localStore, final CUnit unit, final CUnitType newType, + final boolean addAlternateTagAfter, final boolean immediateLanding, final float landingDelay, + final float altitudeAdjustmentDuration) { + unit.setFacing(225); + if (immediateLanding) { + ABTransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); + } else { + final CTimer timer = new ABTransformationMorphAnimationTimer(unit, addAlternateTagAfter, landingDelay); + timer.start(localStore.game); + localStore.put(ABLocalStoreKeys.WAITING_ANIMATION, timer); + } + CTimer timer = localStore.get(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, CTimer.class); + if (timer != null) { + localStore.game.unregisterTimer(timer); + } + timer = new ABAltitudeAdjustmentTimer(unit, newType.getDefaultFlyingHeight(), altitudeAdjustmentDuration); + timer.start(localStore.game); + localStore.put(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, timer); + } + + public static void startSlowTransformation(final ABLocalDataStore localStore, final CUnit unit, + final CUnitType newType, final boolean keepRatios, final OnTransformationActions actions, + final CAbility ability, final boolean addAlternateTagAfter, final boolean takingOff, final boolean landing, + final boolean immediateTakeoff, final boolean immediateLanding, final float altitudeAdjustmentDelay, + final float landingDelay, final float altitudeAdjustmentDuration) { + final CTimer timer = localStore.get(ABLocalStoreKeys.WAITING_ANIMATION, CTimer.class); + if (timer != null) { + localStore.game.unregisterTimer(timer); + } + unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, + addAlternateTagAfter ? SequenceUtils.EMPTY : EnumSet.of(SecondaryTag.ALTERNATE), true); + if (takingOff || landing) { + + if (takingOff) { + ABTransformationHandler.beginTakingOff(localStore, unit, newType, keepRatios, actions, ability, + addAlternateTagAfter, immediateTakeoff, altitudeAdjustmentDelay, altitudeAdjustmentDuration); + } + + if (landing) { + ABTransformationHandler.beginLanding(localStore, unit, newType, addAlternateTagAfter, immediateLanding, + landingDelay, altitudeAdjustmentDuration); + } + } else { + ABTransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); + } + } + + public static void finishSlowTransformation(final ABLocalDataStore localStore, final CUnit unit, + final CUnitType newType, final boolean keepRatios, final OnTransformationActions actions, + final ABAbilityBuilderAbility ability, final boolean addAlternateTagAfter, final boolean permanent, + final boolean takingOff) { + if (!takingOff) { + ABTransformationHandler.setUnitID(localStore, unit, newType, keepRatios, addAlternateTagAfter, actions, + ability); + } + if (permanent) { + unit.remove(localStore.game, ability); + } + } + + public static void instantTransformation(final ABLocalDataStore localStore, final CUnit unit, final CUnitType newType, + final boolean keepRatios, final OnTransformationActions actions, final ABAbilityBuilderAbility ability, + final boolean addAlternateTagAfter, final boolean permanent, final boolean playMorph) { + if (newType.getTypeId().equals(unit.getTypeId())) { + return; + } + setUnitID(localStore, unit, newType, keepRatios, addAlternateTagAfter, actions, ability, false); + if (playMorph) { + ABTransformationHandler.playMorphAnimation(unit, addAlternateTagAfter); + } + if (permanent) { + unit.remove(localStore.game, ability); + } + } + + public static void createSlowTransformBackBuff(CUnit sourceUnit, final ABLocalDataStore localStore, final CUnit unit, + final CUnitType newType, final boolean keepRatios, final OnTransformationActions actions, + final ABAbilityBuilderAbility ability, final War3ID buffId, final boolean addAlternateTagAfter, + final float transformationTime, final float duration, final boolean permanent, final boolean takingOff, + final boolean landing, final boolean immediateTakeoff, final boolean immediateLanding, + final float altitudeAdjustmentDelay, final float landingDelay, final float altitudeAdjustmentDuration) { + if (addAlternateTagAfter && (duration > 0)) { + unit.add(localStore.game, + new ABTimedTransformationBuff(localStore.game.getHandleIdAllocator().createId(), localStore, + ability, sourceUnit, actions, buffId == null ? ability.getAlias() : buffId, duration, + ability, newType, keepRatios, !addAlternateTagAfter, permanent, duration, + transformationTime, landingDelay, altitudeAdjustmentDelay, altitudeAdjustmentDuration, + immediateLanding, immediateTakeoff)); + } + } + + public static void createInstantTransformBackBuff(CUnit sourceUnit, final ABLocalDataStore localStore, + final CUnit unit, final CUnitType newType, final boolean keepRatios, final OnTransformationActions actions, + final ABAbilityBuilderAbility ability, final War3ID buffId, final boolean addAlternateTagAfter, + final float transformationTime, final float duration, final boolean permanent) { + if (addAlternateTagAfter && (duration > 0)) { + final ABBuff thebuff = ability.visit(ABGetInstantTransformationBuffVisitor.getInstance().reset( + localStore.game, sourceUnit, localStore, newType, keepRatios, actions, buffId, addAlternateTagAfter, + transformationTime, duration, permanent)); + if (thebuff != null) { + unit.add(localStore.game, thebuff); + } + } + } + + public static class OnTransformationActions { + private int goldCost; + private int lumberCost; + private Integer foodCost; + private List onTransformActions; + private List onUntransformActions; + private int castId; + + public OnTransformationActions(final List onUntransformActions, int castId) { + this.onUntransformActions = onUntransformActions; + this.castId = castId; + } + + public OnTransformationActions(final int goldCost, final int lumberCost, final Integer foodCost, + final List onTransformActions, final List onUntransformActions, int castId) { + this.goldCost = goldCost; + this.lumberCost = lumberCost; + this.foodCost = foodCost; + this.onTransformActions = onTransformActions; + this.onUntransformActions = onUntransformActions; + this.castId = castId; + } + + public OnTransformationActions createUntransformActions() { + return new OnTransformationActions(-this.goldCost, -this.lumberCost, + this.foodCost != null ? -this.foodCost : null, null, this.onUntransformActions, this.castId); + } + + public void setOnUntransformActions(final List onUntransformActions) { + this.onUntransformActions = onUntransformActions; + } + + public int getCastId() { + return this.castId; + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABNearestUnitComparator.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABNearestUnitComparator.java new file mode 100644 index 000000000..a5d3c3ead --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABNearestUnitComparator.java @@ -0,0 +1,14 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs; + +import java.util.Comparator; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; + +public class ABNearestUnitComparator implements Comparator { + public static ABNearestUnitComparator INSTANCE = new ABNearestUnitComparator(); + + @Override + public int compare(CUnit o1, CUnit o2) { + return (int) (o1.distance(o2) * 10); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABUnitAndRangeComparator.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABUnitAndRangeComparator.java new file mode 100644 index 000000000..461262628 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABUnitAndRangeComparator.java @@ -0,0 +1,21 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; + +public class ABUnitAndRangeComparator { + private CUnit unit; + private double range; + + public CUnit getUnit() { + return unit; + } + public void setUnit(CUnit unit) { + this.unit = unit; + } + public double getRange() { + return range; + } + public void setRange(double range) { + this.range = range; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABUnitComparator.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABUnitComparator.java new file mode 100644 index 000000000..c835be436 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/iterstructs/ABUnitComparator.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.iterstructs; + +import java.util.Comparator; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABUnitComparator implements Comparator { + + private CUnit caster; + private ABLocalDataStore localStore; + private int castId; + private ABIntegerCallback comparison; + + public ABUnitComparator(final CUnit caster, final ABLocalDataStore localStore, final int castId, + ABIntegerCallback comparison) { + this.caster = caster; + this.localStore = localStore; + this.castId = castId; + this.comparison = comparison; + } + + @Override + public int compare(CUnit o1, CUnit o2) { + this.localStore.put(ABLocalStoreKeys.COMPUNIT1, o1); + this.localStore.put(ABLocalStoreKeys.COMPUNIT2, o2); + int v = comparison.callback(caster, localStore, castId); + this.localStore.remove(ABLocalStoreKeys.COMPUNIT1); + this.localStore.remove(ABLocalStoreKeys.COMPUNIT2); + return v; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/jass/ABActionJass.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/jass/ABActionJass.java new file mode 100644 index 000000000..6dbbecce2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/jass/ABActionJass.java @@ -0,0 +1,45 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.jass; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.etheller.interpreter.ast.execution.JassThread; +import com.etheller.interpreter.ast.scope.GlobalScope; +import com.etheller.interpreter.ast.value.CodeJassValue; +import com.etheller.warsmash.parsers.jass.JassTextGenerator; +import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABActionJass implements ABAction { + private final CodeJassValue jassFunction; + + public ABActionJass(final CodeJassValue jassFunction) { + this.jassFunction = jassFunction; + } + + @Override + public void runAction(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + final GlobalScope globalScope = localStore.game.getGlobalScope(); + final JassThread thread = globalScope.createThread(this.jassFunction, + CommonTriggerExecutionScope.abilityBuilder(caster, localStore, castId)); + globalScope.runThreadUntilCompletion(thread); + } + + @Override + public void generateJassEquivalent(final int indent, final JassTextGenerator jassTextGenerator) { + throw new UnsupportedOperationException(); + } + + public static List wrap(final CodeJassValue jassFunction) { + if (jassFunction == null) { + return Collections.emptyList(); + } + else { + return Arrays.asList(new ABActionJass(jassFunction)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/jass/ABConditionJass.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/jass/ABConditionJass.java new file mode 100644 index 000000000..3d1860acf --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/jass/ABConditionJass.java @@ -0,0 +1,34 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.jass; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.etheller.interpreter.ast.scope.trigger.TriggerBooleanExpression; +import com.etheller.warsmash.parsers.jass.scope.CommonTriggerExecutionScope; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABConditionJass extends ABBooleanCallback { + private final TriggerBooleanExpression boolExpr; + + public ABConditionJass(final TriggerBooleanExpression boolExpr) { + this.boolExpr = boolExpr; + } + + @Override + public Boolean callback(final CUnit caster, final ABLocalDataStore localStore, final int castId) { + return this.boolExpr.evaluate(localStore.game.getGlobalScope(), + CommonTriggerExecutionScope.abilityBuilder(caster, localStore, castId)); + } + + public static List wrap(final TriggerBooleanExpression jassFunction) { + if (jassFunction == null) { + return Collections.emptyList(); + } else { + return Arrays.asList(new ABConditionJass(jassFunction)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAbilityEffectReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAbilityEffectReactionListener.java new file mode 100644 index 000000000..681032a94 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAbilityEffectReactionListener.java @@ -0,0 +1,57 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.listeners.CUnitAbilityEffectReactionListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; + +public class ABAbilityEffectReactionListener implements CUnitAbilityEffectReactionListener { + + private ABLocalDataStore localStore; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_ID; + private boolean useCastId; + + public ABAbilityEffectReactionListener(ABLocalDataStore localStore, List actions, int castId, + boolean useCastId) { + this.localStore = localStore; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public boolean onHit(final CSimulation simulation, CUnit source, CUnit target, CAbility ability) { + if (!this.useCastId) { + this.triggerId = ABConstants.incrementTriggerId(triggerId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONALLOWHIT, triggerId), true); + if (actions != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYCASTER, triggerId), source); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYTARGET, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITY, triggerId), ability); + for (ABAction action : actions) { + action.runAction(target, localStore, triggerId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYCASTER, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYTARGET, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITY, triggerId)); + } + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + return (boolean) localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONALLOWHIT, triggerId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAbilityProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAbilityProjReactionListener.java new file mode 100644 index 000000000..ec0193740 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAbilityProjReactionListener.java @@ -0,0 +1,57 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.listeners.CUnitAbilityProjReactionListener; + +public class ABAbilityProjReactionListener implements CUnitAbilityProjReactionListener { + + private ABLocalDataStore localStore; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_ID; + private boolean useCastId; + + public ABAbilityProjReactionListener(ABLocalDataStore localStore, List actions, int castId, + boolean useCastId) { + this.localStore = localStore; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public boolean onHit(final CSimulation simulation, CUnit source, CUnit target, CProjectile projectile) { + if (!this.useCastId) { + this.triggerId = ABConstants.incrementTriggerId(triggerId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONALLOWHIT, triggerId), true); + if (actions != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYCASTER, triggerId), source); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYTARGET, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYPROJ, triggerId), projectile); + for (ABAction action : actions) { + action.runAction(target, localStore, triggerId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYCASTER, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONABILITYTARGET, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ABILITYPROJ, triggerId)); + } + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + return (boolean) localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONALLOWHIT, triggerId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackEvasionListener.java new file mode 100644 index 000000000..b6564bfd9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackEvasionListener.java @@ -0,0 +1,57 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackEvasionListener; + +public class ABAttackEvasionListener implements CUnitAttackEvasionListener { + + private ABLocalDataStore localStore; + private List conditions; + + private int triggerId = ABConstants.STARTING_TRIGGER_ID; + private boolean useCastId; + + public ABAttackEvasionListener(ABLocalDataStore localStore, List conditions, int castId, + boolean useCastId) { + this.localStore = localStore; + this.conditions = conditions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public boolean onAttack(CSimulation simulation, CUnit target, CDamageCalculation damage) { + boolean evade = false; + if (conditions != null) { + if (!this.useCastId) { + this.triggerId = ABConstants.incrementTriggerId(triggerId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId), damage.getSource()); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId), damage); + for (ABBooleanCallback condition : conditions) { + evade = evade || condition.callback(target, localStore, triggerId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + } + return evade; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackModifier.java new file mode 100644 index 000000000..85abc53de --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackModifier.java @@ -0,0 +1,141 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackModifier; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitPriorityLoopData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABAttackModifier implements CUnitAttackModifier { + private ABIntegerCallback priority; + private ABBooleanCallback preLaunchCondition; + private List preLaunchModification; + private ABBooleanCallback condition; + private List modification; + + private ABLocalDataStore localStore; + private int castId = Integer.MAX_VALUE; + private boolean useCastId; + + public ABAttackModifier(ABLocalDataStore localStore, int castId, ABIntegerCallback priority, + ABBooleanCallback preLaunchCondition, List preLaunchModification, ABBooleanCallback condition, + List modification, boolean useCastId) { + this.localStore = localStore; + this.priority = priority; + this.preLaunchCondition = preLaunchCondition; + this.condition = condition; + this.preLaunchModification = preLaunchModification; + this.modification = modification; + this.useCastId = useCastId; + if (useCastId) { + this.castId = castId; + } + } + + @Override + public int getPriority(CSimulation simulation, CUnit source, AbilityTarget target, CUnitAttack attack) { + if (this.priority == null) { + return 0; + } + if (!this.useCastId) { + this.castId--; + } + localStore.put(ABLocalStoreKeys.ATTACKINGUNIT + this.castId, source); + localStore.put(ABLocalStoreKeys.ATTACKTARGET + this.castId, target); + localStore.put(ABLocalStoreKeys.THEATTACK + this.castId, attack); + int prio = this.priority.callback(source, this.localStore, this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKTARGET + this.castId); + localStore.remove(ABLocalStoreKeys.THEATTACK + this.castId); + return prio; + } + + @Override + public boolean checkPreLaunchApplication(CSimulation simulation, CUnit source, AbilityTarget target, + CUnitAttack attack) { + if (!this.useCastId) { + this.castId--; + } + boolean ret = true; + if (this.preLaunchCondition != null) { + localStore.put(ABLocalStoreKeys.ATTACKINGUNIT + this.castId, source); + localStore.put(ABLocalStoreKeys.ATTACKTARGET + this.castId, target); + localStore.put(ABLocalStoreKeys.THEATTACK + this.castId, attack); + ret = this.preLaunchCondition.callback(source, this.localStore, this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKTARGET + this.castId); + localStore.remove(ABLocalStoreKeys.THEATTACK + this.castId); + } + return ret; + } + + @Override + public void applyPreLaunchModification(CSimulation simulation, CUnit source, AbilityTarget target, + CUnitAttack attack, CUnitAttackSettings settings, CUnitPriorityLoopData loop) { + if (this.preLaunchModification != null) { + localStore.put(ABLocalStoreKeys.ATTACKINGUNIT + this.castId, source); + localStore.put(ABLocalStoreKeys.ATTACKTARGET + this.castId, target); + localStore.put(ABLocalStoreKeys.THEATTACK + this.castId, attack); + + localStore.put(ABLocalStoreKeys.ATTACKSETTINGS + this.castId, settings); + localStore.put(ABLocalStoreKeys.ATTACKMODLOOP + this.castId, loop); + for (ABAction action : this.preLaunchModification) { + action.runAction(source, this.localStore, this.castId); + } + localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKTARGET + this.castId); + localStore.remove(ABLocalStoreKeys.THEATTACK + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKSETTINGS + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKMODLOOP + this.castId); + } + } + + @Override + public boolean checkApplication(CSimulation simulation, CUnit source, AbilityTarget target, CUnitAttack attack) { + if (!this.useCastId) { + this.castId--; + } + boolean ret = true; + if (this.condition != null) { + localStore.put(ABLocalStoreKeys.ATTACKINGUNIT + this.castId, source); + localStore.put(ABLocalStoreKeys.ATTACKTARGET + this.castId, target); + localStore.put(ABLocalStoreKeys.THEATTACK + this.castId, attack); + ret = this.condition.callback(source, this.localStore, this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKTARGET + this.castId); + localStore.remove(ABLocalStoreKeys.THEATTACK + this.castId); + } + return ret; + } + + @Override + public void applyModification(CSimulation simulation, CUnit source, AbilityTarget target, CUnitAttack attack, + CUnitAttackSettings settings, CUnitPriorityLoopData loop) { + if (this.modification != null) { + localStore.put(ABLocalStoreKeys.ATTACKINGUNIT + this.castId, source); + localStore.put(ABLocalStoreKeys.ATTACKTARGET + this.castId, target); + localStore.put(ABLocalStoreKeys.THEATTACK + this.castId, attack); + + localStore.put(ABLocalStoreKeys.ATTACKSETTINGS + this.castId, settings); + localStore.put(ABLocalStoreKeys.ATTACKMODLOOP + this.castId, loop); + for (ABAction action : this.modification) { + action.runAction(source, this.localStore, this.castId); + } + localStore.remove(ABLocalStoreKeys.ATTACKINGUNIT + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKTARGET + this.castId); + localStore.remove(ABLocalStoreKeys.THEATTACK + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKSETTINGS + this.castId); + localStore.remove(ABLocalStoreKeys.ATTACKMODLOOP + this.castId); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackPostDamageListener.java new file mode 100644 index 000000000..b7b2949d8 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackPostDamageListener.java @@ -0,0 +1,84 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPostDamageListener; + +public class ABAttackPostDamageListener implements CUnitAttackPostDamageListener { + + private ABLocalDataStore localStore; + private ABIntegerCallback priority; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_PRIORITY_ID; + private boolean useCastId; + + public ABAttackPostDamageListener(ABLocalDataStore localStore, ABIntegerCallback priority, List actions, + int castId, boolean useCastId) { + this.localStore = localStore; + this.priority = priority; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public int getPriority(CSimulation simulation, CUnit attacker, AbilityTarget target, CUnitAttack attack) { + if (priority == null) { + return 0; + } + if (!this.useCastId) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, this.triggerId), attacker); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, this.triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, this.triggerId), attack); + int prio = this.priority.callback(attacker, this.localStore, this.triggerId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, this.triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, this.triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, this.triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + return prio; + } + + @Override + public void onHit(CSimulation simulation, AbilityTarget target, CUnitAttack attack, CDamageCalculation damage) { + if (!this.useCastId) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId), damage.getSource()); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId), damage); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, this.triggerId), attack); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(damage.getSource(), localStore, triggerId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, this.triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + this.triggerId = ABConstants.incrementTriggerId(triggerId); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackPreDamageListener.java new file mode 100644 index 000000000..2f23e4d9c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackPreDamageListener.java @@ -0,0 +1,66 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class ABAttackPreDamageListener implements CUnitAttackPreDamageListener { + + private ABLocalDataStore localStore; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_ID; + private boolean useCastId; + + public ABAttackPreDamageListener(ABLocalDataStore localStore, List actions, int castId, + boolean useCastId) { + this.localStore = localStore; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public void onAttack(CSimulation simulation, AbilityTarget target, AbilityPointTarget attackImpactLocation, + CUnitAttack attack, CUnitAttackSettings settings, CDamageCalculation calc) { + if (!this.useCastId) { + this.triggerId = ABConstants.incrementTriggerId(triggerId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId), calc.getSource()); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKIMPACTLOCATION, triggerId), + attackImpactLocation); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, triggerId), attack); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, triggerId), settings); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId), calc); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(calc.getSource(), localStore, triggerId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKIMPACTLOCATION, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THEATTACK, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKSETTINGS, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackProjReactionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackProjReactionListener.java new file mode 100644 index 000000000..8873813ae --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABAttackProjReactionListener.java @@ -0,0 +1,57 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.listeners.CUnitAttackProjReactionListener; + +public class ABAttackProjReactionListener implements CUnitAttackProjReactionListener { + + private ABLocalDataStore localStore; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_ID; + private boolean useCastId; + + public ABAttackProjReactionListener(ABLocalDataStore localStore, List actions, int castId, + boolean useCastId) { + this.localStore = localStore; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public boolean onHit(final CSimulation simulation, CUnit source, CUnit target, CAttackProjectile projectile) { + if (!this.useCastId) { + this.triggerId = ABConstants.incrementTriggerId(triggerId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONALLOWHIT, triggerId), true); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId), source); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKPROJ, triggerId), projectile); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(target, localStore, triggerId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKTARGET, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.ATTACKPROJ, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + return (boolean) localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.REACTIONALLOWHIT, triggerId)); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABBehaviorChangeListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABBehaviorChangeListener.java new file mode 100644 index 000000000..7b22dc279 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABBehaviorChangeListener.java @@ -0,0 +1,56 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitBehaviorChangeListener; + +public class ABBehaviorChangeListener implements CUnitBehaviorChangeListener { + + private ABLocalDataStore localStore; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_ID; + private boolean useCastId; + + public ABBehaviorChangeListener(ABLocalDataStore localStore, List actions, int castId, + boolean useCastId) { + this.localStore = localStore; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public void onChange(CSimulation game, CUnit unit, CBehavior previousBehavior, CBehavior newBehavior, + boolean ongoing) { + if (!this.useCastId) { + this.triggerId = ABConstants.incrementTriggerId(triggerId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PRECHANGEBEHAVIOR, triggerId), previousBehavior); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.POSTCHANGEBEHAVIOR, triggerId), newBehavior); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BEHAVIORONGOING, triggerId), ongoing); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(unit, localStore, triggerId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PRECHANGEBEHAVIOR, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.POSTCHANGEBEHAVIOR, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.BEHAVIORONGOING, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDamageTakenListener.java new file mode 100644 index 000000000..279b73a7a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDamageTakenListener.java @@ -0,0 +1,80 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenListener; + +public class ABDamageTakenListener implements CUnitAttackDamageTakenListener { + + private ABLocalDataStore localStore; + private ABIntegerCallback priority; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_PRIORITY_ID; + private boolean useCastId; + + public ABDamageTakenListener(ABLocalDataStore localStore, ABIntegerCallback priority, List actions, + int castId, boolean useCastId) { + this.localStore = localStore; + this.priority = priority; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public int getPriority(CSimulation simulation, CUnit target, CDamageCalculation damage) { + if (priority == null) { + return 0; + } + if (!this.useCastId) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId), damage.getSource()); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId), damage); + int prio = this.priority.callback(target, this.localStore, this.triggerId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + return prio; + } + + @Override + public void onDamage(CSimulation simulation, CUnit target, CDamageCalculation damage) { + if (!this.useCastId) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId), damage.getSource()); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId), damage); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(target, localStore, triggerId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + this.triggerId = ABConstants.incrementTriggerId(triggerId); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDamageTakenModificationListener.java new file mode 100644 index 000000000..bc2a5a975 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDamageTakenModificationListener.java @@ -0,0 +1,80 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackDamageTakenModificationListener; + +public class ABDamageTakenModificationListener implements CUnitAttackDamageTakenModificationListener { + + private ABLocalDataStore localStore; + private ABIntegerCallback priority; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_PRIORITY_ID; + private boolean useCastId; + + public ABDamageTakenModificationListener(ABLocalDataStore localStore, ABIntegerCallback priority, + List actions, int castId, boolean useCastId) { + this.localStore = localStore; + this.priority = priority; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public int getPriority(CSimulation simulation, CUnit target, CDamageCalculation damage) { + if (priority == null) { + return 0; + } + if (!this.useCastId) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId), damage.getSource()); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId), damage); + int prio = this.priority.callback(target, this.localStore, this.triggerId); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + return prio; + } + + @Override + public void onDamage(CSimulation simulation, CUnit target, CDamageCalculation damage) { + if (!this.useCastId) { + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId), damage.getSource()); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId), target); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId), damage); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(target, localStore, triggerId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGEDUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DAMAGECALC, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + this.triggerId = ABConstants.incrementTriggerId(triggerId); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDeathReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDeathReplacementEffect.java new file mode 100644 index 000000000..3cffc7f22 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABDeathReplacementEffect.java @@ -0,0 +1,61 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementEffect; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementResult; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitDeathReplacementStacking; + +public class ABDeathReplacementEffect implements CUnitDeathReplacementEffect { + + private ABLocalDataStore localStore; + private List actions; + + private int triggerId = ABConstants.STARTING_TRIGGER_ID; + private boolean useCastId; + + public ABDeathReplacementEffect(ABLocalDataStore localStore, List actions, int castId, + boolean useCastId) { + this.localStore = localStore; + this.actions = actions; + this.useCastId = useCastId; + if (useCastId) { + this.triggerId = castId; + } + } + + @Override + public CUnitDeathReplacementStacking onDeath(CSimulation simulation, CUnit unit, CUnit killer, + CUnitDeathReplacementResult result) { + if (!this.useCastId) { + this.triggerId = ABConstants.incrementTriggerId(triggerId); + this.localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId), + this.localStore.originAbility.getLevel()); + } + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.KILLINGUNIT, triggerId), killer); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DYINGUNIT, triggerId), unit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHRESULT, triggerId), result); + CUnitDeathReplacementStacking stacking = new CUnitDeathReplacementStacking(); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHSTACKING, triggerId), stacking); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(unit, localStore, triggerId); + } + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.KILLINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DYINGUNIT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHRESULT, triggerId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.DEATHSTACKING, triggerId)); + if (!this.useCastId) { + this.localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.CASTINSTANCELEVEL, this.triggerId)); + } + return stacking; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABUnitStateListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABUnitStateListener.java new file mode 100644 index 000000000..ec451e44f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/listener/ABUnitStateListener.java @@ -0,0 +1,207 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.listener; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitStateListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; + +public class ABUnitStateListener implements CUnitStateListener { + private CUnit caster; + private ABLocalDataStore localStore; + private int castId; + + private List onLifeChanged = null; + private List onManaChanged = null; + private List onOrdersChanged = null; + private List onQueueChanged = null; + private List onRallyPointChanged = null; + private List onWaypointsChanged = null; + private List onHeroStatsChanged = null; + private List onInventoryChanged = null; + private List onAttacksChanged = null; + private List onAbilitiesChanged = null; + private List onUpgradesChanged = null; + private List onHideStateChanged = null; + + public ABUnitStateListener(CUnit caster, ABLocalDataStore localStore, int castId, List onLifeChanged, + List onManaChanged, List onOrdersChanged, List onQueueChanged, + List onRallyPointChanged, List onWaypointsChanged, List onHeroStatsChanged, + List onInventoryChanged, List onAttacksChanged, List onAbilitiesChanged, + List onUpgradesChanged, List onHideStateChanged) { + super(); + this.caster = caster; + this.localStore = localStore; + this.castId = castId; + this.onLifeChanged = onLifeChanged; + this.onManaChanged = onManaChanged; + this.onOrdersChanged = onOrdersChanged; + this.onQueueChanged = onQueueChanged; + this.onRallyPointChanged = onRallyPointChanged; + this.onWaypointsChanged = onWaypointsChanged; + this.onHeroStatsChanged = onHeroStatsChanged; + this.onInventoryChanged = onInventoryChanged; + this.onAttacksChanged = onAttacksChanged; + this.onAbilitiesChanged = onAbilitiesChanged; + this.onUpgradesChanged = onUpgradesChanged; + this.onHideStateChanged = onHideStateChanged; + } + + public void setOnLifeChanged(List onLifeChanged) { + this.onLifeChanged = onLifeChanged; + } + + public void setOnManaChanged(List onManaChanged) { + this.onManaChanged = onManaChanged; + } + + public void setOnOrdersChanged(List onOrdersChanged) { + this.onOrdersChanged = onOrdersChanged; + } + + public void setOnQueueChanged(List onQueueChanged) { + this.onQueueChanged = onQueueChanged; + } + + public void setOnRallyPointChanged(List onRallyPointChanged) { + this.onRallyPointChanged = onRallyPointChanged; + } + + public void setOnWaypointsChanged(List onWaypointsChanged) { + this.onWaypointsChanged = onWaypointsChanged; + } + + public void setOnHeroStatsChanged(List onHeroStatsChanged) { + this.onHeroStatsChanged = onHeroStatsChanged; + } + + public void setOnInventoryChanged(List onInventoryChanged) { + this.onInventoryChanged = onInventoryChanged; + } + + public void setOnAttacksChanged(List onAttacksChanged) { + this.onAttacksChanged = onAttacksChanged; + } + + public void setOnAbilitiesChanged(List onAbilitiesChanged) { + this.onAbilitiesChanged = onAbilitiesChanged; + } + + public void setOnUpgradesChanged(List onUpgradesChanged) { + this.onUpgradesChanged = onUpgradesChanged; + } + + public void setOnHideStateChanged(List onHideStateChanged) { + this.onHideStateChanged = onHideStateChanged; + } + + @Override + public void lifeChanged() { + if (onLifeChanged != null) { + for (ABAction action : onLifeChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void manaChanged() { + if (onManaChanged != null) { + for (ABAction action : onManaChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void ordersChanged() { + if (onOrdersChanged != null) { + for (ABAction action : onOrdersChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void queueChanged() { + if (onQueueChanged != null) { + for (ABAction action : onQueueChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void rallyPointChanged() { + if (onRallyPointChanged != null) { + for (ABAction action : onRallyPointChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void waypointsChanged() { + if (onWaypointsChanged != null) { + for (ABAction action : onWaypointsChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void heroStatsChanged() { + if (onHeroStatsChanged != null) { + for (ABAction action : onHeroStatsChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void inventoryChanged() { + if (onInventoryChanged != null) { + for (ABAction action : onInventoryChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void attacksChanged() { + if (onAttacksChanged != null) { + for (ABAction action : onAttacksChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void abilitiesChanged() { + if (onAbilitiesChanged != null) { + for (ABAction action : onAbilitiesChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void upgradesChanged() { + if (onUpgradesChanged != null) { + for (ABAction action : onUpgradesChanged) { + action.runAction(caster, localStore, castId); + } + } + } + + @Override + public void hideStateChanged() { + if (onHideStateChanged != null) { + for (ABAction action : onHideStateChanged) { + action.runAction(caster, localStore, castId); + } + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderConfiguration.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderConfiguration.java new file mode 100644 index 000000000..7b7dd4752 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderConfiguration.java @@ -0,0 +1,384 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields.ABAbilityBuilderOverrideFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields.ABAbilityBuilderSpecialConfigFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields.ABAbilityBuilderSpecialDisplayFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.definitions.impl.ABAbilityBuilderTypeDefinition; + +public class ABAbilityBuilderConfiguration { + private String id; + + private String castId; + private String uncastId; + private String autoCastOnId; + private String autoCastOffId; + private AutocastType autoCastType; + + private ABAbilityBuilderType type; + private ABAbilityBuilderSpecialDisplayFields displayFields; + private ABAbilityBuilderSpecialConfigFields specialFields; + private ABAbilityBuilderOverrideFields overrideFields; + + private List extraTargetConditions; + private List extraAutoTargetConditions; + private List extraAutoNoTargetConditions; + private List extraCastConditions; + + private List onAddAbility; + private List onAddDisabledAbility; + private List onRemoveAbility; + private List onRemoveDisabledAbility; + + private List onDeathPreCast; + private List onCancelPreCast; + private List onOrderIssued; + private List onActivate; + private List onDeactivate; + private List onChangeAutoCast; + + private List onLevelChange; + + private List onBeginCasting; + private List onEndCasting; + private List onChannelTick; + private List onEndChannel; + + private Map> reuseActions; + private Map reuseCallbacks; + + private List initialUniqueFlags; + + public ABAbilityBuilderConfiguration(ABAbilityBuilderParser parser, ABAbilityBuilderDupe dupe) { + this.id = dupe.getId(); + this.castId = dupe.getCastId(); + this.uncastId = dupe.getUncastId(); + this.autoCastOnId = dupe.getAutoCastOnId(); + this.autoCastOffId = dupe.getAutoCastOffId(); + this.autoCastType = dupe.getAutoCastType(); + this.type = parser.getType(); + this.displayFields = parser.getDisplayFields(); + this.specialFields = parser.getSpecialFields(); + this.overrideFields = parser.getOverrideFields(); + + this.extraTargetConditions = parser.getExtraTargetConditions(); + this.extraAutoTargetConditions = parser.getExtraAutoTargetConditions(); + this.extraCastConditions = parser.getExtraCastConditions(); + this.extraAutoNoTargetConditions = parser.getExtraAutoNoTargetConditions(); + + this.onAddAbility = parser.getOnAddAbility(); + this.onAddDisabledAbility = parser.getOnAddDisabledAbility(); + this.onRemoveAbility = parser.getOnRemoveAbility(); + this.onRemoveDisabledAbility = parser.getOnRemoveDisabledAbility(); + this.onDeathPreCast = parser.getOnDeathPreCast(); + this.onCancelPreCast = parser.getOnCancelPreCast(); + this.onOrderIssued = parser.getOnOrderIssued(); + this.onActivate = parser.getOnActivate(); + this.onDeactivate = parser.getOnDeactivate(); + this.onChangeAutoCast = parser.getOnChangeAutoCast(); + + this.onLevelChange = parser.getOnLevelChange(); + + this.onBeginCasting = parser.getOnBeginCasting(); + this.onEndCasting = parser.getOnEndCasting(); + this.onChannelTick = parser.getOnChannelTick(); + this.onEndChannel = parser.getOnEndChannel(); + + this.setReuseActions(parser.getReuseActions()); + this.setReuseCallbacks(parser.getReuseCallbacks()); + + this.setInitialUniqueFlags(parser.getInitialUniqueFlags()); + } + + public ABAbilityBuilderTypeDefinition createDefinition() { + return new ABAbilityBuilderTypeDefinition(this); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCastId() { + return castId; + } + + public void setCastId(String castId) { + this.castId = castId; + } + + public String getUncastId() { + return uncastId; + } + + public void setUncastId(String uncastId) { + this.uncastId = uncastId; + } + + public String getAutoCastOnId() { + return autoCastOnId; + } + + public void setAutoCastOnId(String autoCastOnId) { + this.autoCastOnId = autoCastOnId; + } + + public String getAutoCastOffId() { + return autoCastOffId; + } + + public void setAutoCastOffId(String autoCastOffId) { + this.autoCastOffId = autoCastOffId; + } + + /** + * @return the autoCastType + */ + public AutocastType getAutoCastType() { + return autoCastType; + } + + /** + * @param autoCastType the autoCastType to set + */ + public void setAutoCastType(AutocastType autoCastType) { + this.autoCastType = autoCastType; + } + + public ABAbilityBuilderType getType() { + return type; + } + + public void setType(ABAbilityBuilderType type) { + this.type = type; + } + + public ABAbilityBuilderSpecialDisplayFields getDisplayFields() { + return displayFields; + } + + public void setDisplayFields(ABAbilityBuilderSpecialDisplayFields displayFields) { + this.displayFields = displayFields; + } + + public ABAbilityBuilderSpecialConfigFields getSpecialFields() { + return specialFields; + } + + public void setSpecialFields(ABAbilityBuilderSpecialConfigFields specialFields) { + this.specialFields = specialFields; + } + + public ABAbilityBuilderOverrideFields getOverrideFields() { + return overrideFields; + } + + public void setOverrideFields(ABAbilityBuilderOverrideFields overrideFields) { + this.overrideFields = overrideFields; + } + + public List getExtraTargetConditions() { + return extraTargetConditions; + } + + public void setExtraTargetConditions(List extraTargetConditions) { + this.extraTargetConditions = extraTargetConditions; + } + + /** + * @return the extraAutoTargetConditions + */ + public List getExtraAutoTargetConditions() { + return extraAutoTargetConditions; + } + + /** + * @param extraAutoTargetConditions the extraAutoTargetConditions to set + */ + public void setExtraAutoTargetConditions(List extraAutoTargetConditions) { + this.extraAutoTargetConditions = extraAutoTargetConditions; + } + + public List getExtraAutoNoTargetConditions() { + return extraAutoNoTargetConditions; + } + + public void setExtraAutoNoTargetConditions(List extraAutoNoTargetConditions) { + this.extraAutoNoTargetConditions = extraAutoNoTargetConditions; + } + + public List getExtraCastConditions() { + return extraCastConditions; + } + + public void setExtraCastConditions(List extraCastConditions) { + this.extraCastConditions = extraCastConditions; + } + + public List getOnAddAbility() { + return onAddAbility; + } + + public void setOnAddAbility(List onAddAbility) { + this.onAddAbility = onAddAbility; + } + + /** + * @return the onAddDisabledAbility + */ + public List getOnAddDisabledAbility() { + return onAddDisabledAbility; + } + + /** + * @param onAddDisabledAbility the onAddDisabledAbility to set + */ + public void setOnAddDisabledAbility(List onAddDisabledAbility) { + this.onAddDisabledAbility = onAddDisabledAbility; + } + + public List getOnRemoveAbility() { + return onRemoveAbility; + } + + public void setOnRemoveAbility(List onRemoveAbility) { + this.onRemoveAbility = onRemoveAbility; + } + + /** + * @return the onRemoveDisabledAbility + */ + public List getOnRemoveDisabledAbility() { + return onRemoveDisabledAbility; + } + + /** + * @param onRemoveDisabledAbility the onRemoveDisabledAbility to set + */ + public void setOnRemoveDisabledAbility(List onRemoveDisabledAbility) { + this.onRemoveDisabledAbility = onRemoveDisabledAbility; + } + + public List getOnDeathPreCast() { + return onDeathPreCast; + } + + public void setOnDeathPreCast(List onDeathPreCast) { + this.onDeathPreCast = onDeathPreCast; + } + + public List getOnCancelPreCast() { + return onCancelPreCast; + } + + public void setOnCancelPreCast(List onCancelPreCast) { + this.onCancelPreCast = onCancelPreCast; + } + + public List getOnOrderIssued() { + return onOrderIssued; + } + + public void setOnOrderIssued(List onOrderIssued) { + this.onOrderIssued = onOrderIssued; + } + + public List getOnActivate() { + return onActivate; + } + + public void setOnActivate(List onActivate) { + this.onActivate = onActivate; + } + + public List getOnDeactivate() { + return onDeactivate; + } + + public void setOnDeactivate(List onDeactivate) { + this.onDeactivate = onDeactivate; + } + + public List getOnChangeAutoCast() { + return onChangeAutoCast; + } + + public void setOnChangeAutoCast(List onChangeAutoCast) { + this.onChangeAutoCast = onChangeAutoCast; + } + + public List getOnLevelChange() { + return onLevelChange; + } + + public void setOnLevelChange(List onLevelChange) { + this.onLevelChange = onLevelChange; + } + + public List getOnBeginCasting() { + return onBeginCasting; + } + + public void setOnBeginCasting(List onBeginCasting) { + this.onBeginCasting = onBeginCasting; + } + + public List getOnEndCasting() { + return onEndCasting; + } + + public void setOnEndCasting(List onEndCasting) { + this.onEndCasting = onEndCasting; + } + + public List getOnChannelTick() { + return onChannelTick; + } + + public void setOnChannelTick(List onChannelTick) { + this.onChannelTick = onChannelTick; + } + + public List getOnEndChannel() { + return onEndChannel; + } + + public void setOnEndChannel(List onEndChannel) { + this.onEndChannel = onEndChannel; + } + + public Map> getReuseActions() { + return reuseActions; + } + + public void setReuseActions(Map> reuseActions) { + this.reuseActions = reuseActions; + } + + public Map getReuseCallbacks() { + return reuseCallbacks; + } + + public void setReuseCallbacks(Map reuseCallbacks) { + this.reuseCallbacks = reuseCallbacks; + } + + public List getInitialUniqueFlags() { + return this.initialUniqueFlags; + } + + public void setInitialUniqueFlags( List initialUniqueFlags) { + this.initialUniqueFlags = initialUniqueFlags; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderDupe.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderDupe.java new file mode 100644 index 000000000..b3724cc60 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderDupe.java @@ -0,0 +1,67 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; + +public class ABAbilityBuilderDupe { + private String id; + + private String castId; + private String uncastId; + private String autoCastOnId; + private String autoCastOffId; + private AutocastType autoCastType; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCastId() { + return castId; + } + + public void setCastId(String castId) { + this.castId = castId; + } + + public String getUncastId() { + return uncastId; + } + + public void setUncastId(String uncastId) { + this.uncastId = uncastId; + } + + public String getAutoCastOnId() { + return autoCastOnId; + } + + public void setAutoCastOnId(String autoCastOnId) { + this.autoCastOnId = autoCastOnId; + } + + public String getAutoCastOffId() { + return autoCastOffId; + } + + public void setAutoCastOffId(String autoCastOffId) { + this.autoCastOffId = autoCastOffId; + } + + /** + * @return the autoCastType + */ + public AutocastType getAutoCastType() { + return autoCastType; + } + + /** + * @param autoCastType the autoCastType to set + */ + public void setAutoCastType(AutocastType autoCastType) { + this.autoCastType = autoCastType; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderFile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderFile.java new file mode 100644 index 000000000..6de514491 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderFile.java @@ -0,0 +1,15 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser; + +import java.util.List; + +public class ABAbilityBuilderFile { + List abilityList; + + public List getAbilityList() { + return abilityList; + } + + public void setAbilityList(List abilityList) { + this.abilityList = abilityList; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderParser.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderParser.java new file mode 100644 index 000000000..4ee294d34 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderParser.java @@ -0,0 +1,458 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.strings.ABStringCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields.ABAbilityBuilderOverrideFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields.ABAbilityBuilderParserTemplateFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields.ABAbilityBuilderSpecialConfigFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields.ABAbilityBuilderSpecialDisplayFields; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABMeleeRangeTargetOverride; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABStatBuffFromDataField; + +public class ABAbilityBuilderParser { + + private List ids; + private String parentId; + + private ABAbilityBuilderType type; + private ABAbilityBuilderSpecialDisplayFields displayFields; + private ABAbilityBuilderSpecialConfigFields specialFields; + private ABAbilityBuilderOverrideFields overrideFields; + + private List extraTargetConditions; + private List extraAutoTargetConditions; + private List extraAutoNoTargetConditions; + private List extraCastConditions; + + private List onAddAbility; + private List onAddDisabledAbility; + private List onRemoveAbility; + private List onRemoveDisabledAbility; + private List onDeathPreCast; + private List onCancelPreCast; + private List onOrderIssued; + private List onActivate; + private List onDeactivate; + private List onChangeAutoCast; + + private List onLevelChange; + + private List onBeginCasting; + private List onEndCasting; + private List onChannelTick; + private List onEndChannel; + + private Map> reuseActions; + private Map reuseCallbacks; + + private List initialUniqueFlags; + + //Template only + private ABAbilityBuilderParserTemplateFields templateFields; + + + public void updateFromParent(ABAbilityBuilderParser parent) { + this.type = parent.type; + + if (parent.displayFields != null) { + if (this.displayFields == null) { + this.displayFields = new ABAbilityBuilderSpecialDisplayFields(); + } + this.displayFields.updateFromParent(parent.displayFields); + } + if (parent.specialFields != null) { + if (this.specialFields == null) { + this.specialFields = new ABAbilityBuilderSpecialConfigFields(); + } + this.specialFields.updateFromParent(parent.specialFields); + } + if (parent.overrideFields != null) { + if (this.overrideFields == null) { + this.overrideFields = new ABAbilityBuilderOverrideFields(); + } + this.overrideFields.updateFromParent(parent.overrideFields); + } + if (parent.templateFields != null) { + if (this.templateFields == null) { + this.templateFields = new ABAbilityBuilderParserTemplateFields(); + } + this.templateFields.updateFromParent(parent.templateFields); + } + + if (parent.reuseActions != null) { + if (this.reuseActions == null) { + this.reuseActions = new HashMap<>(); + } + for (String key : parent.reuseActions.keySet()) { + if (!this.reuseActions.containsKey(key)) { + this.reuseActions.put(key, parent.reuseActions.get(key)); + } + } + } + if (parent.reuseCallbacks != null) { + if (this.reuseCallbacks == null) { + this.reuseCallbacks = new HashMap<>(); + } + for (String key : parent.reuseCallbacks.keySet()) { + if (!this.reuseCallbacks.containsKey(key)) { + this.reuseCallbacks.put(key, parent.reuseCallbacks.get(key)); + } + } + } + + if (this.extraTargetConditions == null) + this.extraTargetConditions = parent.extraTargetConditions; + if (this.extraAutoTargetConditions == null) + this.extraAutoTargetConditions = parent.extraAutoTargetConditions; + if (this.extraAutoNoTargetConditions == null) + this.extraAutoNoTargetConditions = parent.extraAutoNoTargetConditions; + if (this.extraCastConditions == null) + this.extraCastConditions = parent.extraCastConditions; + if (this.onAddAbility == null) + this.onAddAbility = parent.onAddAbility; + if (this.onAddDisabledAbility == null) + this.onAddDisabledAbility = parent.onAddDisabledAbility; + if (this.onRemoveAbility == null) + this.onRemoveAbility = parent.onRemoveAbility; + if (this.onRemoveDisabledAbility == null) + this.onRemoveDisabledAbility = parent.onRemoveDisabledAbility; + if (this.onDeathPreCast == null) + this.onDeathPreCast = parent.onDeathPreCast; + if (this.onCancelPreCast == null) + this.onCancelPreCast = parent.onCancelPreCast; + if (this.onOrderIssued == null) + this.onOrderIssued = parent.onOrderIssued; + if (this.onActivate == null) + this.onActivate = parent.onActivate; + if (this.onDeactivate == null) + this.onDeactivate = parent.onDeactivate; + if (this.onChangeAutoCast == null) + this.onChangeAutoCast = parent.onChangeAutoCast; + if (this.onLevelChange == null) + this.onLevelChange = parent.onLevelChange; + if (this.onBeginCasting == null) + this.onBeginCasting = parent.onBeginCasting; + if (this.onEndCasting == null) + this.onEndCasting = parent.onEndCasting; + if (this.onChannelTick == null) + this.onChannelTick = parent.onChannelTick; + if (this.onEndChannel == null) + this.onEndChannel = parent.onEndChannel; + + if (this.initialUniqueFlags == null) + this.initialUniqueFlags = parent.initialUniqueFlags; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public ABAbilityBuilderType getType() { + return type; + } + + public void setType(ABAbilityBuilderType type) { + this.type = type; + } + + public ABAbilityBuilderSpecialDisplayFields getDisplayFields() { + return displayFields; + } + + public void setDisplayFields(ABAbilityBuilderSpecialDisplayFields displayFields) { + this.displayFields = displayFields; + } + + public ABAbilityBuilderSpecialConfigFields getSpecialFields() { + return specialFields; + } + + public void setSpecialFields(ABAbilityBuilderSpecialConfigFields specialFields) { + this.specialFields = specialFields; + } + + public ABAbilityBuilderOverrideFields getOverrideFields() { + return overrideFields; + } + + public void setOverrideFields(ABAbilityBuilderOverrideFields overrideFields) { + this.overrideFields = overrideFields; + } + + public List getExtraTargetConditions() { + return extraTargetConditions; + } + + public void setExtraTargetConditions(List extraTargetConditions) { + this.extraTargetConditions = extraTargetConditions; + } + + /** + * @return the extraAutoTargetConditions + */ + public List getExtraAutoTargetConditions() { + return extraAutoTargetConditions; + } + + /** + * @param extraAutoTargetConditions the extraAutoTargetConditions to set + */ + public void setExtraAutoTargetConditions(List extraAutoTargetConditions) { + this.extraAutoTargetConditions = extraAutoTargetConditions; + } + + public List getExtraAutoNoTargetConditions() { + return extraAutoNoTargetConditions; + } + + public void setExtraAutoNoTargetConditions(List extraAutoNoTargetConditions) { + this.extraAutoNoTargetConditions = extraAutoNoTargetConditions; + } + + public List getExtraCastConditions() { + return extraCastConditions; + } + + public void setExtraCastConditions(List extraCastConditions) { + this.extraCastConditions = extraCastConditions; + } + + public List getOnAddAbility() { + return onAddAbility; + } + + public void setOnAddAbility(List onAddAbility) { + this.onAddAbility = onAddAbility; + } + + /** + * @return the onAddDisabledAbility + */ + public List getOnAddDisabledAbility() { + return onAddDisabledAbility; + } + + /** + * @param onAddDisabledAbility the onAddDisabledAbility to set + */ + public void setOnAddDisabledAbility(List onAddDisabledAbility) { + this.onAddDisabledAbility = onAddDisabledAbility; + } + + public List getOnRemoveAbility() { + return onRemoveAbility; + } + + public void setOnRemoveAbility(List onRemoveAbility) { + this.onRemoveAbility = onRemoveAbility; + } + + /** + * @return the onRemoveDisabledAbility + */ + public List getOnRemoveDisabledAbility() { + return onRemoveDisabledAbility; + } + + /** + * @param onRemoveDisabledAbility the onRemoveDisabledAbility to set + */ + public void setOnRemoveDisabledAbility(List onRemoveDisabledAbility) { + this.onRemoveDisabledAbility = onRemoveDisabledAbility; + } + + public List getOnDeathPreCast() { + return onDeathPreCast; + } + + public void setOnDeathPreCast(List onDeathPreCast) { + this.onDeathPreCast = onDeathPreCast; + } + + public List getOnCancelPreCast() { + return onCancelPreCast; + } + + public void setOnCancelPreCast(List onCancelPreCast) { + this.onCancelPreCast = onCancelPreCast; + } + + public List getOnOrderIssued() { + return onOrderIssued; + } + + public void setOnOrderIssued(List onOrderIssued) { + this.onOrderIssued = onOrderIssued; + } + + public List getOnActivate() { + return onActivate; + } + + public void setOnActivate(List onActivate) { + this.onActivate = onActivate; + } + + public List getOnDeactivate() { + return onDeactivate; + } + + public void setOnDeactivate(List onDeactivate) { + this.onDeactivate = onDeactivate; + } + + public List getOnChangeAutoCast() { + return onChangeAutoCast; + } + + public void setOnChangeAutoCast(List onChangeAutoCast) { + this.onChangeAutoCast = onChangeAutoCast; + } + + public List getOnBeginCasting() { + return onBeginCasting; + } + + public void setOnBeginCasting(List onBeginCasting) { + this.onBeginCasting = onBeginCasting; + } + + public List getOnLevelChange() { + return onLevelChange; + } + + public void setOnLevelChange(List onLevelChange) { + this.onLevelChange = onLevelChange; + } + + public List getOnEndCasting() { + return onEndCasting; + } + + public void setOnEndCasting(List onEndCasting) { + this.onEndCasting = onEndCasting; + } + + public List getOnChannelTick() { + return onChannelTick; + } + + public void setOnChannelTick(List onChannelTick) { + this.onChannelTick = onChannelTick; + } + + public List getOnEndChannel() { + return onEndChannel; + } + + public void setOnEndChannel(List onEndChannel) { + this.onEndChannel = onEndChannel; + } + + public Map> getReuseActions() { + return reuseActions; + } + + public void setReuseActions(Map> reuseActions) { + this.reuseActions = reuseActions; + } + + public Map getReuseCallbacks() { + return reuseCallbacks; + } + + public void setReuseCallbacks(Map reuseCallbacks) { + this.reuseCallbacks = reuseCallbacks; + } + + public ABAbilityBuilderTemplateType getTemplateType() { + return templateFields.getTemplateType(); + } + + public void setTemplateType(ABAbilityBuilderTemplateType templateType) { + this.templateFields.setTemplateType(templateType); + } + + public List getAddToAuraActions() { + return templateFields.getAddToAuraActions(); + } + + public void setAddToAuraActions(List addToAuraActions) { + this.templateFields.setAddToAuraActions(addToAuraActions); + } + + public List getUpdateAuraLevelActions() { + return templateFields.getUpdateAuraLevelActions(); + } + + public void setUpdateAuraLevelActions(List updateAuraLevelActions) { + this.templateFields.setUpdateAuraLevelActions(updateAuraLevelActions); + } + + public List getRemoveFromAuraActions() { + return templateFields.getRemoveFromAuraActions(); + } + + public void setRemoveFromAuraActions(List removeFromAuraActions) { + this.templateFields.setRemoveFromAuraActions(removeFromAuraActions); + } + + public Map> getAbilityIdsToAddPerLevel() { + return templateFields.getAbilityIdsToAddPerLevel(); + } + + public void setAbilityIdsToAddPerLevel(Map> abilityIdsToAddPerLevel) { + this.setAbilityIdsToAddPerLevel(abilityIdsToAddPerLevel); + } + + public List getLevellingAbilityIdsToAdd() { + return templateFields.getLevellingAbilityIdsToAdd(); + } + + public void setLevellingAbilityIdsToAdd(List levellingAbilityIdsToAdd) { + this.templateFields.setLevellingAbilityIdsToAdd(levellingAbilityIdsToAdd); + } + + public List getStatBuffsFromDataFields() { + return templateFields.getStatBuffsFromDataFields(); + } + + public void setStatBuffsFromDataFields(List statBuffsFromDataFields) { + this.templateFields.setStatBuffsFromDataFields(statBuffsFromDataFields); + } + + public ABMeleeRangeTargetOverride getMeleeRangeTargetOverride() { + return templateFields.getMeleeRangeTargetOverride(); + } + + public void setMeleeRangeTargetOverride(ABMeleeRangeTargetOverride meleeRangeTargetOverride) { + this.templateFields.setMeleeRangeTargetOverride(meleeRangeTargetOverride); + } + + public List getInitialUniqueFlags() { + return this.initialUniqueFlags; + } + + public void setInitialUniqueFlags( List initialUniqueFlags) { + this.initialUniqueFlags = initialUniqueFlags; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderParserUtil.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderParserUtil.java new file mode 100644 index 000000000..a5b56752a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderParserUtil.java @@ -0,0 +1,64 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAbilityBuilderGsonBuilder; +import com.google.gson.Gson; +import com.google.gson.JsonParseException; + +public class ABAbilityBuilderParserUtil { + public static void loadAbilityBuilderFiles(final AbilityBuilderFileListener listener) { + loadAbilityBuilderFiles(listener, "abilityBehaviors"); + } + public static void loadAbilityBuilderFiles(final AbilityBuilderFileListener listener, String folder) { + final Gson gson = ABAbilityBuilderGsonBuilder.create(); + try { + final File abilityBehaviorsDir = new File(folder); + final File[] abilityBehaviorFiles = abilityBehaviorsDir.listFiles(); + if (abilityBehaviorFiles != null) { + for (final File abilityBehaviorFile : abilityBehaviorFiles) { + loadAbilityBuilderFile(gson, abilityBehaviorFile, listener); + } + } + } + catch (final Exception e) { + e.printStackTrace(); + } + } + + public static void loadAbilityBuilderFile(final Gson gson, final File abilityBehaviorFile, + final AbilityBuilderFileListener listener) throws FileNotFoundException { + if (abilityBehaviorFile.isDirectory()) { + final File[] abilityBehaviorFiles = abilityBehaviorFile.listFiles(); + if (abilityBehaviorFiles != null) { + for (final File subAbilityBehaviorFile : abilityBehaviorFiles) { + loadAbilityBuilderFile(gson, subAbilityBehaviorFile, listener); + } + } + } + try { + final ABAbilityBuilderFile behaviors = gson.fromJson(new FileReader(abilityBehaviorFile), + ABAbilityBuilderFile.class); + for (final ABAbilityBuilderParser behavior : behaviors.getAbilityList()) { + listener.callback(behavior); + } + } + catch (final JsonParseException e) { + System.err.println("Failed to load Ability Builder config file: " + abilityBehaviorFile.getName()); + e.printStackTrace(); + } + catch (final IllegalArgumentException e) { + System.err.println("Failed to load Ability Builder config file: " + abilityBehaviorFile.getName()); + e.printStackTrace(); + } catch (FileNotFoundException e) { + System.err.println("Failed to find Ability Builder config file: " + abilityBehaviorFile.getName()); + e.printStackTrace(); + } + } + + public static interface AbilityBuilderFileListener { + void callback(ABAbilityBuilderParser behavior); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderTemplateType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderTemplateType.java new file mode 100644 index 000000000..166d6c0cc --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderTemplateType.java @@ -0,0 +1,8 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser; + +public enum ABAbilityBuilderTemplateType { + AURA, + AURA_SIMPLE, + AURA_STATS, + PASSIVE_STATS; +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderType.java new file mode 100644 index 000000000..828a912e6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/ABAbilityBuilderType.java @@ -0,0 +1,23 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser; + +import com.etheller.interpreter.ast.util.CHandle; + +public enum ABAbilityBuilderType implements CHandle { + NORMAL_AUTOTARGET, + NORMAL_PAIRING, + NORMAL_FLEXTARGET, + NORMAL_UNITTARGET, + NORMAL_POINTTARGET, + NORMAL_NOTARGET, + PASSIVE, + TEMPLATE, + INHERIT, + HIDDEN; + + @Override + public int getHandleId() { + return ordinal(); + } + + public static final ABAbilityBuilderType[] VALUES = values(); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderOverrideFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderOverrideFields.java new file mode 100644 index 000000000..6e6eccbbb --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderOverrideFields.java @@ -0,0 +1,158 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABAutocastTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.enums.ABTargetTypeCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; + +public class ABAbilityBuilderOverrideFields { + + private ABFloatCallback areaOverride; + private ABFloatCallback rangeOverride; + private ABFloatCallback castTimeOverride; + private ABFloatCallback cooldownOverride; + private ABIntegerCallback manaCostOverride; + + private ABBooleanCallback ignoreCastTime; + + private ABAutocastTypeCallback autocastTypeOverride; + + private ABIDCallback onTooltipOverride; + private ABIDCallback offTooltipOverride; + + private ABBooleanCallback physicalSpell; + private ABBooleanCallback magicSpell; + private ABBooleanCallback universalSpell; + private ABBooleanCallback dispel; + + List extraTargetsAllowed; + List excludedTargetsAllowed; + + public void updateFromParent(ABAbilityBuilderOverrideFields parent) { + if (this.areaOverride == null) + this.areaOverride = parent.areaOverride; + if (this.rangeOverride == null) + this.rangeOverride = parent.rangeOverride; + if (this.castTimeOverride == null) + this.castTimeOverride = parent.castTimeOverride; + if (this.cooldownOverride == null) + this.cooldownOverride = parent.cooldownOverride; + if (this.manaCostOverride == null) + this.manaCostOverride = parent.manaCostOverride; + + if (this.ignoreCastTime == null) + this.ignoreCastTime = parent.ignoreCastTime; + + if (this.autocastTypeOverride == null) + this.autocastTypeOverride = parent.autocastTypeOverride; + + if (this.onTooltipOverride == null) + this.onTooltipOverride = parent.onTooltipOverride; + if (this.offTooltipOverride == null) + this.offTooltipOverride = parent.offTooltipOverride; + + if (this.physicalSpell == null) + this.physicalSpell = parent.physicalSpell; + if (this.magicSpell == null) + this.magicSpell = parent.magicSpell; + if (this.universalSpell == null) + this.universalSpell = parent.universalSpell; + } + + public ABFloatCallback getAreaOverride() { + return areaOverride; + } + public void setAreaOverride(ABFloatCallback areaOverride) { + this.areaOverride = areaOverride; + } + public ABFloatCallback getRangeOverride() { + return rangeOverride; + } + public void setRangeOverride(ABFloatCallback rangeOverride) { + this.rangeOverride = rangeOverride; + } + public ABFloatCallback getCastTimeOverride() { + return castTimeOverride; + } + public void setCastTimeOverride(ABFloatCallback castTimeOverride) { + this.castTimeOverride = castTimeOverride; + } + public ABFloatCallback getCooldownOverride() { + return cooldownOverride; + } + public void setCooldownOverride(ABFloatCallback cooldownOverride) { + this.cooldownOverride = cooldownOverride; + } + public ABIntegerCallback getManaCostOverride() { + return manaCostOverride; + } + public void setManaCostOverride(ABIntegerCallback manaCostOverride) { + this.manaCostOverride = manaCostOverride; + } + public ABBooleanCallback getIgnoreCastTime() { + return ignoreCastTime; + } + public void setIgnoreCastTime(ABBooleanCallback ignoreCastTime) { + this.ignoreCastTime = ignoreCastTime; + } + public ABAutocastTypeCallback getAutocastTypeOverride() { + return autocastTypeOverride; + } + public void setAutocastTypeOverride(ABAutocastTypeCallback autocastTypeOverride) { + this.autocastTypeOverride = autocastTypeOverride; + } + public ABIDCallback getOnTooltipOverride() { + return onTooltipOverride; + } + public void setOnTooltipOverride(ABIDCallback onTooltipOverride) { + this.onTooltipOverride = onTooltipOverride; + } + public ABIDCallback getOffTooltipOverride() { + return offTooltipOverride; + } + public void setOffTooltipOverride(ABIDCallback offTooltipOverride) { + this.offTooltipOverride = offTooltipOverride; + } + public ABBooleanCallback getPhysicalSpell() { + return physicalSpell; + } + public void setPhysicalSpell(ABBooleanCallback physicalSpell) { + this.physicalSpell = physicalSpell; + } + public ABBooleanCallback getMagicSpell() { + return magicSpell; + } + public void setMagicSpell(ABBooleanCallback magicSpell) { + this.magicSpell = magicSpell; + } + public ABBooleanCallback getUniversalSpell() { + return universalSpell; + } + public void setUniversalSpell(ABBooleanCallback universalSpell) { + this.universalSpell = universalSpell; + } + public ABBooleanCallback getDispel() { + return dispel; + } + public void setDispel(ABBooleanCallback dispel) { + this.dispel = dispel; + } + + public List getExtraTargetsAllowed() { + return extraTargetsAllowed; + } + public void setExtraTargetsAllowed(List extraTargetsAllowed) { + this.extraTargetsAllowed = extraTargetsAllowed; + } + public List getExcludedTargetsAllowed() { + return excludedTargetsAllowed; + } + public void setExcludedTargetsAllowed(List excludedTargetsAllowed) { + this.excludedTargetsAllowed = excludedTargetsAllowed; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderParserTemplateFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderParserTemplateFields.java new file mode 100644 index 000000000..72c6307b6 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderParserTemplateFields.java @@ -0,0 +1,111 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields; + +import java.util.List; +import java.util.Map; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderTemplateType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABMeleeRangeTargetOverride; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABStatBuffFromDataField; + +public class ABAbilityBuilderParserTemplateFields { + //Template only + private ABAbilityBuilderTemplateType templateType; + //Aura template + private List addToAuraActions; + private List updateAuraLevelActions; + private List removeFromAuraActions; + //Simple Aura Template + private Map> abilityIdsToAddPerLevel; + private List levellingAbilityIdsToAdd; + //StatList + private List statBuffsFromDataFields; + private ABMeleeRangeTargetOverride meleeRangeTargetOverride; + + public void updateFromParent(ABAbilityBuilderParserTemplateFields parent) { + if (this.templateType == null) + this.templateType = parent.templateType; + + if (this.addToAuraActions == null) + this.addToAuraActions = parent.addToAuraActions; + if (this.updateAuraLevelActions == null) + this.updateAuraLevelActions = parent.updateAuraLevelActions; + if (this.removeFromAuraActions == null) + this.removeFromAuraActions = parent.removeFromAuraActions; + + if (this.abilityIdsToAddPerLevel == null) + this.abilityIdsToAddPerLevel = parent.abilityIdsToAddPerLevel; + if (this.levellingAbilityIdsToAdd == null) + this.levellingAbilityIdsToAdd = parent.levellingAbilityIdsToAdd; + + if (this.statBuffsFromDataFields == null) + this.statBuffsFromDataFields = parent.statBuffsFromDataFields; + if (this.meleeRangeTargetOverride == null) + this.meleeRangeTargetOverride = parent.meleeRangeTargetOverride; + } + + public ABAbilityBuilderTemplateType getTemplateType() { + return templateType; + } + + public void setTemplateType(ABAbilityBuilderTemplateType templateType) { + this.templateType = templateType; + } + + public List getAddToAuraActions() { + return addToAuraActions; + } + + public void setAddToAuraActions(List addToAuraActions) { + this.addToAuraActions = addToAuraActions; + } + + public List getUpdateAuraLevelActions() { + return updateAuraLevelActions; + } + + public void setUpdateAuraLevelActions(List updateAuraLevelActions) { + this.updateAuraLevelActions = updateAuraLevelActions; + } + + public List getRemoveFromAuraActions() { + return removeFromAuraActions; + } + + public void setRemoveFromAuraActions(List removeFromAuraActions) { + this.removeFromAuraActions = removeFromAuraActions; + } + + public Map> getAbilityIdsToAddPerLevel() { + return abilityIdsToAddPerLevel; + } + + public void setAbilityIdsToAddPerLevel(Map> abilityIdsToAddPerLevel) { + this.abilityIdsToAddPerLevel = abilityIdsToAddPerLevel; + } + + public List getLevellingAbilityIdsToAdd() { + return levellingAbilityIdsToAdd; + } + + public void setLevellingAbilityIdsToAdd(List levellingAbilityIdsToAdd) { + this.levellingAbilityIdsToAdd = levellingAbilityIdsToAdd; + } + + public List getStatBuffsFromDataFields() { + return statBuffsFromDataFields; + } + + public void setStatBuffsFromDataFields(List statBuffsFromDataFields) { + this.statBuffsFromDataFields = statBuffsFromDataFields; + } + + public ABMeleeRangeTargetOverride getMeleeRangeTargetOverride() { + return meleeRangeTargetOverride; + } + + public void setMeleeRangeTargetOverride(ABMeleeRangeTargetOverride meleeRangeTargetOverride) { + this.meleeRangeTargetOverride = meleeRangeTargetOverride; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderSpecialConfigFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderSpecialConfigFields.java new file mode 100644 index 000000000..315484510 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderSpecialConfigFields.java @@ -0,0 +1,246 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.orderid.ABOrderIdCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.CommandStringErrorKeysEnum; + +public class ABAbilityBuilderSpecialConfigFields { + private ABIntegerCallback bufferManaRequired; + private ABIntegerCallback manaDrainedPerSecond; + + private List pointTargeted; + private List targetedSpell; + + private List autoAquireTarget; + + private ABIDCallback pairAbilityId; + private ABIDCallback pairUnitId; + private CommandStringErrorKeysEnum pairUnitTypeError; + private CommandStringErrorKeysEnum cantTargetError; + private CommandStringErrorKeysEnum cantPairError; + private CommandStringErrorKeysEnum cantPairOffError; + private ABFloatCallback pairSearchRadius; + private ABBooleanCallback autoTargetPartner; + private ABIntegerCallback maxPartners; + private ABOrderIdCallback pairingOrderId; + private ABOrderIdCallback pairingOffOrderId; + private ABBooleanCallback orderPairedUnit; + private ABOrderIdCallback orderPairedUnitOrderId; + private ABOrderIdCallback orderPairedUnitOffOrderId; + + private CBehaviorCategory behaviorCategory; + + public void updateFromParent(ABAbilityBuilderSpecialConfigFields parent) { + if (this.bufferManaRequired == null) + this.bufferManaRequired = parent.bufferManaRequired; + if (this.manaDrainedPerSecond == null) + this.manaDrainedPerSecond = parent.manaDrainedPerSecond; + + if (this.pointTargeted == null) + this.pointTargeted = parent.pointTargeted; + if (this.targetedSpell == null) + this.targetedSpell = parent.targetedSpell; + + if (this.autoAquireTarget == null) + this.autoAquireTarget = parent.autoAquireTarget; + + if (this.pairAbilityId == null) + this.pairAbilityId = parent.pairAbilityId; + if (this.pairUnitId == null) + this.pairUnitId = parent.pairUnitId; + if (this.pairUnitTypeError == null) + this.pairUnitTypeError = parent.pairUnitTypeError; + if (this.cantTargetError == null) + this.cantTargetError = parent.cantTargetError; + if (this.cantPairError == null) + this.cantPairError = parent.cantPairError; + if (this.cantPairOffError == null) + this.cantPairOffError = parent.cantPairOffError; + if (this.pairSearchRadius == null) + this.pairSearchRadius = parent.pairSearchRadius; + if (this.autoTargetPartner == null) + this.autoTargetPartner = parent.autoTargetPartner; + if (this.maxPartners == null) + this.maxPartners = parent.maxPartners; + if (this.pairingOrderId == null) + this.pairingOrderId = parent.pairingOrderId; + if (this.pairingOffOrderId == null) + this.pairingOffOrderId = parent.pairingOffOrderId; + if (this.orderPairedUnit == null) + this.orderPairedUnit = parent.orderPairedUnit; + if (this.orderPairedUnitOrderId == null) + this.orderPairedUnitOrderId = parent.orderPairedUnitOrderId; + if (this.orderPairedUnitOffOrderId == null) + this.orderPairedUnitOffOrderId = parent.orderPairedUnitOffOrderId; + + if (this.behaviorCategory == null) + this.behaviorCategory = parent.behaviorCategory; + } + + public ABIntegerCallback getBufferManaRequired() { + return bufferManaRequired; + } + + public void setBufferManaRequired(ABIntegerCallback bufferManaRequired) { + this.bufferManaRequired = bufferManaRequired; + } + + public ABIntegerCallback getManaDrainedPerSecond() { + return manaDrainedPerSecond; + } + + public void setManaDrainedPerSecond(ABIntegerCallback manaDrainedPerSecond) { + this.manaDrainedPerSecond = manaDrainedPerSecond; + } + + public List getPointTargeted() { + return pointTargeted; + } + + public void setPointTargeted(List pointTargeted) { + this.pointTargeted = pointTargeted; + } + + public List getTargetedSpell() { + return targetedSpell; + } + + public void setTargetedSpell(List targetedSpell) { + this.targetedSpell = targetedSpell; + } + + public List getAutoAquireTarget() { + return autoAquireTarget; + } + + public void setAutoAquireTarget(List autoAquireTarget) { + this.autoAquireTarget = autoAquireTarget; + } + + public ABIDCallback getPairAbilityId() { + return pairAbilityId; + } + + public void setPairAbilityId(ABIDCallback pairAbilityId) { + this.pairAbilityId = pairAbilityId; + } + + public ABIDCallback getPairUnitId() { + return pairUnitId; + } + + public void setPairUnitId(ABIDCallback pairUnitId) { + this.pairUnitId = pairUnitId; + } + + public CommandStringErrorKeysEnum getPairUnitTypeError() { + return pairUnitTypeError; + } + + public void setPairUnitTypeError(CommandStringErrorKeysEnum pairUnitTypeError) { + this.pairUnitTypeError = pairUnitTypeError; + } + + public CommandStringErrorKeysEnum getCantTargetError() { + return cantTargetError; + } + + public void setCantTargetError(CommandStringErrorKeysEnum cantTargetError) { + this.cantTargetError = cantTargetError; + } + + public CommandStringErrorKeysEnum getCantPairError() { + return cantPairError; + } + + public void setCantPairError(CommandStringErrorKeysEnum cantPairError) { + this.cantPairError = cantPairError; + } + + public CommandStringErrorKeysEnum getCantPairOffError() { + return cantPairOffError; + } + + public void setCantPairOffError(CommandStringErrorKeysEnum cantPairOffError) { + this.cantPairOffError = cantPairOffError; + } + + public ABFloatCallback getPairSearchRadius() { + return pairSearchRadius; + } + + public void setPairSearchRadius(ABFloatCallback pairSearchRadius) { + this.pairSearchRadius = pairSearchRadius; + } + + public ABBooleanCallback getAutoTargetPartner() { + return autoTargetPartner; + } + + public void setAutoTargetPartner(ABBooleanCallback autoTargetPartner) { + this.autoTargetPartner = autoTargetPartner; + } + + public ABIntegerCallback getMaxPartners() { + return maxPartners; + } + + public void setMaxPartners(ABIntegerCallback maxPartners) { + this.maxPartners = maxPartners; + } + + public ABOrderIdCallback getPairingOrderId() { + return pairingOrderId; + } + + public void setPairingOrderId(ABOrderIdCallback pairingOrderId) { + this.pairingOrderId = pairingOrderId; + } + + public ABOrderIdCallback getPairingOffOrderId() { + return pairingOffOrderId; + } + + public void setPairingOffOrderId(ABOrderIdCallback pairingOffOrderId) { + this.pairingOffOrderId = pairingOffOrderId; + } + + public ABBooleanCallback getOrderPairedUnit() { + return orderPairedUnit; + } + + public void setOrderPairedUnit(ABBooleanCallback orderPairedUnit) { + this.orderPairedUnit = orderPairedUnit; + } + + public ABOrderIdCallback getOrderPairedUnitOrderId() { + return orderPairedUnitOrderId; + } + + public void setOrderPairedUnitOrderId(ABOrderIdCallback orderPairedUnitOrderId) { + this.orderPairedUnitOrderId = orderPairedUnitOrderId; + } + + public ABOrderIdCallback getOrderPairedUnitOffOrderId() { + return orderPairedUnitOffOrderId; + } + + public void setOrderPairedUnitOffOrderId(ABOrderIdCallback orderPairedUnitOffOrderId) { + this.orderPairedUnitOffOrderId = orderPairedUnitOffOrderId; + } + + public CBehaviorCategory getBehaviorCategory() { + return behaviorCategory; + } + + public void setBehaviorCategory(CBehaviorCategory behaviorCategory) { + this.behaviorCategory = behaviorCategory; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderSpecialDisplayFields.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderSpecialDisplayFields.java new file mode 100644 index 000000000..07f39222c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/subfields/ABAbilityBuilderSpecialDisplayFields.java @@ -0,0 +1,145 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.subfields; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.floats.ABFloatCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.id.ABIDCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.callback.integers.ABIntegerCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; + +public class ABAbilityBuilderSpecialDisplayFields { + + private ABBooleanCallback showOnAndOffIcons; + + private ABIntegerCallback foodCost; + private ABIntegerCallback goldCost; + private ABIntegerCallback lumberCost; + + private ABBooleanCallback hideAreaCursor; + private ABFloatCallback areaCursorOverride; + private ABBooleanCallback instantCast; + private ABBooleanCallback castlessNoTarget; + + private ABBooleanCallback toggleable; + private ABBooleanCallback castToggleOff; + private ABBooleanCallback separateOnAndOff; + private ABIDCallback alternateUnitId; + + private ABBooleanCallback isMenu; + private ABIntegerCallback menuId; + + public void updateFromParent(ABAbilityBuilderSpecialDisplayFields parent) { + if (this.showOnAndOffIcons == null) + this.showOnAndOffIcons = parent.showOnAndOffIcons; + + if (this.foodCost == null) + this.foodCost = parent.foodCost; + if (this.goldCost == null) + this.goldCost = parent.goldCost; + if (this.lumberCost == null) + this.lumberCost = parent.lumberCost; + + if (this.hideAreaCursor == null) + this.hideAreaCursor = parent.hideAreaCursor; + if (this.areaCursorOverride == null) + this.areaCursorOverride = parent.areaCursorOverride; + if (this.instantCast == null) + this.instantCast = parent.instantCast; + if (this.castlessNoTarget == null) + this.castlessNoTarget = parent.castlessNoTarget; + + if (this.toggleable == null) + this.toggleable = parent.toggleable; + if (this.castToggleOff == null) + this.castToggleOff = parent.castToggleOff; + if (this.separateOnAndOff == null) + this.separateOnAndOff = parent.separateOnAndOff; + if (this.alternateUnitId == null) + this.alternateUnitId = parent.alternateUnitId; + } + + public ABBooleanCallback getShowOnAndOffIcons() { + return showOnAndOffIcons; + } + public void setShowOnAndOffIcons(ABBooleanCallback showOnAndOffIcons) { + this.showOnAndOffIcons = showOnAndOffIcons; + } + public ABIntegerCallback getFoodCost() { + return foodCost; + } + public void setFoodCost(ABIntegerCallback foodCost) { + this.foodCost = foodCost; + } + public ABIntegerCallback getGoldCost() { + return goldCost; + } + public void setGoldCost(ABIntegerCallback goldCost) { + this.goldCost = goldCost; + } + public ABIntegerCallback getLumberCost() { + return lumberCost; + } + public void setLumberCost(ABIntegerCallback lumberCost) { + this.lumberCost = lumberCost; + } + public ABBooleanCallback getHideAreaCursor() { + return hideAreaCursor; + } + public void setHideAreaCursor(ABBooleanCallback hideAreaCursor) { + this.hideAreaCursor = hideAreaCursor; + } + public ABFloatCallback getAreaCursorOverride() { + return areaCursorOverride; + } + public void setAreaCursorOverride(ABFloatCallback areaCursorOverride) { + this.areaCursorOverride = areaCursorOverride; + } + public ABBooleanCallback getInstantCast() { + return instantCast; + } + public void setInstantCast(ABBooleanCallback instantCast) { + this.instantCast = instantCast; + } + public ABBooleanCallback getCastlessNoTarget() { + return castlessNoTarget; + } + public void setCastlessNoTarget(ABBooleanCallback castlessNoTarget) { + this.castlessNoTarget = castlessNoTarget; + } + public ABBooleanCallback getToggleable() { + return toggleable; + } + public void setToggleable(ABBooleanCallback toggleable) { + this.toggleable = toggleable; + } + public ABBooleanCallback getCastToggleOff() { + return castToggleOff; + } + public void setCastToggleOff(ABBooleanCallback castToggleOff) { + this.castToggleOff = castToggleOff; + } + public ABBooleanCallback getSeparateOnAndOff() { + return separateOnAndOff; + } + public void setSeparateOnAndOff(ABBooleanCallback separateOnAndOff) { + this.separateOnAndOff = separateOnAndOff; + } + public ABIDCallback getAlternateUnitId() { + return alternateUnitId; + } + public void setAlternateUnitId(ABIDCallback alternateUnitId) { + this.alternateUnitId = alternateUnitId; + } + + public ABBooleanCallback getIsMenu() { + return this.isMenu; + } + public void setIsMenu(ABBooleanCallback isMenu) { + this.isMenu = isMenu; + } + public ABIntegerCallback getMenuId() { + return this.menuId; + } + public void setMenuId(ABIntegerCallback menuId) { + this.menuId = menuId; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABDataFieldLetter.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABDataFieldLetter.java new file mode 100644 index 000000000..43e2d1a48 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABDataFieldLetter.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template; + +import com.etheller.interpreter.ast.util.CHandle; + +public enum ABDataFieldLetter implements CHandle { + A(0), + B(1), + C(2), + D(3), + E(4), + F(5), + G(6), + H(7), + I(8), + J(9); + + private int index; + + ABDataFieldLetter(int index) { + this.index = index; + } + + public int getIndex() { + return index; + } + + @Override + public int getHandleId() { + return ordinal(); + } + + public static final ABDataFieldLetter[] VALUES = values(); +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABMeleeRangeTargetOverride.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABMeleeRangeTargetOverride.java new file mode 100644 index 000000000..8c32fd2ae --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABMeleeRangeTargetOverride.java @@ -0,0 +1,18 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template; + +public class ABMeleeRangeTargetOverride { + private boolean targetMelee; + private boolean targetRange; + public boolean isTargetMelee() { + return targetMelee; + } + public void setTargetMelee(boolean targetMelee) { + this.targetMelee = targetMelee; + } + public boolean isTargetRange() { + return targetRange; + } + public void setTargetRange(boolean targetRange) { + this.targetRange = targetRange; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABStatBuffFromDataField.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABStatBuffFromDataField.java new file mode 100644 index 000000000..a36fa379c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABStatBuffFromDataField.java @@ -0,0 +1,121 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; + +public class ABStatBuffFromDataField { + private ABStatBuffType type; + private ABDataFieldLetter percentageBooleanField; + private ABDataFieldLetter flatBooleanField; + private ABDataFieldLetter dataField; + private Boolean percentageOverride; + private ABDataFieldLetter targetMeleeField; + private ABDataFieldLetter targetRangeField; + + private transient NonStackingStatBuff buff; + private transient NonStackingStatBuff secondAtkBuff; + + public ABStatBuffFromDataField(ABStatBuffFromDataField statBuff) { + this.type = statBuff.getType(); + this.percentageBooleanField = statBuff.getPercentageBooleanField(); + this.flatBooleanField = statBuff.getFlatBooleanField(); + this.dataField = statBuff.getDataField(); + this.percentageOverride = statBuff.isPercentageOverride(); + this.targetMeleeField = statBuff.getTargetMeleeField(); + this.targetRangeField = statBuff.getTargetRangeField(); + } + public ABStatBuffType getType() { + return type; + } + public void setType(ABStatBuffType type) { + this.type = type; + } + public ABDataFieldLetter getPercentageBooleanField() { + return percentageBooleanField; + } + public void setPercentageBooleanField(ABDataFieldLetter percentageBooleanField) { + this.percentageBooleanField = percentageBooleanField; + } + public ABDataFieldLetter getFlatBooleanField() { + return flatBooleanField; + } + public void setFlatBooleanField(ABDataFieldLetter flatBooleanField) { + this.flatBooleanField = flatBooleanField; + } + public ABDataFieldLetter getDataField() { + return dataField; + } + public void setDataField(ABDataFieldLetter dataField) { + this.dataField = dataField; + } + public Boolean isPercentageOverride() { + return percentageOverride; + } + public void setPercentageOverride(Boolean percentageOverride) { + this.percentageOverride = percentageOverride; + } + public ABDataFieldLetter getTargetMeleeField() { + return targetMeleeField; + } + public void setTargetMeleeField(ABDataFieldLetter targetMeleeField) { + this.targetMeleeField = targetMeleeField; + } + public ABDataFieldLetter getTargetRangeField() { + return targetRangeField; + } + public void setTargetRangeField(ABDataFieldLetter targetRangeField) { + this.targetRangeField = targetRangeField; + } + public NonStackingStatBuff getBuff() { + return buff; + } + public void setBuff(NonStackingStatBuff buff) { + this.buff = buff; + } + public NonStackingStatBuff getSecondAtkBuff() { + return secondAtkBuff; + } + public void setSecondAtkBuff(NonStackingStatBuff secondAtkBuff) { + this.secondAtkBuff = secondAtkBuff; + } + + public NonStackingStatBuffType convertToNonStackingType(ABAbilityBuilderAbilityTypeLevelData abilityData) { + boolean percentage = false; + if (this.isPercentageOverride() != null) { + percentage = this.isPercentageOverride(); + } else { + if (this.getPercentageBooleanField() != null) { + try { + percentage = Integer.parseInt(abilityData.getData() + .get(this.getPercentageBooleanField().getIndex())) == 1; + } catch (NumberFormatException exc) { + percentage = false; + } + } else if (this.getFlatBooleanField() != null) { + try { + percentage = !(Integer.parseInt( + abilityData.getData().get(this.getFlatBooleanField().getIndex())) == 1); + } catch (NumberFormatException exc) { + percentage = true; + } + } + } + if (this.getType() == ABStatBuffType.ATK) { + boolean targetMelee = false; + boolean targetRange = false; + if (this.getTargetMeleeField() != null) { + targetMelee = Integer.parseInt( + abilityData.getData().get(this.getTargetMeleeField().getIndex())) == 1; + } + if (this.getTargetRangeField() != null) { + targetRange = Integer.parseInt( + abilityData.getData().get(this.getTargetRangeField().getIndex())) == 1; + } + + return this.getType().toAtkNonStackingStatBuffType(percentage, targetMelee, targetRange); + } else { + return this.getType().toNonStackingStatBuffType(percentage); + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABStatBuffType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABStatBuffType.java new file mode 100644 index 000000000..6e934f1c4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/parser/template/ABStatBuffType.java @@ -0,0 +1,135 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; + +public enum ABStatBuffType { + ATK, + ATKSPD, + DEF, + HPGEN, + MAXHPGEN, + MPGEN, + MAXMPGEN, + MVSPD, + HPSTEAL, + THORNS, + MAXHP, + MAXMP, + STR, + AGI, + INT; + + + public NonStackingStatBuffType toNonStackingStatBuffType(boolean percentage) { + switch(this) { + case DEF: + if (percentage) { + return NonStackingStatBuffType.DEFPCT; + } else { + return NonStackingStatBuffType.DEF; + } + case HPGEN: + if (percentage) { + return NonStackingStatBuffType.HPGENPCT; + } else { + return NonStackingStatBuffType.HPGEN; + } + case MAXHPGEN: + if (percentage) { + return NonStackingStatBuffType.MAXHPGENPCT; + } else { + return NonStackingStatBuffType.HPGEN; + } + case MAXMPGEN: + if (percentage) { + return NonStackingStatBuffType.MAXMPGENPCT; + } else { + return NonStackingStatBuffType.MPGEN; + } + case MPGEN: + if (percentage) { + return NonStackingStatBuffType.MPGENPCT; + } else { + return NonStackingStatBuffType.MPGEN; + } + case MAXHP: + if (percentage) { + return NonStackingStatBuffType.MAXHPPCT; + } else { + return NonStackingStatBuffType.MAXHP; + } + case MAXMP: + if (percentage) { + return NonStackingStatBuffType.MAXMPPCT; + } else { + return NonStackingStatBuffType.MAXMP; + } + case MVSPD: + if (percentage) { + return NonStackingStatBuffType.MVSPDPCT; + } else { + return NonStackingStatBuffType.MVSPD; + } + case THORNS: + if (percentage) { + return NonStackingStatBuffType.THORNSPCT; + } else { + return NonStackingStatBuffType.THORNS; + } + case STR: + if (percentage) { + return NonStackingStatBuffType.STRPCT; + } else { + return NonStackingStatBuffType.STR; + } + case AGI: + if (percentage) { + return NonStackingStatBuffType.AGIPCT; + } else { + return NonStackingStatBuffType.AGI; + } + case INT: + if (percentage) { + return NonStackingStatBuffType.INTPCT; + } else { + return NonStackingStatBuffType.INT; + } + case ATKSPD: + return NonStackingStatBuffType.ATKSPD; + case HPSTEAL: + return NonStackingStatBuffType.HPSTEAL; + case ATK: + default: + System.err.println("ERROR: Tried to convert Attack buff type with wrong function"); + return null; + } + } + + public NonStackingStatBuffType toAtkNonStackingStatBuffType(boolean percentage, boolean melee, boolean range) { + switch(this) { + case ATK: + if (percentage) { + if (melee && range) { + return NonStackingStatBuffType.ALLATKPCT; + } else if (melee) { + return NonStackingStatBuffType.MELEEATKPCT; + } else if (range) { + return NonStackingStatBuffType.RNGDATKPCT; + } + } else { + if (melee && range) { + return NonStackingStatBuffType.ALLATK; + } else if (melee) { + return NonStackingStatBuffType.MELEEATK; + } else if (range) { + return NonStackingStatBuffType.RNGDATK; + } + } + System.err.println("ERROR: Tried to convert Attack buff with both melee and range set to false"); + return null; + default: + System.err.println("ERROR: Tried to convert non-Attack buff type with wrong function"); + return null; + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/projectile/ABCollisionProjectileListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/projectile/ABCollisionProjectileListener.java new file mode 100644 index 000000000..743760a03 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/projectile/ABCollisionProjectileListener.java @@ -0,0 +1,114 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityCollisionProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABCollisionProjectileListener implements CAbilityCollisionProjectileListener { + + private List onLaunch; + private List onPreHits; + private List canHitTarget; + private List onHit; + + private CUnit caster; + private ABLocalDataStore localStore; + private int castId; + + public ABCollisionProjectileListener(List onLaunch, List onPreHits, + List canHitTarget, List onHit, CUnit caster, ABLocalDataStore localStore, + int castId) { + super(); + this.onLaunch = onLaunch; + this.onPreHits = onPreHits; + this.canHitTarget = canHitTarget; + this.onHit = onHit; + this.caster = caster; + this.localStore = localStore; + this.castId = castId; + } + + @Override + public void onLaunch(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onLaunch != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), projectile); + for (ABAction action : onLaunch) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + } + } + + @Override + public void onPreHits(CSimulation game, CProjectile projectile, AbilityPointTarget loc) { + if (onPreHits != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), projectile); + for (ABAction action : onPreHits) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + } + } + + @Override + public boolean canHitTarget(CSimulation game, CWidget target) { + boolean result = true; + if (canHitTarget != null) { + CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId), targetUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId), targetDest); + for (ABBooleanCallback condition : canHitTarget) { + result = result && condition.callback(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId)); + } + return result; + } + + @Override + public void onHit(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onHit != null) { + CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), projectile); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId), targetUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId), targetDest); + for (ABAction action : onHit) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + } + } + + @Override + public void setUnitTargets(int units) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEUNITTARGETS, castId), units); + } + + @Override + public void setDestructableTargets(int dests) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEDESTTARGETS, castId), dests); + } + + @Override + public void setCurrentLocation(AbilityPointTarget loc) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId), loc); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/projectile/ABProjectileListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/projectile/ABProjectileListener.java new file mode 100644 index 000000000..11fc78df3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/projectile/ABProjectileListener.java @@ -0,0 +1,67 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.projectile; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; + +public class ABProjectileListener implements CAbilityProjectileListener { + + private List onLaunch; + private List onHit; + + private CUnit caster; + private ABLocalDataStore localStore; + private int castId; + + public ABProjectileListener(List onLaunch, List onHit, CUnit caster, + ABLocalDataStore localStore, int castId) { + super(); + this.onLaunch = onLaunch; + this.onHit = onHit; + this.caster = caster; + this.localStore = localStore; + this.castId = castId; + } + + @Override + public void onLaunch(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onLaunch != null) { + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), projectile); + for (ABAction action : onLaunch) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + } + } + + @Override + public void onHit(CSimulation game, CProjectile projectile, AbilityTarget target) { + if (onHit != null) { + CUnit targetUnit = target.visit(AbilityTargetVisitor.UNIT); + CDestructable targetDest = target.visit(AbilityTargetVisitor.DESTRUCTABLE); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId), projectile); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId), targetUnit); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId), targetDest); + localStore.put(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId), + new AbilityPointTarget(projectile.getX(), projectile.getY())); + for (ABAction action : onHit) { + action.runAction(caster, localStore, castId); + } + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITUNIT, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILEHITDEST, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.THISPROJECTILE, castId)); + localStore.remove(ABLocalStoreKeys.combineKey(ABLocalStoreKeys.PROJECTILECURRENTLOC, castId)); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABAltitudeAdjustmentTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABAltitudeAdjustmentTimer.java new file mode 100644 index 000000000..0bc12f2f5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABAltitudeAdjustmentTimer.java @@ -0,0 +1,47 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer; + +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABAltitudeAdjustmentTimer extends CTimer { + private CUnit unit; + private float heightInc; + private int durTicks; + private int endTick = 0; + + public ABAltitudeAdjustmentTimer(CUnit unit, float targetHeight, float duration) { + super(); + this.unit = unit; + durTicks = Math.round(duration / WarsmashConstants.SIMULATION_STEP_TIME); + if (durTicks == 0) { + durTicks = 1; + } + this.heightInc = (targetHeight - unit.getFlyHeight()) / durTicks; + if (durTicks > 1) { + this.setRepeats(true); + } + this.setTimeoutTime(0f); + } + + @Override + public void start(CSimulation game) { + if (endTick == 0) { + this.endTick = game.getGameTurnTick() + durTicks - 1; + } + super.start(game); + } + + public void onFire(CSimulation game) { + if (this.unit.isDead()) { + this.setRepeats(false); + return; + } + this.unit.setFlyHeight(this.unit.getFlyHeight() + this.heightInc); + if (game.getGameTurnTick() >= endTick) { + this.setRepeats(false); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABDelayInstantTransformationTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABDelayInstantTransformationTimer.java new file mode 100644 index 000000000..adbed42cd --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABDelayInstantTransformationTimer.java @@ -0,0 +1,58 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABDelayInstantTransformationTimer extends CTimer { + private CUnit sourceUnit; + private ABLocalDataStore localStore; + private OnTransformationActions actions; + private CUnit unit; + private boolean addAlternateTagAfter; + private CUnitType baseType; + private CUnitType targetType; + private boolean keepRatios; + private ABAbilityBuilderAbility abil; + private boolean perm; + private War3ID theBuffId; + private float transTime; + private float dur; + + public ABDelayInstantTransformationTimer(CUnit sourceUnit, ABLocalDataStore localStore, CUnit unit, + OnTransformationActions actions, boolean addAlternateTagAfter, float delay, CUnitType baseType, + CUnitType targetType, final boolean keepRatios, ABAbilityBuilderAbility ability, War3ID buffId, + float transformationTime, float duration) { + super(); + this.sourceUnit = sourceUnit; + this.localStore = localStore; + this.unit = unit; + this.actions = actions; + this.addAlternateTagAfter = addAlternateTagAfter; + this.baseType = baseType; + this.targetType = targetType; + this.keepRatios = keepRatios; + this.abil = ability; + this.theBuffId = buffId; + this.transTime = transformationTime; + this.dur = duration; + this.setRepeats(false); + this.setTimeoutTime(delay); + } + + public void onFire(CSimulation game) { + ABTransformationHandler.instantTransformation(localStore, unit, targetType, keepRatios, actions, abil, + addAlternateTagAfter, perm, false); + if (dur > 0) { + ABTransformationHandler.createInstantTransformBackBuff(sourceUnit, localStore, unit, baseType, keepRatios, + actions.createUntransformActions(), abil, theBuffId, addAlternateTagAfter, transTime, dur, perm); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABDelayTimerTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABDelayTimerTimer.java new file mode 100644 index 000000000..5d8f855e4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABDelayTimerTimer.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABDelayTimerTimer extends CTimer { + + private CTimer timer; + ABLocalDataStore localStore; + + public ABDelayTimerTimer(CTimer timer, ABLocalDataStore localStore, float delay) { + super(); + this.timer = timer; + this.localStore = localStore; + this.setRepeats(false); + this.setTimeoutTime(delay); + } + + public void onFire(CSimulation game) { + localStore.put(ABLocalStoreKeys.ACTIVE_ALTITUDE_ADJUSTMENT, timer); + timer.start(game); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABManaDepletedCheckTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABManaDepletedCheckTimer.java new file mode 100644 index 000000000..6693686a9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABManaDepletedCheckTimer.java @@ -0,0 +1,26 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABManaDepletedCheckTimer extends CTimer { + private CUnit caster; + private ABAbilityBuilderActiveAbility ability; + + public ABManaDepletedCheckTimer(CUnit caster, ABAbilityBuilderActiveAbility ability) { + super(); + this.caster = caster; + this.ability = ability; + this.setRepeats(true); + this.setTimeoutTime(0f); + } + + public void onFire(CSimulation game) { + if(caster.getMana() <= 0) { + ability.deactivate(game, caster); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABTimer.java new file mode 100644 index 000000000..89ea9219f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABTimer.java @@ -0,0 +1,49 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer; + +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABTimer extends CTimer { + private CUnit caster; + private ABLocalDataStore localStore; + private List actions; + + private int castId = 0; + private boolean alive = true; + + public ABTimer(CUnit caster, ABLocalDataStore localStore, List actions, final int castId) { + super(); + this.caster = caster; + this.localStore = localStore; + this.actions = actions; + this.castId = castId; + } + + public void kill(CSimulation simulation) { + simulation.unregisterTimer(this); + this.alive = false; + this.caster = null; + this.localStore = null; + this.actions = null; + } + + public void onFire(CSimulation simulation) { + if (alive) { + localStore.put(ABLocalStoreKeys.FIRINGTIMER, this); + if (actions != null) { + for (ABAction action : actions) { + action.runAction(caster, localStore, castId); + } + } + if (localStore != null) + localStore.remove(ABLocalStoreKeys.FIRINGTIMER); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABTransformationMorphAnimationTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABTransformationMorphAnimationTimer.java new file mode 100644 index 000000000..d70bc24a9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/timer/ABTransformationMorphAnimationTimer.java @@ -0,0 +1,43 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.timer; + +import java.util.EnumSet; + +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.timers.CTimer; + +public class ABTransformationMorphAnimationTimer extends CTimer { + private final CUnit unit; + private final boolean addAlternateTagAfter; + + public ABTransformationMorphAnimationTimer(final CUnit unit, final boolean addAlternateTagAfter, final float delay) { + super(); + this.unit = unit; + this.addAlternateTagAfter = addAlternateTagAfter; + this.setRepeats(false); + this.setTimeoutTime(delay); + } + + @Override + public void onFire(final CSimulation game) { + if (this.addAlternateTagAfter) { + this.unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); + this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, SequenceUtils.EMPTY, 1.0f, + true); + } else { + this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.MORPH, + EnumSet.of(SecondaryTag.ALTERNATE), 1.0f, true); + } + this.unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, + this.addAlternateTagAfter ? EnumSet.of(SecondaryTag.ALTERNATE) : SequenceUtils.EMPTY, true); + if (this.addAlternateTagAfter) { + this.unit.getUnitAnimationListener().addSecondaryTag(SecondaryTag.ALTERNATE); + } else { + this.unit.getUnitAnimationListener().removeSecondaryTag(SecondaryTag.ALTERNATE); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/definitions/impl/ABAbilityBuilderTemplateTypeDefinition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/definitions/impl/ABAbilityBuilderTemplateTypeDefinition.java new file mode 100644 index 000000000..41134b414 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/definitions/impl/ABAbilityBuilderTemplateTypeDefinition.java @@ -0,0 +1,104 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.definitions.impl; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.CAbilityTypeDefinition; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParser; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderTemplateType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.data.CUnitData; + +public class ABAbilityBuilderTemplateTypeDefinition + extends AbstractCAbilityTypeDefinition implements CAbilityTypeDefinition { + + private ABAbilityBuilderParser parser; + + public ABAbilityBuilderTemplateTypeDefinition(ABAbilityBuilderParser abilityBuilderParser) { + super(); + this.parser = abilityBuilderParser; + } + + @Override + public CAbilityType createAbilityType(final War3ID alias, final GameObject abilityEditorData) { + if (abilityEditorData != null) { + final int levels = abilityEditorData.getFieldAsInteger(LEVELS, 0); + final List levelData = new ArrayList<>(); + for (int level = 1; level <= levels; level++) { + levelData.add(createLevelData(abilityEditorData, level)); + } + return innerCreateAbilityType(alias, abilityEditorData, levelData); + } else { + return innerCreateAbilityType(alias, null, null); + } + } + + @Override + protected ABAbilityBuilderAbilityTypeLevelData createLevelData(final GameObject abilityEditorData, + final int level) { + final String targetsAllowedAtLevelString = abilityEditorData.readSLKTag(TARGETS_ALLOWED+level); + final float area = abilityEditorData.readSLKTagFloat(AREA+level); + final float castRange = abilityEditorData.readSLKTagFloat(CAST_RANGE+level); + final float castTime = abilityEditorData.readSLKTagFloat(CASTING_TIME+level); + final float cooldown = abilityEditorData.readSLKTagFloat(COOLDOWN+level); + final float durationHero = abilityEditorData.readSLKTagFloat(HERO_DURATION+level); + final float durationNormal = abilityEditorData.readSLKTagFloat(DURATION+level); + final String[] buffStrings = abilityEditorData.readSLKTag(BUFF+level).split(","); + final String[] effectStrings = abilityEditorData.readSLKTag(EFFECT+level).split(","); + final String unitIdStr = abilityEditorData.readSLKTag(UNIT_ID+level); + War3ID unitId = War3ID.NONE; + if (unitIdStr != null && !unitIdStr.isEmpty()) { + unitId = War3ID.fromString(unitIdStr); + } + + final List data = new ArrayList<>(); + List buffs = new ArrayList<>(); + List effects = new ArrayList<>(); + for (String buff : buffStrings) { + if (buff != null && !buff.isEmpty()) { + buffs.add(War3ID.fromString(buff)); + } + } + for (String effect : effectStrings) { + if (effect != null && !effect.isEmpty()) { + effects.add(War3ID.fromString(effect)); + } + } + String[] letters = { "A", "B", "C", "D", "E", "F", "G", "H", "I" }; + for (String letter : letters) { + data.add(abilityEditorData.readSLKTag("Data" + letter + level)); + } + final int manaCost = abilityEditorData.readSLKTagInt(MANA_COST+level); + final EnumSet targetsAllowedAtLevel = CTargetType.parseTargetTypeSet(targetsAllowedAtLevelString); + + int checkDeps = abilityEditorData.readSLKTagInt(CHECK_DEPENDENCIES); + List requirements = null; + if (checkDeps > 0) { + final List requirementsString = abilityEditorData.getFieldAsList(REQUIREMENTS); + final List requirementsLevelsString = abilityEditorData.getFieldAsList(REQUIREMENT_LEVELS); + requirements = CUnitData.parseRequirements(requirementsString, + requirementsLevelsString); + } + + return new ABAbilityBuilderAbilityTypeLevelData(targetsAllowedAtLevel, area, castRange, castTime, cooldown, + durationHero, durationNormal, buffs, effects, manaCost, data, unitId, requirements); + } + + @Override + protected CAbilityType innerCreateAbilityType(final War3ID alias, final GameObject abilityEditorData, + final List levelData) { + if (abilityEditorData != null) { + return new ABAbilityBuilderTemplateType(alias, abilityEditorData.getFieldAsWar3ID(CODE, -1), abilityEditorData, levelData, parser); + } else { + return new ABAbilityBuilderTemplateType(alias, alias, null, null, parser); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/definitions/impl/ABAbilityBuilderTypeDefinition.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/definitions/impl/ABAbilityBuilderTypeDefinition.java new file mode 100644 index 000000000..b6f8cb100 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/definitions/impl/ABAbilityBuilderTypeDefinition.java @@ -0,0 +1,104 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.definitions.impl; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.CAbilityTypeDefinition; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbstractCAbilityTypeDefinition; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl.ABAbilityBuilderAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.data.CUnitData; + +public class ABAbilityBuilderTypeDefinition + extends AbstractCAbilityTypeDefinition implements CAbilityTypeDefinition { + + private ABAbilityBuilderConfiguration parser; + + public ABAbilityBuilderTypeDefinition(ABAbilityBuilderConfiguration abilityBuilderParser) { + super(); + this.parser = abilityBuilderParser; + } + + @Override + public CAbilityType createAbilityType(final War3ID alias, final GameObject abilityEditorData) { + if (abilityEditorData != null) { + final int levels = abilityEditorData.getFieldAsInteger(LEVELS, 0); + final List levelData = new ArrayList<>(); + for (int level = 1; level <= levels; level++) { + levelData.add(createLevelData(abilityEditorData, level)); + } + return innerCreateAbilityType(alias, abilityEditorData, levelData); + } else { + return innerCreateAbilityType(alias, null, null); + } + } + + @Override + protected ABAbilityBuilderAbilityTypeLevelData createLevelData(final GameObject abilityEditorData, + final int level) { + final String targetsAllowedAtLevelString = abilityEditorData.readSLKTag(TARGETS_ALLOWED+level); + final float area = abilityEditorData.readSLKTagFloat(AREA+level); + final float castRange = abilityEditorData.readSLKTagFloat(CAST_RANGE+level); + final float castTime = abilityEditorData.readSLKTagFloat(CASTING_TIME+level); + final float cooldown = abilityEditorData.readSLKTagFloat(COOLDOWN+level); + final float durationHero = abilityEditorData.readSLKTagFloat(HERO_DURATION+level); + final float durationNormal = abilityEditorData.readSLKTagFloat(DURATION+level); + final String[] buffStrings = abilityEditorData.readSLKTag(BUFF+level).split(","); + final String[] effectStrings = abilityEditorData.readSLKTag(EFFECT+level).split(","); + final String unitIdStr = abilityEditorData.readSLKTag(UNIT_ID+level); + War3ID unitId = War3ID.NONE; + if (unitIdStr != null && !unitIdStr.isEmpty() && unitIdStr.length() == 4) { + unitId = War3ID.fromString(unitIdStr); + } + + final List data = new ArrayList<>(); + List buffs = new ArrayList<>(); + List effects = new ArrayList<>(); + for (String buff : buffStrings) { + if (buff != null && !buff.isEmpty()) { + buffs.add(War3ID.fromString(buff)); + } + } + for (String effect : effectStrings) { + if (effect != null && !effect.isEmpty()) { + effects.add(War3ID.fromString(effect)); + } + } + String[] letters = { "A", "B", "C", "D", "E", "F", "G", "H", "I" }; + for (String letter : letters) { + data.add(abilityEditorData.readSLKTag("Data" + letter + level)); + } + final int manaCost = abilityEditorData.readSLKTagInt(MANA_COST+level); + final EnumSet targetsAllowedAtLevel = CTargetType.parseTargetTypeSet(targetsAllowedAtLevelString); + + int checkDeps = abilityEditorData.readSLKTagInt(CHECK_DEPENDENCIES); + List requirements = null; + if (checkDeps > 0) { + final List requirementsString = abilityEditorData.getFieldAsList(REQUIREMENTS); + final List requirementsLevelsString = abilityEditorData.getFieldAsList(REQUIREMENT_LEVELS); + requirements = CUnitData.parseRequirements(requirementsString, + requirementsLevelsString); + } + + return new ABAbilityBuilderAbilityTypeLevelData(targetsAllowedAtLevel, area, castRange, castTime, cooldown, + durationHero, durationNormal, buffs, effects, manaCost, data, unitId, requirements); + } + + @Override + protected CAbilityType innerCreateAbilityType(final War3ID alias, final GameObject abilityEditorData, + final List levelData) { + if (abilityEditorData != null) { + return new ABAbilityBuilderAbilityType(alias, abilityEditorData.getFieldAsWar3ID(CODE, -1), abilityEditorData, levelData, parser); + } else { + return new ABAbilityBuilderAbilityType(alias, alias, null, null, parser); + } + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderAbilityType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderAbilityType.java new file mode 100644 index 000000000..9be950e20 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderAbilityType.java @@ -0,0 +1,69 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl; + +import java.util.List; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.skills.CAbilitySpell; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABMapLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; + +public class ABAbilityBuilderAbilityType extends CAbilityType { + + private ABAbilityBuilderConfiguration parser; + private GameObject abilityEditorData; + + public ABAbilityBuilderAbilityType(War3ID alias, War3ID code, GameObject abilityEditorData, List levelData, ABAbilityBuilderConfiguration parser) { + super(alias, code, levelData); + this.parser = parser; + this.abilityEditorData = abilityEditorData; + } + + @Override + public CAbility createAbility(int handleId) { + ABLocalDataStore localStore = new ABMapLocalDataStore(); + localStore.put(ABLocalStoreKeys.ABILITYEDITORDATA, this.abilityEditorData); + localStore.put(ABLocalStoreKeys.LEVELDATA, getLevelData()); + localStore.put(ABLocalStoreKeys.ALIAS, getAlias()); + localStore.put(ABLocalStoreKeys.CODE, getCode()); + + switch (parser.getType()) { + case PASSIVE: + return new ABAbilityBuilderPassive(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + case HIDDEN: + return new ABAbilityBuilderNoIcon(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + case NORMAL_FLEXTARGET: + return new ABAbilityBuilderActiveFlexTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + case NORMAL_PAIRING: + return new ABAbilityBuilderActivePairing(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + case NORMAL_AUTOTARGET: + return new ABAbilityBuilderActiveAutoTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + case NORMAL_NOTARGET: + return new ABAbilityBuilderActiveNoTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + case NORMAL_POINTTARGET: + return new ABAbilityBuilderActivePointTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + case NORMAL_UNITTARGET: + default: + return new ABAbilityBuilderActiveUnitTarget(handleId, getCode(), getAlias(), getLevelData(), parser, localStore); + } + } + + public void setLevel(CSimulation game, CUnit unit, CAbilitySpell existingAbility, int level) { + existingAbility.setLevel(game, unit, level); + existingAbility.populate(abilityEditorData, level); + } + + @Override + public void setLevel(CSimulation game, CUnit unit, CLevelingAbility existingAbility, int level) { + existingAbility.setLevel(game, unit, level); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderAbilityTypeLevelData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderAbilityTypeLevelData.java new file mode 100644 index 000000000..dd8c4aa5c --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderAbilityTypeLevelData.java @@ -0,0 +1,101 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl; + +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitTypeRequirement; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityTypeLevelData; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; + +public class ABAbilityBuilderAbilityTypeLevelData extends CAbilityTypeLevelData { + private final float area; + private final float castRange; + private final float castTime; + private final float cooldown; + private final float durationHero; + private final float durationNormal; + private final List buffs; + private final List effects; + private final int manaCost; + private final List data; + private final War3ID unitId; + private List requirements; + + public ABAbilityBuilderAbilityTypeLevelData(EnumSet targetsAllowed, float area, float castRange, + float castTime, float cooldown, float durationHero, float durationNormal, List buffs, + List effects, int manaCost, List data, War3ID unitId, List requirements) { + super(targetsAllowed); + this.area = area; + this.castRange = castRange; + this.castTime = castTime; + this.cooldown = cooldown; + this.durationHero = durationHero; + this.durationNormal = durationNormal; + this.buffs = buffs; + this.effects = effects; + this.manaCost = manaCost; + this.data = data; + this.unitId = unitId; + this.requirements = requirements; + } + + public float getArea() { + return area; + } + + public float getCastRange() { + return castRange; + } + + public float getCastTime() { + return castTime; + } + + public float getCooldown() { + return cooldown; + } + + public float getDurationHero() { + return durationHero; + } + + public float getDurationNormal() { + return durationNormal; + } + + public List getBuffs() { + return buffs; + } + + public List getEffects() { + return effects; + } + + public int getManaCost() { + return manaCost; + } + + public List getData() { + return data; + } + + public War3ID getUnitId() { + return unitId; + } + + /** + * @return the requirements + */ + public List getRequirements() { + return requirements; + } + + /** + * @param requirements the requirements to set + */ + public void setRequirements(List requirements) { + this.requirements = requirements; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderTemplateType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderTemplateType.java new file mode 100644 index 000000000..10465d84f --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/types/impl/ABAbilityBuilderTemplateType.java @@ -0,0 +1,57 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.impl; + +import java.util.List; + +import com.etheller.warsmash.units.GameObject; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.CAbilityType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template.ABAbilityBuilderAuraTemplate; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template.ABAbilityBuilderSimpleAuraTemplate; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template.ABAbilityBuilderStatAuraTemplate; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.template.ABAbilityBuilderStatPassiveTemplate; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABMapLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParser; + +public class ABAbilityBuilderTemplateType extends CAbilityType { + + private ABAbilityBuilderParser parser; + private GameObject abilityEditorData; + + public ABAbilityBuilderTemplateType(War3ID alias, War3ID code, GameObject abilityEditorData, List levelData, ABAbilityBuilderParser parser) { + super(alias, code, levelData); + this.parser = parser; + this.abilityEditorData = abilityEditorData; + } + + @Override + public CAbility createAbility(int handleId) { + ABLocalDataStore localStore = new ABMapLocalDataStore(); + localStore.put(ABLocalStoreKeys.ABILITYEDITORDATA, this.abilityEditorData); + localStore.put(ABLocalStoreKeys.LEVELDATA, getLevelData()); + localStore.put(ABLocalStoreKeys.ALIAS, getAlias()); + + switch (parser.getTemplateType()) { + case PASSIVE_STATS: + return new ABAbilityBuilderStatPassiveTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getStatBuffsFromDataFields()); + case AURA_STATS: + return new ABAbilityBuilderStatAuraTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getStatBuffsFromDataFields(), parser.getMeleeRangeTargetOverride()); + case AURA_SIMPLE: + return new ABAbilityBuilderSimpleAuraTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getAbilityIdsToAddPerLevel(), parser.getLevellingAbilityIdsToAdd()); + case AURA: + default: + return new ABAbilityBuilderAuraTemplate(handleId, getCode(), getAlias(), getLevelData(), localStore, parser.getAddToAuraActions(), parser.getUpdateAuraLevelActions(), parser.getRemoveFromAuraActions()); + } + } + + @Override + public void setLevel(CSimulation game, CUnit unit, CLevelingAbility existingAbility, int level) { + existingAbility.setLevel(game, unit, level); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABAbilityTargetStillTargetableVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABAbilityTargetStillTargetableVisitor.java new file mode 100644 index 000000000..5c381a505 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABAbilityTargetStillTargetableVisitor.java @@ -0,0 +1,74 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; + +public final class ABAbilityTargetStillTargetableVisitor implements AbilityTargetVisitor { + private CSimulation simulation; + private CUnit unit; + private ABAbilityBuilderActiveAbility ability; + private boolean autoOrder; + private boolean channeling; + private int orderId; + + public ABAbilityTargetStillTargetableVisitor reset(final CSimulation simulation, final CUnit unit, + final ABAbilityBuilderActiveAbility ability, boolean autoOrder, boolean channeling) { + this.simulation = simulation; + this.unit = unit; + this.ability = ability; + this.autoOrder = autoOrder; + this.channeling = channeling; + this.orderId = this.ability.getBaseOrderId(); + return this; + } + + public ABAbilityTargetStillTargetableVisitor reset(final CSimulation simulation, final CUnit unit, + final ABAbilityBuilderActiveAbility ability, boolean autoOrder, boolean channeling, int orderId) { + this.simulation = simulation; + this.unit = unit; + this.ability = ability; + this.autoOrder = autoOrder; + this.channeling = channeling; + this.orderId = orderId; + return this; + } + + @Override + public Boolean accept(final AbilityPointTarget target) { + return Boolean.TRUE; + } + + @Override + public Boolean accept(final CUnit target) { + if (channeling) { + return !target.isHidden(); + } + BooleanAbilityTargetCheckReceiver receiver = new BooleanAbilityTargetCheckReceiver<>(); + ability.checkCanTarget(simulation, unit, this.orderId, this.autoOrder, target, receiver); + return !target.isHidden() && receiver.isTargetable(); + } + + @Override + public Boolean accept(final CDestructable target) { + if (channeling) { + return !target.isDead(); + } + BooleanAbilityTargetCheckReceiver receiver = new BooleanAbilityTargetCheckReceiver<>(); + ability.checkCanTarget(simulation, unit, this.orderId, this.autoOrder, target, receiver); + return !target.isDead() && receiver.isTargetable(); + } + + @Override + public Boolean accept(final CItem target) { + if (channeling) { + return !target.isDead() && !target.isHidden(); + } + BooleanAbilityTargetCheckReceiver receiver = new BooleanAbilityTargetCheckReceiver<>(); + ability.checkCanTarget(simulation, unit, this.orderId, this.autoOrder, target, receiver); + return !target.isDead() && !target.isHidden() && receiver.isTargetable(); + } + +} \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABGetABAbilityByRawcodeVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABGetABAbilityByRawcodeVisitor.java new file mode 100644 index 000000000..bac50a972 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABGetABAbilityByRawcodeVisitor.java @@ -0,0 +1,182 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityGenericDoNothing; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityMove; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityBuildInProgress; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityHumanBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNagaBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNeutralBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNightElfBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityOrcBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityUndeadBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.combat.CAbilityColdArrows; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.*; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityReturnResources; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.hero.CAbilityHero; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilityNeutralBuilding; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilitySellItems; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.jass.CAbilityJass; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.nightelf.root.CAbilityRoot; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityQueue; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; + +public class ABGetABAbilityByRawcodeVisitor implements CAbilityVisitor { + private static final ABGetABAbilityByRawcodeVisitor INSTANCE = new ABGetABAbilityByRawcodeVisitor(); + + public static ABGetABAbilityByRawcodeVisitor getInstance() { + return INSTANCE; + } + + private War3ID rawcode; + + public ABGetABAbilityByRawcodeVisitor reset(final War3ID rawcode) { + this.rawcode = rawcode; + return this; + } + + @Override + public ABAbilityBuilderAbility accept(final ABAbilityBuilderActiveAbility ability) { + if (this.rawcode.equals(ability.getAlias())) { + return (ABAbilityBuilderAbility) ability; + } + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final GenericSingleIconActiveAbility ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(GenericSingleIconPassiveAbility ability) { + if (ability instanceof ABAbilityBuilderAbility && this.rawcode.equals(ability.getAlias())) { + return (ABAbilityBuilderAbility) ability; + } + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final GenericNoIconAbility ability) { + if (ability instanceof ABAbilityBuilderAbility && this.rawcode.equals(ability.getAlias())) { + return (ABAbilityBuilderAbility) ability; + } + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityAttack ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityMove ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityOrcBuild ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityHumanBuild ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityUndeadBuild ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityNightElfBuild ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityGenericDoNothing ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityColdArrows ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityNagaBuild ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityNeutralBuild ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityBuildInProgress ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityQueue ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilitySellItems ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityUpgrade ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityReviveHero ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityRoot ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityRally ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CBuff ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityReturnResources ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityHero ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityJass ability) { + return null; + } + + @Override + public ABAbilityBuilderAbility accept(final CAbilityNeutralBuilding ability) { + return null; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABGetInstantTransformationBuffVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABGetInstantTransformationBuffVisitor.java new file mode 100644 index 000000000..a931e12e7 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/adjustablebehaviors/visitor/ABGetInstantTransformationBuffVisitor.java @@ -0,0 +1,220 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.visitor; + +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityGenericDoNothing; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityMove; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityBuildInProgress; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityHumanBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNagaBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNeutralBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityNightElfBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityOrcBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityUndeadBuild; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.combat.CAbilityColdArrows; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.GenericNoIconAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.GenericSingleIconActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.GenericSingleIconPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.harvest.CAbilityReturnResources; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.hero.CAbilityHero; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilityNeutralBuilding; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.item.shop.CAbilitySellItems; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.jass.CAbilityJass; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.nightelf.root.CAbilityRoot; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityQueue; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderPassiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedInstantTransformationBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.buff.ABTimedTransformationBuff; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalDataStore; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.handler.ABTransformationHandler.OnTransformationActions; + +public class ABGetInstantTransformationBuffVisitor implements CAbilityVisitor { + private static final ABGetInstantTransformationBuffVisitor INSTANCE = new ABGetInstantTransformationBuffVisitor(); + + public static ABGetInstantTransformationBuffVisitor getInstance() { + return INSTANCE; + } + + private CSimulation game; + private CUnit caster; + private ABLocalDataStore localStore; + private CUnitType newType; + private boolean keepRatios; + private OnTransformationActions actions; + private War3ID buffId; + private boolean addAlternateTagAfter; + private float transformationTime; + private float duration; + private boolean permanent; + + public ABGetInstantTransformationBuffVisitor reset(CSimulation game, CUnit caster, ABLocalDataStore localStore, + CUnitType newType, final boolean keepRatios, OnTransformationActions actions, War3ID buffId, + boolean addAlternateTagAfter, float transformationTime, float duration, boolean permanent) { + this.game = game; + this.caster = caster; + this.localStore = localStore; + this.newType = newType; + this.keepRatios = keepRatios; + this.actions = actions; + this.buffId = buffId; + this.addAlternateTagAfter = addAlternateTagAfter; + this.transformationTime = transformationTime; + this.duration = duration; + this.permanent = permanent; + return this; + } + + @Override + public ABBuff accept(final ABAbilityBuilderActiveAbility ability) { + return new ABTimedTransformationBuff(game.getHandleIdAllocator().createId(), localStore, ability, caster, + actions, buffId == null ? ability.getAlias() : buffId, duration, ability, newType, + !addAlternateTagAfter, permanent, transformationTime); + } + + @Override + public ABBuff accept(final GenericSingleIconActiveAbility ability) { + return null; + } + + @Override + public ABBuff accept(GenericSingleIconPassiveAbility ability) { + if (ability instanceof ABAbilityBuilderPassiveAbility) { + return new ABTimedInstantTransformationBuff(game.getHandleIdAllocator().createId(), localStore, ability, + caster, actions, buffId == null ? ability.getAlias() : buffId, duration, + (ABAbilityBuilderPassiveAbility) ability, newType, keepRatios, !addAlternateTagAfter, permanent, + transformationTime); + } + return null; + } + + @Override + public ABBuff accept(final GenericNoIconAbility ability) { + if (ability instanceof ABAbilityBuilderPassiveAbility) { + return new ABTimedInstantTransformationBuff(game.getHandleIdAllocator().createId(), localStore, ability, + caster, actions, buffId == null ? ability.getAlias() : buffId, duration, + (ABAbilityBuilderPassiveAbility) ability, newType, keepRatios, !addAlternateTagAfter, permanent, + transformationTime); + } + return null; + } + + @Override + public ABBuff accept(final CAbilityAttack ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityMove ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityOrcBuild ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityHumanBuild ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityUndeadBuild ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityNightElfBuild ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityGenericDoNothing ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityColdArrows ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityNagaBuild ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityNeutralBuild ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityBuildInProgress ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityQueue ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilitySellItems ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityUpgrade ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityReviveHero ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityRoot ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityRally ability) { + return null; + } + + @Override + public ABBuff accept(final CBuff ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityReturnResources ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityHero ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityJass ability) { + return null; + } + + @Override + public ABBuff accept(final CAbilityNeutralBuilding ability) { + return null; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorAbilityVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorAbilityVisitor.java index 2f3a5b750..25e1dc356 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorAbilityVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorAbilityVisitor.java @@ -1,8 +1,8 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderNoTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderBase; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderNoTarget; public class BehaviorAbilityVisitor implements CBehaviorVisitor { public static final BehaviorAbilityVisitor INSTANCE = new BehaviorAbilityVisitor(); @@ -18,14 +18,19 @@ public CAbility accept(CRangedBehavior target) { } @Override - public CAbility accept(CBehaviorAbilityBuilderBase target) { + public CAbility accept(ABBehaviorAbilityBuilderBase target) { return target.getAbility(); } @Override - public CAbility accept(CBehaviorAbilityBuilderNoTarget target) { + public CAbility accept(ABBehaviorAbilityBuilderNoTarget target) { return target.getAbility(); } + + @Override + public CAbility accept(CBehaviorMove target) { + return null; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorNextBehaviorVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorNextBehaviorVisitor.java new file mode 100644 index 000000000..8b0da2291 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorNextBehaviorVisitor.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderBase; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderNoTarget; + +public class BehaviorNextBehaviorVisitor implements CBehaviorVisitor { + public static final BehaviorNextBehaviorVisitor INSTANCE = new BehaviorNextBehaviorVisitor(); + + @Override + public CRangedBehavior accept(CBehavior target) { + return null; + } + + @Override + public CRangedBehavior accept(CBehaviorMove target) { + return target.getRangedBehavior(); + } + + @Override + public CRangedBehavior accept(CRangedBehavior target) { + return null; + } + + @Override + public CRangedBehavior accept(ABBehaviorAbilityBuilderBase target) { + return null; + } + + @Override + public CRangedBehavior accept(ABBehaviorAbilityBuilderNoTarget target) { + return null; + } + + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetUnitVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetUnitVisitor.java index 857e4ef59..b92d45307 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetUnitVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetUnitVisitor.java @@ -2,8 +2,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderNoTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderBase; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderNoTarget; public class BehaviorTargetUnitVisitor implements CBehaviorVisitor { public static final BehaviorTargetUnitVisitor INSTANCE = new BehaviorTargetUnitVisitor(); @@ -22,7 +22,7 @@ public CUnit accept(CRangedBehavior target) { } @Override - public CUnit accept(CBehaviorAbilityBuilderBase target) { + public CUnit accept(ABBehaviorAbilityBuilderBase target) { if (target.getTarget() != null) { return target.getTarget().visit(AbilityTargetVisitor.UNIT); } @@ -30,7 +30,12 @@ public CUnit accept(CBehaviorAbilityBuilderBase target) { } @Override - public CUnit accept(CBehaviorAbilityBuilderNoTarget target) { + public CUnit accept(ABBehaviorAbilityBuilderNoTarget target) { + return null; + } + + @Override + public CUnit accept(CBehaviorMove target) { return null; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetVisitor.java index 80356a229..635c4694a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/BehaviorTargetVisitor.java @@ -1,8 +1,8 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderNoTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderBase; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderNoTarget; public class BehaviorTargetVisitor implements CBehaviorVisitor { public static final BehaviorTargetVisitor INSTANCE = new BehaviorTargetVisitor(); @@ -18,14 +18,19 @@ public AbilityTarget accept(CRangedBehavior target) { } @Override - public AbilityTarget accept(CBehaviorAbilityBuilderBase target) { + public AbilityTarget accept(ABBehaviorAbilityBuilderBase target) { return target.getTarget(); } @Override - public AbilityTarget accept(CBehaviorAbilityBuilderNoTarget target) { + public AbilityTarget accept(ABBehaviorAbilityBuilderNoTarget target) { return null; } + + @Override + public AbilityTarget accept(CBehaviorMove target) { + return target.getTarget(); + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorAttack.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorAttack.java index 2d804168c..ddda0a51d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorAttack.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorAttack.java @@ -5,11 +5,11 @@ import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetStillAliveAndTargetableVisitor; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackModifier; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public class CBehaviorAttack extends CAbstractRangedBehavior { @@ -26,6 +26,8 @@ public CBehaviorAttack(final CUnit unit) { private int backSwingTime; private int thisOrderCooldownEndTime; private CBehaviorAttackListener attackListener; + private CUnitAttackModifier forcedModifier; + private CUnitAttackSettings settings; public CBehavior reset(final CSimulation game, final int highlightOrderId, final CUnitAttack unitAttack, final AbilityTarget target, final boolean disableMove, final CBehaviorAttackListener attackListener) { @@ -40,6 +42,12 @@ public CBehavior reset(final CSimulation game, final int highlightOrderId, final return super.innerReset(game, target); } + public CBehavior reset(final CSimulation game, final int highlightOrderId, final CUnitAttack unitAttack, + final AbilityTarget target, final boolean disableMove, final CBehaviorAttackListener attackListener, CUnitAttackModifier forcedModifier) { + this.forcedModifier = forcedModifier; + return this.reset(game, highlightOrderId, unitAttack, target, disableMove, attackListener); + } + @Override public int getHighlightOrderId() { return this.highlightOrderId; @@ -83,13 +91,22 @@ public CBehavior update(final CSimulation simulation, final boolean withinFacing if (this.damagePointLaunchTime != 0) { if (currentTurnTick >= this.damagePointLaunchTime) { final int damage = this.unitAttack.roll(simulation.getSeededRandom()); + this.settings.setBaseDamage(damage); AbilityTarget target = this.target; - if (this.unitAttack.getWeaponType() == CWeaponType.ARTILLERY) { - // NOTE: adding this fixed a bunch of special cases in my code, but - // maybe we should re-use the point objects and not "new" here for - // better performance (maybe in a refactor in the future). - target = new AbilityPointTarget(target.getX(), target.getY()); + if (this.forcedModifier != null && this.forcedModifier.checkApplication(simulation, this.unit, target, this.unitAttack)) { + this.forcedModifier.applyModification(simulation, this.unit, target, this.unitAttack, this.settings, null); + } else { + this.settings = this.unit.checkForAttackModification(simulation, target, unitAttack, this.settings); } + this.forcedModifier = null; + +// if (this.unitAttack.getWeaponType() == CWeaponType.ARTILLERY || this.unitAttack.getWeaponType() == CWeaponType.ALINE) { +// // NOTE: adding this fixed a bunch of special cases in my code, but +// // maybe we should re-use the point objects and not "new" here for +// // better performance (maybe in a refactor in the future). +// target = new AbilityPointTarget(target.getX(), target.getY()); +// } + this.unitAttack.launch(simulation, this.unit, target, damage, this.attackListener); this.damagePointLaunchTime = 0; } @@ -105,8 +122,14 @@ else if (currentTurnTick >= cooldownEndTime) { this.thisOrderCooldownEndTime = currentTurnTick + a1CooldownSteps; this.damagePointLaunchTime = currentTurnTick + a1DamagePointSteps; this.backSwingTime = currentTurnTick + a1DamagePointSteps + a1BackswingSteps; + this.settings = this.unitAttack.initialSettings(); + if (this.forcedModifier != null && this.forcedModifier.checkPreLaunchApplication(simulation, this.unit, target, this.unitAttack)) { + this.forcedModifier.applyPreLaunchModification(simulation, this.unit, target, this.unitAttack, this.settings, null); + } else { + this.settings = this.unit.checkForAttackPreLaunchModification(simulation, target, unitAttack, this.settings); + } this.unit.getUnitAnimationListener().playAnimationWithDuration(true, PrimaryTag.ATTACK, - SequenceUtils.EMPTY, animationBackswingPoint + animationDamagePoint, true); + this.settings.getAnimationNames(), animationBackswingPoint + animationDamagePoint, true); this.unit.getUnitAnimationListener().queueAnimation(PrimaryTag.STAND, SequenceUtils.READY, false); } else if (currentTurnTick >= this.thisOrderCooldownEndTime) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorCategory.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorCategory.java index 745b0c247..fce86f5e9 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorCategory.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorCategory.java @@ -6,7 +6,8 @@ public enum CBehaviorCategory implements CHandle { IDLE, MOVEMENT, ATTACK, - SPELL; + SPELL, + BUILD; @Override public int getHandleId() { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorMove.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorMove.java index c5b21ecba..d45dd5fb9 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorMove.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorMove.java @@ -46,6 +46,7 @@ public CBehaviorMove(final CUnit unit) { private boolean firstPathfindJob = false; private boolean pathfindingFailedGiveUp; private int giveUpUntilTurnTick; + private int prevSpeed = 0; public CBehaviorMove reset(final int highlightOrderId, final AbilityTarget target) { target.visit(this.targetVisitingResetter.reset(highlightOrderId)); @@ -187,6 +188,8 @@ else if ((this.followUnit != null) && (this.path.size() > 1) && (this.target.dis final float propulsionWindow = this.unit.getPropWindow(); final float turnRate = this.unit.getTurnRate(); final int speed = this.unit.getSpeed(); + final boolean speedChange = speed != prevSpeed; + this.prevSpeed = speed; if (delta < -180) { delta = 360 + delta; @@ -325,7 +328,12 @@ else if ((this.followUnit != null) && (this.path.size() > 1) && (this.target.dis return this; } } - this.unit.getUnitAnimationListener().playWalkAnimation(false, this.unit.getSpeed(), true); + if (speed > 0) { + this.unit.getUnitAnimationListener().playWalkAnimation(speedChange, speed, true); + } else { + this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, + SequenceUtils.EMPTY, 1.0f, true); + } this.wasWithinPropWindow = true; } while (continueDistance > 0); @@ -407,6 +415,10 @@ public CUnit getUnit() { return this.unit; } + public CRangedBehavior getRangedBehavior() { + return this.rangedBehavior; + } + public void pathFound(final List waypoints, final CSimulation simulation) { this.pathfindingActive = false; @@ -500,4 +512,13 @@ public T visit(final CBehaviorVisitor visitor) { public CBehaviorCategory getBehaviorCategory() { return CBehaviorCategory.MOVEMENT; } + + public AbilityTarget getTarget() { + if (this.rangedBehavior != null) { + return this.rangedBehavior.getTarget(); + } else if (this.followUnit != null) { + return this.followUnit; + } + return new AbilityPointTarget(this.target.x, this.target.y); + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStop.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStop.java index dac2bd17d..3b8852101 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStop.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStop.java @@ -29,7 +29,8 @@ public CBehavior update(final CSimulation game) { @Override public void begin(final CSimulation game) { - if (!this.unit.isConstructingOrUpgrading()) { + if (!this.unit.isConstructingOrUpgrading() + && !unit.getUnitAnimationListener().isAnimationQueued(PrimaryTag.STAND)) { this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, SequenceUtils.EMPTY, 1.0f, true); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStun.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStun.java index 6e8267cd1..b2b5fcea7 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStun.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorStun.java @@ -9,9 +9,11 @@ public class CBehaviorStun implements CBehavior { private final CUnit unit; + private boolean updateAnims; - public CBehaviorStun(final CUnit unit) { + public CBehaviorStun(final CUnit unit, final boolean updateAnims) { this.unit = unit; + this.updateAnims = updateAnims; } @Override @@ -26,8 +28,9 @@ public CBehavior update(final CSimulation game) { @Override public void begin(final CSimulation game) { - this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, SequenceUtils.EMPTY, 1.0f, - true); + if (this.updateAnims) + this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, SequenceUtils.EMPTY, 1.0f, + true); } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorVisitor.java index 29dea9cdd..e9841d07f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/CBehaviorVisitor.java @@ -1,14 +1,16 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderBase; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.behavior.CBehaviorAbilityBuilderNoTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderBase; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.ABBehaviorAbilityBuilderNoTarget; public interface CBehaviorVisitor { T accept(CBehavior target); T accept(CRangedBehavior target); - T accept(CBehaviorAbilityBuilderBase target); - T accept(CBehaviorAbilityBuilderNoTarget target); + T accept(ABBehaviorAbilityBuilderBase target); + T accept(ABBehaviorAbilityBuilderNoTarget target); + + T accept(CBehaviorMove target); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUnderConstructionVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUnderConstructionVisitor.java index 48cc9352d..2eab9de6d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUnderConstructionVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUnderConstructionVisitor.java @@ -27,7 +27,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; public class AbilityDisableWhileUnderConstructionVisitor implements CAbilityVisitor { public static final AbilityDisableWhileUnderConstructionVisitor INSTANCE = new AbilityDisableWhileUnderConstructionVisitor(); @@ -138,7 +138,7 @@ public Void accept(final CAbilityReviveHero ability) { } @Override - public Void accept(final AbilityBuilderActiveAbility ability) { + public Void accept(final ABAbilityBuilderActiveAbility ability) { ability.setDisabled(true, CAbilityDisableType.CONSTRUCTION); ability.setIconShowing(false); return null; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUpgradingVisitor.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUpgradingVisitor.java index 333cfbfa6..0198562d0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUpgradingVisitor.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/AbilityDisableWhileUpgradingVisitor.java @@ -27,7 +27,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityRally; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.queue.CAbilityReviveHero; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; public class AbilityDisableWhileUpgradingVisitor implements CAbilityVisitor { public static final AbilityDisableWhileUpgradingVisitor INSTANCE = new AbilityDisableWhileUpgradingVisitor(); @@ -138,7 +138,7 @@ public Void accept(final CAbilityReviveHero ability) { } @Override - public Void accept(final AbilityBuilderActiveAbility ability) { + public Void accept(final ABAbilityBuilderActiveAbility ability) { ability.setDisabled(true, CAbilityDisableType.CONSTRUCTION); ability.setIconShowing(false); return null; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanBuild.java index 00475e6fd..3cb884fb9 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanBuild.java @@ -67,7 +67,7 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac final int playerIndex = this.unit.getPlayerIndex(); if (!buildLocationObstructed) { final CUnit constructedStructure = simulation.createUnit(this.orderId, playerIndex, this.target.getX(), - this.target.getY(), simulation.getGameplayConstants().getBuildingAngle()); + this.target.getY(), simulation.getGameplayConstants().getBuildingAngle(), true); if (canBeBuiltOnThem) { CAbilityGoldMinable abilityGoldMine = null; if (this.buildOnBuildingIntersector.getUnitToBuildOn() != null) { @@ -91,7 +91,6 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac } } } - constructedStructure.setConstructing(true); constructedStructure.setConstructingPaused(true); constructedStructure.setLife(simulation, constructedStructure.getMaximumLife() * WarsmashConstants.BUILDING_CONSTRUCT_START_LIFE); @@ -115,14 +114,14 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac if (ability instanceof CAbilityHumanRepair) { final int baseOrderId = ((CAbilityHumanRepair) ability).getBaseOrderId(); ability.checkCanUse(simulation, this.unit, baseOrderId, - BooleanAbilityActivationReceiver.INSTANCE); + false, BooleanAbilityActivationReceiver.INSTANCE); if (BooleanAbilityActivationReceiver.INSTANCE.isOk()) { final BooleanAbilityTargetCheckReceiver targetCheckReceiver = BooleanAbilityTargetCheckReceiver .getInstance(); - ability.checkCanTarget(simulation, this.unit, baseOrderId, constructedStructure, - targetCheckReceiver.reset()); + ability.checkCanTarget(simulation, this.unit, baseOrderId, false, + constructedStructure, targetCheckReceiver.reset()); if (targetCheckReceiver.isTargetable()) { - return ability.begin(simulation, this.unit, baseOrderId, constructedStructure); + return ability.begin(simulation, this.unit, baseOrderId, false, constructedStructure); } } } @@ -187,7 +186,7 @@ public boolean interruptable() { @Override public CBehaviorCategory getBehaviorCategory() { - return CBehaviorCategory.SPELL; + return CBehaviorCategory.BUILD; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanRepair.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanRepair.java index ae323845a..45977a28a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanRepair.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanRepair.java @@ -120,7 +120,7 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac if (this.nextNotifyTick == 0 || simulation.getGameTurnTick() >= this.nextNotifyTick) { if (this.nextNotifyTick == 0) { this.nextNotifyTick = (int) (simulation.getGameTurnTick() - + 0.5 / WarsmashConstants.SIMULATION_STEP_TIME); + + WarsmashConstants.ONGOING_BEHAVIOR_NOTIFICATION_TICKS / WarsmashConstants.SIMULATION_STEP_TIME); } else { this.unit.fireBehaviorChangeEvent(simulation, this, true); } @@ -224,6 +224,6 @@ public boolean interruptable() { @Override public CBehaviorCategory getBehaviorCategory() { - return CBehaviorCategory.SPELL; + return CBehaviorCategory.BUILD; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorOrcBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorOrcBuild.java index f0cf5a12e..389b5ec1f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorOrcBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorOrcBuild.java @@ -69,7 +69,7 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac final int playerIndex = this.unit.getPlayerIndex(); if (!buildLocationObstructed) { final CUnit constructedStructure = simulation.createUnit(this.orderId, playerIndex, this.target.getX() - , this.target.getY(), simulation.getGameplayConstants().getBuildingAngle()); + , this.target.getY(), simulation.getGameplayConstants().getBuildingAngle(), true); if (canBeBuiltOnThem) { CAbilityGoldMinable abilityGoldMine = null; if (this.buildOnBuildingIntersector.getUnitToBuildOn() != null) { @@ -91,7 +91,6 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac } } } - constructedStructure.setConstructing(true); constructedStructure.setWorker(this.unit, true); final CAbilityBuildInProgress abilityBuildInProgress = new CAbilityBuildInProgress(simulation.getHandleIdAllocator().createId()); @@ -174,6 +173,6 @@ public boolean interruptable() { @Override public CBehaviorCategory getBehaviorCategory() { - return CBehaviorCategory.SPELL; + return CBehaviorCategory.BUILD; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorRepair.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorRepair.java index 105d97643..e9e58d910 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorRepair.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorRepair.java @@ -94,7 +94,7 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac if (this.nextNotifyTick == 0 || simulation.getGameTurnTick() >= this.nextNotifyTick) { if (this.nextNotifyTick == 0) { this.nextNotifyTick = (int) (simulation.getGameTurnTick() - + 0.5 / WarsmashConstants.SIMULATION_STEP_TIME); + + WarsmashConstants.ONGOING_BEHAVIOR_NOTIFICATION_TICKS); } else { this.unit.fireBehaviorChangeEvent(simulation, this, true); } @@ -152,6 +152,6 @@ public boolean interruptable() { @Override public CBehaviorCategory getBehaviorCategory() { - return CBehaviorCategory.SPELL; + return CBehaviorCategory.BUILD; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorUndeadBuild.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorUndeadBuild.java index 49cfdae17..a2eaea0fb 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorUndeadBuild.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorUndeadBuild.java @@ -79,7 +79,7 @@ else if (!this.unitCreated) { final int playerIndex = this.unit.getPlayerIndex(); if (!buildLocationObstructed) { final CUnit constructedStructure = simulation.createUnit(this.orderId, playerIndex, this.target.getX(), - this.target.getY(), simulation.getGameplayConstants().getBuildingAngle()); + this.target.getY(), simulation.getGameplayConstants().getBuildingAngle(), true); if (canBeBuiltOnThem) { CAbilityGoldMinable abilityGoldMine = null; if (this.buildOnBuildingIntersector.getUnitToBuildOn() != null) { @@ -103,7 +103,6 @@ else if (!this.unitCreated) { } } } - constructedStructure.setConstructing(true); constructedStructure.setWorker(this.unit, false); constructedStructure.setLife(simulation, constructedStructure.getMaximumLife() * WarsmashConstants.BUILDING_CONSTRUCT_START_LIFE); @@ -186,6 +185,6 @@ public boolean interruptable() { @Override public CBehaviorCategory getBehaviorCategory() { - return CBehaviorCategory.SPELL; + return CBehaviorCategory.BUILD; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorAcolyteHarvest.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorAcolyteHarvest.java index 763e86d8e..a71aac76f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorAcolyteHarvest.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorAcolyteHarvest.java @@ -2,6 +2,7 @@ import com.badlogic.gdx.math.Vector2; import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag; +import com.etheller.warsmash.util.WarsmashConstants; import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; @@ -21,12 +22,15 @@ public class CBehaviorAcolyteHarvest extends CAbstractRangedBehavior { private boolean harvesting = false; private float harvestStandX, harvestStandY; + private int nextNotifyTick = 0; + public CBehaviorAcolyteHarvest(final CUnit unit, final CAbilityAcolyteHarvest abilityWispHarvest) { super(unit); this.abilityAcolyteHarvest = abilityWispHarvest; } public CBehavior reset(CSimulation game, final CWidget target) { + this.nextNotifyTick = 0; return innerReset(game, target, false); } @@ -53,6 +57,14 @@ else if (result == HarvestStartResult.ACCEPTED) { simulation.unitRepositioned(this.unit); // dont interpolate, instant jump } this.unit.getUnitAnimationListener().playAnimation(false, PrimaryTag.STAND, SequenceUtils.WORK, 1.0f, true); + if (this.nextNotifyTick == 0 || simulation.getGameTurnTick() >= this.nextNotifyTick) { + if (this.nextNotifyTick == 0) { + this.nextNotifyTick = (int) (simulation.getGameTurnTick() + + WarsmashConstants.ONGOING_BEHAVIOR_NOTIFICATION_TICKS); + } else { + this.unit.fireBehaviorChangeEvent(simulation, this, true); + } + } } return this; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorHarvest.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorHarvest.java index 78eb11160..309d25419 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorHarvest.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorHarvest.java @@ -76,6 +76,7 @@ public CBehavior accept(final CUnit target) { final CAbilityGoldMinable abilityGoldMine = (CAbilityGoldMinable) ability; final int activeMiners = abilityGoldMine.getActiveMinerCount(); if (activeMiners < abilityGoldMine.getMiningCapacity()) { + this.unit.fireBehaviorChangeEvent(simulation, this, true); abilityGoldMine.addMiner(this); this.unit.setHidden(true); this.unit.setInvulnerable(true); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorWispHarvest.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorWispHarvest.java index 3e5d61055..79275808e 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorWispHarvest.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/harvest/CBehaviorWispHarvest.java @@ -43,7 +43,8 @@ protected CBehavior update(final CSimulation simulation, final boolean withinFac final CPlayer player = simulation.getPlayer(this.unit.getPlayerIndex()); player.setLumber(player.getLumber() + this.abilityWispHarvest.getLumberPerInterval()); simulation.unitGainResourceEvent(this.unit, player.getId(), ResourceType.LUMBER, - this.abilityWispHarvest.getLumberPerInterval()); + abilityWispHarvest.getLumberPerInterval()); + this.unit.fireBehaviorChangeEvent(simulation, this, true); } if (!this.harvesting) { onStartHarvesting(simulation); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CAttackDamageFlags.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CAttackDamageFlags.java new file mode 100644 index 000000000..1fa5e0571 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CAttackDamageFlags.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat; + +public class CAttackDamageFlags extends CBaseDamageFlags { + + public CAttackDamageFlags(boolean ranged) { + super(); + this.setRanged(ranged); + } + + private CAttackDamageFlags(CAttackDamageFlags base) { + super(base); + } + + @Override + public CDamageFlags copy() { + return new CAttackDamageFlags(this); + } + + @Override + public boolean isAttack() { + return true; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CAttackType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CAttackType.java index 3d54d27e1..4a41fb924 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CAttackType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CAttackType.java @@ -3,24 +3,30 @@ import com.etheller.interpreter.ast.util.CHandle; public enum CAttackType implements CodeKeyType, CHandle { - UNKNOWN, - NORMAL, - PIERCE, - SIEGE, - SPELLS, - CHAOS, - MAGIC, - HERO; + SPELLS(true, false, false), + NORMAL(false, false, true), + PIERCE(false, false, true), + SIEGE(false, false, true), + MAGIC(false, true, false), + CHAOS(false, false, true), + HERO(false, false, true), + UNKNOWN(false, false, false); public static CAttackType[] VALUES = values(); private final String codeKey; private final String damageKey; + private final boolean universal; + private final boolean magic; + private final boolean physical; - private CAttackType() { + private CAttackType(boolean universal, boolean magic, boolean physical) { final String name = name(); this.codeKey = name.charAt(0) + name.substring(1).toLowerCase(); this.damageKey = this.codeKey; + this.universal = universal; + this.magic = magic; + this.physical = physical; } @Override @@ -54,4 +60,16 @@ public String nameForJass() { public int getHandleId() { return ordinal(); } + + public boolean isUniversal() { + return this.universal; + } + + public boolean isMagic() { + return this.magic; + } + + public boolean isPhysical() { + return this.physical; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CBaseDamageFlags.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CBaseDamageFlags.java new file mode 100644 index 000000000..5c3d87011 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CBaseDamageFlags.java @@ -0,0 +1,91 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat; + +public abstract class CBaseDamageFlags implements CDamageFlags { + private static int ATTACK = 0b1; + private static int RANGED = 0b10; + private static int IGNOREINVUL = 0b100; + private static int EXPLODE = 0b1000; + private static int SUMMON = 0b10000; + private static int NONLETHAL = 0b100000; + private static int PASSLIMITEDMAGICIMMUNE = 0b1000000; + + private int flags = 0; + + public CBaseDamageFlags() { + } + + protected CBaseDamageFlags(CBaseDamageFlags base) { + this.flags = base.flags; + } + + @Override + public boolean isAttack() { + return (this.flags & ATTACK) != 0; + } + + @Override + public void setAttack(boolean attack) { + this.flags = attack ? this.flags | ATTACK : this.flags & ~ATTACK; + } + + @Override + public boolean isRanged() { + return (this.flags & RANGED) != 0; + } + + @Override + public void setRanged(boolean ranged) { + this.flags = ranged ? this.flags | RANGED : this.flags & ~RANGED; + } + + @Override + public boolean isIgnoreInvulnerable() { + return (this.flags & IGNOREINVUL) != 0; + } + + @Override + public void setIgnoreInvulnerable(boolean ignoreInvulnerable) { + this.flags = ignoreInvulnerable ? this.flags | IGNOREINVUL : this.flags & ~IGNOREINVUL; + } + + @Override + public boolean isExplode() { + return (this.flags & EXPLODE) != 0; + } + + @Override + public void setExplode(boolean explode) { + this.flags = explode ? this.flags | EXPLODE : this.flags & ~EXPLODE; + } + + @Override + public boolean isOnlyDamageSummons() { + return (this.flags & SUMMON) != 0; + } + + @Override + public void setOnlyDamageSummons(boolean summon) { + this.flags = summon ? this.flags | SUMMON : this.flags & ~SUMMON; + } + + @Override + public boolean isNonlethal() { + return (this.flags & NONLETHAL) != 0; + } + + @Override + public void setNonlethal(boolean nonlethal) { + this.flags = nonlethal ? this.flags | NONLETHAL : this.flags & ~NONLETHAL; + } + + @Override + public boolean isPassLimitedMagicImmune() { + return (this.flags & PASSLIMITEDMAGICIMMUNE) != 0; + } + + @Override + public void setPassLimitedMagicImmune(boolean passLimitedMagicImmune) { + this.flags = passLimitedMagicImmune ? this.flags | PASSLIMITEDMAGICIMMUNE + : this.flags & ~PASSLIMITEDMAGICIMMUNE; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CBonusDamage.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CBonusDamage.java new file mode 100644 index 000000000..d0898c8ba --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CBonusDamage.java @@ -0,0 +1,111 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; + +public class CBonusDamage { + protected final static int PREVENTMULTIPLY = 0b1; + private float amount; + private CAttackType attackType = null; + private CDamageType damageType; + private CDamageFlags damageFlags; + private int internalFlags = 0b0; + + public float computeRawDamage(float multiplier) { + return this.amount * (this.isPreventMultiply() ? 1 : multiplier); + } + + public void applyMultiplier(float damageMultiplier) { + this.amount *= damageMultiplier; + } + + public float computeFinalDamage(CSimulation simulation, CUnit unit, CAttackType primaryAttackType, CDamageType primaryDamageType, float multiplier, + float currentDamage) { + if (isImmuneToDamage(simulation, unit, this.attackType == null ? primaryAttackType : this.attackType) + || (unit.isInvulnerable() && !this.isPassInvulnerable(simulation, unit))) { + return 0; + } + float trueDamage = CDamageCalculation.calculateDamageByArmor(simulation, unit, + this.attackType == null ? primaryAttackType : this.attackType, primaryDamageType, amount, damageFlags) + * (this.isPreventMultiply() ? 1 : multiplier); + if (damageFlags.isNonlethal() && trueDamage > 0 && (trueDamage + currentDamage) > unit.getLife() - 1) { + trueDamage = Math.max(unit.getLife() - 1 - currentDamage, 0); + } + System.err.println("Computing damage for bonus damage... bonus:" + this.amount + " attackType:" + + (this.attackType == null ? primaryAttackType : this.attackType) + " damageType:" + this.damageType + " final:" + trueDamage); + return trueDamage; + } + + public boolean isImmuneToDamage(CSimulation simulation, CUnit unit, CAttackType attackType) { + if (damageFlags != null && damageFlags.isOnlyDamageSummons() && !unit.isUnitType(CUnitTypeJass.SUMMONED)) { + return true; + } + if (simulation.getGameplayConstants().isMagicImmuneResistsDamage()) { + if (attackType.isMagic() || damageType.isMagic()) { + if (unit.isMagicImmune() || (unit.isLimitedMagicImmune() && !damageFlags.isPassLimitedMagicImmune())) { + return true; + } + } else if (attackType.isPhysical() || damageType.isPhysical()) { + if (unit.isUnitType(CUnitTypeJass.ETHEREAL)) { + return true; + } + } + } else { + if (damageType.isOldMagic() && (unit.isMagicImmune() + || (unit.isLimitedMagicImmune() && !damageFlags.isPassLimitedMagicImmune()))) { + return true; + } + } + return false; + } + + public boolean isPassInvulnerable(CSimulation simulation, CUnit unit) { + return (this.damageFlags != null + && (this.damageFlags.isIgnoreInvulnerable() || (this.damageFlags.isOnlyDamageSummons() + && simulation.getGameplayConstants().isInvulnerableSummonsTakeDispelDamage() + && unit.isUnitType(CUnitTypeJass.SUMMONED)))); + } + + public float getAmount() { + return amount; + } + + public void setAmount(float amount) { + this.amount = amount; + } + + public CAttackType getAttackType() { + return attackType; + } + + public void setAttackType(CAttackType attackType) { + this.attackType = attackType; + } + + public CDamageType getDamageType() { + return damageType; + } + + public void setDamageType(CDamageType damageType) { + this.damageType = damageType; + } + + public CDamageFlags getDamageFlags() { + return damageFlags; + } + + public void setDamageFlags(CDamageFlags damageFlags) { + this.damageFlags = damageFlags; + } + + public void setPreventMultiply(boolean preventMultiply) { + this.internalFlags = preventMultiply ? this.internalFlags | PREVENTMULTIPLY + : this.internalFlags & ~PREVENTMULTIPLY; + } + + public boolean isPreventMultiply() { + return ((this.internalFlags & PREVENTMULTIPLY) != 0); + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDamageCalculation.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDamageCalculation.java new file mode 100644 index 000000000..7664b8fa2 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDamageCalculation.java @@ -0,0 +1,403 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; + +public class CDamageCalculation { + public static float calculateDamageByArmor(CSimulation simulation, CUnit unit, CAttackType attackType, + CDamageType damageType, float amount, CDamageFlags damageFlags) { + float trueDamage = 0; + final float damageRatioFromArmorClass = simulation.getGameplayConstants().getDamageRatioAgainst(attackType, + (unit.isBuilding() && unit.isConstructing()) ? CDefenseType.NORMAL : unit.getDefenseType()); + final float damageRatioFromDefense; + final float defense = unit.getDefense(); + if (damageType != CDamageType.NORMAL || (unit.isBuilding() && unit.isConstructing())) { + damageRatioFromDefense = 1.0f; + } else if (defense >= 0) { + damageRatioFromDefense = 1f - ((defense * simulation.getGameplayConstants().getDefenseArmor()) + / (1 + (simulation.getGameplayConstants().getDefenseArmor() * defense))); + } else { + damageRatioFromDefense = 2f + - (float) StrictMath.pow(1f - simulation.getGameplayConstants().getDefenseArmor(), -defense); + } + trueDamage = damageRatioFromArmorClass * damageRatioFromDefense * amount; + if (damageFlags.isNonlethal() && trueDamage > 0 && trueDamage > unit.getLife() - 1) { + trueDamage = unit.getLife() - 1; + } + return trueDamage; + } + + private CAttackType attackType; + private float primaryAmount; + private CDamageType primaryDamageType; + private CDamageFlags primaryDamageFlags; + private String weaponSoundType; + + private LinkedList bonusDamages; + + private CUnit source; + + private float damageMultiplier; + private boolean miss; + + private boolean unlockBonus; + private boolean unlockMultiplier; + + private boolean splash; + private float splashFactor; + + private boolean endLoop = false; + private boolean endLevel = false; + + public CDamageCalculation(CUnit source, float damage, CAttackType attackType, CDamageType damageType, + CDamageFlags flags, String weaponSoundType) { + this.source = source; + this.primaryAmount = damage; + this.attackType = attackType; + this.primaryDamageType = damageType; + this.primaryDamageFlags = flags; + this.weaponSoundType = weaponSoundType; + + this.bonusDamages = null; + this.damageMultiplier = 1; + this.miss = false; + this.unlockBonus = true; + this.unlockMultiplier = true; + } + + public void applyMultiplier() { + if (this.damageMultiplier == 1f) { + return; + } + this.primaryAmount *= this.damageMultiplier; + if (bonusDamages != null) { + for (CBonusDamage bonus : bonusDamages) { + bonus.applyMultiplier(this.damageMultiplier); + } + } + this.damageMultiplier = 1f; + } + + public float computeFinalDamage(CSimulation simulation, CUnit unit) { + if (this.miss) { + return 0; + } + float trueDamage = 0; + if (!isImmuneToPrimaryDamage(simulation, unit) + && (!unit.isInvulnerable() || this.isPassInvulnerable(simulation, unit))) { + trueDamage = calculateDamageByArmor(simulation, unit, attackType, primaryDamageType, primaryAmount, + primaryDamageFlags); + } + + if (bonusDamages != null) { + for (CBonusDamage bonus : bonusDamages) { + trueDamage += bonus.computeFinalDamage(simulation, unit, this.attackType, this.primaryDamageType, + this.damageMultiplier, trueDamage); + } + } + + return trueDamage * (this.splash ? this.splashFactor : 1); + } + + public float computeRawPrimaryDamage() { + return this.miss ? 0 : this.primaryAmount * this.damageMultiplier * (this.splash ? this.splashFactor : 1); + } + + public float computeRawBonusDamage() { + if (this.miss) { + return 0; + } + float trueDamage = 0; + + if (bonusDamages != null) { + for (CBonusDamage bonus : bonusDamages) { + trueDamage += bonus.computeRawDamage(this.damageMultiplier); + } + } + + return trueDamage * (this.splash ? this.splashFactor : 1); + } + + public float computeRawTotalDamage() { + return this.miss ? 0 : this.computeRawPrimaryDamage() + this.computeRawBonusDamage(); + } + + public boolean isImmuneToPrimaryDamage(CSimulation simulation, CUnit unit) { + if (primaryDamageFlags != null && primaryDamageFlags.isOnlyDamageSummons() + && !unit.isUnitType(CUnitTypeJass.SUMMONED)) { + return true; + } + if (simulation.getGameplayConstants().isMagicImmuneResistsDamage()) { + if (attackType.isMagic() || primaryDamageType.isMagic()) { + if (unit.isMagicImmune() + || (unit.isLimitedMagicImmune() && !primaryDamageFlags.isPassLimitedMagicImmune())) { + return true; + } + } else if (attackType.isPhysical() || primaryDamageType.isPhysical()) { + if (unit.isUnitType(CUnitTypeJass.ETHEREAL)) { + return true; + } + } + } else { + if (primaryDamageType.isOldMagic() && (unit.isMagicImmune() + || (unit.isLimitedMagicImmune() && !primaryDamageFlags.isPassLimitedMagicImmune()))) { + return true; + } + } + return false; + } + + public boolean isImmuneToDamage(CSimulation simulation, CUnit unit) { + if (this.isImmuneToPrimaryDamage(simulation, unit)) { + if (bonusDamages != null) { + for (CBonusDamage bonus : bonusDamages) { + if (!bonus.isImmuneToDamage(simulation, unit, this.attackType)) { + return false; + } + } + } + return true; + } + return false; + } + + public boolean isExplode() { + if (this.primaryDamageFlags.isExplode()) { + return true; + } + if (this.bonusDamages != null) { + for (CBonusDamage bonus : this.bonusDamages) { + if (bonus.getDamageFlags().isExplode()) { + return true; + } + } + } + return false; + } + + public boolean isPassInvulnerable(CSimulation simulation, CUnit unit) { + if (this.primaryDamageFlags != null + && (this.primaryDamageFlags.isIgnoreInvulnerable() || (this.primaryDamageFlags.isOnlyDamageSummons() + && simulation.getGameplayConstants().isInvulnerableSummonsTakeDispelDamage() + && unit.isUnitType(CUnitTypeJass.SUMMONED)))) { + return true; + } + if (this.bonusDamages != null) { + for (CBonusDamage bonus : this.bonusDamages) { + if (bonus.isPassInvulnerable(simulation, unit)) { + return true; + } + } + } + return false; + } + + public CAttackType getAttackType() { + return attackType; + } + + public void setAttackType(CAttackType attackType) { + this.attackType = attackType; + } + + public float getPrimaryAmount() { + return primaryAmount; + } + + public void setPrimaryAmount(float primaryAmount) { + this.primaryAmount = primaryAmount; + } + + public CDamageType getPrimaryDamageType() { + return primaryDamageType; + } + + public void setPrimaryDamageType(CDamageType primaryDamageType) { + this.primaryDamageType = primaryDamageType; + } + + public CDamageFlags getPrimaryDamageFlags() { + return primaryDamageFlags; + } + + public void setPrimaryDamageFlags(CDamageFlags primaryDamageFlags) { + this.primaryDamageFlags = primaryDamageFlags; + } + + public String getWeaponSoundType() { + return weaponSoundType; + } + + public void setWeaponSoundType(String weaponSoundType) { + this.weaponSoundType = weaponSoundType; + } + + public List getBonusDamages() { + return bonusDamages; + } + + public void setBonusDamages(LinkedList bonusDamages) { + this.bonusDamages = bonusDamages; + } + + public CUnit getSource() { + return source; + } + + public void setSource(CUnit source) { + this.source = source; + } + + public float getDamageMultiplier() { + return damageMultiplier; + } + + public void setDamageMultiplier(float damageMultiplier) { + if (unlockMultiplier) { + this.damageMultiplier = damageMultiplier; + } + } + + public void addDamageMultiplier(float damageMultiplier) { + if (unlockMultiplier) { + this.damageMultiplier *= damageMultiplier; + } + } + + public void lockBonus() { + unlockBonus = false; + unlockMultiplier = false; + } + + public void lock() { + unlockBonus = false; + unlockMultiplier = false; + } + + public boolean isMiss() { + return miss; + } + + public void setMiss(boolean miss) { + this.miss = miss; + } + + public boolean isUnlockBonus() { + return unlockBonus; + } + + public void setUnlockBonus(boolean unlockBonus) { + this.unlockBonus = unlockBonus; + } + + public boolean isUnlockMultiplier() { + return unlockMultiplier; + } + + public void setUnlockMultiplier(boolean unlockMultiplier) { + this.unlockMultiplier = unlockMultiplier; + } + + public void startSplash(float splashFactor) { + this.splashFactor = splashFactor; + this.splash = true; + } + + public void endSplash() { + this.splash = false; + } + + // Loop controls + public void startLoop(int i) { + this.endLevel = false; + } + + public void preventOtherModificationsWithSamePriority() { + this.endLevel = true; + } + + public void preventOtherModificationsOfOtherPriorities() { + this.endLoop = true; + } + + public void preventAllOtherModifications() { + this.endLevel = true; + this.endLoop = true; + } + + public boolean isSkipCurrentLevel() { + return this.endLevel; + } + + public boolean isEndLoop() { + return this.endLoop; + } + + public void resetLoop() { + this.endLevel = false; + this.endLoop = false; + } + + public void subtractTotalDamageDealt(float reduction, float minimum) { + float primMinus = this.primaryAmount - reduction; + if (primMinus > minimum) { + this.primaryAmount = primMinus; + } else { + if (this.bonusDamages != null) { + float total = this.primaryAmount; + for (CBonusDamage bonus : this.bonusDamages) { + total += bonus.getAmount(); + } + float target = Math.max(minimum, total - reduction); + if (target < total) { + Iterator reverse = this.bonusDamages.descendingIterator(); + CBonusDamage bonus = null; + do { + bonus = reverse.next(); + float cur = bonus.getAmount(); + if (cur > target) { + bonus.setAmount(target); + target = 0; + } else { + target = Math.max(0, target - cur); + } + } while (reverse.hasNext()); + this.primaryAmount = target; + } + } else { + this.primaryAmount = Math.max(minimum, primMinus); + } + } + + } + + public CBonusDamage addBonusDamage(float amount, CAttackType attackType, CDamageType damageType, + CDamageFlags flags) { + if (bonusDamages == null) { + this.bonusDamages = new LinkedList<>(); + } + CBonusDamage nb = new CBonusDamage(); + nb.setAmount(amount); + if (attackType != null) { + nb.setAttackType(attackType); + } + if (damageType == null) { + nb.setDamageType(primaryDamageType); + } else { + nb.setDamageType(damageType); + } + if (flags == null) { + nb.setDamageFlags(primaryDamageFlags.copy()); + } else { + nb.setDamageFlags(flags); + } + this.bonusDamages.add(nb); + return nb; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDamageFlags.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDamageFlags.java new file mode 100644 index 000000000..83422485b --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDamageFlags.java @@ -0,0 +1,35 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat; + +public interface CDamageFlags { + + boolean isAttack(); + + void setAttack(boolean attack); + + boolean isRanged(); + + void setRanged(boolean ranged); + + boolean isIgnoreInvulnerable(); + + void setIgnoreInvulnerable(boolean ignoreInvulnerable); + + boolean isExplode(); + + void setExplode(boolean explode); + + boolean isOnlyDamageSummons(); + + void setOnlyDamageSummons(boolean callback); + + boolean isNonlethal(); + + void setNonlethal(boolean callback); + + boolean isPassLimitedMagicImmune(); + + void setPassLimitedMagicImmune(boolean limitedMagicImmune); + + CDamageFlags copy(); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDefenseType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDefenseType.java index 5b430da50..b8d328779 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDefenseType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CDefenseType.java @@ -30,7 +30,13 @@ public static CDefenseType parseDefenseType(final String typeString) { if (upperCaseTypeString.equals("HEAVY")) { return LARGE; } - return valueOf(upperCaseTypeString); + try { + return valueOf(upperCaseTypeString); + } + catch (final Exception exc) { + exc.printStackTrace(); + return NONE; + } } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CGenericDamageFlags.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CGenericDamageFlags.java new file mode 100644 index 000000000..17c4a00c5 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CGenericDamageFlags.java @@ -0,0 +1,20 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat; + +public class CGenericDamageFlags extends CBaseDamageFlags { + + public CGenericDamageFlags(final boolean attack, final boolean ranged) { + super(); + this.setAttack(attack); + this.setRanged(ranged); + } + + private CGenericDamageFlags(CGenericDamageFlags base) { + super(base); + } + + @Override + public CDamageFlags copy() { + return new CGenericDamageFlags(this); + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CSpellDamageFlags.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CSpellDamageFlags.java new file mode 100644 index 000000000..5ab1e77e4 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CSpellDamageFlags.java @@ -0,0 +1,24 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat; + +public class CSpellDamageFlags extends CBaseDamageFlags { + + public CSpellDamageFlags() { + super(); + this.setRanged(true); + } + + private CSpellDamageFlags(CSpellDamageFlags base) { + super(base); + } + + @Override + public CDamageFlags copy() { + return new CSpellDamageFlags(this); + } + + @Override + public boolean isAttack() { + return false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CTargetType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CTargetType.java index cf96eee01..4f6e09a84 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CTargetType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CTargetType.java @@ -39,7 +39,9 @@ public enum CTargetType implements CHandle { DECORATION, // BELOW: internal values: NON_MAGIC_IMMUNE, - NON_ETHEREAL + LIMITED_MAGIC_IMMUNE, + NON_ETHEREAL, + REPAIRABLE ; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CWeaponType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CWeaponType.java index f3fd8c76f..04ccb7eed 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CWeaponType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/CWeaponType.java @@ -4,21 +4,24 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; public enum CWeaponType implements CHandle { - NONE(CDamageType.UNKNOWN, false), - NORMAL(CDamageType.NORMAL, false), - INSTANT(CDamageType.NORMAL, true), - ARTILLERY(CDamageType.NORMAL, true), - ALINE(CDamageType.NORMAL, true), - MISSILE(CDamageType.NORMAL, true), - MSPLASH(CDamageType.NORMAL, true), - MBOUNCE(CDamageType.NORMAL, true), - MLINE(CDamageType.NORMAL, true); + NONE(CDamageType.UNKNOWN, false, false), + NORMAL(CDamageType.NORMAL, false, false), + INSTANT(CDamageType.NORMAL, true, false), + ARTILLERY(CDamageType.NORMAL, true, true), + ALINE(CDamageType.NORMAL, true, true), + MISSILE(CDamageType.NORMAL, true, true), + MSPLASH(CDamageType.NORMAL, true, true), + MBOUNCE(CDamageType.NORMAL, true, true), + MLINE(CDamageType.NORMAL, true, true); private CDamageType damageType; private boolean ranged; + private boolean projectile; - CWeaponType(final CDamageType damageType, final boolean ranged) { + CWeaponType(final CDamageType damageType, final boolean ranged, final boolean projectile) { this.damageType = damageType; + this.ranged = ranged; + this.projectile = projectile; } public CDamageType getDamageType() { @@ -29,8 +32,8 @@ public boolean isRanged() { return this.ranged; } - public void setRanged(final boolean ranged) { - this.ranged = ranged; + public boolean isProjectile() { + return this.projectile; } public static CWeaponType parseWeaponType(final String weaponTypeString) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttack.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttack.java index 4ab9a3ebe..56018dd61 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttack.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttack.java @@ -8,16 +8,17 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackEffectListenerStacking; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPostDamageListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerPriority; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackReplacementEffect; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuff; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.TextTagConfigType; @@ -64,8 +65,8 @@ public abstract class CUnitAttack { private Map> nonStackingFlatBuffs = new HashMap<>(); private Map> nonStackingPctBuffs = new HashMap<>(); - - protected CUnitAttackReplacementEffect attackReplacement = null; + + protected CUnitAttackSettings attackModifier = null; // calculate private int totalBaseDamage; @@ -136,9 +137,8 @@ public void computeDerivedFields() { for (final NonStackingStatBuff buff : this.nonStackingFlatBuffs.get(key)) { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey : buff.getValue(); } } totalNSAtkBuff += buffForKey; @@ -149,13 +149,11 @@ public void computeDerivedFields() { for (final NonStackingStatBuff buff : this.nonStackingPctBuffs.get(key)) { if (buffForKey == null) { buffForKey = buff.getValue(); - } - else { + } else { if (key.equals(NonStackingStatBuff.ALLOW_STACKING_KEY)) { buffForKey += buff.getValue(); - } - else { - buffForKey = Math.max(buffForKey, buff.getValue()); + } else { + buffForKey = Math.abs(buffForKey) > Math.abs(buff.getValue()) ? buffForKey : buff.getValue(); } } } @@ -184,7 +182,8 @@ public void computeDerivedFields() { + totalNSAtkBuff + totalNSAtkPctBuff; float totalAttackSpeedBonus = this.agiAttackSpeedBonus + this.attackSpeedBonus + this.attackSpeedModifier; float totalAttackSpeedPercent = 1.0f + Math.max(Math.min(totalAttackSpeedBonus, 4), -0.9f); - // TODO there might be a gameplay constants value for this instead of 0.0001, didn't look + // TODO there might be a gameplay constants value for this instead of 0.0001, + // didn't look if (totalAttackSpeedPercent <= 0.0001f) { totalAttackSpeedPercent = 0.0001f; } @@ -408,6 +407,8 @@ public int getTotalTemporaryDamageBonus() { public float getTotalAttackSpeedPercent() { return this.totalAttackSpeedPercent; } + + public abstract CDamageFlags getBaseAttackDamageFlags(); public abstract void launch(CSimulation simulation, CUnit unit, AbilityTarget target, float damage, CUnitAttackListener attackListener); @@ -423,64 +424,108 @@ public int roll(final Random seededRandom) { return damage + getTotalTemporaryDamageBonus(); } - public CUnitAttackPreDamageListenerDamageModResult runPreDamageListeners(final CSimulation simulation, - final CUnit attacker, final AbilityTarget target, final float damage) { - final CUnitAttackPreDamageListenerDamageModResult result = new CUnitAttackPreDamageListenerDamageModResult( - damage); - CUnitAttackEffectListenerStacking allowContinue = new CUnitAttackEffectListenerStacking(); + public CDamageCalculation runPreDamageListeners(final CSimulation simulation, final CUnit attacker, + final AbilityTarget target, final AbilityPointTarget attackImpactLocation, final float damage, + final CUnitAttackSettings settings) { + final CDamageCalculation calc = new CDamageCalculation(attacker, damage, getAttackType(), + getWeaponType().getDamageType(), this.getBaseAttackDamageFlags(), getWeaponSound()); + calc.resetLoop(); for (final CUnitAttackPreDamageListenerPriority priority : CUnitAttackPreDamageListenerPriority.values()) { - if (allowContinue.isAllowStacking()) { - if (priority == CUnitAttackPreDamageListenerPriority.ATTACKREPLACEMENT && this.attackReplacement != null && this.attackReplacement.getPreDamageListeners() != null) { - for (CUnitAttackPreDamageListener listener : this.attackReplacement.getPreDamageListeners()) { - if (allowContinue.isAllowSamePriorityStacking()) { - allowContinue = listener.onAttack(simulation, attacker, target, weaponType, attackType, weaponType.getDamageType(), result); + calc.startLoop(priority.getPriority()); + if (!calc.isEndLoop()) { + if (priority == CUnitAttackPreDamageListenerPriority.ATTACKREPLACEMENT && settings != null + && settings.getPreDamageListeners() != null) { + for (CUnitAttackPreDamageListener listener : settings.getPreDamageListeners()) { + if (!calc.isSkipCurrentLevel()) { + listener.onAttack(simulation, target, attackImpactLocation, this, settings, + calc); } } } else { for (CUnitAttackPreDamageListener listener : attacker.getPreDamageListenersForPriority(priority)) { - if (allowContinue.isAllowSamePriorityStacking()) { - allowContinue = listener.onAttack(simulation, attacker, target, weaponType, attackType, weaponType.getDamageType(), result); + if (!calc.isSkipCurrentLevel()) { + listener.onAttack(simulation, target, attackImpactLocation, this, settings, + calc); } } } } } - if (result.isMiss()) { - if (this.weaponType == CWeaponType.ARTILLERY) { - result.setDamageMultiplier(simulation.getGameplayConstants().getMissDamageReduction()); - } - else if (this.weaponType == CWeaponType.MSPLASH) { - result.setDamageMultiplier(simulation.getGameplayConstants().getMissDamageReduction()); + if (calc.isMiss()) { + if (this.weaponType == CWeaponType.ARTILLERY || this.weaponType == CWeaponType.ALINE) { + // no miss text for artillery + } else { simulation.spawnTextTag(attacker, attacker.getPlayerIndex(), TextTagConfigType.CRITICAL_STRIKE, "miss"); - } - else { - result.setBaseDamage(0); - result.setBonusDamage(0); - result.setDamageMultiplier(0); - simulation.spawnTextTag(attacker, attacker.getPlayerIndex(), TextTagConfigType.CRITICAL_STRIKE, "miss"); // TODO - // Technically - // cheating - // here + // TODO Technically cheating here, using Critical Strike color for miss + // For some reason, the actual miss doesn't seem to load the values properly } } - if (!result.isMiss() && (result.getDamageMultiplier() != 1) && (result.getDamageMultiplier() != 0)) { - simulation.spawnTextTag(attacker, attacker.getPlayerIndex(), TextTagConfigType.CRITICAL_STRIKE, - Math.round(result.computeFinalDamage())); + if (!calc.isMiss()) { + if ((calc.getDamageMultiplier() != 1) && (calc.getDamageMultiplier() != 0) + && calc.computeRawTotalDamage() != 0) { + simulation.spawnTextTag(attacker, attacker.getPlayerIndex(), TextTagConfigType.CRITICAL_STRIKE, + Math.round(calc.computeRawTotalDamage())); + } else if (calc.computeRawBonusDamage() != 0) { + simulation.spawnTextTag(attacker, attacker.getPlayerIndex(), TextTagConfigType.BASH, + Math.round(calc.computeRawBonusDamage())); + } } - else if (result.getBonusDamage() != 0) { - simulation.spawnTextTag(attacker, attacker.getPlayerIndex(), TextTagConfigType.BASH, - Math.round(result.getBonusDamage())); + return calc; + } + + public void runPostDamageListeners(final CSimulation simulation, final AbilityTarget target, + final CDamageCalculation damage, final CUnitAttackSettings settings) { + CUnit attacker = damage.getSource(); + int maxPriority = 0; + int priorityMask = 0; + int i = 0; + boolean firstLoop = true; + damage.resetLoop(); + while (i <= maxPriority) { + if (i == 0 || (priorityMask & (1 << (i < 31 ? i : 31))) != 0) { + damage.startLoop(i); + + if (settings.getPostDamageListeners() != null) { + for (int j = settings.getPostDamageListeners().size() - 1; j >= 0; j--) { + CUnitAttackPostDamageListener listener = settings.getPostDamageListeners().get(j); + int prio = listener.getPriority(simulation, attacker, target, this); + if (firstLoop) { + if (prio > maxPriority) { + maxPriority = prio; + } + priorityMask |= 1 << (prio < 31 ? prio : 31); + } + if (prio == i && !damage.isSkipCurrentLevel()) { + listener.onHit(simulation, target, this, damage); + } + } + } + for (int j = attacker.getPostDamageListeners().size() - 1; j >= 0; j--) { + CUnitAttackPostDamageListener listener = attacker.getPostDamageListeners().get(j); + int prio = listener.getPriority(simulation, attacker, target, this); + if (firstLoop) { + if (prio > maxPriority) { + maxPriority = prio; + } + priorityMask |= 1 << (prio < 31 ? prio : 31); + } + if (prio == i && !damage.isSkipCurrentLevel()) { + listener.onHit(simulation, target, this, damage); + } + } + if (damage.isEndLoop()) { + break; + } + } + i++; + firstLoop = false; } - return result; } - public void runPostDamageListeners(final CSimulation simulation, final CUnit attacker, final AbilityTarget target, - final float actualDamage) { - for (final CUnitAttackPostDamageListener listener : attacker.getPostDamageListeners()) { - listener.onHit(simulation, attacker, target, actualDamage); - - } + public CUnitAttackSettings initialSettings() { + this.attackModifier = new CUnitAttackSettings(); + return this.attackModifier; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackInstant.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackInstant.java index 4811d4965..df5a9bde2 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackInstant.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackInstant.java @@ -5,15 +5,21 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetWidgetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectileInstant; public class CUnitAttackInstant extends CUnitAttack { + private static CAttackDamageFlags ATTACK_FLAGS = new CAttackDamageFlags(true); private String projectileArt; public CUnitAttackInstant(final float animationBackswingPoint, final float animationDamagePoint, @@ -43,6 +49,10 @@ public void setProjectileArt(final String projectileArt) { this.projectileArt = projectileArt; } + public CDamageFlags getBaseAttackDamageFlags() { + return ATTACK_FLAGS; + } + @Override public void launch(final CSimulation simulation, final CUnit unit, final AbilityTarget target, final float damage, final CUnitAttackListener attackListener) { @@ -50,7 +60,8 @@ public void launch(final CSimulation simulation, final CUnit unit, final Ability CWidget widget = target.visit(AbilityTargetWidgetVisitor.INSTANCE); if (widget != null) { simulation.createInstantAttackEffect(unit, this, widget); - CAttackProjectileInstant proj = new CAttackProjectileInstant(widget.getX(), widget.getY(), widget, unit, damage, this, attackListener); + CAttackProjectileInstant proj = new CAttackProjectileInstant(widget.getX(), widget.getY(), widget, unit, + damage, this, attackListener, this.attackModifier); int i = 0; while (!proj.update(simulation) && i < 100) { i++; @@ -61,13 +72,16 @@ public void launch(final CSimulation simulation, final CUnit unit, final Ability } public void doDamage(final CSimulation cSimulation, final CUnit source, final AbilityTarget target, - final float damage, final float x, final float y, - final CUnitAttackListener attackListener) { + final float damage, final float x, final float y, final CUnitAttackListener attackListener, + final CUnitAttackSettings settings) { final CWidget widget = target.visit(AbilityTargetWidgetVisitor.INSTANCE); if (widget != null) { - CUnitAttackPreDamageListenerDamageModResult modDamage = runPreDamageListeners(cSimulation, source, target, damage); - float damageDealt = widget.damage(cSimulation, source, true, true, getAttackType(), getWeaponType().getDamageType(), getWeaponSound(), modDamage.computeFinalDamage(), modDamage.getBonusDamage()); - runPostDamageListeners(cSimulation, source, target, damageDealt); + CDamageCalculation modDamage = runPreDamageListeners(cSimulation, source, target, + target.visit(AbilityTargetVisitor.POINT) != null ? target.visit(AbilityTargetVisitor.POINT) + : new AbilityPointTarget(x, y), + damage, settings); + widget.damage(cSimulation, modDamage); + runPostDamageListeners(cSimulation, target, modDamage, settings); attackListener.onHit(target, damage); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissile.java index 33ad04a16..db68a7788 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissile.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissile.java @@ -5,19 +5,27 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetWidgetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public class CUnitAttackMissile extends CUnitAttack { + private static CAttackDamageFlags ATTACK_FLAGS = new CAttackDamageFlags(true); private float projectileArc; private String projectileArt; private boolean projectileHomingEnabled; private int projectileSpeed; + protected CDamageFlags damageFlags; + public CUnitAttackMissile(final float animationBackswingPoint, final float animationDamagePoint, final CAttackType attackType, final float cooldownTime, final int damageBase, final int damageDice, final int damageSidesPerDie, final int damageUpgradeAmount, final int range, final float rangeMotionBuffer, @@ -31,6 +39,8 @@ public CUnitAttackMissile(final float animationBackswingPoint, final float anima this.projectileArt = projectileArt; this.projectileHomingEnabled = projectileHomingEnabled; this.projectileSpeed = projectileSpeed; + this.damageFlags = ATTACK_FLAGS; + initialSettings(); } @Override @@ -42,30 +52,18 @@ public CUnitAttack copy() { } public float getProjectileArc() { - if (this.attackReplacement != null) { - return this.attackReplacement.getProjectileArc(); - } return this.projectileArc; } public String getProjectileArt() { - if (this.attackReplacement != null) { - return this.attackReplacement.getProjectileArt(); - } return this.projectileArt; } public boolean isProjectileHomingEnabled() { - if (this.attackReplacement != null) { - return this.attackReplacement.isProjectileHomingEnabled(); - } return this.projectileHomingEnabled; } public int getProjectileSpeed() { - if (this.attackReplacement != null) { - return this.attackReplacement.getProjectileSpeed(); - } return this.projectileSpeed; } @@ -85,23 +83,36 @@ public void setProjectileSpeed(final int projectileSpeed) { this.projectileSpeed = projectileSpeed; } + public CDamageFlags getBaseAttackDamageFlags() { + return ATTACK_FLAGS; + } + @Override public void launch(final CSimulation simulation, final CUnit unit, final AbilityTarget target, final float damage, final CUnitAttackListener attackListener) { attackListener.onLaunch(); simulation.createProjectile(unit, unit.getX(), unit.getY(), (float) Math.toRadians(unit.getFacing()), this, - target, damage, 0, attackListener); + target, damage, 0, attackListener, this.attackModifier); } public void doDamage(final CSimulation cSimulation, final CUnit source, final AbilityTarget target, final float damage, final float x, final float y, final int bounceIndex, - final CUnitAttackListener attackListener) { + final CUnitAttackListener attackListener, final CUnitAttackSettings settings) { final CWidget widget = target.visit(AbilityTargetWidgetVisitor.INSTANCE); if (widget != null) { - CUnitAttackPreDamageListenerDamageModResult modDamage = runPreDamageListeners(cSimulation, source, target, damage); - float damageDealt = widget.damage(cSimulation, source, true, true, getAttackType(), getWeaponType().getDamageType(), getWeaponSound(), modDamage.computeFinalDamage(), modDamage.getBonusDamage()); - runPostDamageListeners(cSimulation, source, target, damageDealt); + CDamageCalculation modDamage = runPreDamageListeners(cSimulation, source, target, + target.visit(AbilityTargetVisitor.POINT) != null ? target.visit(AbilityTargetVisitor.POINT) + : new AbilityPointTarget(x, y), + damage, settings); + widget.damage(cSimulation, modDamage); + runPostDamageListeners(cSimulation, target, modDamage, settings); attackListener.onHit(target, damage); } } + + public CUnitAttackSettings initialSettings() { + this.attackModifier = new CUnitAttackSettings(this.projectileArc, this.projectileArt, + this.projectileHomingEnabled, this.projectileSpeed); + return this.attackModifier; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileBounce.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileBounce.java index 03fe33cd7..a41e06e93 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileBounce.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileBounce.java @@ -12,7 +12,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.util.BooleanAbilityTargetCheckReceiver; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public class CUnitAttackMissileBounce extends CUnitAttackMissile { private float damageLossFactor; @@ -35,6 +35,7 @@ public CUnitAttackMissileBounce(final float animationBackswingPoint, final float this.maximumNumberOfTargets = maximumNumberOfTargets; this.areaOfEffectFullDamage = areaOfEffectFullDamage; this.areaOfEffectTargets = areaOfEffectTargets; + initialSettings(); } @Override @@ -66,14 +67,14 @@ public void setMaximumNumberOfTargets(final int maximumNumberOfTargets) { @Override public void doDamage(final CSimulation cSimulation, final CUnit source, final AbilityTarget target, final float damage, final float x, final float y, final int bounceIndex, - final CUnitAttackListener attackListener) { - super.doDamage(cSimulation, source, target, damage, x, y, bounceIndex, attackListener); + final CUnitAttackListener attackListener, final CUnitAttackSettings settings) { + super.doDamage(cSimulation, source, target, damage, x, y, bounceIndex, attackListener, settings); final CWidget widget = target.visit(AbilityTargetWidgetVisitor.INSTANCE); if (widget != null) { final int nextBounceIndex = bounceIndex + 1; if (nextBounceIndex != this.maximumNumberOfTargets) { BounceMissileConsumer.INSTANCE.nextBounce(cSimulation, source, widget, this, x, y, damage, - nextBounceIndex, attackListener); + nextBounceIndex, attackListener, settings); } } } @@ -91,10 +92,11 @@ private static final class BounceMissileConsumer implements CUnitEnumFunction { private int bounceIndex; private CUnitAttackListener attackListener; private boolean launched = false; + private CUnitAttackSettings settings; public void nextBounce(final CSimulation simulation, final CUnit source, final CWidget target, final CUnitAttackMissileBounce attack, final float x, final float y, final float damage, - final int bounceIndex, final CUnitAttackListener attackListener) { + final int bounceIndex, final CUnitAttackListener attackListener, CUnitAttackSettings settings) { this.simulation = simulation; this.source = source; this.target = target; @@ -105,6 +107,7 @@ public void nextBounce(final CSimulation simulation, final CUnit source, final C this.bounceIndex = bounceIndex; this.attackListener = attackListener; this.launched = false; + this.settings = settings; final float doubleMaxArea = attack.areaOfEffectFullDamage + (this.simulation.getGameplayConstants().getCloseEnoughRange() * 2); final float maxArea = doubleMaxArea / 2; @@ -126,7 +129,7 @@ public boolean call(final CUnit enumUnit) { final float dy = enumUnit.getY() - this.y; final float angle = (float) Math.atan2(dy, dx); this.simulation.createProjectile(this.source, this.x, this.y, angle, this.attack, enumUnit, - this.damage * (1.0f - this.attack.damageLossFactor), this.bounceIndex, this.attackListener); + this.damage * (1.0f - this.attack.damageLossFactor), this.bounceIndex, this.attackListener, this.settings); this.launched = true; return true; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileLine.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileLine.java index bd95e8ab7..43ee5bce7 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileLine.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileLine.java @@ -2,13 +2,16 @@ import java.util.EnumSet; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public class CUnitAttackMissileLine extends CUnitAttackMissile { private float damageSpillDistance; private float damageSpillRadius; + private boolean artillery; public CUnitAttackMissileLine(final float animationBackswingPoint, final float animationDamagePoint, final CAttackType attackType, final float cooldownTime, final int damageBase, final int damageDice, @@ -16,12 +19,18 @@ public CUnitAttackMissileLine(final float animationBackswingPoint, final float a final boolean showUI, final EnumSet targetsAllowed, final String weaponSound, final CWeaponType weaponType, final float projectileArc, final String projectileArt, final boolean projectileHomingEnabled, final int projectileSpeed, final float damageSpillDistance, - final float damageSpillRadius) { + final float damageSpillRadius, final boolean isArtillery) { super(animationBackswingPoint, animationDamagePoint, attackType, cooldownTime, damageBase, damageDice, damageSidesPerDie, damageUpgradeAmount, range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, - weaponType, projectileArc, projectileArt, projectileHomingEnabled, projectileSpeed); + weaponType, projectileArc, projectileArt, isArtillery ? false : projectileHomingEnabled, projectileSpeed); this.damageSpillDistance = damageSpillDistance; this.damageSpillRadius = damageSpillRadius; + this.artillery = isArtillery; + if (isArtillery) { + this.damageFlags = new CAttackDamageFlags(true); + this.damageFlags.setExplode(true); + } + initialSettings(); } @Override @@ -30,7 +39,7 @@ public CUnitAttack copy() { getCooldownTime(), getDamageBase(), getDamageDice(), getDamageSidesPerDie(), getDamageUpgradeAmount(), getRange(), getRangeMotionBuffer(), isShowUI(), getTargetsAllowed(), getWeaponSound(), getWeaponType(), getProjectileArc(), getProjectileArt(), isProjectileHomingEnabled(), getProjectileSpeed(), - this.damageSpillDistance, this.damageSpillRadius); + this.damageSpillDistance, this.damageSpillRadius, this.artillery); } public float getDamageSpillDistance() { @@ -49,4 +58,17 @@ public void setDamageSpillRadius(final float damageSpillRadius) { this.damageSpillRadius = damageSpillRadius; } + public Boolean isArtillery() { + return this.artillery; + } + + public CUnitAttackSettings initialSettings() { + this.attackModifier = super.initialSettings(); + if (this.artillery) { + this.attackModifier.setImpactZ(0f); + this.attackModifier.setApplyEffectsOnMiss(true); + } + return this.attackModifier; + } + } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileSplash.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileSplash.java index ba850069e..a7d7da577 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileSplash.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackMissileSplash.java @@ -9,12 +9,16 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetWidgetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public class CUnitAttackMissileSplash extends CUnitAttackMissile { private int areaOfEffectFullDamage; @@ -23,6 +27,7 @@ public class CUnitAttackMissileSplash extends CUnitAttackMissile { private EnumSet areaOfEffectTargets; private float damageFactorMedium; private float damageFactorSmall; + private boolean artillery; public CUnitAttackMissileSplash(final float animationBackswingPoint, final float animationDamagePoint, final CAttackType attackType, final float cooldownTime, final int damageBase, final int damageDice, @@ -32,16 +37,23 @@ public CUnitAttackMissileSplash(final float animationBackswingPoint, final float final boolean projectileHomingEnabled, final int projectileSpeed, final int areaOfEffectFullDamage, final int areaOfEffectMediumDamage, final int areaOfEffectSmallDamage, final EnumSet areaOfEffectTargets, final float damageFactorMedium, - final float damageFactorSmall) { + final float damageFactorSmall, final boolean isArtillery) { super(animationBackswingPoint, animationDamagePoint, attackType, cooldownTime, damageBase, damageDice, damageSidesPerDie, damageUpgradeAmount, range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, - weaponType, projectileArc, projectileArt, projectileHomingEnabled, projectileSpeed); + weaponType, projectileArc, projectileArt, isArtillery ? false : projectileHomingEnabled, + projectileSpeed); this.areaOfEffectFullDamage = areaOfEffectFullDamage; this.areaOfEffectMediumDamage = areaOfEffectMediumDamage; this.areaOfEffectSmallDamage = areaOfEffectSmallDamage; this.areaOfEffectTargets = areaOfEffectTargets; this.damageFactorMedium = damageFactorMedium; this.damageFactorSmall = damageFactorSmall; + this.artillery = isArtillery; + if (isArtillery) { + this.damageFlags = new CAttackDamageFlags(true); + this.damageFlags.setExplode(true); + } + initialSettings(); } @Override @@ -51,7 +63,7 @@ public CUnitAttack copy() { getRange(), getRangeMotionBuffer(), isShowUI(), getTargetsAllowed(), getWeaponSound(), getWeaponType(), getProjectileArc(), getProjectileArt(), isProjectileHomingEnabled(), getProjectileSpeed(), this.areaOfEffectFullDamage, this.areaOfEffectMediumDamage, this.areaOfEffectSmallDamage, - this.areaOfEffectTargets, this.damageFactorMedium, this.damageFactorSmall); + this.areaOfEffectTargets, this.damageFactorMedium, this.damageFactorSmall, this.artillery); } @Override @@ -82,6 +94,10 @@ public float getDamageFactorMedium() { public float getDamageFactorSmall() { return this.damageFactorSmall; } + + public boolean isArtillery() { + return this.artillery; + } public void setAreaOfEffectFullDamage(final int areaOfEffectFullDamage) { this.areaOfEffectFullDamage = areaOfEffectFullDamage; @@ -110,9 +126,10 @@ public void setDamageFactorSmall(final float damageFactorSmall) { @Override public void doDamage(final CSimulation cSimulation, final CUnit source, final AbilityTarget target, final float damage, final float x, final float y, final int bounceIndex, - final CUnitAttackListener attackListener) { - SplashDamageConsumer.INSTANCE.doDamage(cSimulation, source, target, this, x, y, damage, attackListener); - if (!SplashDamageConsumer.INSTANCE.hitTarget) { + final CUnitAttackListener attackListener, final CUnitAttackSettings settings) { + SplashDamageConsumer.INSTANCE.doDamage(cSimulation, source, target, this, x, y, damage, attackListener, + settings); + if (!SplashDamageConsumer.INSTANCE.hitTarget && this.isProjectileHomingEnabled()) { final CWidget widget = target.visit(AbilityTargetWidgetVisitor.INSTANCE); if (widget != null) { SplashDamageConsumer.INSTANCE.damageTarget(widget); @@ -124,45 +141,51 @@ private static final class SplashDamageConsumer implements CUnitEnumFunction, CD private static final SplashDamageConsumer INSTANCE = new SplashDamageConsumer(); private final Rectangle rect = new Rectangle(); private CUnitAttackMissileSplash attack; + private CUnitAttackSettings settings; private CSimulation simulation; private CUnit source; private AbilityTarget target; private float x; private float y; - private float damage; - private float bonusDamage; + private CDamageCalculation damage; private CUnitAttackListener attackListener; private boolean hitTarget; public void doDamage(final CSimulation simulation, final CUnit source, final AbilityTarget target, final CUnitAttackMissileSplash attack, final float x, final float y, final float damage, - final CUnitAttackListener attackListener) { + final CUnitAttackListener attackListener, final CUnitAttackSettings settings) { this.simulation = simulation; this.source = source; this.target = target; this.attack = attack; + this.settings = settings; this.x = x; this.y = y; - this.damage = damage; this.attackListener = attackListener; this.hitTarget = false; - final float doubleMaxArea = Math.max(Math.max(attack.areaOfEffectFullDamage, attack.areaOfEffectMediumDamage), attack.areaOfEffectSmallDamage) * 2; + final float doubleMaxArea = Math.max( + Math.max(settings.getAreaOfEffectFullDamage(), settings.getAreaOfEffectMediumDamage()), + settings.getAreaOfEffectSmallDamage()) * 2; final float maxArea = doubleMaxArea / 2; this.rect.set(x - maxArea, y - maxArea, doubleMaxArea, doubleMaxArea); - CUnitAttackPreDamageListenerDamageModResult result = this.attack.runPreDamageListeners(simulation, this.source, this.target, this.damage); - this.damage = result.computeFinalDamage(); - this.bonusDamage = result.getBonusDamage(); + this.damage = this.attack.runPreDamageListeners(simulation, + this.source, this.target, + this.target.visit(AbilityTargetVisitor.POINT) != null + ? this.target.visit(AbilityTargetVisitor.POINT) + : new AbilityPointTarget(x, y), + damage, settings); simulation.getWorldCollision().enumUnitsInRect(this.rect, this); simulation.getWorldCollision().enumDestructablesInRect(this.rect, this); } @Override public boolean call(final CUnit enumUnit) { - if (enumUnit != this.source && enumUnit.canBeTargetedBy(this.simulation, this.source, this.attack.areaOfEffectTargets)) { - float damageDealt = damageTarget(enumUnit); + if (enumUnit != this.source + && enumUnit.canBeTargetedBy(this.simulation, this.source, this.attack.areaOfEffectTargets)) { + damageTarget(enumUnit); if (enumUnit == this.target) { this.hitTarget = true; - this.attack.runPostDamageListeners(simulation, this.source, target, damageDealt); + this.attack.runPostDamageListeners(simulation, target, this.damage, settings); } } return false; @@ -171,34 +194,45 @@ public boolean call(final CUnit enumUnit) { @Override public boolean call(final CDestructable enumDestructable) { if (enumDestructable.canBeTargetedBy(this.simulation, this.source, this.attack.areaOfEffectTargets)) { - float damageDealt = damageTarget(enumDestructable); + damageTarget(enumDestructable); if (enumDestructable == this.target) { this.hitTarget = true; - this.attack.runPostDamageListeners(simulation, this.source, target, damageDealt); + this.attack.runPostDamageListeners(simulation, target, this.damage, settings); } } return false; } - public float damageTarget(final CWidget enumUnit) { - float damageDealt = this.damage; + public void damageTarget(final CWidget enumUnit) { + float damageDealt = 0; final double distance = enumUnit.distance(this.x, this.y); - if (distance <= (this.attack.areaOfEffectFullDamage)) { - damageDealt = enumUnit.damage(this.simulation, this.source, true, true, this.attack.getAttackType(), - this.attack.getWeaponType().getDamageType(), this.attack.getWeaponSound(), this.damage, this.bonusDamage); - this.attackListener.onHit(enumUnit, this.damage + this.bonusDamage); - } else if (distance <= (this.attack.areaOfEffectMediumDamage)) { - damageDealt = enumUnit.damage(this.simulation, this.source, true, true, this.attack.getAttackType(), - this.attack.getWeaponType().getDamageType(), this.attack.getWeaponSound(), - this.damage * this.attack.damageFactorMedium, this.bonusDamage * this.attack.damageFactorMedium); - this.attackListener.onHit(enumUnit, this.damage + this.bonusDamage); - } else if (distance <= (this.attack.areaOfEffectSmallDamage)) { - damageDealt = enumUnit.damage(this.simulation, this.source, true, true, this.attack.getAttackType(), - this.attack.getWeaponType().getDamageType(), this.attack.getWeaponSound(), - this.damage * this.attack.damageFactorSmall, this.bonusDamage * this.attack.damageFactorSmall); - this.attackListener.onHit(enumUnit, this.damage + this.bonusDamage); + if (distance <= (this.settings.getAreaOfEffectFullDamage())) { + damageDealt = enumUnit.damage(this.simulation, this.damage); + this.attackListener.onHit(enumUnit, damageDealt); + } else if (distance <= (this.settings.getAreaOfEffectMediumDamage())) { + this.damage.startSplash(this.settings.getDamageFactorMedium()); + damageDealt = enumUnit.damage(this.simulation, this.damage); + this.attackListener.onHit(enumUnit, damageDealt); + this.damage.endSplash(); + } else if (distance <= (this.settings.getDamageFactorSmall())) { + this.damage.startSplash(this.settings.getDamageFactorMedium()); + damageDealt = enumUnit.damage(this.simulation, this.damage); + this.attackListener.onHit(enumUnit, damageDealt); + this.damage.endSplash(); } - return damageDealt; } } + + @Override + public CUnitAttackSettings initialSettings() { + this.attackModifier = new CUnitAttackSettings(this.getProjectileArc(), this.getProjectileArt(), + this.isProjectileHomingEnabled(), this.getProjectileSpeed(), this.areaOfEffectFullDamage, + this.areaOfEffectMediumDamage, this.areaOfEffectSmallDamage, this.damageFactorMedium, + this.damageFactorSmall); + this.attackModifier.setApplyEffectsOnMiss(true); + if (this.artillery) { + this.attackModifier.setImpactZ(0f); + } + return this.attackModifier; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackNormal.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackNormal.java index 06c16fd7b..f322317f4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackNormal.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/CUnitAttackNormal.java @@ -5,14 +5,19 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetWidgetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListenerDamageModResult; public class CUnitAttackNormal extends CUnitAttack { + private static CAttackDamageFlags ATTACK_FLAGS = new CAttackDamageFlags(false); public CUnitAttackNormal(final float animationBackswingPoint, final float animationDamagePoint, final CAttackType attackType, final float cooldownTime, final int damageBase, final int damageDice, @@ -31,16 +36,22 @@ public CUnitAttack copy() { getRange(), getRangeMotionBuffer(), isShowUI(), getTargetsAllowed(), getWeaponSound(), getWeaponType()); } + public CDamageFlags getBaseAttackDamageFlags() { + return ATTACK_FLAGS; + } + @Override public void launch(final CSimulation simulation, final CUnit unit, final AbilityTarget target, final float damage, final CUnitAttackListener attackListener) { attackListener.onLaunch(); final CWidget widget = target.visit(AbilityTargetWidgetVisitor.INSTANCE); if (widget != null) { - CUnitAttackPreDamageListenerDamageModResult modDamage = runPreDamageListeners(simulation, unit, target, damage); - float damageDealt = widget.damage(simulation, unit, true, false, getAttackType(), getWeaponType().getDamageType(), - modDamage.isMiss() ? null : getWeaponSound(), modDamage.computeFinalDamage(), modDamage.getBonusDamage()); - runPostDamageListeners(simulation, unit, target, damageDealt); + CDamageCalculation modDamage = runPreDamageListeners(simulation, unit, target, + target.visit(AbilityTargetVisitor.POINT) != null ? target.visit(AbilityTargetVisitor.POINT) + : new AbilityPointTarget(target.getX(), target.getY()), + damage, this.attackModifier); + widget.damage(simulation, modDamage); + runPostDamageListeners(simulation, target, modDamage, this.attackModifier); attackListener.onHit(target, damage); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenListener.java index c576a30ac..cda3ee531 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenListener.java @@ -4,11 +4,13 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; public interface CUnitAttackDamageTakenListener { public static final EnumSet ENEMY_TARGET = EnumSet.of(CTargetType.ENEMIES); - public void onDamage(final CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, CDamageType weaponType, float damage, float bonusDamage, float trueDamage); + public int getPriority(CSimulation simulation, CUnit target, CDamageCalculation damage); + + public void onDamage(CSimulation simulation, CUnit target, CDamageCalculation damage); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenModificationListener.java index c85c06bba..56d7ff3f0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenModificationListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenModificationListener.java @@ -2,9 +2,10 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; public interface CUnitAttackDamageTakenModificationListener { - public CUnitAttackDamageTakenModificationListenerDamageModResult onDamage(final CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, CAttackType attackType, CDamageType damageType, CUnitAttackDamageTakenModificationListenerDamageModResult previousDamage); + public int getPriority(CSimulation simulation, CUnit cUnit, CDamageCalculation damage); + + public void onDamage(CSimulation simulation, CUnit cUnit, CDamageCalculation damage); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenModificationListenerDamageModResult.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenModificationListenerDamageModResult.java deleted file mode 100644 index 6daf1c9f7..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackDamageTakenModificationListenerDamageModResult.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners; - -public class CUnitAttackDamageTakenModificationListenerDamageModResult { - private float baseDamage; - private float bonusDamage; - private float damageMultiplier; - - public CUnitAttackDamageTakenModificationListenerDamageModResult(float baseDamage, float bonusDamage) { - this.baseDamage = baseDamage; - this.bonusDamage = bonusDamage; - this.damageMultiplier = 1; - - } - - public float getBaseDamage() { - return baseDamage; - } - - public void setBaseDamage(float baseDamage) { - this.baseDamage = baseDamage; - } - - public float getBonusDamage() { - return bonusDamage; - } - - public void setBonusDamage(float bonusDamage) { - this.bonusDamage = bonusDamage; - } - - public void addBonusDamage(float bonusDamage) { - this.bonusDamage += bonusDamage; - } - - public float getDamageMultiplier() { - return damageMultiplier; - } - - public void setDamageMultiplier(float damageMultiplier) { - this.damageMultiplier = damageMultiplier; - } - - public void addDamageMultiplier(float damageMultiplier) { - this.damageMultiplier *= damageMultiplier; - } - - public float computeFinalDamage() { - return (baseDamage * damageMultiplier) + bonusDamage; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackEffectListenerStacking.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackEffectListenerStacking.java deleted file mode 100644 index 4d5bcb1ff..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackEffectListenerStacking.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners; - -public class CUnitAttackEffectListenerStacking { - private boolean allowStacking; - private boolean allowSamePriorityStacking; - - public CUnitAttackEffectListenerStacking() { - setAllowStacking(true); - setAllowSamePriorityStacking(true); - } - - public CUnitAttackEffectListenerStacking(boolean allowStacking) { - setAllowStacking(allowStacking); - setAllowSamePriorityStacking(true); - } - - public CUnitAttackEffectListenerStacking(boolean allowStacking, boolean allowSamePriorityStacking) { - setAllowStacking(allowStacking); - setAllowSamePriorityStacking(allowSamePriorityStacking); - } - - public boolean isAllowStacking() { - return allowStacking; - } - - public void setAllowStacking(boolean allowStacking) { - this.allowStacking = allowStacking; - } - - public boolean isAllowSamePriorityStacking() { - return allowSamePriorityStacking; - } - - public void setAllowSamePriorityStacking(boolean allowSamePriorityStacking) { - this.allowSamePriorityStacking = allowSamePriorityStacking; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackEvasionListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackEvasionListener.java index d2a2af439..aad02bb08 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackEvasionListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackEvasionListener.java @@ -2,8 +2,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; public interface CUnitAttackEvasionListener { - public boolean onAttack(final CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, CDamageType weaponType); + public boolean onAttack(CSimulation simulation, CUnit cUnit, CDamageCalculation damage); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackFinalDamageTakenModificationListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackFinalDamageTakenModificationListener.java deleted file mode 100644 index 31f3324ad..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackFinalDamageTakenModificationListener.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public interface CUnitAttackFinalDamageTakenModificationListener { - public float onDamage(final CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, CAttackType attackType, CDamageType damageType, float previousDamage); -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPostDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPostDamageListener.java index 1c0147a55..87caa8e26 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPostDamageListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPostDamageListener.java @@ -3,7 +3,11 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; public interface CUnitAttackPostDamageListener { - public void onHit(final CSimulation simulation, CUnit attacker, AbilityTarget target, float damage); + public int getPriority(CSimulation simulation, CUnit attacker, AbilityTarget target, CUnitAttack cUnitAttack); + + public void onHit(CSimulation simulation, AbilityTarget target, CUnitAttack cUnitAttack, CDamageCalculation damage); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPreDamageListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPreDamageListener.java index 1642642ee..99e483a3f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPreDamageListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPreDamageListener.java @@ -1,12 +1,14 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public interface CUnitAttackPreDamageListener { - public CUnitAttackEffectListenerStacking onAttack(final CSimulation simulation, CUnit attacker, AbilityTarget target, CWeaponType weaponType, CAttackType attackType, CDamageType damageType, CUnitAttackPreDamageListenerDamageModResult damageResult); + public void onAttack(CSimulation simulation, AbilityTarget target, + AbilityPointTarget attackImpactLocation, CUnitAttack cUnitAttack, CUnitAttackSettings settings, + CDamageCalculation calc); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPreDamageListenerDamageModResult.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPreDamageListenerDamageModResult.java deleted file mode 100644 index d61c90781..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitAttackPreDamageListenerDamageModResult.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners; - -public class CUnitAttackPreDamageListenerDamageModResult { - private float baseDamage; - private float bonusDamage; - private float damageMultiplier; - - private boolean miss = false; - - private boolean unlockBonus; - private boolean unlockMultiplier; - - public CUnitAttackPreDamageListenerDamageModResult(float baseDamage) { - this.baseDamage = baseDamage; - this.bonusDamage = 0; - this.damageMultiplier = 1; - - unlockBonus = true; - unlockMultiplier = true; - } - - public float getBaseDamage() { - return baseDamage; - } - - public void setBaseDamage(float baseDamage) { - this.baseDamage = baseDamage; - } - - public float getBonusDamage() { - return bonusDamage; - } - - public void setBonusDamage(float bonusDamage) { - if (unlockBonus) { - this.bonusDamage = bonusDamage; - } - } - - public void addBonusDamage(float bonusDamage) { - if (unlockBonus) { - this.bonusDamage += bonusDamage; - } - } - - public float getDamageMultiplier() { - return damageMultiplier; - } - - public void setDamageMultiplier(float damageMultiplier) { - if (unlockMultiplier) { - this.damageMultiplier = damageMultiplier; - } - } - - public void addDamageMultiplier(float damageMultiplier) { - if (unlockMultiplier) { - this.damageMultiplier *= damageMultiplier; - } - } - - public void lockBonus() { - unlockBonus = false; - unlockMultiplier = false; - } - - public void lock() { - unlockBonus = false; - unlockMultiplier = false; - } - - public float computeFinalDamage() { - return (baseDamage * damageMultiplier); - } - - public boolean isMiss() { - return miss; - } - - public void setMiss(boolean miss) { - this.miss = miss; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultAccuracyCheckListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultAccuracyCheckListener.java index 18e663e18..ad432bee6 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultAccuracyCheckListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultAccuracyCheckListener.java @@ -4,35 +4,39 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CWeaponType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; + +public class CUnitDefaultAccuracyCheckListener implements CUnitAttackPreDamageListener { -public class CUnitDefaultAccuracyCheckListener implements CUnitAttackPreDamageListener{ - public CUnitDefaultAccuracyCheckListener() { super(); } @Override - public CUnitAttackEffectListenerStacking onAttack(CSimulation simulation, CUnit attacker, AbilityTarget target, CWeaponType weaponType, CAttackType attackType, CDamageType damageType, - CUnitAttackPreDamageListenerDamageModResult damageResult) { + public void onAttack(CSimulation simulation, AbilityTarget target, + AbilityPointTarget attackImpactLocation, CUnitAttack attack, CUnitAttackSettings settings, + CDamageCalculation damageResult) { boolean miss = false; - if (target instanceof CUnit) { - if (simulation.getTerrainHeight(attacker.getX(), attacker.getY()) < simulation.getTerrainHeight(target.getX(), target.getY())) { + if (target instanceof CUnit && damageResult.getSource() != null) { + if (simulation.getTerrainHeight(damageResult.getSource().getX(), damageResult.getSource().getY()) < simulation + .getTerrainHeight(target.getX(), target.getY())) { Random random = simulation.getSeededRandom(); if (random.nextFloat(1f) < simulation.getGameplayConstants().getChanceToMiss()) { miss = true; } } - miss = miss || ((CUnit) target).checkForMiss(simulation, attacker, true, miss, null, null, damageResult.getBaseDamage(), damageResult.getBonusDamage()); - + miss = miss || ((CUnit) target).checkForMiss(simulation, damageResult); } if (miss) { damageResult.setMiss(true); - return new CUnitAttackEffectListenerStacking(false, true); + if (!settings.isApplyEffectsOnMiss()) { + damageResult.preventOtherModificationsOfOtherPriorities(); + return; + } } - return new CUnitAttackEffectListenerStacking(); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultEtherealDamageModListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultEtherealDamageModListener.java index 79ec42ab9..338568d2f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultEtherealDamageModListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultEtherealDamageModListener.java @@ -2,32 +2,22 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; public class CUnitDefaultEtherealDamageModListener implements CUnitAttackDamageTakenModificationListener { public static CUnitDefaultEtherealDamageModListener INSTANCE = new CUnitDefaultEtherealDamageModListener(); @Override - public CUnitAttackDamageTakenModificationListenerDamageModResult onDamage(CSimulation game, CUnit attacker, - CUnit target, boolean isAttack, boolean isRanged, CAttackType attackType, CDamageType damageType, - CUnitAttackDamageTakenModificationListenerDamageModResult previousDamage) { - boolean allied = game.getPlayer(attacker.getPlayerIndex()).hasAlliance(target.getPlayerIndex(), CAllianceType.PASSIVE); - if (!allied || (allied && game.getGameplayConstants().isEtherealDamageBonusAlly())) { - if (attackType == CAttackType.MAGIC) { - previousDamage.addDamageMultiplier(game.getGameplayConstants().getEtherealDamageBonusMagic()); - } - if (attackType == CAttackType.SPELLS) { - previousDamage.addDamageMultiplier(game.getGameplayConstants().getEtherealDamageBonusSpells()); - } - } - if (damageType == CDamageType.NORMAL && attackType != CAttackType.MAGIC) { - previousDamage.setBaseDamage(0); - previousDamage.setBonusDamage(0); - previousDamage.setDamageMultiplier(0); + public int getPriority(CSimulation simulation, CUnit target, CDamageCalculation damage) { + return 0; + } + + @Override + public void onDamage(CSimulation game, CUnit target, CDamageCalculation damage) { + if (damage.getSource() == null || game.getGameplayConstants().isEtherealDamageBonusAlly() || !game + .getPlayer(damage.getSource().getPlayerIndex()).hasAlliance(target.getPlayerIndex(), CAllianceType.PASSIVE)) { + damage.addDamageMultiplier(game.getGameplayConstants().getEtherealDamageBonus()[damage.getAttackType().ordinal()]); } - - return previousDamage; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultLifestealListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultLifestealListener.java index 21a8a24f9..202f69b4d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultLifestealListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultLifestealListener.java @@ -4,6 +4,8 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CAllianceType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; @@ -15,17 +17,25 @@ public CUnitDefaultLifestealListener(float amount) { this.amount = amount; } - public void onHit(final CSimulation simulation, CUnit attacker, AbilityTarget target, float damage) { + @Override + public void onHit(CSimulation simulation, AbilityTarget target, CUnitAttack cUnitAttack, + CDamageCalculation damage) { CUnit tarU = target.visit(AbilityTargetVisitor.UNIT); - if (tarU != null && !tarU.isBuilding() && !tarU.isUnitType(CUnitTypeJass.MECHANICAL) - && !simulation.getPlayer(attacker.getPlayerIndex()).hasAlliance(tarU.getPlayerIndex(), + if (damage.getSource() != null && tarU != null && !tarU.isBuilding() + && !tarU.isUnitType(CUnitTypeJass.MECHANICAL) + && !simulation.getPlayer(damage.getSource().getPlayerIndex()).hasAlliance(tarU.getPlayerIndex(), CAllianceType.PASSIVE) && (!simulation.getGameplayConstants().isMagicImmuneResistsLeech() || !tarU.isUnitType(CUnitTypeJass.MAGIC_IMMUNE))) { - attacker.heal(simulation, damage * this.amount); + damage.getSource().heal(simulation, damage.computeFinalDamage(simulation, tarU) * this.amount); } } + @Override + public int getPriority(CSimulation simulation, CUnit attacker, AbilityTarget target, CUnitAttack cUnitAttack) { + return 0; + } + public float getAmount() { return amount; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultMagicImmuneDamageModListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultMagicImmuneDamageModListener.java deleted file mode 100644 index ac7765344..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultMagicImmuneDamageModListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; - -public class CUnitDefaultMagicImmuneDamageModListener implements CUnitAttackFinalDamageTakenModificationListener { - public static CUnitDefaultMagicImmuneDamageModListener INSTANCE = new CUnitDefaultMagicImmuneDamageModListener(); - - @Override - public float onDamage(CSimulation game, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, - CAttackType attackType, CDamageType damageType, float previousDamage) { - if ((damageType != CDamageType.NORMAL && (damageType != CDamageType.UNIVERSAL && game.getGameplayConstants().isMagicImmuneResistsUltimates()) - && attackType == CAttackType.SPELLS) - || (attackType == CAttackType.MAGIC && game.getGameplayConstants().isMagicImmuneResistsDamage())) { - return 0; - } - - return previousDamage; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultSleepListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultSleepListener.java index d3a956b7c..a1ad5de21 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultSleepListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultSleepListener.java @@ -2,19 +2,26 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.StateModBuffType; public class CUnitDefaultSleepListener implements CUnitAttackDamageTakenListener { public static CUnitDefaultSleepListener INSTANCE = new CUnitDefaultSleepListener(); - - public CUnitDefaultSleepListener () { + + public CUnitDefaultSleepListener() { } - + + @Override + public int getPriority(CSimulation simulation, CUnit target, CDamageCalculation damage) { + return 0; + } + @Override - public void onDamage(final CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, CDamageType damageType, float damage, float bonusDamage, float trueDamage) { - target.removeAllStateModBuffs(StateModBuffType.SLEEPING); - target.computeUnitState(simulation, StateModBuffType.SLEEPING); + public void onDamage(CSimulation simulation, CUnit target, CDamageCalculation damage) { + if (damage.computeFinalDamage(simulation, target) > 0) { + target.removeAllStateModBuffs(StateModBuffType.SLEEPING); + target.computeUnitState(simulation, StateModBuffType.SLEEPING); + } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultThornsListener.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultThornsListener.java index f5cdd8873..a1059be73 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultThornsListener.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/listeners/CUnitDefaultThornsListener.java @@ -3,11 +3,15 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageCalculation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDamageFlags; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CSpellDamageFlags; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CDamageType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CWeaponSoundTypeJass; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.CUnitTypeJass; public class CUnitDefaultThornsListener implements CUnitAttackDamageTakenListener { + private final static CDamageFlags DAMAGE_FLAGS = new CSpellDamageFlags(); private boolean percentage; private float amount; @@ -18,16 +22,24 @@ public CUnitDefaultThornsListener(boolean percentage, float amount) { } @Override - public void onDamage(final CSimulation simulation, CUnit attacker, CUnit target, boolean isAttack, boolean isRanged, - CDamageType damageType, float damage, float bonusDamage, float trueDamage) { - if (damageType == CDamageType.NORMAL && !isRanged && target.canBeTargetedBy(simulation, attacker, ENEMY_TARGET) + public int getPriority(CSimulation simulation, CUnit target, CDamageCalculation damage) { + return 0; + } + + @Override + public void onDamage(CSimulation simulation, CUnit target, CDamageCalculation damage) { + if (damage.getSource() != null && damage.getPrimaryDamageType() == CDamageType.NORMAL + && !damage.getPrimaryDamageFlags().isRanged() + && target.canBeTargetedBy(simulation, damage.getSource(), ENEMY_TARGET) + && damage.computeRawTotalDamage() > 0 && (!simulation.getGameplayConstants().isMagicImmuneResistsThorns() - || !attacker.isUnitType(CUnitTypeJass.MAGIC_IMMUNE))) { + || !damage.getSource().isUnitType(CUnitTypeJass.MAGIC_IMMUNE))) { float thornsAmount = amount; if (percentage) { - thornsAmount *= damage; + thornsAmount *= damage.getPrimaryAmount(); + thornsAmount = Math.max(thornsAmount, 1); } - attacker.damage(simulation, target, false, true, CAttackType.SPELLS, CDamageType.DEFENSIVE, + damage.getSource().damage(simulation, target, DAMAGE_FLAGS, CAttackType.SPELLS, CDamageType.DEFENSIVE, CWeaponSoundTypeJass.WHOKNOWS.name(), thornsAmount); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackModifier.java new file mode 100644 index 000000000..9668bd4f9 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackModifier.java @@ -0,0 +1,22 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; + +public interface CUnitAttackModifier { + + public int getPriority(CSimulation simulation, CUnit source, AbilityTarget target, CUnitAttack attack); + + public boolean checkPreLaunchApplication(CSimulation simulation, CUnit source, AbilityTarget target, CUnitAttack attack); + + public void applyPreLaunchModification(CSimulation simulation, CUnit unit, AbilityTarget target, + CUnitAttack unitAttack, CUnitAttackSettings settings, CUnitPriorityLoopData loop); + + public boolean checkApplication(CSimulation simulation, CUnit source, AbilityTarget target, CUnitAttack attack); + + public void applyModification(CSimulation simulation, CUnit source, AbilityTarget target, CUnitAttack attack, + CUnitAttackSettings settings, CUnitPriorityLoopData loop); + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackReplacementEffect.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackReplacementEffect.java deleted file mode 100644 index f9ca8125d..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackReplacementEffect.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement; - -import java.util.List; - -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListener; - -public class CUnitAttackReplacementEffect { - - public List getPreDamageListeners() { - return null; - } - - public float getProjectileArc() { - // TODO Auto-generated method stub - return 0; - } - - public boolean isProjectileHomingEnabled() { - // TODO Auto-generated method stub - return false; - } - - public int getProjectileSpeed() { - // TODO Auto-generated method stub - return 0; - } - - public String getProjectileArt() { - // TODO Auto-generated method stub - return null; - } - - public boolean chargeResources(CUnit unit) { - - return false; - } - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackReplacementPriority.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackReplacementPriority.java deleted file mode 100644 index 54f15f953..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackReplacementPriority.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement; - -public enum CUnitAttackReplacementPriority { - AUTOCAST(0), - HIGHPRI(1), - INVENTORY(2), - LOWPRIORITY(3), - NOPRIORITY(4); - - private int priority; - - CUnitAttackReplacementPriority(int priority) { - this.priority = priority; - } - public int getPriority() { - return priority; - } - public void setPriority(int priority) { - this.priority = priority; - } - - -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackSettings.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackSettings.java new file mode 100644 index 000000000..cc9379032 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitAttackSettings.java @@ -0,0 +1,228 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils; +import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPostDamageListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.listeners.CUnitAttackPreDamageListener; + +public class CUnitAttackSettings { + + private int areaOfEffectFullDamage; + private int areaOfEffectMediumDamage; + private int areaOfEffectSmallDamage; + private float damageFactorMedium; + private float damageFactorSmall; + private int projectileSpeed = 0; + private String projectileArt = ""; + private float projectileArc = 0; + private boolean isHomingEnabled = false; + private boolean isApplyEffectsOnMiss = false; + private Float z = null; + private Float impactZ = null; + private Float deathTime = null; + + private EnumSet animationNames = null; + + private List listeners = null; + private List postDamageListeners = null; + private float baseDamage; // This is a hack, as Barrage needs the damage early + + public CUnitAttackSettings(float projectileArc, String projectileArt, boolean projectileHomingEnabled, int projectileSpeed) { + this.projectileSpeed = projectileSpeed; + this.projectileArt = projectileArt; + this.projectileArc = projectileArc; + this.isHomingEnabled = projectileHomingEnabled; + } + + public CUnitAttackSettings() { + } + + public CUnitAttackSettings(float projectileArc, String projectileArt, boolean projectileHomingEnabled, + int projectileSpeed, int areaOfEffectFullDamage, int areaOfEffectMediumDamage, + int areaOfEffectSmallDamage, float damageFactorMedium, float damageFactorSmall) { + this.projectileSpeed = projectileSpeed; + this.projectileArt = projectileArt; + this.projectileArc = projectileArc; + this.isHomingEnabled = projectileHomingEnabled; + this.areaOfEffectFullDamage = areaOfEffectFullDamage; + this.areaOfEffectMediumDamage = areaOfEffectMediumDamage; + this.areaOfEffectSmallDamage = areaOfEffectSmallDamage; + this.damageFactorMedium = damageFactorMedium; + this.damageFactorSmall = damageFactorSmall; + } + + public List getPreDamageListeners() { + return listeners; + } + + public void addPreDamageListener(CUnitAttackPreDamageListener listener) { + if (this.listeners == null) { + this.listeners = new ArrayList<>(); + } + this.listeners.add(listener); + } + + public void removePreDamageListener(CUnitAttackPreDamageListener listener) { + if (this.listeners != null) { + this.listeners.remove(listener); + } + } + + public void setEmptyPreDamageListeners() { + this.listeners = new ArrayList<>(); + } + + public List getPostDamageListeners() { + return postDamageListeners; + } + + public void addPostDamageListener(CUnitAttackPostDamageListener listener) { + if (this.postDamageListeners == null) { + this.postDamageListeners = new ArrayList<>(); + } + this.postDamageListeners.add(0, listener); + } + + public void removePostDamageListener(CUnitAttackPostDamageListener listener) { + if (this.postDamageListeners != null) { + this.postDamageListeners.remove(listener); + } + } + + public float getProjectileArc() { + return projectileArc; + } + + public void setProjectileArc(float projectileArc) { + this.projectileArc = projectileArc ; + } + + public boolean isProjectileHomingEnabled() { + return isHomingEnabled; + } + + public void setProjectileHomingEnabled(boolean isHomingEnabled) { + this.isHomingEnabled = isHomingEnabled ; + } + + public boolean isApplyEffectsOnMiss() { + return isApplyEffectsOnMiss; + } + + public void setApplyEffectsOnMiss(boolean isApplyEffectsOnMiss) { + this.isApplyEffectsOnMiss = isApplyEffectsOnMiss; + } + + public int getProjectileSpeed() { + return projectileSpeed; + } + + public void setProjectileSpeed(int projectileSpeed) { + this.projectileSpeed = projectileSpeed ; + } + + public String getProjectileArt() { + return projectileArt; + } + + public void setProjectileArt(String projectileArt) { + this.projectileArt = projectileArt ; + } + + public int getAreaOfEffectFullDamage() { + return areaOfEffectFullDamage; + } + + public void setAreaOfEffectFullDamage(int areaOfEffectFullDamage) { + this.areaOfEffectFullDamage = areaOfEffectFullDamage; + } + + public int getAreaOfEffectMediumDamage() { + return areaOfEffectMediumDamage; + } + + public void setAreaOfEffectMediumDamage(int areaOfEffectMediumDamage) { + this.areaOfEffectMediumDamage = areaOfEffectMediumDamage; + } + + public int getAreaOfEffectSmallDamage() { + return areaOfEffectSmallDamage; + } + + public void setAreaOfEffectSmallDamage(int areaOfEffectSmallDamage) { + this.areaOfEffectSmallDamage = areaOfEffectSmallDamage; + } + + public float getDamageFactorMedium() { + return damageFactorMedium; + } + + public void setDamageFactorMedium(float damageFactorMedium) { + this.damageFactorMedium = damageFactorMedium; + } + + public float getDamageFactorSmall() { + return damageFactorSmall; + } + + public void setDamageFactorSmall(float damageFactorSmall) { + this.damageFactorSmall = damageFactorSmall; + } + + public EnumSet getAnimationNames() { + if (this.animationNames == null) { + return SequenceUtils.EMPTY; + } + return animationNames; + } + + public void addAnimationName(SecondaryTag animationName) { + if (this.animationNames == null) { + this.animationNames = EnumSet.of(animationName); + } else { + this.animationNames.add(animationName); + } + } + + public void removeAnimationName(SecondaryTag animationName) { + if (this.animationNames != null) { + this.animationNames.remove(animationName); + } + } + + public Float getZ() { + return this.z; + } + + public void setZ(Float z) { + this.z = z; + } + + public Float getImpactZ() { + return this.impactZ; + } + + public void setImpactZ(Float impactZ) { + this.impactZ = impactZ; + } + + public Float getArtDeathTime() { + return this.deathTime; + } + + public void setArtDeathTime(Float deathTime) { + this.deathTime = deathTime; + } + + public void setBaseDamage(int damage) { + this.baseDamage = damage; + } + + public float getBaseDamage() { + return this.baseDamage; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitPriorityLoopData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitPriorityLoopData.java new file mode 100644 index 000000000..baa67aca3 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/attacks/replacement/CUnitPriorityLoopData.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement; + +public class CUnitPriorityLoopData { + private boolean endLoop = false; + private boolean endLevel = false; + + public void startLoop(int i) { + this.endLevel = false; + } + + public void preventOtherModificationsWithSamePriority() { + this.endLevel = true; + } + + public void preventAllOtherModifications() { + this.endLevel = true; + this.endLoop = true; + } + + public boolean skipCurrentLevel() { + return this.endLevel; + } + + public boolean end() { + return this.endLoop; + } + + public void reset() { + this.endLevel = false; + this.endLoop = false; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileInstant.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileInstant.java index 14f71ea43..9a4d37881 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileInstant.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileInstant.java @@ -7,15 +7,18 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackInstant; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackListener; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public class CAttackProjectileInstant extends CAttackProjectile { CUnitAttackInstant attack; + private CUnitAttackSettings settings; public CAttackProjectileInstant(final float x, final float y, final AbilityTarget target, final CUnit source, final float damage, final CUnitAttackInstant unitAttack, - final CUnitAttackListener attackListener) { + final CUnitAttackListener attackListener, final CUnitAttackSettings settings) { super(x, y, Float.MAX_VALUE, target, source, damage, true, attackListener); this.attack = unitAttack; + this.settings = settings; } @Override public boolean update(final CSimulation game) { @@ -37,7 +40,7 @@ protected void onHitTarget(CSimulation game) { CUnit tarU = getTarget().visit(AbilityTargetVisitor.UNIT); if (tarU == null || tarU.checkForAttackProjReaction(game, getSource(), this)) { this.attack.doDamage(game, getSource(), getTarget(), this.damage, getX(), getY(), - this.attackListener); + this.attackListener, settings); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileMissile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileMissile.java index 09a063b7e..4d308e9b3 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileMissile.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CAttackProjectileMissile.java @@ -7,17 +7,20 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttack; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackMissile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; public class CAttackProjectileMissile extends CAttackProjectile { protected final CUnitAttackMissile unitAttack; protected final int bounceIndex; + private CUnitAttackSettings settings; public CAttackProjectileMissile(final float x, final float y, final float speed, final AbilityTarget target, final CUnit source, final float damage, final CUnitAttackMissile unitAttack, final int bounceIndex, - final CUnitAttackListener attackListener) { - super(x, y, speed, target, source, damage, unitAttack.isProjectileHomingEnabled(), attackListener); + final CUnitAttackListener attackListener, final CUnitAttackSettings settings) { + super(x, y, speed, target, source, damage, settings.isProjectileHomingEnabled(), attackListener); this.unitAttack = unitAttack; this.bounceIndex = bounceIndex; + this.settings = settings; } @Override @@ -25,7 +28,7 @@ protected void onHitTarget(CSimulation game) { CUnit tarU = getTarget().visit(AbilityTargetVisitor.UNIT); if (tarU == null || tarU.checkForAttackProjReaction(game, getSource(), this)) { this.unitAttack.doDamage(game, getSource(), getTarget(), this.damage, getX(), getY(), this.bounceIndex, - this.attackListener); + this.attackListener, this.settings); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CProjectile.java index 73f7054a1..6f4043c05 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CProjectile.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CProjectile.java @@ -22,7 +22,7 @@ public CProjectile(final float x, final float y, final float speed, final Abilit final boolean homingEnabled, final CUnit source) { this.x = x; this.y = y; - this.speed = speed; + this.speed = speed != 0 ? speed : 9999999; this.target = target; this.homingEnabled = homingEnabled; this.source = source; @@ -115,6 +115,9 @@ public final float getTargetY() { return this.initialTargetY; } } + public boolean isHomingEnabled() { + return this.homingEnabled; + } public boolean isReflected() { return this.reflected; diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CPseudoProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CPseudoProjectile.java new file mode 100644 index 000000000..984f71570 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CPseudoProjectile.java @@ -0,0 +1,207 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile; + +import java.util.concurrent.atomic.AtomicInteger; + +import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.utils.IntMap; +import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructableEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; + +public class CPseudoProjectile extends CProjectile { + + private static final Rectangle recycleRect = new Rectangle(); + + private final CAbilityCollisionProjectileListener projectileListener; + + private int maxHits = 0; + private int maxHitsPerTarget = 0; + + private int stepInterval = 1; + + private int nextActionTick = 0; + + private float collisionRadius = 0; + + private float finalCollisionRadius = 0; + private float startingCollisionRadius = 0; + private float distanceToTarget = 0; + + private IntMap collisions = new IntMap<>(); + private int hits = 0; + + private War3ID alias; + private CEffectType effectType; + private int effectArtIndex; + + private boolean provideCounts; + private int artSkip; + private int artCount = 1; + + private float dx; + private float dy; + private int steps; + + private int stepCount = 0; + + public CPseudoProjectile(final float x, final float y, final float speed, final float projectileStepInterval, final int projectileArtSkip, + final AbilityTarget target, boolean homingEnabled, final CUnit source, final War3ID alias, + final CEffectType effectType, final int effectArtIndex, final int maxHits, final int hitsPerTarget, + final float startingRadius, final float finalRadius, final CAbilityCollisionProjectileListener projectileListener, boolean provideCounts) { + super(x, y, speed, target, homingEnabled, source); + this.projectileListener = projectileListener; + + this.maxHits = maxHits; + this.maxHits = maxHits; + if (this.maxHits <= 0) { + this.maxHits = 0; + this.hits = -1; + } + + this.maxHitsPerTarget = hitsPerTarget; + this.startingCollisionRadius = startingRadius; + this.finalCollisionRadius = finalRadius; + this.provideCounts = provideCounts; + + this.alias = alias; + this.effectType = effectType; + this.effectArtIndex = effectArtIndex; + + final float dtsx = getTargetX() - this.x; + final float dtsy = getTargetY() - this.y; + this.distanceToTarget = (float) Math.sqrt((dtsx * dtsx) + (dtsy * dtsy)); + + final float d1x = dtsx / this.distanceToTarget; + final float d1y = dtsy / this.distanceToTarget; + if (speed != 0) { + this.steps = ((int)Math.round(this.distanceToTarget) / (int)speed) + 1; + } + + float travelDistance = Math.min(speed, distanceToTarget/this.steps); + + this.dx = d1x * travelDistance; + this.dy = d1y * travelDistance; + + this.stepInterval = (int) (projectileStepInterval / WarsmashConstants.SIMULATION_STEP_TIME); + this.artSkip = projectileArtSkip; + } + + @Override + protected void onHitTarget(CSimulation game) { + // Not used + } + + protected boolean canHitTarget(CSimulation game, CWidget target) { + return this.projectileListener.canHitTarget(game, target); + } + + protected void onHitTarget(CSimulation game, CWidget target) { + projectileListener.onHit(game, this, target); + } + + @Override + public boolean update(final CSimulation game) { + if (this.nextActionTick == 0) { + this.nextActionTick = game.getGameTurnTick(); + } + + if (game.getGameTurnTick() >= this.nextActionTick) { + + artCount = (artCount+1) % artSkip; + if (artCount == 0) { + game.spawnTemporarySpellEffectOnPoint(this.x, this.y, 0, this.alias, this.effectType, this.effectArtIndex); + } + + if (this.collisionRadius != this.finalCollisionRadius) { + final float dtsx = getTargetX() - this.x; + final float dtsy = getTargetY() - this.y; + final float c = (float) Math.sqrt((dtsx * dtsx) + (dtsy * dtsy)); + this.collisionRadius = this.startingCollisionRadius + + (this.finalCollisionRadius - this.startingCollisionRadius) + * (1 - (c / this.distanceToTarget)); + } + AbilityPointTarget loc = new AbilityPointTarget(this.x, this.y); + this.projectileListener.setCurrentLocation(loc); + recycleRect.set(this.getX() - collisionRadius, this.getY() - collisionRadius, collisionRadius * 2, + collisionRadius * 2); + + if (provideCounts ) { + AtomicInteger destCount = new AtomicInteger(0); + AtomicInteger unitCount = new AtomicInteger(0); + game.getWorldCollision().enumDestructablesInRect(recycleRect, new CDestructableEnumFunction() { + @Override + public boolean call(CDestructable enumDestructable) { + if (hits < maxHits && collisions.get(enumDestructable.getHandleId(), 0) < maxHitsPerTarget + && enumDestructable.distance(loc.getX(), loc.getY()) < collisionRadius && canHitTarget(game, enumDestructable)) { + destCount.incrementAndGet(); + } + return false; + } + }); + game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (hits < maxHits && collisions.get(enumUnit.getHandleId(), 0) < maxHitsPerTarget + && enumUnit.canReach(loc, collisionRadius) && canHitTarget(game, enumUnit)) { + unitCount.incrementAndGet(); + } + return false; + } + }); + + this.projectileListener.setUnitTargets(unitCount.get()); + this.projectileListener.setDestructableTargets(destCount.get()); + } + + + this.projectileListener.onPreHits(game, this, loc); + + game.getWorldCollision().enumDestructablesInRect(recycleRect, new CDestructableEnumFunction() { + @Override + public boolean call(CDestructable enumDestructable) { + if (hits < maxHits && collisions.get(enumDestructable.getHandleId(), 0) < maxHitsPerTarget + && enumDestructable.distance(loc.getX(), loc.getY()) < collisionRadius && canHitTarget(game, enumDestructable)) { + onHitTarget(game, enumDestructable); + if (maxHits > 0) { + hits++; + } + collisions.put(enumDestructable.getHandleId(), collisions.get(enumDestructable.getHandleId(), 0) + 1); + } + return false; + } + }); + game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { + @Override + public boolean call(final CUnit enumUnit) { + if (hits < maxHits && collisions.get(enumUnit.getHandleId(), 0) < maxHitsPerTarget + && enumUnit.canReach(loc, collisionRadius) && canHitTarget(game, enumUnit)) { + onHitTarget(game, enumUnit); + if (maxHits > 0) { + hits++; + } + collisions.put(enumUnit.getHandleId(), collisions.get(enumUnit.getHandleId(), 0) + 1); + } + return false; + } + }); + + this.x = this.x + this.dx; + this.y = this.y + this.dy; + + this.nextActionTick = game.getGameTurnTick() + this.stepInterval; + this.stepCount++; + this.done |= this.stepCount > this.steps; + } + this.done |= hits >= maxHits; + + return this.done; + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CPsuedoProjectile.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CPsuedoProjectile.java deleted file mode 100644 index d9307adbb..000000000 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/combat/projectile/CPsuedoProjectile.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile; - -import java.util.concurrent.atomic.AtomicInteger; - -import com.badlogic.gdx.math.Rectangle; -import com.badlogic.gdx.utils.IntMap; -import com.etheller.warsmash.util.War3ID; -import com.etheller.warsmash.util.WarsmashConstants; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructable; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CDestructableEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitEnumFunction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; - -public class CPsuedoProjectile extends CProjectile { - - private static final Rectangle recycleRect = new Rectangle(); - - private final CAbilityCollisionProjectileListener projectileListener; - - private int maxHits = 0; - private int maxHitsPerTarget = 0; - - private int stepInterval = 1; - - private int nextActionTick = 0; - - private float collisionRadius = 0; - - private float finalCollisionRadius = 0; - private float startingCollisionRadius = 0; - private float distanceToTarget = 0; - - private IntMap collisions = new IntMap<>(); - private int hits = 0; - - private War3ID alias; - private CEffectType effectType; - private int effectArtIndex; - - private boolean provideCounts; - private int artSkip; - private int artCount = 1; - - private float dx; - private float dy; - private int steps; - - private int stepCount = 0; - - public CPsuedoProjectile(final float x, final float y, final float speed, final float projectileStepInterval, final int projectileArtSkip, - final AbilityTarget target, boolean homingEnabled, final CUnit source, final War3ID alias, - final CEffectType effectType, final int effectArtIndex, final int maxHits, final int hitsPerTarget, - final float startingRadius, final float finalRadius, final CAbilityCollisionProjectileListener projectileListener, boolean provideCounts) { - super(x, y, speed, target, homingEnabled, source); - this.projectileListener = projectileListener; - - this.maxHits = maxHits; - this.maxHits = maxHits; - if (this.maxHits <= 0) { - this.maxHits = 0; - this.hits = -1; - } - - this.maxHitsPerTarget = hitsPerTarget; - this.startingCollisionRadius = startingRadius; - this.finalCollisionRadius = finalRadius; - this.provideCounts = provideCounts; - - this.alias = alias; - this.effectType = effectType; - this.effectArtIndex = effectArtIndex; - - final float dtsx = getTargetX() - this.x; - final float dtsy = getTargetY() - this.y; - this.distanceToTarget = (float) Math.sqrt((dtsx * dtsx) + (dtsy * dtsy)); - - final float d1x = dtsx / this.distanceToTarget; - final float d1y = dtsy / this.distanceToTarget; - if (speed != 0) { - this.steps = ((int)Math.round(this.distanceToTarget) / (int)speed) + 1; - } - - float travelDistance = Math.min(speed, distanceToTarget/this.steps); - - this.dx = d1x * travelDistance; - this.dy = d1y * travelDistance; - - this.stepInterval = (int) (projectileStepInterval / WarsmashConstants.SIMULATION_STEP_TIME); - this.artSkip = projectileArtSkip; - } - - @Override - protected void onHitTarget(CSimulation game) { - // Not used - } - - protected boolean canHitTarget(CSimulation game, CWidget target) { - return this.projectileListener.canHitTarget(game, target); - } - - protected void onHitTarget(CSimulation game, CWidget target) { - projectileListener.onHit(game, this, target); - } - - @Override - public boolean update(final CSimulation game) { - if (this.nextActionTick == 0) { - this.nextActionTick = game.getGameTurnTick(); - } - - if (game.getGameTurnTick() >= this.nextActionTick) { - - artCount = (artCount+1) % artSkip; - if (artCount == 0) { - game.spawnTemporarySpellEffectOnPoint(this.x, this.y, 0, this.alias, this.effectType, this.effectArtIndex); - } - - if (this.collisionRadius != this.finalCollisionRadius) { - final float dtsx = getTargetX() - this.x; - final float dtsy = getTargetY() - this.y; - final float c = (float) Math.sqrt((dtsx * dtsx) + (dtsy * dtsy)); - this.collisionRadius = this.startingCollisionRadius - + (this.finalCollisionRadius - this.startingCollisionRadius) - * (1 - (c / this.distanceToTarget)); - } - AbilityPointTarget loc = new AbilityPointTarget(this.x, this.y); - this.projectileListener.setCurrentLocation(loc); - recycleRect.set(this.getX() - collisionRadius, this.getY() - collisionRadius, collisionRadius * 2, - collisionRadius * 2); - - if (provideCounts ) { - AtomicInteger destCount = new AtomicInteger(0); - AtomicInteger unitCount = new AtomicInteger(0); - game.getWorldCollision().enumDestructablesInRect(recycleRect, new CDestructableEnumFunction() { - @Override - public boolean call(CDestructable enumDestructable) { - if (hits < maxHits && collisions.get(enumDestructable.getHandleId(), 0) < maxHitsPerTarget - && enumDestructable.distance(loc.getX(), loc.getY()) < collisionRadius && canHitTarget(game, enumDestructable)) { - destCount.incrementAndGet(); - } - return false; - } - }); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (hits < maxHits && collisions.get(enumUnit.getHandleId(), 0) < maxHitsPerTarget - && enumUnit.canReach(loc, collisionRadius) && canHitTarget(game, enumUnit)) { - unitCount.incrementAndGet(); - } - return false; - } - }); - - this.projectileListener.setUnitTargets(unitCount.get()); - this.projectileListener.setDestructableTargets(destCount.get()); - } - - - this.projectileListener.onPreHits(game, this, loc); - - game.getWorldCollision().enumDestructablesInRect(recycleRect, new CDestructableEnumFunction() { - @Override - public boolean call(CDestructable enumDestructable) { - if (hits < maxHits && collisions.get(enumDestructable.getHandleId(), 0) < maxHitsPerTarget - && enumDestructable.distance(loc.getX(), loc.getY()) < collisionRadius && canHitTarget(game, enumDestructable)) { - onHitTarget(game, enumDestructable); - if (maxHits > 0) { - hits++; - } - collisions.put(enumDestructable.getHandleId(), collisions.get(enumDestructable.getHandleId(), 0) + 1); - } - return false; - } - }); - game.getWorldCollision().enumUnitsInRect(recycleRect, new CUnitEnumFunction() { - @Override - public boolean call(final CUnit enumUnit) { - if (hits < maxHits && collisions.get(enumUnit.getHandleId(), 0) < maxHitsPerTarget - && enumUnit.canReach(loc, collisionRadius) && canHitTarget(game, enumUnit)) { - onHitTarget(game, enumUnit); - if (maxHits > 0) { - hits++; - } - collisions.put(enumUnit.getHandleId(), collisions.get(enumUnit.getHandleId(), 0) + 1); - } - return false; - } - }); - - this.x = this.x + this.dx; - this.y = this.y + this.dy; - - this.nextActionTick = game.getGameTurnTick() + this.stepInterval; - this.stepCount++; - this.done |= this.stepCount > this.steps; - } - this.done |= hits >= maxHits; - - return this.done; - } -} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CAbilityData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CAbilityData.java index 8e4e3d8bc..fe90947fa 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CAbilityData.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CAbilityData.java @@ -1,11 +1,14 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.data; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.etheller.warsmash.units.GameObject; import com.etheller.warsmash.units.ObjectData; import com.etheller.warsmash.util.War3ID; +import com.etheller.warsmash.util.WarsmashConstants; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityGenericDoNothing; @@ -85,11 +88,12 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionStandDown; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.CAbilityTypeDefinitionWispHarvest; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.jass.CAbilityTypeJassDefinition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderDupe; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParserUtil; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.types.definitions.impl.CAbilityTypeDefinitionAbilityTemplateBuilder; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderDupe; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParser; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParserUtil; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.types.definitions.impl.ABAbilityBuilderTemplateTypeDefinition; public class CAbilityData { @@ -139,12 +143,12 @@ private void registerCodes() { // ----Orc---- this.codeToAbilityTypeDefinition.put(War3ID.fromString("AOsf"), new CAbilityTypeDefinitionSpellBase((handleId, alias) -> new CAbilityFeralSpirit(handleId, alias))); - this.codeToAbilityTypeDefinition.put(War3ID.fromString("AOcl"), - new CAbilityTypeDefinitionSpellBase((handleId, alias) -> new CAbilityChainLightning(handleId, alias))); +// this.codeToAbilityTypeDefinition.put(War3ID.fromString("AOcl"), +// new CAbilityTypeDefinitionSpellBase((handleId, alias) -> new CAbilityChainLightning(handleId, alias))); // Tauren Chieftain - this.codeToAbilityTypeDefinition.put(War3ID.fromString("AOws"), - new CAbilityTypeDefinitionSpellBase((handleId, alias) -> new CAbilityWarStomp(handleId, alias))); +// this.codeToAbilityTypeDefinition.put(War3ID.fromString("AOws"), +// new CAbilityTypeDefinitionSpellBase((handleId, alias) -> new CAbilityWarStomp(handleId, alias))); // Burrow: this.codeToAbilityTypeDefinition.put(War3ID.fromString("Abun"), new CAbilityTypeDefinitionCargoHoldBurrow()); @@ -218,7 +222,7 @@ private void registerCodes() { this.codeToAbilityTypeDefinition.put(War3ID.fromString("ANsw"), new CAbilityTypeDefinitionSpellBase((handleId, alias) -> new CAbilitySummonHawk(handleId, alias))); - this.codeToAbilityTypeDefinition.put(War3ID.fromString("AHca"), new CAbilityTypeDefinitionColdArrows()); +// this.codeToAbilityTypeDefinition.put(War3ID.fromString("AHca"), new CAbilityTypeDefinitionColdArrows()); this.codeToAbilityTypeDefinition.put(War3ID.fromString("Agld"), new CAbilityTypeDefinitionGoldMine()); this.codeToAbilityTypeDefinition.put(War3ID.fromString("Agl2"), new CAbilityTypeDefinitionGoldMineOverlayed()); this.codeToAbilityTypeDefinition.put(War3ID.fromString("Abgm"), new CAbilityTypeDefinitionBlightedGoldMine()); @@ -282,22 +286,132 @@ private void registerCodes() { System.err.println("Starting to load ability builder"); System.err.println("========================================================================"); - if (true) { - AbilityBuilderParserUtil.loadAbilityBuilderFiles(behavior -> { - if (behavior.getType().equals(AbilityBuilderType.TEMPLATE)) { - for (final AbilityBuilderDupe dupe : behavior.getIds()) { + + try { + final List inheritingAbilities = new ArrayList<>(); + final Map previousAbilityParsers = new HashMap<>(); + + ABAbilityBuilderParserUtil.loadAbilityBuilderFiles(behavior -> { + if (behavior.getType().equals(ABAbilityBuilderType.INHERIT)) { + inheritingAbilities.add(behavior); + } else if (behavior.getType().equals(ABAbilityBuilderType.TEMPLATE)) { + for (ABAbilityBuilderDupe dupe : behavior.getIds()) { + previousAbilityParsers.put(dupe.getId(), behavior); this.codeToAbilityTypeDefinition.put(War3ID.fromString(dupe.getId()), - new CAbilityTypeDefinitionAbilityTemplateBuilder(behavior)); + new ABAbilityBuilderTemplateTypeDefinition(behavior)); } - } - else { - for (final AbilityBuilderDupe dupe : behavior.getIds()) { - final AbilityBuilderConfiguration config = new AbilityBuilderConfiguration(behavior, dupe); + } else { + for (ABAbilityBuilderDupe dupe : behavior.getIds()) { + previousAbilityParsers.put(dupe.getId(), behavior); + ABAbilityBuilderConfiguration config = new ABAbilityBuilderConfiguration(behavior, dupe); this.codeToAbilityTypeDefinition.put(War3ID.fromString(config.getId()), config.createDefinition()); } } }); + + + int prevIter = 1; + List loopInheritingAbilities = inheritingAbilities; + while (loopInheritingAbilities.size() > 0) { + List iter = loopInheritingAbilities; + loopInheritingAbilities = new ArrayList<>(); + + if (prevIter == 0) { + for (ABAbilityBuilderParser parser : iter) { + System.err.println("Couldn't parse INHERIT ability due to no parent ability definition: " + parser.getIds().get(0).getId()); + } + break; + } + prevIter = 0; + + for (ABAbilityBuilderParser parser : iter) { + if (parser.getParentId() == null) { + System.err.println("Couldn't parse INHERIT ability due to missing parent ID: " + parser.getIds().get(0).getId()); + continue; + } + ABAbilityBuilderParser parent = previousAbilityParsers.get(parser.getParentId()); + if (parent != null) { + parser.updateFromParent(parent); + for (ABAbilityBuilderDupe dupe : parser.getIds()) { + previousAbilityParsers.put(dupe.getId(), parser); + ABAbilityBuilderConfiguration config = new ABAbilityBuilderConfiguration(parser, dupe); + this.codeToAbilityTypeDefinition.put(War3ID.fromString(config.getId()), + config.createDefinition()); + prevIter++; + } + } else { + loopInheritingAbilities.add(parser); + } + } + } + + if (WarsmashConstants.ABILITY_COMPATIBILITY != null && WarsmashConstants.ABILITY_COMPATIBILITY.size() > 0) { + final List inheritingCompatAbilities = new ArrayList<>(); + boolean all = WarsmashConstants.ABILITY_COMPATIBILITY.contains("all"); + + ABAbilityBuilderParserUtil.loadAbilityBuilderFiles(behavior -> { + if (behavior.getType().equals(ABAbilityBuilderType.INHERIT)) { + inheritingCompatAbilities.add(behavior); + } else if (behavior.getType().equals(ABAbilityBuilderType.TEMPLATE)) { + for (ABAbilityBuilderDupe dupe : behavior.getIds()) { + if (all || WarsmashConstants.ABILITY_COMPATIBILITY.contains(dupe.getId())) { + previousAbilityParsers.put(dupe.getId(), behavior); + this.codeToAbilityTypeDefinition.put(War3ID.fromString(dupe.getId()), + new ABAbilityBuilderTemplateTypeDefinition(behavior)); + } + } + } else { + for (ABAbilityBuilderDupe dupe : behavior.getIds()) { + if (all || WarsmashConstants.ABILITY_COMPATIBILITY.contains(dupe.getId())) { + previousAbilityParsers.put(dupe.getId(), behavior); + ABAbilityBuilderConfiguration config = new ABAbilityBuilderConfiguration(behavior, dupe); + this.codeToAbilityTypeDefinition.put(War3ID.fromString(config.getId()), + config.createDefinition()); + } + } + } + }, "abilityBehaviors_compatibility"); + + prevIter = 1; + List loopInheritingCompatAbilities = inheritingCompatAbilities; + while (loopInheritingCompatAbilities.size() > 0) { + List iter = loopInheritingCompatAbilities; + loopInheritingCompatAbilities = new ArrayList<>(); + + if (prevIter == 0) { + for (ABAbilityBuilderParser parser : iter) { + System.err.println("Couldn't parse INHERIT ability due to no parent ability definition: " + parser.getIds().get(0).getId()); + } + break; + } + prevIter = 0; + + for (ABAbilityBuilderParser parser : iter) { + if (parser.getParentId() == null) { + System.err.println("Couldn't parse INHERIT ability due to missing parent ID: " + parser.getIds().get(0).getId()); + continue; + } + ABAbilityBuilderParser parent = previousAbilityParsers.get(parser.getParentId()); + if (parent != null) { + parser.updateFromParent(parent); + for (ABAbilityBuilderDupe dupe : parser.getIds()) { + if (all || WarsmashConstants.ABILITY_COMPATIBILITY.contains(dupe.getId())) { + previousAbilityParsers.put(dupe.getId(), parser); + ABAbilityBuilderConfiguration config = new ABAbilityBuilderConfiguration(parser, dupe); + this.codeToAbilityTypeDefinition.put(War3ID.fromString(config.getId()), + config.createDefinition()); + prevIter++; + } + } + } else { + loopInheritingCompatAbilities.add(parser); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); } System.err.println("========================================================================"); @@ -310,7 +424,7 @@ public void registerJassType(final War3ID war3id, final CAbilityTypeJassDefiniti this.codeToAbilityTypeDefinition.put(war3id, whichAbilityType); } - public void registerAbilityBuilderType(final War3ID war3id, final AbilityBuilderConfiguration configuration) { + public void registerAbilityBuilderType(final War3ID war3id, final ABAbilityBuilderConfiguration configuration) { this.codeToAbilityTypeDefinition.put(war3id, configuration.createDefinition()); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CItemData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CItemData.java index dd3408a83..85786f39d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CItemData.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CItemData.java @@ -1,6 +1,7 @@ package com.etheller.warsmash.viewer5.handlers.w3x.simulation.data; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -132,7 +133,7 @@ private CItemType getItemTypeInstance(final War3ID typeId, final GameObject item // do not bother to log this, means it didn't match constant (it's a user input) } - itemTypeInstance = new CItemType(abilityList, cooldownGroup, ignoreCooldown, numberOfCharges, activelyUsed, + itemTypeInstance = new CItemType(typeId, abilityList, cooldownGroup, ignoreCooldown, numberOfCharges, activelyUsed, perishable, useAutomaticallyWhenAcquired, goldCost, lumberCost, stockMax, stockReplenishInterval, stockStartDelay, hitPoints, armorType, level, levelUnclassified, priority, sellable, pawnable, droppedWhenCarrierDies, canBeDropped, validTargetForTransformation, includeAsRandomChoice, @@ -189,4 +190,8 @@ private static final class RandomItemSet { private final List unclassifiedItems = new ArrayList<>(); private final Map> classificationToItems = new HashMap<>(); } + + public Collection getAllItemTypes() { + return this.itemIdToItemType.values(); + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java index 8c54a930c..04ec7917f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java @@ -3,6 +3,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; @@ -28,6 +29,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.HandleIdAllocator; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityAttack; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityMove; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.GetAbilityByRawcodeVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.CAutocastAbility; @@ -70,6 +72,8 @@ public class CUnitData { private static final String HIT_POINT_REGEN = "regenHP"; // replaced from 'uhpr' private static final String HIT_POINT_REGEN_TYPE = "regenType"; // replaced from 'uhrt' private static final String MOVEMENT_SPEED_BASE = "spd"; // replaced from 'umvs' + private static final String MOVEMENT_SPEED_MAX = "maxSpd"; + private static final String MOVEMENT_SPEED_MIN = "minSpd"; private static final String PROPULSION_WINDOW = "propWin"; // replaced from 'uprw' private static final String TURN_RATE = "turnRate"; // replaced from 'umvr' private static final String IS_BLDG = "isbldg"; // replaced from 'ubdg' @@ -223,10 +227,14 @@ public class CUnitData { private static final String LUMBER_BOUNTY_AWARDED_SIDES = "lumberbountysides"; // replaced from 'ulbs' private static final String NEUTRAL_BUILDING_SHOW_ICON = "nbmmIcon"; + + private static final String TILESETS = "tilesets"; + private static final String SPECIAL = "special"; private final CGameplayConstants gameplayConstants; private final ObjectData unitData; private final Map unitIdToUnitType = new HashMap<>(); + private final Map unitIdToUnitTypeLightweight = new HashMap<>(); private final Map jassLegacyNameToUnitId = new HashMap<>(); private final CAbilityData abilityData; private final CUpgradeData upgradeData; @@ -244,19 +252,28 @@ public CUnitData(final CGameplayConstants gameplayConstants, final ObjectData un public CUnit create(final CSimulation simulation, final int playerIndex, final War3ID typeId, final float x, final float y, final float facing, final BufferedImage buildingPathingPixelMap, - final HandleIdAllocator handleIdAllocator) { + final HandleIdAllocator handleIdAllocator, int editorConfigHitPointPercent, int editorConfigManaAmount) { final GameObject unitType = this.unitData.get(typeId.asStringValue()); final int handleId = handleIdAllocator.createId(); final CUnitType unitTypeInstance = getUnitTypeInstance(typeId, buildingPathingPixelMap, unitType); - final int life = unitTypeInstance.getMaxLife(); + final float life = editorConfigHitPointPercent > 0 ? unitTypeInstance.getMaxLife()* (editorConfigHitPointPercent / 100f) : unitTypeInstance.getMaxLife(); final float lifeRegen = unitTypeInstance.getLifeRegen(); final int manaInitial = unitTypeInstance.getManaInitial(); final int manaMaximum = unitTypeInstance.getManaMaximum(); final int speed = unitTypeInstance.getSpeed(); + int maxSpeed = unitTypeInstance.getMaxSpeed(); + if (maxSpeed == 0) { + maxSpeed = (int) simulation.getGameplayConstants().getMaxUnitSpeed(); + } + int minSpeed = unitTypeInstance.getMinSpeed(); + if (minSpeed == 0) { + minSpeed = (int) simulation.getGameplayConstants().getMinUnitSpeed(); + } - final CUnit unit = new CUnit(handleId, playerIndex, x, y, life, typeId, facing, manaInitial, life, lifeRegen, - manaMaximum, speed, unitTypeInstance); + final CUnit unit = new CUnit(handleId, playerIndex, x, y, life, typeId, facing, + editorConfigManaAmount >= 0 ? editorConfigManaAmount : manaInitial, unitTypeInstance.getMaxLife(), + lifeRegen, manaMaximum, speed, maxSpeed, minSpeed, unitTypeInstance); return unit; } @@ -369,13 +386,12 @@ public void addDefaultAbilitiesToUnit(final CSimulation simulation, final Handle } if (ability.equals(unitTypeInstance.getDefaultAutocastAbility()) && (createAbility instanceof CAutocastAbility)) { - ((CAutocastAbility) createAbility).setAutoCastOn(unit, true); + ((CAutocastAbility) createAbility).setAutoCastOn(simulation, unit, true, true); } - } - else { + } else { if (ability.equals(unitTypeInstance.getDefaultAutocastAbility()) && (existingAbility instanceof CAutocastAbility)) { - ((CAutocastAbility) existingAbility).setAutoCastOn(unit, true); + ((CAutocastAbility) existingAbility).setAutoCastOn(simulation, unit, true, true); } } } @@ -458,16 +474,36 @@ public void addMissingDefaultAbilitiesToUnit(final CSimulation simulation, unit.add(simulation, new CAbilityRally(handleIdAllocator.createId())); } if (unitTypeInstance.isHero()) { - final List heroAbilityList = unitTypeInstance.getHeroAbilityList(); if (unit.getFirstAbilityOfType(CAbilityHero.class) != null) { final CAbilityHero abil = unit.getFirstAbilityOfType(CAbilityHero.class); - abil.setSkillsAvailable(heroAbilityList); - abil.recalculateAllStats(simulation, unit); - } - else { - unit.add(simulation, new CAbilityHero(handleIdAllocator.createId(), heroAbilityList)); + if (abil.isDisabled()) { + abil.setDisabled(false, CAbilityDisableType.TRANSFORMATION); + abil.setIconShowing(true); + for (CAbility habl : abil.getLearnedHeroAbilities()) { + unit.add(simulation, habl); + } + } + abil.setHeroName(unitTypeInstance); +// abil.setSkillsAvailable(heroAbilityList); + abil.calculateDerivatedFields(simulation, unit); + } else { + final List heroAbilityList = unitTypeInstance.getHeroAbilityList(); + final CAbilityHero abil = new CAbilityHero(handleIdAllocator.createId(), heroAbilityList); + unit.add(simulation, abil); // reset initial mana after the value is adjusted for hero data unit.setMana(manaInitial); + abil.recalculateAllStats(simulation, unit); + } + } else { + if (unit.getFirstAbilityOfType(CAbilityHero.class) != null) { + final CAbilityHero abil = unit.getFirstAbilityOfType(CAbilityHero.class); +// abil.setSkillsAvailable(heroAbilityList); + abil.calculateDerivatedFields(simulation, unit); + abil.setDisabled(true, CAbilityDisableType.TRANSFORMATION); + abil.setIconShowing(false); + for (CAbility habl : abil.getLearnedHeroAbilities()) { + unit.remove(simulation, habl); + } } } for (final War3ID ability : unitTypeInstance.getAbilityList()) { @@ -480,13 +516,12 @@ public void addMissingDefaultAbilitiesToUnit(final CSimulation simulation, } if (ability.equals(unitTypeInstance.getDefaultAutocastAbility()) && (createAbility instanceof CAutocastAbility)) { - ((CAutocastAbility) createAbility).setAutoCastOn(unit, true); + ((CAutocastAbility) createAbility).setAutoCastOn(simulation, unit, true, true); } - } - else { + } else { if (ability.equals(unitTypeInstance.getDefaultAutocastAbility()) && (existingAbility instanceof CAutocastAbility)) { - ((CAutocastAbility) existingAbility).setAutoCastOn(unit, true); + ((CAutocastAbility) existingAbility).setAutoCastOn(simulation, unit, true, true); } } } @@ -511,6 +546,8 @@ private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage b final int manaMaximum = unitType.getFieldAsInteger(MANA_MAXIMUM, 0); final float manaRegen = unitType.getFieldAsFloat(MANA_REGEN, 0); final int speed = unitType.getFieldAsInteger(MOVEMENT_SPEED_BASE, 0); + final int maxSpeed = unitType.getFieldAsInteger(MOVEMENT_SPEED_MAX, 0); + final int minSpeed = unitType.getFieldAsInteger(MOVEMENT_SPEED_MIN, 0); final int defense = unitType.getFieldAsInteger(DEFENSE, 0); final String defaultAutocastAbility = unitType.getFieldAsString(ABILITIES_DEFAULT_AUTO, 0); final List abilityListString = unitType.getFieldAsList(ABILITIES_NORMAL); @@ -540,7 +577,7 @@ private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage b final CPrimaryAttribute primaryAttribute = CPrimaryAttribute .parsePrimaryAttribute(unitType.getFieldAsString(PRIMARY_ATTRIBUTE, 0)); - final String properNames = unitType.getFieldAsString(PROPER_NAMES, 0); + final String properNames = unitType.getField(PROPER_NAMES); final int properNamesCount = unitType.getFieldAsInteger(PROPER_NAMES_COUNT, 0); final boolean isBldg = unitType.getFieldAsBoolean(IS_BLDG, 0); @@ -612,8 +649,7 @@ private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage b damageSidesPerDie, damageSpillDistance, damageSpillRadius, damageUpgradeAmount, maximumNumberOfTargets, projectileArc, projectileArt, projectileHomingEnabled, projectileSpeed, range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, weaponType)); - } - catch (final Exception exc) { + } catch (final Exception exc) { System.err.println("Attack 1 failed to parse with: " + exc.getClass() + ":" + exc.getMessage()); } try { @@ -676,8 +712,7 @@ private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage b damageSidesPerDie, damageSpillDistance, damageSpillRadius, damageUpgradeAmount, maximumNumberOfTargets, projectileArc, projectileArt, projectileHomingEnabled, projectileSpeed, range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, weaponType)); - } - catch (final Exception exc) { + } catch (final Exception exc) { System.err.println("Attack 2 failed to parse with: " + exc.getClass() + ":" + exc.getMessage()); } final List enabledAttacks = getEnabledAttacks(attacks, attacksEnabled); @@ -745,8 +780,7 @@ private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage b if ((defaultAutocastAbility != null) && !defaultAutocastAbility.isEmpty() && !defaultAutocastAbility.equals("_")) { defaultAutocastAbilityId = War3ID.fromString(defaultAutocastAbility); - } - else { + } else { defaultAutocastAbilityId = null; } final List heroAbilityList = parseIDList(heroAbilityListString); @@ -778,9 +812,12 @@ private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage b final List heroProperNames = Arrays.asList(properNames.split(",")); final boolean neutralBuildingShowMinimapIcon = unitType.getFieldAsBoolean(NEUTRAL_BUILDING_SHOW_ICON, 0); + + final String tilesets = unitType.getFieldAsString(TILESETS, 0); + final boolean special = unitType.getFieldAsBoolean(SPECIAL, 0); unitTypeInstance = new CUnitType(unitName, legacyName, typeId, life, lifeRegen, manaRegen, lifeRegenType, - manaInitial, manaMaximum, speed, defense, defaultAutocastAbilityId, abilityList, isBldg, + manaInitial, manaMaximum, speed, maxSpeed, minSpeed, defense, defaultAutocastAbilityId, abilityList, isBldg, movementType, moveHeight, collisionSize, classifications, attacks, attacksEnabled, armorType, raise, decay, defenseType, impactZ, buildingPathingPixelMap, deathTime, targetedAs, acquisitionRange, minimumAttackRange, structuresBuilt, unitsTrained, researchesAvailable, upgradesUsed, @@ -792,8 +829,9 @@ private CUnitType getUnitTypeInstance(final War3ID typeId, final BufferedImage b castPoint, canBeBuiltOnThem, canBuildOnMe, defenseUpgradeBonus, sightRadiusDay, sightRadiusNight, extendedLineOfSight, goldBountyAwardedBase, goldBountyAwardedDice, goldBountyAwardedSides, lumberBountyAwardedBase, lumberBountyAwardedDice, lumberBountyAwardedSides, - neutralBuildingShowMinimapIcon); + neutralBuildingShowMinimapIcon, tilesets, special); this.unitIdToUnitType.put(typeId, unitTypeInstance); + this.unitIdToUnitTypeLightweight.put(typeId, unitTypeInstance); this.jassLegacyNameToUnitId.put(legacyName, typeId); } return unitTypeInstance; @@ -844,31 +882,25 @@ public static List parseRequirements(final List re if (i < requirementsLevelsString.size()) { if (requirementsLevelsString.get(i).isEmpty()) { level = 1; - } - else { + } else { try { level = Integer.parseInt(requirementsLevelsString.get(i)); - } - catch (final NumberFormatException exc) { + } catch (final NumberFormatException exc) { level = 1; } } - } - else if (requirementsLevelsString.size() > 0) { + } else if (requirementsLevelsString.size() > 0) { final String requirementLevel = requirementsLevelsString.get(requirementsLevelsString.size() - 1); if (requirementLevel.isEmpty()) { level = 1; - } - else { + } else { try { level = Integer.parseInt(requirementLevel); - } - catch (final NumberFormatException exc) { + } catch (final NumberFormatException exc) { level = 1; } } - } - else { + } else { level = 1; } requirements.add(new CUnitTypeRequirement(War3ID.fromString(item), level)); @@ -888,8 +920,7 @@ private static int[] populateHeroStatTable(final int maxHeroLevel, final float s final float newSumBonusAtLevel = sumBonusAtLevel + statPerLevel; if (i == 0) { table[i] = (int) newSumBonusAtLevel; - } - else { + } else { table[i] = (int) newSumBonusAtLevel - table[i - 1]; } sumBonusAtLevel = newSumBonusAtLevel; @@ -928,14 +959,15 @@ private CUnitAttack createAttack(final float animationBackswingPoint, final floa cooldownTime, damageBase, damageDice, damageSidesPerDie, damageUpgradeAmount, range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, weaponType, projectileArc, projectileArt, projectileHomingEnabled, projectileSpeed, areaOfEffectFullDamage, areaOfEffectMediumDamage, - areaOfEffectSmallDamage, areaOfEffectTargets, damageFactorMedium, damageFactorSmall); + areaOfEffectSmallDamage, areaOfEffectTargets, damageFactorMedium, damageFactorSmall, + weaponType == CWeaponType.ARTILLERY); break; case MLINE: case ALINE: attack = new CUnitAttackMissileLine(animationBackswingPoint, animationDamagePoint, attackType, cooldownTime, damageBase, damageDice, damageSidesPerDie, damageUpgradeAmount, range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, weaponType, projectileArc, projectileArt, projectileHomingEnabled, - projectileSpeed, damageSpillDistance, damageSpillRadius); + projectileSpeed, damageSpillDistance, damageSpillRadius, weaponType == CWeaponType.ALINE); break; case INSTANT: attack = new CUnitAttackInstant(animationBackswingPoint, animationDamagePoint, attackType, cooldownTime, @@ -1069,4 +1101,330 @@ public CUnitType getUnitTypeByJassLegacyName(final String jassLegacyName) { } return getUnitType(typeId); } + private CUnitType getUnitTypeInstanceLightweight(final War3ID typeId, + final GameObject unitType) { + CUnitType unitTypeInstance = this.unitIdToUnitType.get(typeId); + if (unitTypeInstance == null) { + unitTypeInstance = this.unitIdToUnitTypeLightweight.get(typeId); + } + if (unitTypeInstance == null) { + final String legacyName = getLegacyName(unitType); + final int life = unitType.getFieldAsInteger(HIT_POINT_MAXIMUM, 0); + final float lifeRegen = unitType.getFieldAsFloat(HIT_POINT_REGEN, 0); + final CRegenType lifeRegenType = CRegenType + .parseRegenType(unitType.getFieldAsString(HIT_POINT_REGEN_TYPE, 0)); + final int manaInitial = unitType.getFieldAsInteger(MANA_INITIAL_AMOUNT, 0); + final int manaMaximum = unitType.getFieldAsInteger(MANA_MAXIMUM, 0); + final float manaRegen = unitType.getFieldAsFloat(MANA_REGEN, 0); + final int speed = unitType.getFieldAsInteger(MOVEMENT_SPEED_BASE, 0); + final int maxSpeed = unitType.getFieldAsInteger(MOVEMENT_SPEED_MAX, 0); + final int minSpeed = unitType.getFieldAsInteger(MOVEMENT_SPEED_MIN, 0); + final int defense = unitType.getFieldAsInteger(DEFENSE, 0); + final String defaultAutocastAbility = unitType.getFieldAsString(ABILITIES_DEFAULT_AUTO, 0); + final List abilityListString = unitType.getFieldAsList(ABILITIES_NORMAL); + final List heroAbilityListString = unitType.getFieldAsList(ABILITIES_HERO); + final int unitLevel = unitType.getFieldAsInteger(UNIT_LEVEL, 0); + final int priority = unitType.getFieldAsInteger(PRIORITY, 0); + final int defenseUpgradeBonus = unitType.getFieldAsInteger(DEFENSE_UPGRADE_BONUS, 0); + + final float moveHeight = unitType.getFieldAsFloat(MOVE_HEIGHT, 0); + final String movetp = unitType.getFieldAsString(MOVE_TYPE, 0); + final float collisionSize = unitType.getFieldAsFloat(COLLISION_SIZE, 0); + final float propWindow = unitType.getFieldAsFloat(PROPULSION_WINDOW, 0); + final float turnRate = unitType.getFieldAsFloat(TURN_RATE, 0); + + final boolean canFlee = unitType.getFieldAsBoolean(CAN_FLEE, 0); + + final boolean canBeBuiltOnThem = unitType.getFieldAsBoolean(CAN_BE_BUILT_ON_THEM, 0); + final boolean canBuildOnMe = unitType.getFieldAsBoolean(CAN_BUILD_ON_ME, 0); + + final float strPlus = unitType.getFieldAsFloat(STR_PLUS, 0); + final float agiPlus = unitType.getFieldAsFloat(AGI_PLUS, 0); + final float intPlus = unitType.getFieldAsFloat(INT_PLUS, 0); + + final int strength = unitType.getFieldAsInteger(STR, 0); + final int agility = unitType.getFieldAsInteger(AGI, 0); + final int intelligence = unitType.getFieldAsInteger(INT, 0); + final CPrimaryAttribute primaryAttribute = CPrimaryAttribute + .parsePrimaryAttribute(unitType.getFieldAsString(PRIMARY_ATTRIBUTE, 0)); + + final String properNames = unitType.getField(PROPER_NAMES); + final int properNamesCount = unitType.getFieldAsInteger(PROPER_NAMES_COUNT, 0); + + final boolean isBldg = unitType.getFieldAsBoolean(IS_BLDG, 0); + PathingGrid.MovementType movementType = PathingGrid.getMovementType(movetp); + if (movementType == null) { + movementType = MovementType.DISABLED; + } + final String unitName = unitType.getFieldAsString(NAME, 0); + final float acquisitionRange = unitType.getFieldAsFloat(ACQUISITION_RANGE, 0); + // note: uamn expected type int below, not exactly sure why that decision was + // made but I'll support it + final float minimumAttackRange = unitType.getFieldAsInteger(MINIMUM_ATTACK_RANGE, 0); + final EnumSet targetedAs = CTargetType + .parseTargetTypeSet(unitType.getFieldAsList(TARGETED_AS)); + final List classificationStringList = unitType.getFieldAsList(CLASSIFICATION); + final EnumSet classifications = EnumSet.noneOf(CUnitClassification.class); + if (!classificationStringList.isEmpty()) { + for (final String unitEditorKey : classificationStringList) { + final CUnitClassification unitClassification = CUnitClassification + .parseUnitClassification(unitEditorKey); + if (unitClassification != null) { + classifications.add(unitClassification); + } + } + } + final List attacks = new ArrayList<>(); + final int attacksEnabled = unitType.getFieldAsInteger(ATTACKS_ENABLED, 0); + try { + // attack one + final float animationBackswingPoint = unitType.getFieldAsFloat(ATTACK1_BACKSWING_POINT, 0); + final float animationDamagePoint = unitType.getFieldAsFloat(ATTACK1_DAMAGE_POINT, 0); + final int areaOfEffectFullDamage = unitType.getFieldAsInteger(ATTACK1_AREA_OF_EFFECT_FULL_DMG, 0); + final int areaOfEffectMediumDamage = unitType.getFieldAsInteger(ATTACK1_AREA_OF_EFFECT_HALF_DMG, 0); + final int areaOfEffectSmallDamage = unitType.getFieldAsInteger(ATTACK1_AREA_OF_EFFECT_QUARTER_DMG, 0); + final EnumSet areaOfEffectTargets = CTargetType + .parseTargetTypeSet(unitType.getFieldAsList(ATTACK1_AREA_OF_EFFECT_TARGETS)); + final CAttackType attackType = CAttackType + .parseAttackType(unitType.getFieldAsString(ATTACK1_ATTACK_TYPE, 0)); + final float cooldownTime = unitType.getFieldAsFloat(ATTACK1_COOLDOWN, 0); + final int damageBase = unitType.getFieldAsInteger(ATTACK1_DMG_BASE, 0); + final float damageFactorMedium = unitType.getFieldAsFloat(ATTACK1_DAMAGE_FACTOR_HALF, 0); + final float damageFactorSmall = unitType.getFieldAsFloat(ATTACK1_DAMAGE_FACTOR_QUARTER, 0); + final float damageLossFactor = unitType.getFieldAsFloat(ATTACK1_DAMAGE_LOSS_FACTOR, 0); + final int damageDice = unitType.getFieldAsInteger(ATTACK1_DMG_DICE, 0); + final int damageSidesPerDie = unitType.getFieldAsInteger(ATTACK1_DMG_SIDES_PER_DIE, 0); + final float damageSpillDistance = unitType.getFieldAsFloat(ATTACK1_DMG_SPILL_DIST, 0); + final float damageSpillRadius = unitType.getFieldAsFloat(ATTACK1_DMG_SPILL_RADIUS, 0); + final int damageUpgradeAmount = unitType.getFieldAsInteger(ATTACK1_DMG_UPGRADE_AMT, 0); + final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK1_TARGET_COUNT, 0); + final float projectileArc = unitType.getFieldAsFloat(ATTACK1_PROJECTILE_ARC, 0); + final String projectileArt = unitType.getFieldAsString(ATTACK1_MISSILE_ART, 0); + final boolean projectileHomingEnabled = unitType.getFieldAsBoolean(ATTACK1_PROJECTILE_HOMING_ENABLED, + 0); + final int projectileSpeed = unitType.getFieldAsInteger(ATTACK1_PROJECTILE_SPEED, 0); + final int range = unitType.getFieldAsInteger(ATTACK1_RANGE, 0); + final float rangeMotionBuffer = unitType.getFieldAsFloat(ATTACK1_RANGE_MOTION_BUFFER, 0); + final boolean showUI = unitType.getFieldAsBoolean(ATTACK1_SHOW_UI, 0); + final EnumSet targetsAllowed = CTargetType + .parseTargetTypeSet(unitType.getFieldAsList(ATTACK1_TARGETS_ALLOWED)); + final String weaponSound = unitType.getFieldAsString(ATTACK1_WEAPON_SOUND, 0); + final String weapon_type_temp = unitType.getFieldAsString(ATTACK1_WEAPON_TYPE, 0); + CWeaponType weaponType = CWeaponType.NONE; + if (!"_".equals(weapon_type_temp)) { + weaponType = CWeaponType.parseWeaponType(weapon_type_temp); + } + attacks.add(createAttack(animationBackswingPoint, animationDamagePoint, areaOfEffectFullDamage, + areaOfEffectMediumDamage, areaOfEffectSmallDamage, areaOfEffectTargets, attackType, + cooldownTime, damageBase, damageFactorMedium, damageFactorSmall, damageLossFactor, damageDice, + damageSidesPerDie, damageSpillDistance, damageSpillRadius, damageUpgradeAmount, + maximumNumberOfTargets, projectileArc, projectileArt, projectileHomingEnabled, projectileSpeed, + range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, weaponType)); + } catch (final Exception exc) { + System.err.println("Attack 1 failed to parse with: " + exc.getClass() + ":" + exc.getMessage()); + } + try { + // attack two + final float animationBackswingPoint = unitType.getFieldAsFloat(ATTACK2_BACKSWING_POINT, 0); + final float animationDamagePoint = unitType.getFieldAsFloat(ATTACK2_DAMAGE_POINT, 0); + final int areaOfEffectFullDamage = unitType.getFieldAsInteger(ATTACK2_AREA_OF_EFFECT_FULL_DMG, 0); + final int areaOfEffectMediumDamage = unitType.getFieldAsInteger(ATTACK2_AREA_OF_EFFECT_HALF_DMG, 0); + final int areaOfEffectSmallDamage = unitType.getFieldAsInteger(ATTACK2_AREA_OF_EFFECT_QUARTER_DMG, 0); + final EnumSet areaOfEffectTargets = CTargetType + .parseTargetTypeSet(unitType.getFieldAsList(ATTACK2_AREA_OF_EFFECT_TARGETS)); + final CAttackType attackType = CAttackType + .parseAttackType(unitType.getFieldAsString(ATTACK2_ATTACK_TYPE, 0)); + final float cooldownTime = unitType.getFieldAsFloat(ATTACK2_COOLDOWN, 0); + final int damageBase = unitType.getFieldAsInteger(ATTACK2_DMG_BASE, 0); + final float damageFactorMedium = unitType.getFieldAsFloat(ATTACK2_DAMAGE_FACTOR_HALF, 0); + final float damageFactorSmall = unitType.getFieldAsFloat(ATTACK2_DAMAGE_FACTOR_QUARTER, 0); + final float damageLossFactor = unitType.getFieldAsFloat(ATTACK2_DAMAGE_LOSS_FACTOR, 0); + final int damageDice = unitType.getFieldAsInteger(ATTACK2_DMG_DICE, 0); + final int damageSidesPerDie = unitType.getFieldAsInteger(ATTACK2_DMG_SIDES_PER_DIE, 0); + final float damageSpillDistance = unitType.getFieldAsFloat(ATTACK2_DMG_SPILL_DIST, 0); + final float damageSpillRadius = unitType.getFieldAsFloat(ATTACK2_DMG_SPILL_RADIUS, 0); + final int damageUpgradeAmount = unitType.getFieldAsInteger(ATTACK2_DMG_UPGRADE_AMT, 0); + final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK2_TARGET_COUNT, 0); + float projectileArc = unitType.getFieldAsFloat(ATTACK2_PROJECTILE_ARC, 0); + String projectileArt = unitType.getFieldAsString(ATTACK2_MISSILE_ART, 0); + int projectileSpeed = unitType.getFieldAsInteger(ATTACK2_PROJECTILE_SPEED, 0); + if ("_".equals(projectileArt) || projectileArt.isEmpty()) { + projectileArt = unitType.getFieldAsString(ATTACK1_MISSILE_ART, 0); + projectileSpeed = unitType.getFieldAsInteger(ATTACK1_PROJECTILE_SPEED, 0); + projectileArc = unitType.getFieldAsFloat(ATTACK1_PROJECTILE_ARC, 0); + } + final boolean projectileHomingEnabled = unitType.getFieldAsBoolean(ATTACK2_PROJECTILE_HOMING_ENABLED, + 0); + final int range = unitType.getFieldAsInteger(ATTACK2_RANGE, 0); + final float rangeMotionBuffer = unitType.getFieldAsFloat(ATTACK2_RANGE_MOTION_BUFFER, 0); + boolean showUI = unitType.getFieldAsBoolean(ATTACK2_SHOW_UI, 0); + final EnumSet targetsAllowed = CTargetType + .parseTargetTypeSet(unitType.getFieldAsList(ATTACK2_TARGETS_ALLOWED)); + final String weaponSound = unitType.getFieldAsString(ATTACK2_WEAPON_SOUND, 0); + final String weapon_type_temp = unitType.getFieldAsString(ATTACK2_WEAPON_TYPE, 0); + CWeaponType weaponType = CWeaponType.NONE; + if (!"_".equals(weapon_type_temp)) { + weaponType = CWeaponType.parseWeaponType(weapon_type_temp); + } + if (!attacks.isEmpty()) { + final CUnitAttack otherAttack = attacks.get(0); + if ((otherAttack.getAttackType() == attackType) && (targetsAllowed.size() == 1) + && (targetsAllowed.contains(CTargetType.TREE) + || (targetsAllowed.contains(CTargetType.STRUCTURE) + && (otherAttack.getDamageBase() == damageBase) + && (otherAttack.getDamageSidesPerDie() == damageSidesPerDie) + && (otherAttack.getDamageDice() == damageDice)))) { + showUI = false; + } + } + attacks.add(createAttack(animationBackswingPoint, animationDamagePoint, areaOfEffectFullDamage, + areaOfEffectMediumDamage, areaOfEffectSmallDamage, areaOfEffectTargets, attackType, + cooldownTime, damageBase, damageFactorMedium, damageFactorSmall, damageLossFactor, damageDice, + damageSidesPerDie, damageSpillDistance, damageSpillRadius, damageUpgradeAmount, + maximumNumberOfTargets, projectileArc, projectileArt, projectileHomingEnabled, projectileSpeed, + range, rangeMotionBuffer, showUI, targetsAllowed, weaponSound, weaponType)); + } catch (final Exception exc) { + System.err.println("Attack 2 failed to parse with: " + exc.getClass() + ":" + exc.getMessage()); + } + final List enabledAttacks = getEnabledAttacks(attacks, attacksEnabled); + final int deathType = unitType.getFieldAsInteger(DEATH_TYPE, 0); + final boolean raise = (deathType & 0x1) != 0; + final boolean decay = (deathType & 0x2) != 0; + final String armorType = unitType.getFieldAsString(ARMOR_TYPE, 0); + final float impactZ = unitType.getFieldAsFloat(PROJECTILE_IMPACT_Z, 0); + final CDefenseType defenseType = CDefenseType.parseDefenseType(unitType.getFieldAsString(DEFENSE_TYPE, 0)); + final float deathTime = unitType.getFieldAsFloat(DEATH_TIME, 0); + final int goldCost = unitType.getFieldAsInteger(GOLD_COST, 0); + final int lumberCost = unitType.getFieldAsInteger(LUMBER_COST, 0); + final int buildTime = (int) Math + .ceil(unitType.getFieldAsInteger(BUILD_TIME, 0) * WarsmashConstants.GAME_SPEED_TIME_FACTOR); + final int goldRepairCost = unitType.getFieldAsInteger(GOLD_REPAIR_COST, 0); + final int lumberRepairCost = unitType.getFieldAsInteger(LUMBER_REPAIR_COST, 0); + final int repairTime = (int) Math + .ceil(unitType.getFieldAsInteger(REPAIR_TIME, 0) * WarsmashConstants.GAME_SPEED_TIME_FACTOR); + final int foodUsed = unitType.getFieldAsInteger(FOOD_USED, 0); + final int foodMade = unitType.getFieldAsInteger(FOOD_MADE, 0); + + final float castBackswingPoint = unitType.getFieldAsFloat(CAST_BACKSWING_POINT, 0); + final float castPoint = unitType.getFieldAsFloat(CAST_POINT, 0); + + final int pointValue = unitType.getFieldAsInteger(POINT_VALUE, 0); + + final int sightRadiusDay = unitType.getFieldAsInteger(SIGHT_RADIUS_DAY, 0); + final int sightRadiusNight = unitType.getFieldAsInteger(SIGHT_RADIUS_NIGHT, 0); + final boolean extendedLineOfSight = unitType.getFieldAsBoolean(EXTENDED_LOS, 0); + + final int goldBountyAwardedBase = unitType.getFieldAsInteger(GOLD_BOUNTY_AWARDED_BASE, 0); + final int goldBountyAwardedDice = unitType.getFieldAsInteger(GOLD_BOUNTY_AWARDED_DICE, 0); + final int goldBountyAwardedSides = unitType.getFieldAsInteger(GOLD_BOUNTY_AWARDED_SIDES, 0); + + final int lumberBountyAwardedBase = unitType.getFieldAsInteger(LUMBER_BOUNTY_AWARDED_BASE, 0); + final int lumberBountyAwardedDice = unitType.getFieldAsInteger(LUMBER_BOUNTY_AWARDED_DICE, 0); + final int lumberBountyAwardedSides = unitType.getFieldAsInteger(LUMBER_BOUNTY_AWARDED_SIDES, 0); + + final boolean revivesHeroes = unitType.getFieldAsBoolean(REVIVES_HEROES, 0); + + final List unitsTrained = parseIDList(unitType.getFieldAsList(UNITS_TRAINED)); + + final List upgradesTo = parseIDList(unitType.getFieldAsList(UPGRADES_TO)); + + final List researchesAvailable = parseIDList(unitType.getFieldAsList(RESEARCHES_AVAILABLE)); + + final List upgradesUsed = parseIDList(unitType.getFieldAsList(UPGRADES_USED)); + final EnumMap upgradeClassToType = new EnumMap<>(CUpgradeClass.class); + for (final War3ID upgradeUsed : upgradesUsed) { + final CUpgradeType upgradeType = this.upgradeData.getType(upgradeUsed); + if (upgradeType != null) { + final CUpgradeClass upgradeClass = upgradeType.getUpgradeClass(); + if (upgradeClass != null) { + upgradeClassToType.put(upgradeClass, upgradeUsed); + } + } + } + + final List structuresBuilt = parseIDList(unitType.getFieldAsList(STRUCTURES_BUILT)); + + final List itemsSold = parseIDList(unitType.getFieldAsList(ITEMS_SOLD)); + final List itemsMade = parseIDList(unitType.getFieldAsList(ITEMS_MADE)); + + final War3ID defaultAutocastAbilityId; + if ((defaultAutocastAbility != null) && !defaultAutocastAbility.isEmpty() + && !defaultAutocastAbility.equals("_")) { + defaultAutocastAbilityId = War3ID.fromString(defaultAutocastAbility); + } else { + defaultAutocastAbilityId = null; + } + final List heroAbilityList = parseIDList(heroAbilityListString); + final List abilityList = parseIDList(abilityListString); + + final List requirementsString = unitType.getFieldAsList(REQUIRES); + final List requirementsLevelsString = unitType.getFieldAsList(REQUIRES_AMOUNT); + final List requirements = parseRequirements(requirementsString, + requirementsLevelsString); + final int requirementsTiersCount = unitType.getFieldAsInteger(REQUIRES_TIER_COUNT, 0); + final List> requirementTiers = new ArrayList<>(); + for (int i = 1; i <= requirementsTiersCount; i++) { + final List requirementsTierString = unitType.getFieldAsList(REQUIRES_TIER_X[i - 1]); + final List tierRequirements = parseRequirements(requirementsTierString, + Collections.emptyList()); + requirementTiers.add(tierRequirements); + } + + final EnumSet preventedPathingTypes = CBuildingPathingType + .parsePathingTypeListSet(unitType.getFieldAsString(PREVENT_PLACE, 0)); + final EnumSet requiredPathingTypes = CBuildingPathingType + .parsePathingTypeListSet(unitType.getFieldAsString(REQUIRE_PLACE, 0)); + + final String raceString = unitType.getFieldAsString(UNIT_RACE, 0); + final CUnitRace unitRace = CUnitRace.parseRace(raceString); + + final boolean hero = Character.isUpperCase(typeId.charAt(0)); + + final List heroProperNames = Arrays.asList(properNames.split(",")); + + final boolean neutralBuildingShowMinimapIcon = unitType.getFieldAsBoolean(NEUTRAL_BUILDING_SHOW_ICON, 0); + + final String tilesets = unitType.getField(TILESETS); + final boolean special = unitType.getFieldAsBoolean(SPECIAL, 0); + + unitTypeInstance = new CUnitType(unitName, legacyName, typeId, life, lifeRegen, manaRegen, lifeRegenType, + manaInitial, manaMaximum, speed, maxSpeed, minSpeed, defense, defaultAutocastAbilityId, abilityList, isBldg, + movementType, moveHeight, collisionSize, classifications, attacks, attacksEnabled, armorType, raise, + decay, defenseType, impactZ, null, deathTime, targetedAs, acquisitionRange, + minimumAttackRange, structuresBuilt, unitsTrained, researchesAvailable, upgradesUsed, + upgradeClassToType, upgradesTo, itemsSold, itemsMade, unitRace, goldCost, lumberCost, foodUsed, + foodMade, buildTime, goldRepairCost, lumberRepairCost, repairTime, preventedPathingTypes, + requiredPathingTypes, propWindow, turnRate, requirements, requirementTiers, unitLevel, hero, + strength, strPlus, agility, agiPlus, intelligence, intPlus, primaryAttribute, heroAbilityList, + heroProperNames, properNamesCount, canFlee, priority, revivesHeroes, pointValue, castBackswingPoint, + castPoint, canBeBuiltOnThem, canBuildOnMe, defenseUpgradeBonus, sightRadiusDay, sightRadiusNight, + extendedLineOfSight, goldBountyAwardedBase, goldBountyAwardedDice, goldBountyAwardedSides, + lumberBountyAwardedBase, lumberBountyAwardedDice, lumberBountyAwardedSides, + neutralBuildingShowMinimapIcon, tilesets, special); + this.unitIdToUnitTypeLightweight.put(typeId, unitTypeInstance); + } + return unitTypeInstance; + } + + public CUnitType getUnitTypeLightweight(final War3ID rawcode) { + final CUnitType unitTypeInstance = this.unitIdToUnitType.get(rawcode); + if (unitTypeInstance != null) { + return unitTypeInstance; + } + final GameObject unitType = this.unitData.get(rawcode.asStringValue()); + if (unitType == null) { + return null; + } + return getUnitTypeInstanceLightweight(rawcode, unitType); + } + + public Collection getAllUnitTypesLightweight() { + Set keys = this.unitData.keySet(); + if (this.unitIdToUnitTypeLightweight.size() < keys.size()) { + for (String key : keys) { + this.getUnitTypeLightweight(War3ID.fromString(key)); + } + } + return this.unitIdToUnitTypeLightweight.values(); + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtPoint.java index 3570de72e..b2729b50d 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtPoint.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtPoint.java @@ -50,7 +50,7 @@ public CBehavior begin(final CSimulation game, final CUnit caster) { game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); return caster.pollNextOrderBehavior(game); } - ability.checkCanUse(game, caster, this.orderId, this.abilityActivationReceiver.reset()); + ability.checkCanUse(game, caster, this.orderId, false, this.abilityActivationReceiver.reset()); if (this.abilityActivationReceiver.isUseOk()) { final CItem itemToDrop = (CItem) game.getWidget(this.itemHandleId); return ability.beginDropItem(game, caster, this.orderId, itemToDrop, this.target); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtTargetWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtTargetWidget.java index 410813d7c..17d3214c1 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtTargetWidget.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderDropItemAtTargetWidget.java @@ -52,12 +52,12 @@ public CBehavior begin(final CSimulation game, final CUnit caster) { game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); return caster.pollNextOrderBehavior(game); } - ability.checkCanUse(game, caster, this.orderId, this.abilityActivationReceiver.reset()); + ability.checkCanUse(game, caster, this.orderId, false, this.abilityActivationReceiver.reset()); if (this.abilityActivationReceiver.isUseOk()) { final CItem itemToDrop = (CItem) game.getWidget(this.itemHandleId); final CUnit targetHero = (CUnit) game.getWidget(this.targetHeroHandleId); final ExternStringMsgTargetCheckReceiver targetReceiver = (ExternStringMsgTargetCheckReceiver) targetCheckReceiver; - ability.checkCanTarget(game, caster, this.orderId, targetHero, targetReceiver.reset()); + ability.checkCanTarget(game, caster, this.orderId, false, targetHero, targetReceiver.reset()); if (targetReceiver.getTarget() != null) { return ability.beginDropItem(game, caster, this.orderId, itemToDrop, targetHero); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderNoTarget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderNoTarget.java index a271b1bda..8af4d91f4 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderNoTarget.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderNoTarget.java @@ -11,11 +11,17 @@ public class COrderNoTarget implements COrder { private final int abilityHandleId; private final int orderId; private final boolean queued; + private boolean autoOrder; public COrderNoTarget(final int abilityHandleId, final int orderId, final boolean queued) { + this(abilityHandleId, orderId, queued, false); + } + + public COrderNoTarget(final int abilityHandleId, final int orderId, final boolean queued, final boolean autoOrder) { this.abilityHandleId = abilityHandleId; this.orderId = orderId; this.queued = queued; + this.autoOrder = autoOrder; } @Override @@ -40,23 +46,24 @@ public CBehavior begin(final CSimulation game, final CUnit caster) { } final CAbility ability = game.getAbility(this.abilityHandleId); if (ability == null) { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); + if (!caster.order(game, this.orderId, null)) { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); + } return caster.pollNextOrderBehavior(game); } - ability.checkCanUse(game, caster, this.orderId, this.abilityActivationReceiver.reset()); + ability.checkCanUse(game, caster, this.orderId, this.autoOrder, this.abilityActivationReceiver.reset()); if (this.abilityActivationReceiver.isUseOk()) { final ExternStringMsgTargetCheckReceiver targetReceiver = (ExternStringMsgTargetCheckReceiver) targetCheckReceiver; - ability.checkCanTargetNoTarget(game, caster, this.orderId, targetReceiver); + ability.checkCanTargetNoTarget(game, caster, this.orderId, this.autoOrder, targetReceiver); if (targetReceiver.getExternStringKey() == null) { caster.fireOrderEvents(game, this); - return ability.beginNoTarget(game, caster, this.orderId); - } - else { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), targetReceiver.getExternStringKey()); + return ability.beginNoTarget(game, caster, this.orderId, this.autoOrder); + } else { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), + targetReceiver.getExternStringKey()); return caster.pollNextOrderBehavior(game); } - } - else { + } else { game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), this.abilityActivationReceiver.getExternStringKey()); return caster.pollNextOrderBehavior(game); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetPoint.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetPoint.java index 7600a0a36..5c34fd9ad 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetPoint.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetPoint.java @@ -12,13 +12,20 @@ public class COrderTargetPoint implements COrder { private final int orderId; private final AbilityPointTarget target; private final boolean queued; + private boolean autoOrder; public COrderTargetPoint(final int abilityHandleId, final int orderId, final AbilityPointTarget target, final boolean queued) { + this(abilityHandleId, orderId, target, queued, false); + } + + public COrderTargetPoint(final int abilityHandleId, final int orderId, final AbilityPointTarget target, + final boolean queued, boolean autoOrder) { this.abilityHandleId = abilityHandleId; this.orderId = orderId; this.target = target; this.queued = queued; + this.autoOrder = autoOrder; } @Override @@ -45,16 +52,18 @@ public boolean isQueued() { public CBehavior begin(final CSimulation game, final CUnit caster) { final CAbility ability = game.getAbility(this.abilityHandleId); if (ability == null) { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); + if (!caster.order(game, this.orderId, this.target)) { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); + } return caster.pollNextOrderBehavior(game); } - ability.checkCanUse(game, caster, this.orderId, this.abilityActivationReceiver.reset()); + ability.checkCanUse(game, caster, this.orderId, this.autoOrder, this.abilityActivationReceiver.reset()); if (this.abilityActivationReceiver.isUseOk()) { final ExternStringMsgTargetCheckReceiver targetReceiver = (ExternStringMsgTargetCheckReceiver) targetCheckReceiver; - ability.checkCanTarget(game, caster, this.orderId, this.target, targetReceiver); + ability.checkCanTarget(game, caster, this.orderId, this.autoOrder, this.target, targetReceiver); if (targetReceiver.getTarget() != null) { caster.fireOrderEvents(game, this); - return ability.begin(game, caster, this.orderId, this.target); + return ability.begin(game, caster, this.orderId, this.autoOrder, this.target); } else { game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), targetReceiver.getExternStringKey()); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetWidget.java index df5dcc0f8..07cae5009 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetWidget.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetWidget.java @@ -12,13 +12,20 @@ public class COrderTargetWidget implements COrder { private final int orderId; private final int targetHandleId; private final boolean queued; + private boolean autoOrder; public COrderTargetWidget(final int abilityHandleId, final int orderId, final int targetHandleId, final boolean queued) { + this(abilityHandleId, orderId, targetHandleId, queued, false); + } + + public COrderTargetWidget(final int abilityHandleId, final int orderId, final int targetHandleId, + final boolean queued, final boolean autoOrder) { this.abilityHandleId = abilityHandleId; this.orderId = orderId; this.targetHandleId = targetHandleId; this.queued = queued; + this.autoOrder = autoOrder; } @Override @@ -45,17 +52,19 @@ public boolean isQueued() { public CBehavior begin(final CSimulation game, final CUnit caster) { final CAbility ability = game.getAbility(this.abilityHandleId); if (ability == null) { - game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); + if (!caster.order(game, this.orderId, this.getTarget(game))) { + game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), "NOTEXTERN: No such ability"); + } return caster.pollNextOrderBehavior(game); } - ability.checkCanUse(game, caster, this.orderId, abilityActivationReceiver.reset()); + ability.checkCanUse(game, caster, this.orderId, this.autoOrder, abilityActivationReceiver.reset()); if (abilityActivationReceiver.isUseOk()) { final CWidget target = game.getWidget(this.targetHandleId); final ExternStringMsgTargetCheckReceiver targetReceiver = (ExternStringMsgTargetCheckReceiver) targetCheckReceiver; - ability.checkCanTarget(game, caster, this.orderId, target, targetReceiver.reset()); + ability.checkCanTarget(game, caster, this.orderId, this.autoOrder, target, targetReceiver.reset()); if (targetReceiver.getTarget() != null) { caster.fireOrderEvents(game, this); - return ability.begin(game, caster, this.orderId, targetReceiver.getTarget()); + return ability.begin(game, caster, this.orderId, this.autoOrder, targetReceiver.getTarget()); } else { game.getCommandErrorListener().showInterfaceError(caster.getPlayerIndex(), targetReceiver.getExternStringKey()); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/CPlayer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/CPlayer.java index f7d0a09f2..d1bf4962c 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/CPlayer.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/CPlayer.java @@ -187,8 +187,7 @@ public void addTechtreeUnlocked(CSimulation simulation, final War3ID rawcode) { final Integer techtreeUnlocked = this.rawcodeToTechtreeUnlocked.get(rawcode); if (techtreeUnlocked == null) { this.rawcodeToTechtreeUnlocked.put(rawcode, 1); - } - else { + } else { this.rawcodeToTechtreeUnlocked.put(rawcode, techtreeUnlocked + 1); } fireRequirementUpdateForAbilities(simulation, false); @@ -204,8 +203,7 @@ public void removeTechtreeUnlocked(CSimulation simulation, final War3ID rawcode) final Integer techtreeUnlocked = this.rawcodeToTechtreeUnlocked.get(rawcode); if (techtreeUnlocked == null) { this.rawcodeToTechtreeUnlocked.put(rawcode, -1); - } - else { + } else { this.rawcodeToTechtreeUnlocked.put(rawcode, techtreeUnlocked - 1); } fireRequirementUpdateForAbilities(simulation, true); @@ -215,8 +213,7 @@ public void addTechtreeInProgress(final War3ID rawcode) { final Integer techtreeUnlocked = this.rawcodeToTechtreeInProgress.get(rawcode); if (techtreeUnlocked == null) { this.rawcodeToTechtreeInProgress.put(rawcode, 1); - } - else { + } else { this.rawcodeToTechtreeInProgress.put(rawcode, techtreeUnlocked + 1); } } @@ -225,8 +222,7 @@ public void removeTechtreeInProgress(final War3ID rawcode) { final Integer techtreeUnlocked = this.rawcodeToTechtreeInProgress.get(rawcode); if (techtreeUnlocked == null) { this.rawcodeToTechtreeInProgress.put(rawcode, -1); - } - else { + } else { this.rawcodeToTechtreeInProgress.put(rawcode, techtreeUnlocked - 1); } } @@ -343,8 +339,7 @@ public List getHeroes() { public int getHeroCount(final CSimulation game, final boolean includeInProgress) { if (!includeInProgress) { return this.heroes.size(); - } - else { + } else { int heroInProgressCount = 0; for (final Map.Entry entry : this.rawcodeToTechtreeInProgress.entrySet()) { final CUnitType unitType = game.getUnitData().getUnitType(entry.getKey()); @@ -371,6 +366,15 @@ public void fireUnitDeathEvents(final CUnit dyingUnit, final CUnit killingUnit) } } + public void fireSimpleUnitEvents(final CUnit unit, final JassGameEventsWar3 type, final CSimulation game) { + final List eventList = getEventList(type); + if (eventList != null) { + for (final CPlayerEvent event : eventList) { + event.fire(unit, CommonTriggerExecutionScope.simpleUnitScope(type, event.getTrigger(), unit, this)); + } + } + } + public void fireOrderEvents(final CUnit unit, final CSimulation game, final COrderNoTarget orderNoTarget) { final List eventList = getEventList(JassGameEventsWar3.EVENT_PLAYER_UNIT_ISSUED_ORDER); if (eventList != null) { @@ -753,8 +757,7 @@ private void setTechToLevel(final CSimulation simulation, final War3ID techIdRaw public void addFogModifer(final CSimulation game, final CFogModifier fogModifier, boolean afterUnits) { if (afterUnits) { this.fogModifiersAfterUnits.add(fogModifier); - } - else { + } else { this.fogModifiers.add(fogModifier); } fogModifier.onAdd(game, this); @@ -781,8 +784,7 @@ public void updateFogModifiersAfterUnits(final CSimulation game) { public void setAbilityEnabled(final CSimulation simulation, War3ID ability, boolean enabled) { if (enabled) { this.disabledAbilities.remove(ability); - } - else { + } else { this.disabledAbilities.add(ability); } fireRequirementUpdateForAbilities(simulation, !enabled); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CProjectileVisionFogModifier.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CProjectileVisionFogModifier.java new file mode 100644 index 000000000..ce4f61677 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/players/vision/CProjectileVisionFogModifier.java @@ -0,0 +1,82 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.vision; + +import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CFogState; + +public class CProjectileVisionFogModifier extends CFogModifier { + private boolean enabled = true; + private CProjectile projectile; + private float sightRadius; + + public CProjectileVisionFogModifier(final CProjectile projectile, final float sightRadius) { + this.projectile = projectile; + this.sightRadius = sightRadius; + } + + @Override + public void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + + @Override + public void update(final CSimulation game, final CPlayer player, final PathingGrid pathingGrid, + final CPlayerFogOfWar fogOfWar) { + if (enabled && !this.projectile.isDone()) { + if (sightRadius > 0) { + final boolean flying = true; + final float radSq = sightRadius * sightRadius / (CPlayerFogOfWar.GRID_STEP * CPlayerFogOfWar.GRID_STEP); + final float myX = this.projectile.getX(); + final float myY = this.projectile.getY(); + final int myZ = flying ? Integer.MAX_VALUE : game.getTerrainHeight(myX, myY); + fogOfWar.setVisible(game.getPathingGrid().getFogOfWarIndexX(myX), + game.getPathingGrid().getFogOfWarIndexY(myY), CFogState.VISIBLE); + + int myXi = game.getPathingGrid().getFogOfWarIndexX(myX); + int myYi = game.getPathingGrid().getFogOfWarIndexY(myY); + int maxXi = game.getPathingGrid().getFogOfWarIndexX(myX + sightRadius); + int maxYi = game.getPathingGrid().getFogOfWarIndexY(myY + sightRadius); + for (int a = 1; a <= Math.max(maxYi - myYi, maxXi - myXi); a++) { + if (a * a <= radSq) { + fogOfWar.checkCardinalVision(game, pathingGrid, flying, myXi, myYi - a, myXi, myYi - a + 1, myX, + myY - a * CPlayerFogOfWar.GRID_STEP, myX, myY - (a - 1) * CPlayerFogOfWar.GRID_STEP, + myZ); + fogOfWar.checkCardinalVision(game, pathingGrid, flying, myXi, myYi + a, myXi, myYi + a - 1, myX, + myY + a * CPlayerFogOfWar.GRID_STEP, myX, myY + (a - 1) * CPlayerFogOfWar.GRID_STEP, + myZ); + fogOfWar.checkCardinalVision(game, pathingGrid, flying, myXi - a, myYi, myXi - a + 1, myYi, + myX - a * CPlayerFogOfWar.GRID_STEP, myY, myX - (a - 1) * CPlayerFogOfWar.GRID_STEP, + myY, myZ); + fogOfWar.checkCardinalVision(game, pathingGrid, flying, myXi + a, myYi, myXi + a - 1, myYi, + myX + a * CPlayerFogOfWar.GRID_STEP, myY, myX + (a - 1) * CPlayerFogOfWar.GRID_STEP, + myY, myZ); + } + } + + for (int y = 1; y <= maxYi - myYi; y++) { + for (int x = 1; x <= maxXi - myXi; x++) { + if (x * x + y * y <= radSq) { + int xf = x * CPlayerFogOfWar.GRID_STEP; + int yf = y * CPlayerFogOfWar.GRID_STEP; + + fogOfWar.checkDiagonalVision(game, pathingGrid, flying, x, y, myXi - x, myYi - y, + myXi - x + 1, myYi - y + 1, myX - xf, myY - yf, + myX - xf + CPlayerFogOfWar.GRID_STEP, myY - yf + CPlayerFogOfWar.GRID_STEP, myZ); + fogOfWar.checkDiagonalVision(game, pathingGrid, flying, x, y, myXi - x, myYi + y, + myXi - x + 1, myYi + y - 1, myX - xf, myY + yf, + myX - xf + CPlayerFogOfWar.GRID_STEP, myY + yf - CPlayerFogOfWar.GRID_STEP, myZ); + fogOfWar.checkDiagonalVision(game, pathingGrid, flying, x, y, myXi + x, myYi - y, + myXi + x - 1, myYi - y + 1, myX + xf, myY - yf, + myX + xf - CPlayerFogOfWar.GRID_STEP, myY - yf + CPlayerFogOfWar.GRID_STEP, myZ); + fogOfWar.checkDiagonalVision(game, pathingGrid, flying, x, y, myXi + x, myYi + y, + myXi + x - 1, myYi + y - 1, myX + xf, myY + yf, + myX + xf - CPlayerFogOfWar.GRID_STEP, myY + yf - CPlayerFogOfWar.GRID_STEP, myZ); + } + } + } + } + } + } +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/timers/CTimer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/timers/CTimer.java index 2a022dca4..4fb570a76 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/timers/CTimer.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/timers/CTimer.java @@ -15,6 +15,12 @@ public void setTimeoutTime(final float timeoutTime) { this.timeoutTime = timeoutTime; } + public void resetTimeoutTime(final float timeoutTime) { + this.timeoutTime = timeoutTime; + final int ticks = (int) (timeoutTime / WarsmashConstants.SIMULATION_STEP_TIME); + this.engineFireTick = this.scheduleTick + ticks; + } + public boolean isRepeats() { return this.repeats; } @@ -55,6 +61,11 @@ public void pause(final CSimulation simulation) { this.remainingTimeAfterPause = getRemaining(simulation); simulation.unregisterTimer(this); } + + public void kill(final CSimulation simulation) { + this.pause(simulation); + this.repeats = false; + } public void resume(final CSimulation simulation) { if (this.remainingTimeAfterPause == 0) { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/trigger/enumtypes/CDamageType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/trigger/enumtypes/CDamageType.java index a770b69ff..83fe7964a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/trigger/enumtypes/CDamageType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/trigger/enumtypes/CDamageType.java @@ -3,33 +3,45 @@ import com.etheller.interpreter.ast.util.CHandle; public enum CDamageType implements CHandle { - UNKNOWN, - UNKNOWN_CODE_1, - UNKNOWN_CODE_2, - UNKNOWN_CODE_3, - NORMAL, - ENHANCED, - UNKNOWN_CODE_6, - UNKNOWN_CODE_7, - FIRE, - COLD, - LIGHTNING, - POISON, - DISEASE, - DIVINE, - MAGIC, - SONIC, - ACID, - FORCE, - DEATH, - MIND, - PLANT, - DEFENSIVE, - DEMOLITION, - SLOW_POISON, - SPIRIT_LINK, - SHADOW_STRIKE, - UNIVERSAL; + UNKNOWN(false, false, false, true), + UNKNOWN_CODE_1(false, false, false, true), + UNKNOWN_CODE_2(false, false, false, true), + UNKNOWN_CODE_3(false, false, false, true), + NORMAL(false, false, true, false), + ENHANCED(false, false, true, false), + UNKNOWN_CODE_6(false, false, false, true), + UNKNOWN_CODE_7(false, false, false, true), + FIRE(false, true, false, true), + COLD(false, true, false, true), + LIGHTNING(false, true, false, true), + POISON(false, false, true, true), + DISEASE(false, false, true, true), + DIVINE(false, true, false, true), + MAGIC(false, true, false, true), + SONIC(false, true, false, true), + ACID(false, false, true, true), + FORCE(false, true, false, true), + DEATH(false, true, false, true), + MIND(false, true, false, true), + PLANT(false, true, false, true), + DEFENSIVE(false, true, false, true), + DEMOLITION(false, false, true, false), + SLOW_POISON(false, false, true, true), + SPIRIT_LINK(false, true, false, true), + SHADOW_STRIKE(false, true, false, true), + UNIVERSAL(true, false, false, false); + + private boolean universal; + private boolean magic; + private boolean physical; + private boolean oldMagic; + + private CDamageType(boolean universal, boolean magic, boolean physical, boolean oldMagic) { + this.universal = universal; + this.magic = magic; + this.physical = physical; + this.oldMagic = oldMagic; + } public static CDamageType[] VALUES = values(); @@ -37,4 +49,20 @@ public enum CDamageType implements CHandle { public int getHandleId() { return ordinal(); } + + public boolean isUniversal() { + return this.universal; + } + + public boolean isMagic() { + return this.magic; + } + + public boolean isPhysical() { + return this.physical; + } + + public boolean isOldMagic() { + return this.oldMagic; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/CUnitAppliedUpgrade.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/CUnitAppliedUpgrade.java new file mode 100644 index 000000000..c2ef03f14 --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/CUnitAppliedUpgrade.java @@ -0,0 +1,30 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit; + +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUpgradeType; + +public class CUnitAppliedUpgrade { + private int level; + private CUpgradeType type; + + public CUnitAppliedUpgrade(CUpgradeType type, int level) { + this.type = type; + this.level = level; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public CUpgradeType getType() { + return type; + } + + public void setType(CUpgradeType type) { + this.type = type; + } + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/CWidgetEvent.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/CWidgetEvent.java index 87258eef1..2cdaa5cd0 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/CWidgetEvent.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/CWidgetEvent.java @@ -39,6 +39,10 @@ public JassGameEventsWar3 getEventType() { return this.eventType; } + public CWidget getWidget() { + return this.widget; + } + @Override public void remove() { this.widget.removeEvent(this); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/NonStackingStatBuffType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/NonStackingStatBuffType.java index e9d383b95..c08534c84 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/NonStackingStatBuffType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/NonStackingStatBuffType.java @@ -3,32 +3,41 @@ import com.etheller.interpreter.ast.util.CHandle; public enum NonStackingStatBuffType implements CHandle { - MELEEATK, - MELEEATKPCT, - RNGDATK, - RNGDATKPCT, - ATKSPD, - DEF, - DEFPCT, - HPGEN, - HPGENPCT, - MAXHPGENPCT, - MPGEN, - MPGENPCT, - MAXMPGENPCT, - MVSPD, - MVSPDPCT, - HPSTEAL, - THORNS, - THORNSPCT, + MELEEATK(false), + MELEEATKPCT(false), + RNGDATK(false), + RNGDATKPCT(false), + ATKSPD(false), + DEF(false), + DEFPCT(false), + HPGEN(false), + HPGENPCT(false), + MAXHPGENPCT(false), + MPGEN(false), + MPGENPCT(false), + MAXMPGENPCT(false), + MVSPD(false), + MVSPDPCT(false), + HPSTEAL(false), + THORNS(false), + THORNSPCT(false), - MAXHP, - MAXHPPCT, - MAXMP, - MAXMPPCT, + MAXHP(false), + MAXHPPCT(false), + MAXMP(false), + MAXMPPCT(false), + + STR(true), + STRPCT(true), + AGI(true), + AGIPCT(true), + INT(true), + INTPCT(true), - ALLATK, // These are for parsing - ALLATKPCT; + ALLATK(false), // These are for parsing + ALLATKPCT(false); + + private boolean heroStat; @Override public int getHandleId() { @@ -36,4 +45,12 @@ public int getHandleId() { } public static final NonStackingStatBuffType[] VALUES = values(); + + private NonStackingStatBuffType(final boolean hero) { + this.heroStat = hero; + } + + public boolean isHeroStat() { + return this.heroStat; + } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/StateModBuffType.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/StateModBuffType.java index 8517fa994..95007fe47 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/StateModBuffType.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/unit/StateModBuffType.java @@ -7,12 +7,17 @@ public enum StateModBuffType implements CHandle { RESISTANT, SLEEPING, STUN, + PAUSED, MAGIC_IMMUNE, MORPH_IMMUNE, SNARED, + POLYMORPHED, + ENABLE_ATTACK, DISABLE_AUTO_ATTACK, DISABLE_AUTO_CAST, DISABLE_ASSIST_ALLY, + DISABLE_ALL, + DISABLE_MOVE, DISABLE_ATTACK, DISABLE_MELEE_ATTACK, DISABLE_RANGED_ATTACK, @@ -21,9 +26,18 @@ public enum StateModBuffType implements CHandle { DISABLE_UNIT_COLLISION, DISABLE_BUILDING_COLLISION, INVULNERABLE, + HIDE_MINIMAP_ICON, + FALSE_OWNERSHIP, INVISIBLE, DETECTOR, - DETECTED; + DETECTED, + UNSELECTABLE, + UNTARGETABLE, + UNENUMERABLE, + UNAUTOATTACKABLE, + BLOCK_REPAIR, + BLOCK_TRAINING, + BLOCK_CONSTRUCTION; @Override public int getHandleId() { diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/upgrade/CUpgradeEffectAttackSpeed.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/upgrade/CUpgradeEffectAttackSpeed.java index 6a6c913b4..75f084da7 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/upgrade/CUpgradeEffectAttackSpeed.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/upgrade/CUpgradeEffectAttackSpeed.java @@ -22,14 +22,14 @@ public CUpgradeEffectAttackSpeed(final float base, final float mod) { @Override public void apply(final CSimulation simulation, final CUnit unit, final int level) { this.buff.setValue(base + mod * level); - unit.addNonStackingStatBuff(buff); + unit.addNonStackingStatBuff(simulation, buff); unit.notifyAttacksChanged(); // rebuild - ui for selected unit maybe } @Override public void unapply(final CSimulation simulation, final CUnit unit, final int level) { this.buff.setValue(base + mod * level); - unit.removeNonStackingStatBuff(buff); + unit.removeNonStackingStatBuff(simulation, buff); unit.notifyAttacksChanged(); // rebuild - ui for selected unit maybe } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/util/SimulationRenderController.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/util/SimulationRenderController.java index 6758c4116..80fc24013 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/util/SimulationRenderController.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/util/SimulationRenderController.java @@ -14,33 +14,40 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackInstant; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.CUnitAttackMissile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.attacks.replacement.CUnitAttackSettings; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityCollisionProjectileListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAbilityProjectileListener; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CAttackProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CCollisionProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CJassProjectile; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CPsuedoProjectile; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.projectile.CPseudoProjectile; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.trigger.enumtypes.CEffectType; public interface SimulationRenderController { + char getTileset(); + CAttackProjectile createAttackProjectile(CSimulation simulation, float launchX, float launchY, float launchFacing, CUnit source, CUnitAttackMissile attack, AbilityTarget target, float damage, int bounceIndex, - CUnitAttackListener attackListener); + CUnitAttackListener attackListener, CUnitAttackSettings settings); CAbilityProjectile createProjectile(CSimulation cSimulation, float launchX, float launchY, float launchFacing, - float speed, boolean homing, CUnit source, War3ID spellAlias, AbilityTarget target, + Float speed, Boolean homing, CUnit source, War3ID spellAlias, AbilityTarget target, + CAbilityProjectileListener projectileListener); + + CAbilityProjectile createProjectile(CSimulation cSimulation, float launchX, float launchY, float launchFacing, + CUnit source, CUnitAttackSettings settings, AbilityTarget target, CAbilityProjectileListener projectileListener); CJassProjectile createJassProjectile(CSimulation cSimulation, float launchX, float launchY, float launchFacing, float speed, boolean homing, CUnit source, War3ID spellAlias, AbilityTarget target); CCollisionProjectile createCollisionProjectile(CSimulation cSimulation, float launchX, float launchY, - float launchFacing, float projectileSpeed, boolean homing, CUnit source, War3ID spellAlias, + float launchFacing, Float projectileSpeed, Boolean homing, CUnit source, War3ID spellAlias, AbilityTarget target, int maxHits, int hitsPerTarget, float startingRadius, float finalRadius, float collisionInterval, CAbilityCollisionProjectileListener projectileListener, boolean provideCounts); - CPsuedoProjectile createPseudoProjectile(CSimulation cSimulation, float launchX, float launchY, float launchFacing, + CPseudoProjectile createPseudoProjectile(CSimulation cSimulation, float launchX, float launchY, float launchFacing, float projectileSpeed, float projectileStepInterval, int projectileArtSkip, boolean homing, CUnit source, War3ID spellAlias, CEffectType effectType, int effectArtIndex, AbilityTarget target, int maxHits, int hitsPerTarget, float startingRadius, float finalRadius, @@ -58,11 +65,15 @@ SimulationRenderComponentLightning createAbilityLightning(CSimulation simulation SimulationRenderComponentLightning createAbilityLightning(CSimulation simulation, War3ID lightningId, CUnit source, CUnit target, int index, Float duration); + SimulationRenderComponent createStaticUberSplat(float x, float y, War3ID id); + CUnit createUnit(CSimulation simulation, final War3ID typeId, final int playerIndex, final float x, final float y, final float facing); CItem createItem(CSimulation simulation, final War3ID typeId, final float x, final float y); + void updateItemModel(CItem item); + CDestructable createDestructable(War3ID typeId, float x, float y, float facing, float scale, int variation); CDestructable createDestructableZ(War3ID typeId, float x, float y, float z, float facing, float scale, @@ -144,7 +155,7 @@ SimulationRenderComponentModel createSpellEffectOverDestructable(CUnit source, C void setBlight(float x, float y, float radius, boolean blighted); - void unitUpdatedType(CUnit unit, War3ID typeId); + void unitUpdatedType(CUnit unit, War3ID typeId, boolean updatePortrait); void changeUnitColor(CUnit unit, int playerIndex); @@ -158,10 +169,26 @@ SimulationRenderComponentModel createSpellEffectOverDestructable(CUnit source, C float[] getUnitVertexColor(CUnit unit); + int[] getTerrainModBufferSize(float x, float y, float width, float height); + + int[] getTerrainModBufferSize(float centerX, float centerY, float radius); + + void adjustTerrain(float x, float y, float i); + + void adjustTerrain(int[] rect, float[] modBuffer); + + float getTerrainSpaceX(float x); + + float getTerrainSpaceY(float y); + int getTerrainHeight(float x, float y); boolean isTerrainRomp(float x, float y); boolean isTerrainWater(float x, float y); + void changeUnitScale(CUnit unit, float scale, boolean multiplier); + + SimulationRenderComponent spawnAbilitySoundEffect(float x, float y, War3ID alias, boolean looping); + } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/BuffBarIcon.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/BuffBarIcon.java index aba19c21d..3103d8f7a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/BuffBarIcon.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/BuffBarIcon.java @@ -16,6 +16,8 @@ public class BuffBarIcon extends AbstractClickableActionFrame implements Clickab private String toolTip; private String uberTip; + private boolean positive; + private boolean leveled; public BuffBarIcon(final String name, final UIFrame parent) { super(name, parent); @@ -25,10 +27,13 @@ public void setIconFrame(final TextureFrame iconFrame) { this.iconFrame = iconFrame; } - public void set(final Texture texture, final String toolTip, final String uberTip) { + public void set(final Texture texture, final String toolTip, final String uberTip, final boolean positive, final boolean leveled, final int level) { this.iconFrame.setTexture(texture); - this.toolTip = toolTip; - this.uberTip = uberTip; + this.positive = positive; + this.leveled = leveled; + this.setLevel(level); + this.setToolTip(toolTip); + this.setUberTip(uberTip); setVisible(true); } @@ -67,11 +72,27 @@ public UIFrame getFrameChildUnderMouse(final float screenX, final float screenY) } public void setToolTip(final String toolTip) { - this.toolTip = toolTip; + if (toolTip != null && !toolTip.isBlank()) { + if (this.positive) { + this.toolTip = "|c0000FF00" + toolTip + "|r"; + } else { + this.toolTip = "|c00FF0000" + toolTip + "|r"; + } + } else { + this.toolTip = toolTip; + } } public void setUberTip(final String uberTip) { - this.uberTip = uberTip; + if (uberTip != null) { + if (this.leveled) { + this.uberTip = "|c007d7d7dLevel:|r " + this.level + "|n|n" + uberTip; + } else { + this.uberTip = uberTip; + } + } else { + this.uberTip = "|c007d7d7dLevel:|r " + this.level; + } } @Override diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java index 8ac39d149..fd6d04d89 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java @@ -163,7 +163,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTarget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityTargetVisitor; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.upgrade.CAbilityUpgrade; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.ability.AbilityBuilderActiveAbility; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.ability.ABAbilityBuilderActiveAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CAttackType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CDefenseType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CUpgradeClass; @@ -471,16 +471,14 @@ public MeleeUI(final DataSource dataSource, final ExtendViewport uiViewport, fin if (war3MapViewer.dataSource.has(musicSLKPath)) { try (InputStream miscDataTxtStream = war3MapViewer.dataSource.getResourceAsStream(musicSLKPath)) { this.musicSLK.readSLK(miscDataTxtStream); - } - catch (final IOException e) { + } catch (final IOException e) { e.printStackTrace(); } } if (WarsmashConstants.ENABLE_MUSIC) { this.musicPlayer = new MusicPlayerLibGDX(dataSource, this.musicSLK); - } - else { + } else { this.musicPlayer = MusicPlayer.DO_NOTHING; } } @@ -494,13 +492,11 @@ private MeleeUIMinimap createMinimap(final War3MapViewer war3MapViewer) { try { minimapTexture = ImageUtils.getTextureNoColorCorrection(TgaFile.readTGA("war3mapMap.tga", war3MapViewer.dataSource.getResourceAsStream("war3mapMap.tga"))); - } - catch (final IOException e) { + } catch (final IOException e) { System.err.println("Could not load minimap TGA file"); e.printStackTrace(); } - } - else if (war3MapViewer.dataSource.has("war3mapMap.blp")) { + } else if (war3MapViewer.dataSource.has("war3mapMap.blp")) { minimapTexture = ImageUtils.getAnyExtensionTexture(war3MapViewer.dataSource, "war3mapMap.blp"); } final Texture[] teamColors = new Texture[WarsmashConstants.MAX_PLAYERS]; @@ -540,14 +536,12 @@ public void main() { this.rootFrameListener.onCreate(this.rootFrame); try { this.rootFrame.loadTOCFile("UI\\FrameDef\\FrameDef.toc"); - } - catch (final IOException exc) { + } catch (final IOException exc) { throw new IllegalStateException("Unable to load FrameDef.toc", exc); } try { this.rootFrame.loadTOCFile("UI\\FrameDef\\SmashFrameDef.toc"); - } - catch (final IOException exc) { + } catch (final IOException exc) { throw new IllegalStateException("Unable to load SmashFrameDef.toc", exc); } this.damageBackdrops = new InfoPanelIconBackdrops(CAttackType.values(), this.rootFrame, "Damage", ""); @@ -941,10 +935,11 @@ public void multiSelectIconClicked(final int index) { if ((index >= 0) && (index < cargoData.getCargoCount())) { final BooleanAbilityActivationReceiver activationReceiver = BooleanAbilityActivationReceiver.INSTANCE; final CSimulation simulation = MeleeUI.this.war3MapViewer.simulation; - cargoData.checkCanUse(simulation, simulationUnit, OrderIds.unload, activationReceiver); + cargoData.checkCanUse(simulation, simulationUnit, OrderIds.unload, false, + activationReceiver); if (activationReceiver.isOk()) { final CWidgetAbilityTargetCheckReceiver targetCheckReceiver = CWidgetAbilityTargetCheckReceiver.INSTANCE; - cargoData.checkCanTarget(simulation, simulationUnit, OrderIds.unload, unitInside, + cargoData.checkCanTarget(simulation, simulationUnit, OrderIds.unload, false, unitInside, targetCheckReceiver.reset()); if (targetCheckReceiver.getTarget() != null) { final CPlayer player = simulation.getPlayer(simulationUnit.getPlayerIndex()); @@ -965,13 +960,11 @@ public void multiSelectIconClicked(final int index) { final RenderUnit clickUnit = MeleeUI.this.selectedUnits.get(index); if (MeleeUI.this.activeCommand != null) { useActiveCommandOnUnit(isShiftDown(), clickUnit); - } - else if (clickUnit == MeleeUI.this.selectedUnit) { + } else if (clickUnit == MeleeUI.this.selectedUnit) { final List newSelection = Arrays.asList(MeleeUI.this.selectedUnit); selectWidgets(newSelection); MeleeUI.this.war3MapViewer.doSelectUnit(newSelection); - } - else { + } else { selectUnit(clickUnit); } } @@ -1196,8 +1189,7 @@ public void multiSelectIconRelease(final int index) { try { this.consoleInventoryNoCapacityTexture = ImageUtils.getAnyExtensionTexture(this.dataSource, this.rootFrame.getSkinField("ConsoleInventoryNoCapacity")); - } - catch (final Exception exc) { + } catch (final Exception exc) { exc.printStackTrace(); } @@ -1398,13 +1390,13 @@ public void onClick(final int abilityHandleId, final int orderId, final boolean } if (abilityToUse != null) { abilityToUse.checkCanUse(this.war3MapViewer.simulation, this.selectedUnit.getSimulationUnit(), orderId, - this.meleeUIAbilityActivationReceiver.reset(this, this.war3MapViewer.worldScene.audioContext, + false, this.meleeUIAbilityActivationReceiver.reset(this, this.war3MapViewer.worldScene.audioContext, this.selectedUnit)); if (this.meleeUIAbilityActivationReceiver.isUseOk()) { final BooleanAbilityTargetCheckReceiver noTargetReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); abilityToUse.checkCanTargetNoTarget(this.war3MapViewer.simulation, - this.selectedUnit.getSimulationUnit(), orderId, noTargetReceiver); + this.selectedUnit.getSimulationUnit(), orderId, false, noTargetReceiver); if (noTargetReceiver.isTargetable()) { final boolean shiftDown = isShiftDown(); this.unitOrderListener.issueImmediateOrder(this.selectedUnit.getSimulationUnit().getHandleId(), @@ -1424,7 +1416,8 @@ public void onClick(final int abilityHandleId, final int orderId, final boolean final BooleanAbilityTargetCheckReceiver receiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); ability.checkCanTargetNoTarget(this.war3MapViewer.simulation, - otherSelectedUnit.getSimulationUnit(), this.activeCommandOrderId, receiver); + otherSelectedUnit.getSimulationUnit(), this.activeCommandOrderId, false, + receiver); if (receiver.isTargetable()) { abilityToUse = ability; } @@ -1437,16 +1430,14 @@ public void onClick(final int abilityHandleId, final int orderId, final boolean } } } - } - else { + } else { this.activeCommand = abilityToUse; this.activeCommandOrderId = orderId; this.activeCommandUnit = this.selectedUnit; clearAndRepopulateCommandCard(); } } - } - else { + } else { this.unitOrderListener.issueImmediateOrder(this.selectedUnit.getSimulationUnit().getHandleId(), abilityHandleId, orderId, isShiftDown()); if (this.selectedUnits.size() > 1) { @@ -1470,8 +1461,7 @@ public void openMenu(final int orderId) { this.activeCommandUnit = null; this.activeCommand = null; this.activeCommandOrderId = -1; - } - else { + } else { this.subMenuOrderIdStack.add(orderId); } clearAndRepopulateCommandCard(); @@ -1574,12 +1564,10 @@ public void showUpgradeCompleteAlert(final int playerIndex, final War3ID queuedR final UpgradeLevel upgradeLevel = upgradeType.getLevel(level - 1); if (upgradeLevel != null) { upgradeName = upgradeLevel.getName(); - } - else { + } else { upgradeName = "NOTEXTERN Unknown Level " + level + " for '" + queuedRawcode + "'"; } - } - else { + } else { upgradeName = "NOTEXTERN Unknown ('" + queuedRawcode + "')"; } innerShowLocalCommandErrorString(playerIndex, @@ -1653,12 +1641,10 @@ public void update(final float deltaTime) { // mines even though they are invulnerable simpleStatusBarFrame.setVisible(false); } - } - else { + } else { this.hovertipFrame.setVisible(false); } - } - else if (this.draggingMouseButton == Input.Buttons.LEFT) { + } else if (this.draggingMouseButton == Input.Buttons.LEFT) { final float minDragX = Math.min(this.lastMouseClickLocation.x, this.lastMouseDragStart.x); final float minDragY = Math.min(this.lastMouseClickLocation.y, this.lastMouseDragStart.y); final float maxDragX = Math.max(this.lastMouseClickLocation.x, this.lastMouseDragStart.x); @@ -1718,13 +1704,11 @@ public boolean call(final CUnit unit) { if (this.activeCommand != null) { if (this.draggingItem != null) { setCursorState(MenuCursorState.HOLD_ITEM); - } - else { + } else { setCursorState(MenuCursorState.TARGET_CURSOR); this.activeCommand.visit(this.cursorTargetSetupVisitor.reset(baseMouseX, baseMouseY)); } - } - else { + } else { if (this.cursorModelInstance != null) { this.cursorModelInstance.detach(); this.cursorModelInstance = null; @@ -1742,50 +1726,40 @@ public boolean call(final CUnit unit) { if (down) { if (left) { setCursorState(MenuCursorState.SCROLL_DOWN_LEFT); - } - else if (right) { + } else if (right) { setCursorState(MenuCursorState.SCROLL_DOWN_RIGHT); - } - else { + } else { setCursorState(MenuCursorState.SCROLL_DOWN); } - } - else if (up) { + } else if (up) { if (left) { setCursorState(MenuCursorState.SCROLL_UP_LEFT); - } - else if (right) { + } else if (right) { setCursorState(MenuCursorState.SCROLL_UP_RIGHT); - } - else { + } else { setCursorState(MenuCursorState.SCROLL_UP); } - } - else if (left) { + } else if (left) { setCursorState(MenuCursorState.SCROLL_LEFT); - } - else if (right) { + } else if (right) { setCursorState(MenuCursorState.SCROLL_RIGHT); - } - else if (this.mouseOverUnit != null) { + } else if (this.mouseOverUnit != null) { if (this.mouseOverUnit instanceof RenderUnit) { final RenderUnit mouseOverUnitUnit = (RenderUnit) this.mouseOverUnit; - final int playerIndex = mouseOverUnitUnit.getSimulationUnit().getPlayerIndex(); + final int playerIndex = mouseOverUnitUnit.getSimulationUnit().getFakePlayerIndex(); if (!this.localPlayer.hasAlliance(playerIndex, CAllianceType.PASSIVE)) { setCursorState(MenuCursorState.SELECT, Color.RED); - } - else if (this.localPlayer.hasAlliance(playerIndex, CAllianceType.SHARED_CONTROL)) { + } else if (this.localPlayer.hasAlliance(playerIndex, CAllianceType.SHARED_CONTROL) + || this.localPlayer.hasAlliance(mouseOverUnitUnit.getSimulationUnit().getPlayerIndex(), + CAllianceType.SHARED_CONTROL)) { setCursorState(MenuCursorState.SELECT, Color.GREEN); - } - else { + } else { setCursorState(MenuCursorState.SELECT, Color.YELLOW); } - } - else { + } else { setCursorState(MenuCursorState.SELECT, Color.YELLOW); } - } - else { + } else { setCursorState(MenuCursorState.NORMAL); } } @@ -1807,8 +1781,7 @@ else if (this.localPlayer.hasAlliance(playerIndex, CAllianceType.SHARED_CONTROL) final long currentMillis = TimeUtils.millis(); if (currentMillis > this.lastErrorMessageExpireTime) { this.errorMessageFrame.setVisible(false); - } - else if (currentMillis > this.lastErrorMessageFadeTime) { + } else if (currentMillis > this.lastErrorMessageFadeTime) { final float fadeAlpha = (this.lastErrorMessageExpireTime - currentMillis) / (float) WORLD_FRAME_MESSAGE_FADE_DURATION; this.errorMessageFrame.setAlpha(fadeAlpha); @@ -1819,8 +1792,7 @@ else if (currentMillis > this.lastErrorMessageFadeTime) { if (currentMillis > gameMessage.lastGameMessageExpireTime) { this.rootFrame.remove(gameMessage.stringFrame); iterator.remove(); - } - else if (currentMillis > gameMessage.lastGameMessageFadeTime) { + } else if (currentMillis > gameMessage.lastGameMessageFadeTime) { final float fadeAlpha = (gameMessage.lastGameMessageExpireTime - currentMillis) / (float) (gameMessage.lastGameMessageExpireTime - gameMessage.lastGameMessageFadeTime); gameMessage.stringFrame.setAlpha(fadeAlpha); @@ -1857,71 +1829,67 @@ private String getWorldFrameHoverTipText(final CSimulation game, final RenderWid final RenderUnit renderUnit = (RenderUnit) whichUnit; final CUnit simulationUnit = renderUnit.getSimulationUnit(); final CAbilityHero heroData = simulationUnit.getHeroData(); - if (heroData != null) { - final String level = this.rootFrame.getTemplates().getDecoratedString("LEVEL"); - return heroData.getProperName() + "|n" + level + " " + heroData.getHeroLevel(); - } - else { - final int simulationUnitPlayerIndex = simulationUnit.getPlayerIndex(); - final boolean neutralHostile = simulationUnitPlayerIndex == (WarsmashConstants.MAX_PLAYERS - 4); - final boolean neutralPassive = simulationUnitPlayerIndex == (WarsmashConstants.MAX_PLAYERS - 1); - String returnValue = ""; - if ((simulationUnitPlayerIndex != this.localPlayer.getId()) - && (simulationUnitPlayerIndex < (WarsmashConstants.MAX_PLAYERS - 4))) { - final boolean ally = simulationUnit.isUnitAlly(this.localPlayer); - final CPlayer unitPlayer = game.getPlayer(simulationUnitPlayerIndex); - final String name = unitPlayer.getName(); - if (name != null) { - if (ally) { - if (unitPlayer.hasAlliance(this.localPlayer.getId(), CAllianceType.SHARED_CONTROL)) { - returnValue = "|CFF00FF00" + name; - } - else { - returnValue = "|CFFFFFF00" + name; - } - } - else { - returnValue = "|CFFFF0000" + name; + final int simulationUnitPlayerIndex = simulationUnit.getFakePlayerIndex(); + final boolean neutralHostile = simulationUnitPlayerIndex == (WarsmashConstants.MAX_PLAYERS - 4); + final boolean neutralPassive = simulationUnitPlayerIndex == (WarsmashConstants.MAX_PLAYERS - 1); + String returnValue = ""; + if ((simulationUnitPlayerIndex != this.localPlayer.getId()) + && (!this.localPlayer.hasAlliance(simulationUnitPlayerIndex, CAllianceType.SHARED_CONTROL)) + && (simulationUnitPlayerIndex < (WarsmashConstants.MAX_PLAYERS - 4))) { + final CPlayer unitPlayer = game.getPlayer(simulationUnitPlayerIndex); + final String name = unitPlayer.getName(); + if (name != null) { + if (unitPlayer.hasAlliance(this.localPlayer.getId(), CAllianceType.PASSIVE)) { + if (unitPlayer.hasAlliance(this.localPlayer.getId(), CAllianceType.SHARED_SPELLS)) { + returnValue = "|CFF00FF00" + name; + } else { + returnValue = "|CFFFFFF00" + name; } + } else { + returnValue = "|CFFFF0000" + name; } } - final CAbilityGoldMinable goldMineData = simulationUnit.getGoldMineData(); - final CAbilityOverlayedMine blightedGoldMineData = simulationUnit.getOverlayedGoldMineData(); - final boolean neutral = (neutralPassive && simulationUnit.isBuilding()) || neutralHostile - || (goldMineData != null) || (blightedGoldMineData != null); - if (neutral) { - if (!returnValue.isEmpty()) { - returnValue += "|n"; - } - returnValue += simulationUnit.getUnitType().getName(); - if (goldMineData != null) { + } + if (heroData != null) { + if (!returnValue.isEmpty()) { + returnValue += "|r|n"; + } + final String level = this.rootFrame.getTemplates().getDecoratedString("LEVEL"); + return returnValue + heroData.getProperName() + "|n" + level + " " + heroData.getHeroLevel(); + } + final CAbilityGoldMinable goldMineData = simulationUnit.getGoldMineData(); + final CAbilityOverlayedMine blightedGoldMineData = simulationUnit.getOverlayedGoldMineData(); + final boolean neutral = (neutralPassive && simulationUnit.isBuilding()) || neutralHostile + || (goldMineData != null) || (blightedGoldMineData != null); + if (neutral) { + if (!returnValue.isEmpty()) { + returnValue += "|n"; + } + returnValue += simulationUnit.getUnitType().getName(); + if (goldMineData != null) { + final String colonGold = this.rootFrame.getTemplates().getDecoratedString("COLON_GOLD"); + returnValue += "|n" + colonGold + " " + goldMineData.getGold(); + } else { + if (blightedGoldMineData != null) { final String colonGold = this.rootFrame.getTemplates().getDecoratedString("COLON_GOLD"); - returnValue += "|n" + colonGold + " " + goldMineData.getGold(); - } - else { - if (blightedGoldMineData != null) { - final String colonGold = this.rootFrame.getTemplates().getDecoratedString("COLON_GOLD"); - returnValue += "|n" + colonGold + " " + blightedGoldMineData.getGold(); - } - } - final int creepLevel = simulationUnit.getUnitType().getLevel(); - if (neutralHostile && (creepLevel > 0)) { - final String level = this.rootFrame.getTemplates().getDecoratedString("LEVEL"); - returnValue += "|n" + level + " " + creepLevel; + returnValue += "|n" + colonGold + " " + blightedGoldMineData.getGold(); } } - if (!returnValue.isEmpty()) { - return returnValue; + final int creepLevel = simulationUnit.getUnitType().getLevel(); + if (neutralHostile && (creepLevel > 0)) { + final String level = this.rootFrame.getTemplates().getDecoratedString("LEVEL"); + returnValue += "|n" + level + " " + creepLevel; } } - } - else if (whichUnit instanceof RenderItem) { + if (!returnValue.isEmpty()) { + return returnValue; + } + } else if (whichUnit instanceof RenderItem) { final RenderItem renderItem = (RenderItem) whichUnit; final ItemUI itemUI = this.war3MapViewer.getAbilityDataUI() .getItemUI(renderItem.getSimulationItem().getTypeId()); return itemUI.getName(); - } - else if (whichUnit instanceof RenderDestructable) { + } else if (whichUnit instanceof RenderDestructable) { final RenderDestructable renderDest = (RenderDestructable) whichUnit; final String name = renderDest.getSimulationDestructable().getDestType().getName(); return name; @@ -1993,8 +1961,7 @@ private SimpleStatusBarFrame getHpBar() { true, 3.0f); this.rootFrame.add(simpleStatusBarFrame); this.hpBarFrames.add(simpleStatusBarFrame); - } - else { + } else { simpleStatusBarFrame = this.hpBarFrames.get(this.hpBarFrameIndex); } this.hpBarFrameIndex++; @@ -2017,14 +1984,12 @@ private UIFrame getHoveredFrame(final AbstractUIFrame startFrame, final float sc if (found) { outFrame = renderFrame; } - } - else { + } else { outFrame = getHoveredFrame((AbstractUIFrame) child, screenX, screenY, includeParent, ignoreFrame); found = outFrame != null; } - } - else { + } else { final AbstractRenderableFrame renderFrame = (AbstractRenderableFrame) child; found = renderFrame.getRenderBounds().contains(screenX, screenY) && renderFrame.isVisible(); if (found) { @@ -2043,8 +2008,7 @@ private UIFrame getHoveredFrame(final AbstractUIFrame startFrame, final float sc private boolean checkFrameInArray(final UIFrame frame, final String[] targetFrames) { if ((targetFrames == null) || (frame == null)) { return false; - } - else { + } else { if (frame.getName() == null) { return false; } @@ -2102,7 +2066,8 @@ public void render(final SpriteBatch batch, final GlyphLayout glyphLayout) { if (this.war3MapViewer.worldScene.camera.rect.contains(screenCoordsVector.x, (Gdx.graphics.getHeight() - screenCoordsVector.y))) { final Vector2 unprojected = this.uiViewport.unproject(screenCoordsVector); - unprojected.add(textTag.getScreenCoordTravelOffset()); + unprojected.add(this.uiViewport.getMinWorldWidth() * textTag.getScreenCoordTravelOffset().x, + this.uiViewport.getMinWorldHeight() * textTag.getScreenCoordTravelOffset().y); this.textTagFontParam.size = (int) GameUI.convertY(this.uiViewport, textTag.getFontHeight() * 0.5f); // below: generateFont is a caching call, so hopefully this is not allocating // font object on every loop, which would be wasteful @@ -2115,8 +2080,7 @@ public void render(final SpriteBatch batch, final GlyphLayout glyphLayout) { glyphLayout.setText(myTextTagFont, textTag.getText()); x -= (glyphLayout.width / 2); y += (glyphLayout.height / 2); - } - else { + } else { y += glyphLayout.height; } myTextTagFont.draw(batch, textTag.getText(), x + 3, (y - 1)); @@ -2189,8 +2153,7 @@ public Void accept(final CAbilityAttack ability) { final int areaOfEffectSmallDamage = ((CUnitAttackMissileSplash) attack) .getAreaOfEffectSmallDamage(); radius = areaOfEffectSmallDamage; - } - else if (attack instanceof CUnitAttackMissileLine) { + } else if (attack instanceof CUnitAttackMissileLine) { final float areaOfEffectSmallDamage = ((CUnitAttackMissileLine) attack) .getDamageSpillRadius(); radius = areaOfEffectSmallDamage; @@ -2198,8 +2161,7 @@ else if (attack instanceof CUnitAttackMissileLine) { } } handlePlacementCursor(ability, radius); - } - else { + } else { handleTargetCursor(ability); } return null; @@ -2296,12 +2258,11 @@ public Void accept(final CAbilityReviveHero ability) { } @Override - public Void accept(final AbilityBuilderActiveAbility ability) { + public Void accept(final ABAbilityBuilderActiveAbility ability) { final float uiAreaOfEffect = ability.getUIAreaOfEffect(); if (Float.isNaN(uiAreaOfEffect)) { handleTargetCursor(ability); - } - else { + } else { handlePlacementCursor(ability, uiAreaOfEffect); } return null; @@ -2312,8 +2273,7 @@ public Void accept(final GenericSingleIconActiveAbility ability) { final float uiAreaOfEffect = ability.getUIAreaOfEffect(); if (Float.isNaN(uiAreaOfEffect)) { handleTargetCursor(ability); - } - else { + } else { handlePlacementCursor(ability, uiAreaOfEffect); } return null; @@ -2374,11 +2334,9 @@ public Void accept(final CAbilityJass ability) { .getRenderPeer(orderCommandCardIcon); if (renderPeer.getMouseTargetRadius() > 0) { handlePlacementCursor(ability, renderPeer.getMouseTargetRadius()); - } - else if (renderPeer.getPreviewBuildUnitId() != null) { + } else if (renderPeer.getPreviewBuildUnitId() != null) { handleBuildCursor(null, renderPeer.getPreviewBuildUnitId().getValue()); - } - else { + } else { handleTargetCursor(ability); } return null; @@ -2477,8 +2435,7 @@ private void handleBuildCursor(final AbstractCAbilityBuild ability, final int pr Color.rgba8888(1, 0, 0, 1.0f)); } } - } - else if (!canBeBuiltOnThem) { + } else if (!canBeBuiltOnThem) { for (int i = 0; i < MeleeUI.this.cursorModelUnderneathPathingRedGreenPixmap.getWidth(); i++) { for (int j = 0; j < MeleeUI.this.cursorModelUnderneathPathingRedGreenPixmap.getHeight(); j++) { boolean blocked = false; @@ -2502,8 +2459,7 @@ else if (!canBeBuiltOnThem) { MeleeUI.this.cursorModelUnderneathPathingRedGreenPixmap.getHeight() - 1 - j, color); } } - } - else { + } else { for (int i = 0; i < MeleeUI.this.cursorModelUnderneathPathingRedGreenPixmap.getWidth(); i++) { for (int j = 0; j < MeleeUI.this.cursorModelUnderneathPathingRedGreenPixmap.getHeight(); j++) { MeleeUI.this.cursorModelUnderneathPathingRedGreenPixmap.drawPixel(i, @@ -2601,8 +2557,7 @@ public Void accept(final CUnit target) { final MdxNode attachment = renderUnit.instance.getAttachment(index); this.rallyPointInstance.setParent(attachment); this.rallyPointInstance.setLocation(0, 0, 0); - } - else { + } else { this.rallyPointInstance.setParent(null); final float rallyPointX = target.getX(); final float rallyPointY = target.getY(); @@ -2641,7 +2596,7 @@ public boolean call(final CWidget unit) { final ExternStringMsgTargetCheckReceiver targetReceiver = ExternStringMsgTargetCheckReceiver .getInstance().reset(); MeleeUI.this.activeCommand.checkCanTarget(MeleeUI.this.war3MapViewer.simulation, - MeleeUI.this.activeCommandUnit.getSimulationUnit(), MeleeUI.this.activeCommandOrderId, unit, + MeleeUI.this.activeCommandUnit.getSimulationUnit(), MeleeUI.this.activeCommandOrderId, false, unit, targetReceiver); this.lastFailureMessage = targetReceiver.getExternStringKey(); return targetReceiver.getTarget() != null; @@ -2689,8 +2644,7 @@ public void update(final float dt) { if (this.portraitTargetDuration != 0) { if (this.portraitCurrentDuration < this.portraitTargetDuration) { this.modelInstance.sequenceLoopMode = SequenceLoopMode.ALWAYS_LOOP; - } - else { + } else { this.modelInstance.sequenceEnded = true; this.modelInstance.sequenceLoopMode = SequenceLoopMode.NEVER_LOOP; this.portraitTargetDuration = 0; @@ -2728,8 +2682,7 @@ private void innerTalk(final UnitSound us, float extraDuration) { this.recycleSet.add(SecondaryTag.TALK); if (us != null) { this.portraitTargetDuration = (long) (1000 * Extensions.audio.getDuration(us.getLastPlayedSound())); - } - else { + } else { this.portraitTargetDuration = 0; } this.portraitTargetDuration += (long) (1000 * extraDuration); @@ -2754,8 +2707,7 @@ public void setSelectedUnit(final RenderUnit unit) { } this.modelInstance = null; this.portraitCameraManager.setModelInstance(null, null); - } - else { + } else { this.secondaryTags = unit.getSecondaryAnimationTags(); final MdxModel portraitModel = unit.portraitModel; if (portraitModel != null) { @@ -2787,8 +2739,7 @@ public void setSelectedItem(final RenderItem unit) { } this.modelInstance = null; this.portraitCameraManager.setModelInstance(null, null); - } - else { + } else { final MdxModel portraitModel = unit.portraitModel; if (portraitModel != null) { if (this.modelInstance != null) { @@ -2818,8 +2769,7 @@ public void setSelectedDestructable(final RenderDestructable unit) { } this.modelInstance = null; this.portraitCameraManager.setModelInstance(null, null); - } - else { + } else { final MdxModel portraitModel = unit.getPortraitModel(); if (portraitModel != null) { if (this.modelInstance != null) { @@ -2881,14 +2831,12 @@ public void endCinematicSequence() { public void update(final float dt) { if (isResetNeeded()) { endCinematicSequence(); - } - else { + } else { this.portraitCurrentDuration += (dt * 1000); if (this.portraitTargetDuration != 0) { if (this.portraitCurrentDuration < this.portraitTargetDuration) { this.cinematicPortrait.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP); - } - else { + } else { this.cinematicPortrait.setSequenceEnded(true); this.cinematicPortrait.setSequenceLoopMode(SequenceLoopMode.NEVER_LOOP); this.portraitTargetDuration = 0; @@ -2917,8 +2865,7 @@ public void talk(final UnitSound us, float extraDuration) { this.recycleSet.add(SecondaryTag.TALK); if (us != null) { this.portraitTargetDuration = (long) (1000 * Extensions.audio.getDuration(us.getLastPlayedSound())); - } - else { + } else { this.portraitTargetDuration = 0; } this.portraitTargetDuration += (long) (1000 * extraDuration); @@ -2961,8 +2908,7 @@ public void setDraggingItem(final CItem itemInSlot) { index++; } } - } - else { + } else { if (this.selectedUnit != null) { final CAbilityInventory inventory = this.selectedUnit.getSimulationUnit().getInventoryData(); if (inventory != null) { @@ -3034,8 +2980,7 @@ public void selectUnit(RenderUnit unit) { frame.setVisible(false); } repositionWaypointFlags(null); - } - else { + } else { unit.getSimulationUnit().addStateListener(this); reloadSelectedUnitUI(unit); } @@ -3058,8 +3003,7 @@ private void repositionRallyPoint(final CUnit simulationUnit) { this.rallyPointInstance.detach(); rallyPoint.visit(this.rallyPositioningVisitor.reset(this.rallyPointInstance)); this.rallyPointInstance.setScene(this.war3MapViewer.worldScene); - } - else { + } else { this.rallyPointInstance.hide(); this.rallyPointInstance.detach(); } @@ -3070,8 +3014,7 @@ public void waypointsChanged() { if (this.selectedUnit != null) { final CUnit simulationUnit = this.selectedUnit.getSimulationUnit(); repositionWaypointFlags(simulationUnit); - } - else { + } else { repositionWaypointFlags(null); } } @@ -3091,15 +3034,13 @@ private void repositionWaypointFlags(final CUnit simulationUnit) { waypointModelInstance.detach(); target.visit(this.rallyPositioningVisitor.reset(waypointModelInstance)); waypointModelInstance.setScene(this.war3MapViewer.worldScene); - } - else { + } else { waypointModelInstance.hide(); waypointModelInstance.detach(); } orderIndex++; } - } - else { + } else { iterator = Collections.emptyIterator(); } for (; (orderIndex < this.waypointModelInstances.size()) || iterator.hasNext(); orderIndex++) { @@ -3113,18 +3054,15 @@ private void repositionWaypointFlags(final CUnit simulationUnit) { waypointModelInstance.detach(); target.visit(this.rallyPositioningVisitor.reset(waypointModelInstance)); waypointModelInstance.setScene(this.war3MapViewer.worldScene); - } - else { + } else { waypointModelInstance.hide(); waypointModelInstance.detach(); } - } - else { + } else { waypointModelInstance.hide(); waypointModelInstance.detach(); } - } - else { + } else { waypointModelInstance.hide(); waypointModelInstance.detach(); } @@ -3158,8 +3096,7 @@ private void reloadSelectedUnitUI(final RenderUnit unit) { if (maximumMana > 0) { this.rootFrame.setText(this.unitManaText, FastNumberFormat.formatWholeNumber(simulationUnit.getMana()) + " / " + maximumMana); - } - else { + } else { this.rootFrame.setText(this.unitManaText, ""); } final boolean multiSelect = this.selectedUnits.size() > 1; @@ -3183,8 +3120,7 @@ private void reloadSelectedUnitUI(final RenderUnit unit) { if ((queueItemType == null) || ((i > 0) && QueueItemType.SACRIFICE.equals(simulationUnit.getBuildQueueTypes()[0]))) { this.queueIconFrames[i].setVisible(false); - } - else { + } else { this.queueIconFrames[i].setVisible(true); switch (queueItemType) { case RESEARCH: @@ -3232,17 +3168,14 @@ private void reloadSelectedUnitUI(final RenderUnit unit) { if (simulationUnit.getBuildQueueTypes()[0] == QueueItemType.UNIT) { this.rootFrame.setText(this.simpleBuildingBuildingActionLabel, this.rootFrame.getTemplates().getDecoratedString("TRAINING")); - } - else if (simulationUnit.getBuildQueueTypes()[0] == QueueItemType.SACRIFICE) { + } else if (simulationUnit.getBuildQueueTypes()[0] == QueueItemType.SACRIFICE) { this.rootFrame.setText(this.simpleBuildingBuildingActionLabel, this.rootFrame.getTemplates().getDecoratedString("TRAINING")); this.simpleBuildQueueBackdrop.setVisible(false); - } - else if (simulationUnit.getBuildQueueTypes()[0] == QueueItemType.HERO_REVIVE) { + } else if (simulationUnit.getBuildQueueTypes()[0] == QueueItemType.HERO_REVIVE) { this.rootFrame.setText(this.simpleBuildingBuildingActionLabel, this.rootFrame.getTemplates().getDecoratedString("REVIVING")); - } - else { + } else { this.rootFrame.setText(this.simpleBuildingBuildingActionLabel, this.rootFrame.getTemplates().getDecoratedString("RESEARCHING")); } @@ -3252,8 +3185,7 @@ else if (simulationUnit.getBuildQueueTypes()[0] == QueueItemType.HERO_REVIVE) { this.heroInfoPanel.setVisible(false); this.selectWorkerInsideFrame.setVisible(false); this.smashBuffStatusBar.setVisible(false); - } - else if (multiSelect) { + } else if (multiSelect) { for (int i = 0; i < this.queueIconFrames.length; i++) { this.queueIconFrames[i].setVisible(false); } @@ -3281,13 +3213,11 @@ else if (multiSelect) { this.selectedUnitFrames[i].showFocused(this.rootFrame, this.uiViewport); if (useManaBar) { this.selectedUnitHighlightBackdrop[i].setHeight(this.frontQueueIconWidth * 1.75f); - } - else { + } else { this.selectedUnitHighlightBackdrop[i].setHeight(this.frontQueueIconWidth * 1.55f); } this.selectedUnitHighlightBackdrop[i].positionBounds(this.rootFrame, this.uiViewport); - } - else { + } else { this.selectedUnitFrames[i].showUnFocused(this.rootFrame, this.uiViewport); } } @@ -3305,8 +3235,7 @@ else if (multiSelect) { this.heroInfoPanel.setVisible(false); this.selectWorkerInsideFrame.setVisible(false); this.smashBuffStatusBar.setVisible(false); - } - else { + } else { for (final QueueIcon queueIconFrame : this.queueIconFrames) { queueIconFrame.setVisible(false); } @@ -3346,8 +3275,7 @@ else if (multiSelect) { this.cargoUnitFrames[i].setToolTip(cargoContainedUnit.getHeroData().getProperName()); this.cargoUnitFrames[i] .setUberTip("Level " + cargoContainedUnit.getHeroData().getHeroLevel()); - } - else { + } else { this.cargoUnitFrames[i].setToolTip(cargoContainedUnit.getUnitType().getName()); this.cargoUnitFrames[i].setUberTip(unitUI.getUberTip()); } @@ -3360,13 +3288,11 @@ else if (multiSelect) { this.cargoUnitFrames[i].setManaRatioRemaining( cargoContainedUnit.getMana() / cargoContainedUnit.getMaximumMana()); } - } - else { + } else { this.cargoUnitFrames[i].setTexture(null); } } - } - else { + } else { for (int i = 0; i < this.cargoUnitFrames.length; i++) { this.cargoUnitFrames[i].setVisible(false); } @@ -3425,8 +3351,7 @@ else if (multiSelect) { this.war3MapViewer.simulation.getPlayer(simulationUnit.getPlayerIndex()) .getTechtreeUnlocked(weaponUpgradeId))); } - } - else { + } else { this.attack2Icon.setVisible(false); } @@ -3435,8 +3360,7 @@ else if (multiSelect) { GameUI.convertX(this.uiViewport, 0f), GameUI.convertY(this.uiViewport, -0.0705f))); this.smashArmorIconWrapper.positionBounds(this.rootFrame, this.uiViewport); this.armorIcon.positionBounds(this.rootFrame, this.uiViewport); - } - else { + } else { this.attack1Icon.setVisible(false); this.attack2Icon.setVisible(false); @@ -3448,7 +3372,7 @@ else if (multiSelect) { } final CAbilityHero heroData = simulationUnit.getHeroData(); - final boolean hero = heroData != null; + final boolean hero = heroData != null && !heroData.isDisabled(); this.heroInfoPanel.setVisible(hero); if (hero) { final CPrimaryAttribute primaryAttribute = simulationUnit.getUnitType().getPrimaryAttribute(); @@ -3482,8 +3406,7 @@ else if (multiSelect) { this.simpleHeroLevelBar .setValue((heroData.getXp() - gameplayConstants.getNeedHeroXPSum(heroLevel - 1)) / (float) gameplayConstants.getNeedHeroXP(heroLevel)); - } - else { + } else { this.simpleClassValue.setVisible(!simulationUnit.isBuilding()); this.rootFrame.setText(this.simpleNameValue, unitTypeName); String classText = null; @@ -3494,8 +3417,7 @@ else if (multiSelect) { } if (classText != null) { this.rootFrame.setText(this.simpleClassValue, classText); - } - else { + } else { this.rootFrame.setText(this.simpleClassValue, ""); } this.simpleHeroLevelBar.setVisible(false); @@ -3523,12 +3445,10 @@ else if (multiSelect) { this.selectWorkerInsideFrame.setVisible(true); this.selectWorkerInsideFrame.setTexture(this.war3MapViewer.getAbilityDataUI() .getUnitUI(simulationUnit.getWorker().getTypeId()).getIcon()); - } - else { + } else { this.selectWorkerInsideFrame.setVisible(false); } - } - else { + } else { this.rootFrame.setText(this.simpleBuildingActionLabel, ""); this.selectWorkerInsideFrame.setVisible(false); } @@ -3544,15 +3464,13 @@ else if (multiSelect) { String defenseDisplayString; if (simulationUnit.isInvulnerable()) { defenseDisplayString = this.rootFrame.getTemplates().getDecoratedString("INVULNERABLE"); - } - else { + } else { defenseDisplayString = Integer.toString(simulationUnit.getCurrentDefenseDisplay()); final float temporaryDefenseBonus = simulationUnit.getTotalTemporaryDefenseBonus(); if (temporaryDefenseBonus != 0) { if (temporaryDefenseBonus > 0) { defenseDisplayString += "|cFF00FF00 +" + String.format("%.1f", temporaryDefenseBonus) + ""; - } - else { + } else { defenseDisplayString += "|cFFFF0000 " + String.format("%.1f", temporaryDefenseBonus) + ""; } } @@ -3608,7 +3526,7 @@ else if (multiSelect) { this.recycleStringBuilder.append("|n"); } inventory.checkCanUse(this.war3MapViewer.simulation, this.selectedUnit.getSimulationUnit(), - OrderIds.itemuse00 + index, this.activationReceiverPreviewCallback.reset()); + OrderIds.itemuse00 + index, false, this.activationReceiverPreviewCallback.reset()); this.recycleStringBuilder.append(uberTip); inventoryIcon.setCommandButtonData( inventoryEnabled ? iconUI.getIcon() : iconUI.getIconDisabled(), 0, @@ -3620,18 +3538,15 @@ else if (multiSelect) { this.activationReceiverPreviewCallback.getCooldownRemaining(), this.activationReceiverPreviewCallback.getCooldownMax(), item.getCharges() > 0 ? item.getCharges() : -1); - } - else { + } else { if (index >= inventory.getItemCapacity()) { inventoryIcon.setCommandButtonData(this.consoleInventoryNoCapacityTexture, 0, 0, 0, false, false, false, null, null, '\0', 0, 0, 0, 0, false, 0, 0, -1); - } - else { + } else { if (this.draggingItem != null) { inventoryIcon.setCommandButtonData(null, 0, 0, index + 1, true, false, false, null, null, '\0', 0, 0, 0, 0, false, 0, 0, -1); - } - else { + } else { inventoryIcon.clear(); } } @@ -3699,10 +3614,11 @@ public void commandButton(final int buttonPositionX, final int buttonPositionY, } @Override - public void buff(final Texture icon, final int level, final String tip, final String uberTip) { + public void buff(final Texture icon, final int level, final String tip, final String uberTip, + final boolean positive, final boolean leveled) { if ((this.selectedUnit == null) || !this.selectedUnit.getSimulationUnit().isBuilding()) { if (this.currentBuffBarIconIndex < this.buffBarIcons.length) { - this.buffBarIcons[this.currentBuffBarIconIndex++].set(icon, tip, uberTip); + this.buffBarIcons[this.currentBuffBarIconIndex++].set(icon, tip, uberTip, positive, leveled, level); } } } @@ -3740,8 +3656,7 @@ private Rectangle setupWorldFrameViewport(final int width, final int height) { public void positionPortrait() { if (this.cinematicPanel.isVisible()) { this.portrait.portraitScene.show = false; - } - else { + } else { this.portrait.portraitScene.show = true; this.projectionTemp1.x = 422 * this.widthRatioCorrection; this.projectionTemp1.y = 57 * this.heightRatioCorrection; @@ -3773,8 +3688,7 @@ public InfoPanelIconBackdrops(final CodeKeyType[] attackTypes, final GameUI game final Texture suffixTexture = gameUI.loadTexture(gameUI.getSkinField(skinLookupKey)); if (suffixTexture != null) { this.damageBackdropTextures[index] = suffixTexture; - } - else { + } else { skinLookupKey = "InfoPanelIcon" + prefix + attackType.getCodeKey(); if (!gameUI.hasSkinField(skinLookupKey) && (attackType == CAttackType.SPELLS)) { skinLookupKey = "InfoPanelIcon" + prefix + CAttackType.MAGIC.getCodeKey(); @@ -3802,8 +3716,7 @@ public void lifeChanged() { } if (this.selectedUnit.getSimulationUnit().isDead()) { removeSubGroupHighlightSelectedUnitFromSelection(); - } - else { + } else { final float lifeRatioRemaining = this.selectedUnit.getSimulationUnit().getLife() / this.selectedUnit.getSimulationUnit().getMaxLife(); this.rootFrame.setText(this.unitLifeText, @@ -3852,8 +3765,7 @@ public void manaChanged() { this.rootFrame.setText(this.unitManaText, FastNumberFormat.formatWholeNumber(this.selectedUnit.getSimulationUnit().getMana()) + " / " + maximumMana); - } - else { + } else { this.rootFrame.setText(this.unitManaText, ""); } } @@ -3874,8 +3786,7 @@ public void foodChanged() { if (foodCap == 0) { this.rootFrame.setText(this.resourceBarSupplyText, Integer.toString(this.localPlayer.getFoodUsed())); this.resourceBarSupplyText.setColor(Color.WHITE); - } - else { + } else { this.rootFrame.setText(this.resourceBarSupplyText, this.localPlayer.getFoodUsed() + "/" + foodCap); this.resourceBarSupplyText.setColor(this.localPlayer.getFoodUsed() > foodCap ? Color.RED : Color.WHITE); } @@ -3924,6 +3835,11 @@ public void abilitiesChanged() { reloadSelectedUnitUI(this.selectedUnit); } + @Override + public void upgradesChanged() { + reloadSelectedUnitUI(this.selectedUnit); + } + @Override public void inventoryChanged() { reloadSelectedUnitUI(this.selectedUnit); @@ -3943,8 +3859,7 @@ private void clearAndRepopulateCommandCard() { commandButton(cancelUI.getButtonPositionX(), cancelUI.getButtonPositionY(), cancelUI.getIcon(), 0, menuOrderId, 0, false, false, true, cancelUI.getToolTip(), cancelUI.getUberTip(), cancelUI.getHotkey(), 0, 0, 0, 0, 0, 0, -1); - } - else { + } else { if (menuOrderId != 0) { final int exitOrderId = this.subMenuOrderIdStack.size() > 1 ? this.subMenuOrderIdStack.get(this.subMenuOrderIdStack.size() - 2) @@ -4055,8 +3970,7 @@ public boolean touchDown(final int screenX, final int screenY, final float world 0, 0); } return false; - } - else if (button == Input.Buttons.BACK) { + } else if (button == Input.Buttons.BACK) { if (this.selectedUnits.size() > 1) { advanceSelectedSubGroupReverse(); this.war3MapViewer.getUiSounds().getSound("SubGroupSelectionChange").play(this.uiScene.audioContext, 0, @@ -4085,16 +3999,14 @@ else if (button == Input.Buttons.BACK) { setDraggingItem(null); } clearAndRepopulateCommandCard(); - } - else if (button == Input.Buttons.LEFT) { + } else if (button == Input.Buttons.LEFT) { final boolean shiftDown = isShiftDown(); this.activeCommandUnitTargetFilter.reset(); final RenderWidget rayPickUnit = this.war3MapViewer.rayPickUnit(screenX, worldScreenY, this.activeCommandUnitTargetFilter); if (rayPickUnit != null) { useActiveCommandOnUnit(shiftDown, rayPickUnit); - } - else { + } else { this.war3MapViewer.getClickLocation(clickLocationTemp, screenX, (int) worldScreenY, this.activeCommandUnit.getSimulationUnit().isMovementOnWaterAllowed(), true); clickLocationTemp2.set(clickLocationTemp.x, clickLocationTemp.y); @@ -4116,21 +4028,19 @@ else if (button == Input.Buttons.LEFT) { this.activeCommandOrderId = -1; setDraggingItem(null); clearAndRepopulateCommandCard(); - } - else { + } else { final ExternStringMsgTargetCheckReceiver pointTargetReceiver = ExternStringMsgTargetCheckReceiver .getInstance(); pointTargetReceiver.reset(); this.activeCommand.checkCanTarget(this.war3MapViewer.simulation, - this.activeCommandUnit.getSimulationUnit(), this.activeCommandOrderId, + this.activeCommandUnit.getSimulationUnit(), this.activeCommandOrderId, false, clickLocationTemp2, pointTargetReceiver); final Vector2 target = pointTargetReceiver.getTarget(); if (target != null) { if ((this.activeCommand instanceof CAbilityAttack) && (this.activeCommandOrderId == OrderIds.attack)) { this.war3MapViewer.showConfirmation(clickLocationTemp, 1, 0, 0); - } - else { + } else { this.war3MapViewer.showConfirmation(clickLocationTemp, 0, 1, 0); } this.unitOrderListener.issuePointOrder( @@ -4148,7 +4058,7 @@ else if (button == Input.Buttons.LEFT) { .reset(); ability.checkCanTarget(this.war3MapViewer.simulation, otherSelectedUnit.getSimulationUnit(), - this.activeCommandOrderId, clickLocationTemp2, receiver); + this.activeCommandOrderId, false, clickLocationTemp2, receiver); if (receiver.getTarget() != null) { abilityToUse = ability; targetToUse = receiver.getTarget(); @@ -4171,8 +4081,7 @@ this.war3MapViewer.worldScene.audioContext, getSelectedUnit())) { if (this.activeCommand instanceof AbstractCAbilityBuild) { this.war3MapViewer.getUiSounds().getSound("PlaceBuildingDefault") .play(this.uiScene.audioContext, 0, 0, 0); - } - else if (this.activeCommand instanceof CAbilityRally) { + } else if (this.activeCommand instanceof CAbilityRally) { this.war3MapViewer.getUiSounds().getSound("RallyPointPlace") .play(this.uiScene.audioContext, 0, 0, 0); } @@ -4184,20 +4093,17 @@ else if (this.activeCommand instanceof CAbilityRally) { clearAndRepopulateCommandCard(); } - } - else { + } else { if ((this.activeCommandUnitTargetFilter.lastFailureMessage != null) && !this.activeCommandUnitTargetFilter.lastFailureMessage.isEmpty()) { showInterfaceError(this.activeCommandUnit.getSimulationUnit().getPlayerIndex(), this.activeCommandUnitTargetFilter.lastFailureMessage); - } - else { + } else { final String externStringKey = pointTargetReceiver.getExternStringKey(); if ((externStringKey != null) && !externStringKey.isEmpty()) { showInterfaceError(this.activeCommandUnit.getSimulationUnit().getPlayerIndex(), externStringKey); - } - else { + } else { showInterfaceError(this.activeCommandUnit.getSimulationUnit().getPlayerIndex(), CommandStringErrorKeys.MUST_TARGET_A_UNIT_WITH_THIS_ACTION); } @@ -4207,11 +4113,13 @@ else if (this.activeCommand instanceof CAbilityRally) { } } - } - else { + } else { if (button == Input.Buttons.RIGHT) { if ((getSelectedUnit() != null) && (getSelectedUnit().getSimulationUnit() - .getPlayerIndex() == this.war3MapViewer.getLocalPlayerIndex())) { + .getPlayerIndex() == this.war3MapViewer.getLocalPlayerIndex() + || this.war3MapViewer.simulation.getPlayer(this.war3MapViewer.getLocalPlayerIndex()) + .hasAlliance(getSelectedUnit().getSimulationUnit().getPlayerIndex(), + CAllianceType.SHARED_CONTROL))) { RenderWidget rayPickUnit = this.war3MapViewer.rayPickUnit(screenX, worldScreenY, this.anyClickableUnitFilter); if (rayPickUnit == null) { @@ -4227,7 +4135,7 @@ else if (this.activeCommand instanceof CAbilityRally) { CWidget targetToUse = null; for (final CAbility ability : unit.getSimulationUnit().getAbilities()) { ability.checkCanTarget(this.war3MapViewer.simulation, unit.getSimulationUnit(), - OrderIds.smart, rayPickUnit.getSimulationWidget(), + OrderIds.smart, false, rayPickUnit.getSimulationWidget(), CWidgetAbilityTargetCheckReceiver.INSTANCE); final CWidget targetWidget = CWidgetAbilityTargetCheckReceiver.INSTANCE.getTarget(); if (targetWidget != null) { @@ -4256,17 +4164,14 @@ else if (this.activeCommand instanceof CAbilityRally) { .play(this.uiScene.audioContext, 0, 0, 0); } this.selectedSoundCount = 0; - } - else { + } else { rightClickMove(screenX, worldScreenY); } - } - else { + } else { rightClickMove(screenX, worldScreenY); } } - } - else { + } else { if (getHoveredFrame(this.rootFrame, screenCoordsVector.x, screenCoordsVector.y, this.includeFrames, this.ignoreFrames) != null) { return false; @@ -4280,8 +4185,7 @@ else if (this.activeCommand instanceof CAbilityRally) { this.draggingMouseButton = button; } } - } - else { + } else { if (clickedUIFrame instanceof ClickableFrame) { this.mouseDownUIFrame = (ClickableFrame) clickedUIFrame; this.mouseDownUIFrame.mouseDown(this.rootFrame, this.uiViewport); @@ -4298,8 +4202,7 @@ private void advanceSelectedSubGroup() { selectUnit(unit); return; } - } - else if (unit == this.selectedUnit) { + } else if (unit == this.selectedUnit) { foundSubSelection = true; } } @@ -4317,8 +4220,7 @@ private void advanceSelectedSubGroupReverse() { selectUnit(unit); return; } - } - else if (unit == this.selectedUnit) { + } else if (unit == this.selectedUnit) { foundSubSelection = true; } } @@ -4333,8 +4235,7 @@ private void useActiveCommandOnUnit(final boolean shiftDown, final RenderWidget this.activeCommand.getHandleId(), this.activeCommandOrderId, this.draggingItem.getHandleId(), rayPickUnit.getSimulationWidget().getHandleId(), shiftDown); setDraggingItem(null); - } - else { + } else { this.unitOrderListener.issueTargetOrder(this.activeCommandUnit.getSimulationUnit().getHandleId(), this.activeCommand.getHandleId(), this.activeCommandOrderId, rayPickUnit.getSimulationWidget().getHandleId(), shiftDown); @@ -4347,7 +4248,7 @@ private void useActiveCommandOnUnit(final boolean shiftDown, final RenderWidget final CWidgetAbilityTargetCheckReceiver receiver = CWidgetAbilityTargetCheckReceiver.INSTANCE .reset(); ability.checkCanTarget(this.war3MapViewer.simulation, otherSelectedUnit.getSimulationUnit(), - this.activeCommandOrderId, rayPickUnit.getSimulationWidget(), receiver); + this.activeCommandOrderId, false, rayPickUnit.getSimulationWidget(), receiver); if (receiver.getTarget() != null) { abilityToUse = ability; targetToUse = receiver.getTarget(); @@ -4389,13 +4290,15 @@ private void rightClickMove(final int screenX, final float worldScreenY) { boolean ordered = false; boolean rallied = false; for (final RenderUnit unit : this.selectedUnits) { - if (unit.getSimulationUnit().getPlayerIndex() == this.war3MapViewer.getLocalPlayerIndex()) { + if (unit.getSimulationUnit().getPlayerIndex() == this.war3MapViewer.getLocalPlayerIndex() + || this.war3MapViewer.simulation.getPlayer(this.war3MapViewer.getLocalPlayerIndex()) + .hasAlliance(unit.getSimulationUnit().getPlayerIndex(), CAllianceType.SHARED_CONTROL)) { for (final CAbility ability : unit.getSimulationUnit().getAbilities()) { - ability.checkCanUse(this.war3MapViewer.simulation, unit.getSimulationUnit(), OrderIds.smart, + ability.checkCanUse(this.war3MapViewer.simulation, unit.getSimulationUnit(), OrderIds.smart, false, BooleanAbilityActivationReceiver.INSTANCE); if (BooleanAbilityActivationReceiver.INSTANCE.isOk()) { ability.checkCanTarget(this.war3MapViewer.simulation, unit.getSimulationUnit(), OrderIds.smart, - clickLocationTemp2, PointAbilityTargetCheckReceiver.INSTANCE); + false, clickLocationTemp2, PointAbilityTargetCheckReceiver.INSTANCE); final Vector2 target = PointAbilityTargetCheckReceiver.INSTANCE.getTarget(); if (target != null) { this.unitOrderListener.issuePointOrder(unit.getSimulationUnit().getHandleId(), @@ -4444,12 +4347,10 @@ public int compare(final RenderWidget widget1, final RenderWidget widget2) { final int levelSort = unitType1.getLevel() - unitType2.getLevel(); if (levelSort == 0) { return unitType1.getTypeId().getValue() - unitType2.getTypeId().getValue(); - } - else { + } else { return levelSort; } - } - else { + } else { return prioSort; } } @@ -4498,8 +4399,8 @@ private void selectUnits(final List selectedUnits) { } UnitSound USAudio = null; if ((unit.getSimulationUnit().getPlayerIndex() == this.war3MapViewer.getLocalPlayerIndex()) - || (unit.getSimulationUnit().getUnitType().getRace() == CUnitRace.CRITTERS) - || ((unit.getSimulationUnit().getUnitType().getRace() == CUnitRace.OTHER) + || (((unit.getSimulationUnit().getUnitType().getRace() == CUnitRace.CRITTERS) + || (unit.getSimulationUnit().getUnitType().getRace() == CUnitRace.OTHER)) && (unit.getSimulationUnit().getPlayerIndex() == (WarsmashConstants.MAX_PLAYERS - 1)))) { if (unit.soundset != null) { UnitSound ackSoundToPlay = unit.soundset.what; @@ -4509,13 +4410,11 @@ private void selectUnits(final List selectedUnits) { ackSoundToPlay = this.war3MapViewer.getUiSounds() .getSound(this.rootFrame.getSkinField("ConstructingBuilding")); soundIndex = (int) (Math.random() * ackSoundToPlay.getSoundCount()); - } - else { + } else { if ((this.selectedSoundCount >= 3) && (pissedSoundCount > 0)) { soundIndex = this.selectedSoundCount - 3; ackSoundToPlay = unit.soundset.pissed; - } - else { + } else { soundIndex = (int) (Math.random() * ackSoundToPlay.getSoundCount()); } } @@ -4529,8 +4428,7 @@ private void selectUnits(final List selectedUnits) { playedNewSound = true; } } - } - else { + } else { this.war3MapViewer.getUiSounds().getSound("InterfaceClick").play(this.uiScene.audioContext, 0, 0, 0); } if (selectionChanged) { @@ -4555,8 +4453,7 @@ private void selectUnits(final List selectedUnits) { if (playedNewSound) { portraitTalk(USAudio); } - } - else { + } else { selectUnit(null); } } @@ -4565,8 +4462,7 @@ private void selectUnits(final List selectedUnits) { public boolean touchUp(final int screenX, final int screenY, final float worldScreenY, final int button) { if (button == Input.Buttons.FORWARD) { return false; - } - else if (button == Input.Buttons.BACK) { + } else if (button == Input.Buttons.BACK) { return false; } if (!this.userControlEnabled) { @@ -4585,8 +4481,7 @@ else if (button == Input.Buttons.BACK) { } } this.mouseDownUIFrame.mouseUp(this.rootFrame, this.uiViewport); - } - else { + } else { if (this.draggingMouseButton == Input.Buttons.LEFT) { if (!this.dragSelectPreviewUnits.isEmpty()) { if (this.allowDrag) { @@ -4617,8 +4512,7 @@ else if (button == Input.Buttons.BACK) { selectWidgets(selectedWidgets); } this.dragSelectPreviewUnits.clear(); - } - else { + } else { if (this.allowDrag) { if (button == Input.Buttons.LEFT) { updateMouseOverUnit(screenX, worldScreenY); @@ -4634,8 +4528,7 @@ else if (button == Input.Buttons.BACK) { } if ((this.mouseOverUnit instanceof RenderUnit) && controlDown) { processSelectNearbyUnits(unitList, shiftDown, (RenderUnit) this.mouseOverUnit); - } - else { + } else { processClickSelect(unitList, shiftDown, this.mouseOverUnit); } this.war3MapViewer.doSelectUnit(unitList); @@ -4675,12 +4568,10 @@ private void processClickSelect(final List unitList, final boolean if (shiftDown) { if (this.selectedUnits.contains(mouseOverUnit)) { unitList.remove(mouseOverUnit); - } - else { + } else { unitList.add(mouseOverUnit); } - } - else { + } else { unitList.add(mouseOverUnit); } } @@ -4706,8 +4597,7 @@ public boolean touchDragged(final int screenX, final int screenY, final float wo screenCoordsVector.y); this.cameraManager.target.x = worldPoint.x; this.cameraManager.target.y = worldPoint.y; - } - else { + } else { if (this.allowDrag) { if (null != this.mouseOverUnit) { this.war3MapViewer.clearUnitMouseOverHighlight(); @@ -4721,13 +4611,11 @@ public boolean touchDragged(final int screenX, final int screenY, final float wo if (this.draggingMouseButton == Input.Buttons.MIDDLE) { this.cameraManager.target.set(clickLocationTemp.sub(this.lastMouseDragStart).scl(-1) .add(this.lastMouseDragCameraTargetStart)); - } - else if (this.draggingMouseButton == Input.Buttons.LEFT) { + } else if (this.draggingMouseButton == Input.Buttons.LEFT) { // update mouseover } this.lastMouseClickLocation.set(clickLocationTemp); - } - else { + } else { if (this.mouseDownUIFrame != null) { this.mouseDownUIFrame.mouseDragged(this.rootFrame, this.uiViewport, screenCoordsVector.x, screenCoordsVector.y); @@ -4755,8 +4643,7 @@ public boolean mouseMoved(final int screenX, final int screenY, final float worl if (mousedUIFrame instanceof ClickableActionFrame) { loadTooltip((ClickableActionFrame) mousedUIFrame); } - } - else { + } else { this.mouseOverUIFrame = null; this.tooltipFrame.setVisible(false); } @@ -4765,8 +4652,7 @@ public boolean mouseMoved(final int screenX, final int screenY, final float worl this.includeFrames, this.ignoreFrames); if (hover == null) { updateMouseOverUnit(screenX, worldScreenY); - } - else { + } else { this.war3MapViewer.clearUnitMouseOverHighlight(); this.mouseOverUnit = null; } @@ -4777,8 +4663,7 @@ private void updateMouseOverUnit(final int screenX, final float worldScreenY) { final RenderWidget newMouseOverUnit; if (this.userControlEnabled) { newMouseOverUnit = this.war3MapViewer.rayPickUnit(screenX, worldScreenY, this.anyClickableUnitFilter); - } - else { + } else { newMouseOverUnit = null; } if (newMouseOverUnit != this.mouseOverUnit) { @@ -4800,8 +4685,7 @@ private void loadTooltip(final ClickableActionFrame mousedUIFrame) { final String uberTip = mousedUIFrame.getUberTip(); if ((toolTip == null) || (uberTip == null)) { this.tooltipFrame.setVisible(false); - } - else { + } else { this.rootFrame.setText(this.tooltipUberTipText, uberTip); int resourceIndex = 0; if (goldCost != 0) { @@ -4835,8 +4719,7 @@ private void loadTooltip(final ClickableActionFrame mousedUIFrame) { if (resourceIndex != 0) { this.tooltipUberTipText.addSetPoint(this.uberTipWithResourcesSetPoint); resourcesHeight = 0.014f; - } - else { + } else { this.tooltipUberTipText.addSetPoint(this.uberTipNoResourcesSetPoint); resourcesHeight = 0.004f; } @@ -4861,14 +4744,14 @@ public void queueIconClicked(final int index) { switch (index) { case 0: for (final CAbility ability : simulationUnit.getAbilities()) { - ability.checkCanUse(this.war3MapViewer.simulation, simulationUnit, OrderIds.cancel, + ability.checkCanUse(this.war3MapViewer.simulation, simulationUnit, OrderIds.cancel, false, BooleanAbilityActivationReceiver.INSTANCE); if (BooleanAbilityActivationReceiver.INSTANCE.isOk()) { final BooleanAbilityTargetCheckReceiver targetCheckReceiver = BooleanAbilityTargetCheckReceiver .getInstance().reset(); ability.checkCanTargetNoTarget(this.war3MapViewer.simulation, simulationUnit, OrderIds.cancel, - targetCheckReceiver); + false, targetCheckReceiver); if (targetCheckReceiver.isTargetable()) { this.unitOrderListener.issueImmediateOrder(simulationUnit.getHandleId(), ability.getHandleId(), OrderIds.cancel, false); @@ -4883,8 +4766,7 @@ public void queueIconClicked(final int index) { selectWidgets(unitList); break; } - } - else { + } else { this.unitOrderListener.unitCancelTrainingItem(simulationUnit.getHandleId(), index); } } @@ -4916,8 +4798,7 @@ public void onClick(final int abilityHandleId, final int orderId, final boolean setDraggingItem(null); MeleeUI.this.activeCommand = null; MeleeUI.this.activeCommandUnit = null; - } - else { + } else { if (itemInSlot != null) { setDraggingItem(itemInSlot); MeleeUI.this.activeCommand = inventoryData; @@ -4925,29 +4806,26 @@ public void onClick(final int abilityHandleId, final int orderId, final boolean MeleeUI.this.activeCommandOrderId = OrderIds.dropitem; } } - } - else { + } else { final CSimulation game = MeleeUI.this.war3MapViewer.simulation; final ExternStringMsgAbilityActivationReceiver receiver = ExternStringMsgAbilityActivationReceiver.INSTANCE; receiver.reset(); - inventoryData.checkCanUse(game, simulationUnit, orderId, receiver); + inventoryData.checkCanUse(game, simulationUnit, orderId, false, receiver); if (receiver.isUseOk()) { final BooleanAbilityTargetCheckReceiver targetReceiver = BooleanAbilityTargetCheckReceiver .getInstance(); targetReceiver.reset(); - inventoryData.checkCanTargetNoTarget(game, simulationUnit, orderId, targetReceiver); + inventoryData.checkCanTargetNoTarget(game, simulationUnit, orderId, false, targetReceiver); if (targetReceiver.isTargetable()) { MeleeUI.this.unitOrderListener.issueImmediateOrder(simulationUnit.getHandleId(), inventoryData.getHandleId(), orderId, isShiftDown()); - } - else { + } else { MeleeUI.this.activeCommand = inventoryData; MeleeUI.this.activeCommandOrderId = orderId; MeleeUI.this.activeCommandUnit = selectedUnit2; clearAndRepopulateCommandCard(); } - } - else { + } else { final String externStringKey = receiver.getExternStringKey(); if ((externStringKey != null) && !externStringKey.isEmpty()) { showInterfaceError(simulationUnit.getPlayerIndex(), externStringKey); @@ -4985,8 +4863,7 @@ public void lifeChanged() { } if (this.sourceUnit.getSimulationUnit().isDead()) { removeSourceUnitFromSelection(); - } - else { + } else { MeleeUI.this.selectedUnitFrames[this.index] .setLifeRatioRemaining(this.sourceUnit.getSimulationUnit().getLife() / this.sourceUnit.getSimulationUnit().getMaximumLife()); @@ -5088,6 +4965,13 @@ public void abilitiesChanged() { } } + @Override + public void upgradesChanged() { + if (this.disposed) { + return; + } + } + } @Override @@ -5216,8 +5100,7 @@ public void removedUnit(final CUnit whichUnit) { final List newSelectedUnits = new ArrayList<>(this.selectedUnits); newSelectedUnits.remove(renderUnit); selectUnits(newSelectedUnits); - } - else if (this.selectedUnit == renderUnit) { + } else if (this.selectedUnit == renderUnit) { selectUnit(null); } } @@ -5325,8 +5208,7 @@ public void setCinematicScene(int portraitUnitId, CPlayerColor color, String spe unitTypeData == null ? null : unitTypeData.getPortraitModel(), color.getHandleId(), unitTypeData.getRequiredAnimationNames(), sceneDuration); this.cinematicPortrait.talk(null, voiceoverDuration); - } - else { + } else { if (unitTypeData != null) { this.portrait.setCinematicTalkingHead(unitTypeData.getPortraitModel(), color.getHandleId(), unitTypeData.getRequiredAnimationNames(), sceneDuration, null, voiceoverDuration); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java index cd241f2d8..dd0556a86 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java @@ -68,8 +68,7 @@ public void render(final CSimulation game, final SpriteBatch batch, final Iterab batch.setColor(0f, 0f, 0f, 0.5f); batch.draw(this.teamColors[0], this.minimapFilledArea.x + (x * mapXMod), this.minimapFilledArea.y + (y * mapYMod), mapXMod, mapYMod); - } - else if (CFogState.MASKED.equals(state)) { + } else if (CFogState.MASKED.equals(state)) { batch.setColor(0f, 0f, 0f, 1f); batch.draw(this.teamColors[0], this.minimapFilledArea.x + (x * mapXMod), this.minimapFilledArea.y + (y * mapYMod), mapXMod, mapYMod); @@ -85,43 +84,38 @@ else if (CFogState.MASKED.equals(state)) { for (final RenderUnit unit : units) { final CUnit simUnit = unit.getSimulationUnit(); int dimensions = 4; - if (!simUnit.isHidden() && !simUnit.isDead() && simUnit.isVisible(game, player.getId())) { + if (!(simUnit.isHidden() || simUnit.isHideMinimapIcon() || simUnit.isDead()) + && simUnit.isVisible(game, player.getId())) { batch.setColor(1, 1, 1, 1); final Texture minimapIcon; if (simUnit.getGoldMineData() != null) { minimapIcon = this.specialIcons[0]; dimensions = 21; - } - else if (simUnit.getOverlayedGoldMineData() != null) { + } else if (simUnit.getOverlayedGoldMineData() != null) { final CAbilityOverlayedMine overlayedGoldMineData = simUnit.getOverlayedGoldMineData(); if (overlayedGoldMineData instanceof CAbilityEntangledMine) { minimapIcon = this.specialIcons[3]; - } - else { + } else { minimapIcon = this.specialIcons[4]; } dimensions = 21; - } - else if (simUnit.getUnitType().isNeutralBuildingShowMinimapIcon()) { + } else if (simUnit.getUnitType().isNeutralBuildingShowMinimapIcon()) { minimapIcon = this.specialIcons[1]; dimensions = 21; - } - else if (simUnit.isHero()) { - if (player.hasAlliance(simUnit.getPlayerIndex(), CAllianceType.PASSIVE)) { + } else if (simUnit.isHero()) { + if (player.hasAlliance(simUnit.getFakePlayerIndex(), CAllianceType.PASSIVE)) { batch.setColor(1f, 1f, 1f, this.heroAlpha); - } - else { + } else { // Color pc = new Color(game.getPlayer(simUnit.getPlayerIndex()).getColor()); batch.setColor(1f, 0.2f, 0.2f, this.heroAlpha); } minimapIcon = this.specialIcons[2]; dimensions = 28; - } - else { + } else { if (simUnit.isBuilding()) { dimensions = 10; } - minimapIcon = this.teamColors[unit.getSimulationUnit().getPlayerIndex()]; + minimapIcon = this.teamColors[unit.getSimulationUnit().getFakePlayerIndex()]; } final int offset = dimensions / 2; batch.draw(minimapIcon, diff --git a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderConfigTree.java b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderConfigTree.java index 6abd8338a..4b03ce7cf 100644 --- a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderConfigTree.java +++ b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderConfigTree.java @@ -9,9 +9,9 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABCondition; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.behavior.condition.ABBooleanCallback; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; public class AbilityBuilderConfigTree extends JTree { private DefaultMutableTreeNode root; @@ -59,10 +59,10 @@ private DefaultMutableTreeNode createActionsNode(String name) { return conditionTreeNode; } - public void setConfig(AbilityBuilderConfiguration config) { + public void setConfig(ABAbilityBuilderConfiguration config) { root = new DefaultMutableTreeNode(config.getId() + " \"" + config.getCastId() + "\""); - Method[] declaredMethods = AbilityBuilderConfiguration.class.getDeclaredMethods(); + Method[] declaredMethods = ABAbilityBuilderConfiguration.class.getDeclaredMethods(); for (Method declaredMethod : declaredMethods) { String name = declaredMethod.getName(); if (name.startsWith("getOn")) { @@ -84,10 +84,10 @@ public void setConfig(AbilityBuilderConfiguration config) { String fixedName = fixConditionsName(name); DefaultMutableTreeNode conditionsNode = createConditionsNode(fixedName); try { - List conditions = (List) declaredMethod.invoke(config, new Object[0]); + List conditions = (List) declaredMethod.invoke(config, new Object[0]); if (conditions != null) { root.add(conditionsNode); - for (ABCondition condition : conditions) { + for (ABBooleanCallback condition : conditions) { generateInto(conditionsNode, condition); } } @@ -129,7 +129,7 @@ public void generateInto(DefaultMutableTreeNode actionsNode, Object action) { } } if (ABAction.class.isAssignableFrom(field.getType()) - || ABCondition.class.isAssignableFrom(field.getType())) { + || ABBooleanCallback.class.isAssignableFrom(field.getType())) { try { DefaultMutableTreeNode nodeForField = new DefaultMutableTreeNode(field.getName()); nodeForAction.add(nodeForField); @@ -176,7 +176,7 @@ private Object describe(Object action) { boolean first = true; for (Field field : fields) { if (!ABAction.class.isAssignableFrom(field.getType()) - && !ABCondition.class.isAssignableFrom(field.getType())) { + && !ABBooleanCallback.class.isAssignableFrom(field.getType())) { String fieldName = field.getName(); if ("recycleRect".equals(fieldName)) { continue; diff --git a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderDupeCellRenderer.java b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderDupeCellRenderer.java index cc09ca857..af3053c2f 100644 --- a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderDupeCellRenderer.java +++ b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderDupeCellRenderer.java @@ -5,14 +5,14 @@ import javax.swing.DefaultListCellRenderer; import javax.swing.JList; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; public class AbilityBuilderDupeCellRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - if (value instanceof AbilityBuilderConfiguration) { - AbilityBuilderConfiguration config = (AbilityBuilderConfiguration) value; + if (value instanceof ABAbilityBuilderConfiguration) { + ABAbilityBuilderConfiguration config = (ABAbilityBuilderConfiguration) value; value = config.getId() + " \"" + config.getCastId() + "\""; } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); diff --git a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderJassBrainstorm.java b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderJassBrainstorm.java index 5699ad18a..2366454cb 100644 --- a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderJassBrainstorm.java +++ b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderJassBrainstorm.java @@ -9,39 +9,39 @@ import com.etheller.warsmash.parsers.jass.JassTextGenerator; import com.etheller.warsmash.parsers.jass.JassTextGeneratorImpl1; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.AbilityBuilderGsonBuilder; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderDupe; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParser; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParserUtil; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParserUtil.AbilityBuilderFileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAbilityBuilderGsonBuilder; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderDupe; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParser; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParserUtil; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParserUtil.AbilityBuilderFileListener; import com.google.gson.Gson; public class AbilityBuilderJassBrainstorm { public static void main(final String[] args) { - final Gson gson = AbilityBuilderGsonBuilder.create(); - AbilityBuilderParserUtil.loadAbilityBuilderFiles(new AbilityBuilderFileListener() { + final Gson gson = ABAbilityBuilderGsonBuilder.create(); + ABAbilityBuilderParserUtil.loadAbilityBuilderFiles(new AbilityBuilderFileListener() { @Override - public void callback(final AbilityBuilderParser behavior) { + public void callback(final ABAbilityBuilderParser behavior) { System.out.println(behavior); convertTheThing(behavior); } }); } - private static void convertTheThing(final AbilityBuilderParser behavior) { - if (behavior.getType() == AbilityBuilderType.TEMPLATE) { - for (final AbilityBuilderDupe dupe : behavior.getIds()) { + private static void convertTheThing(final ABAbilityBuilderParser behavior) { + if (behavior.getType() == ABAbilityBuilderType.TEMPLATE) { + for (final ABAbilityBuilderDupe dupe : behavior.getIds()) { System.out.println("//template: " + dupe.getId()); // idsListModel.addElement(new AbilityBuilderConfiguration(behavior, dupe)); } } else { - for (final AbilityBuilderDupe dupe : behavior.getIds()) { - final AbilityBuilderConfiguration abilityBuilderConfiguration = new AbilityBuilderConfiguration( + for (final ABAbilityBuilderDupe dupe : behavior.getIds()) { + final ABAbilityBuilderConfiguration abilityBuilderConfiguration = new ABAbilityBuilderConfiguration( behavior, dupe); try { generateJassForConf(dupe, abilityBuilderConfiguration); @@ -66,8 +66,8 @@ private static void generateFunctions(final JassTextGenerator out, final StringB } } - private static void generateJassForConf(final AbilityBuilderDupe dupe, - final AbilityBuilderConfiguration abilityBuilderConfiguration) { + private static void generateJassForConf(final ABAbilityBuilderDupe dupe, + final ABAbilityBuilderConfiguration abilityBuilderConfiguration) { String abilityName = null; final StringBuilder initCode = new StringBuilder(); @@ -112,7 +112,7 @@ private static void generateJassForConf(final AbilityBuilderDupe dupe, if (autoCastType != null) { initCode.append(" call SetABConfAutoCastType(abc, AUTOCAST_TYPE_" + autoCastType.name() + ")\n"); } - final AbilityBuilderType type = abilityBuilderConfiguration.getType(); + final ABAbilityBuilderType type = abilityBuilderConfiguration.getType(); if (type != null) { initCode.append(" call SetABConfType(abc, AB_CONF_TYPE_" + type.name() + ")\n"); } diff --git a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderSmashJassBrainstorm.java b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderSmashJassBrainstorm.java index f4bbfcf6a..fa95f812c 100644 --- a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderSmashJassBrainstorm.java +++ b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderSmashJassBrainstorm.java @@ -9,39 +9,39 @@ import com.etheller.warsmash.parsers.jass.JassTextGenerator; import com.etheller.warsmash.parsers.jass.JassTextGeneratorImpl1; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABAction; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.AbilityBuilderGsonBuilder; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderDupe; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParser; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParserUtil; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParserUtil.AbilityBuilderFileListener; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAbilityBuilderGsonBuilder; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAction; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderDupe; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParser; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParserUtil; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParserUtil.AbilityBuilderFileListener; import com.google.gson.Gson; public class AbilityBuilderSmashJassBrainstorm { public static void main(final String[] args) { - final Gson gson = AbilityBuilderGsonBuilder.create(); - AbilityBuilderParserUtil.loadAbilityBuilderFiles(new AbilityBuilderFileListener() { + final Gson gson = ABAbilityBuilderGsonBuilder.create(); + ABAbilityBuilderParserUtil.loadAbilityBuilderFiles(new AbilityBuilderFileListener() { @Override - public void callback(final AbilityBuilderParser behavior) { + public void callback(final ABAbilityBuilderParser behavior) { System.out.println(behavior); convertTheThing(behavior); } }); } - private static void convertTheThing(final AbilityBuilderParser behavior) { - if (behavior.getType() == AbilityBuilderType.TEMPLATE) { - for (final AbilityBuilderDupe dupe : behavior.getIds()) { + private static void convertTheThing(final ABAbilityBuilderParser behavior) { + if (behavior.getType() == ABAbilityBuilderType.TEMPLATE) { + for (final ABAbilityBuilderDupe dupe : behavior.getIds()) { System.out.println("//template: " + dupe.getId()); // idsListModel.addElement(new AbilityBuilderConfiguration(behavior, dupe)); } } else { - for (final AbilityBuilderDupe dupe : behavior.getIds()) { - final AbilityBuilderConfiguration abilityBuilderConfiguration = new AbilityBuilderConfiguration( + for (final ABAbilityBuilderDupe dupe : behavior.getIds()) { + final ABAbilityBuilderConfiguration abilityBuilderConfiguration = new ABAbilityBuilderConfiguration( behavior, dupe); try { generateJassForConf(dupe, abilityBuilderConfiguration); @@ -66,8 +66,8 @@ private static void generateFunctions(final JassTextGenerator out, final StringB } } - private static void generateJassForConf(final AbilityBuilderDupe dupe, - final AbilityBuilderConfiguration abilityBuilderConfiguration) { + private static void generateJassForConf(final ABAbilityBuilderDupe dupe, + final ABAbilityBuilderConfiguration abilityBuilderConfiguration) { String abilityName = null; final StringBuilder structCode = new StringBuilder(); @@ -113,7 +113,7 @@ private static void generateJassForConf(final AbilityBuilderDupe dupe, if (autoCastType != null) { initCode.append(" call SetABConfAutoCastType(abc, AUTOCAST_TYPE_" + autoCastType.name() + ")\n"); } - final AbilityBuilderType type = abilityBuilderConfiguration.getType(); + final ABAbilityBuilderType type = abilityBuilderConfiguration.getType(); if (type != null) { initCode.append(" call SetABConfType(abc, AB_CONF_TYPE_" + type.name() + ")\n"); switch (type) { @@ -123,29 +123,19 @@ private static void generateJassForConf(final AbilityBuilderDupe dupe, break; case NORMAL_FLEXTARGET: break; - case NORMAL_FLEXTARGET_SIMPLE: - break; case NORMAL_NOTARGET: break; - case NORMAL_NOTARGET_SIMPLE: - break; case NORMAL_PAIRING: break; case NORMAL_POINTTARGET: break; - case NORMAL_POINTTARGET_SIMPLE: - break; case NORMAL_UNITTARGET: break; - case NORMAL_UNITTARGET_SIMPLE: - break; case PASSIVE: break; - case SMART: - break; case TEMPLATE: break; - case TOGGLE: + case INHERIT: break; } } diff --git a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderUIPanel.java b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderUIPanel.java index cc74e9b4a..dc911966f 100644 --- a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderUIPanel.java +++ b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/AbilityBuilderUIPanel.java @@ -20,18 +20,18 @@ import javax.swing.event.ListSelectionListener; import javax.swing.filechooser.FileNameExtensionFilter; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.AbilityBuilderGsonBuilder; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderConfiguration; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderDupe; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderParserUtil; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.core.ABAbilityBuilderGsonBuilder; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderConfiguration; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderDupe; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderParserUtil; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderType; import com.google.gson.Gson; public class AbilityBuilderUIPanel extends JPanel { private final JFileChooser jsonFileChooser = new JFileChooser(new File("abilityBehaviors")); - private final Gson gson = AbilityBuilderGsonBuilder.create(); - private DefaultListModel idsListModel; - private JList idsList; + private final Gson gson = ABAbilityBuilderGsonBuilder.create(); + private DefaultListModel idsListModel; + private JList idsList; private AbilityBuilderConfigTree abilityBuilderConfigTree; public AbilityBuilderUIPanel() { @@ -40,8 +40,8 @@ public AbilityBuilderUIPanel() { jsonFileChooser.addChoosableFileFilter(jsonFilenameFilter); jsonFileChooser.setFileFilter(jsonFilenameFilter); - idsListModel = new DefaultListModel(); - idsList = new JList(idsListModel); + idsListModel = new DefaultListModel(); + idsList = new JList(idsListModel); idsList.setPreferredSize(new Dimension(200, 1)); idsList.setCellRenderer(new AbilityBuilderDupeCellRenderer()); @@ -52,7 +52,7 @@ public AbilityBuilderUIPanel() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { - AbilityBuilderConfiguration selectedValue = idsList.getSelectedValue(); + ABAbilityBuilderConfiguration selectedValue = idsList.getSelectedValue(); if (selectedValue != null) { abilityBuilderConfigTree.setConfig(selectedValue); } @@ -89,16 +89,16 @@ public void fileOpenClicked() { try { idsListModel.clear(); abilityBuilderConfigTree.clearConfig(); - AbilityBuilderParserUtil.loadAbilityBuilderFile(gson, selectedFile, behavior -> { - if (behavior.getType() == AbilityBuilderType.TEMPLATE) { - for (AbilityBuilderDupe dupe : behavior.getIds()) { + ABAbilityBuilderParserUtil.loadAbilityBuilderFile(gson, selectedFile, behavior -> { + if (behavior.getType() == ABAbilityBuilderType.TEMPLATE) { + for (ABAbilityBuilderDupe dupe : behavior.getIds()) { System.out.println("template: " + dupe.getId()); - idsListModel.addElement(new AbilityBuilderConfiguration(behavior, dupe)); + idsListModel.addElement(new ABAbilityBuilderConfiguration(behavior, dupe)); } } else { - for (AbilityBuilderDupe dupe : behavior.getIds()) { + for (ABAbilityBuilderDupe dupe : behavior.getIds()) { System.out.println("non-template: " + dupe.getId()); - idsListModel.addElement(new AbilityBuilderConfiguration(behavior, dupe)); + idsListModel.addElement(new ABAbilityBuilderConfiguration(behavior, dupe)); } } }); diff --git a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/JassGeneratorForType.java b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/JassGeneratorForType.java index a3bc23e1d..6698d0702 100644 --- a/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/JassGeneratorForType.java +++ b/desktop/src/com/etheller/warsmash/desktop/editor/abilitybuilder/JassGeneratorForType.java @@ -7,9 +7,9 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbilityDisableType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.autocast.AutocastType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.types.definitions.impl.AbilityFields; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.core.ABLocalStoreKeys; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.AbilityBuilderType; -import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilitybuilder.parser.template.DataFieldLetter; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.datastore.ABLocalStoreKeys; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.ABAbilityBuilderType; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.adjustablebehaviors.parser.template.ABDataFieldLetter; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehaviorCategory; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.combat.CTargetType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.unit.NonStackingStatBuffType; @@ -38,7 +38,7 @@ public static void main(final String[] args) { System.out.println(String.format(" constant statemodtype STATE_MOD_TYPE_%-34s= ConvertStateModType(%d)", type.name(), type.ordinal())); } - for (final DataFieldLetter type : DataFieldLetter.values()) { + for (final ABDataFieldLetter type : ABDataFieldLetter.values()) { System.out.println( String.format(" constant datafieldletter DATA_FIELD_LETTER_%-34s= ConvertDataFieldLetter(%d)", type.name(), type.ordinal())); @@ -47,7 +47,7 @@ public static void main(final String[] args) { System.out.println(String.format(" constant autocasttype AUTOCAST_TYPE_%-34s= ConvertAutocastType(%d)", type.name(), type.ordinal())); } - for (final AbilityBuilderType type : AbilityBuilderType.values()) { + for (final ABAbilityBuilderType type : ABAbilityBuilderType.values()) { System.out.println(String.format(" constant abconftype AB_CONF_TYPE_%-34s= ConvertABConfType(%d)", type.name(), type.ordinal())); } diff --git a/jassparser/src/com/etheller/interpreter/ast/scope/trigger/RemovableTriggerEvent.java b/jassparser/src/com/etheller/interpreter/ast/scope/trigger/RemovableTriggerEvent.java index 884604e94..204c2a844 100644 --- a/jassparser/src/com/etheller/interpreter/ast/scope/trigger/RemovableTriggerEvent.java +++ b/jassparser/src/com/etheller/interpreter/ast/scope/trigger/RemovableTriggerEvent.java @@ -2,7 +2,8 @@ public abstract class RemovableTriggerEvent { public RemovableTriggerEvent(final Trigger t) { - t.addEvent(this); + if (t != null) + t.addEvent(this); } public abstract void remove();