Modding Help [SOLVED] LUA term to change weapon's elementalType

Discussion in 'Starbound Modding' started by sethyuikora, Feb 21, 2023.

  1. sethyuikora

    sethyuikora Void-Bound Voyager

    Been scouring code for a few days to determine a method of directly altering a weapon's elementalType or damageSourceKind parameter via a weaponability. I'll include all of what I'm working with to help anyone helping better understand what I'm working with, but be warned: It's a bit extensive, but it's a stable loading WIP at this point with no errors in the log.
    I believe the issue lies in the sp-dragonlimit.lua file, but here's what I've got so far:

    Here's the activeitem, elementalType is set to physical here, as that'd be a good default. This is the value I'm hoping to change if possible, to deal fire, ice, electric, poison, or physical, depending on which form the weapon is in.


    {
    "itemName" : "sp-dragonspear5",
    "price" : 2500,
    "level" : 7,
    "maxStack" : 1,
    "rarity" : "Essential",
    "description" : "A True Spear of a True Dragon Slayer.
    ^green;[Down]+[Special]: ^cyan;Elemental Mastery^reset;",
    "shortdescription" : "True Dragon Spear",
    "tooltipKind" : "base",
    "category" : "spear",
    "twoHanded" : true,
    "itemTags" : ["weapon","melee","spear","upgradeableWeapon"],

    "inventoryIcon" : "icon.png",
    "animation" : "/items/active/weapons/melee/spear/sp-dragonspear5/sp-dragonspear5.animation",
    "animationParts" : {
    "handle" : "handle.png",
    "blade" : "blade.png"
    },
    "animationCustom" : { },

    "scripts" : ["/items/active/weapons/melee/meleeweapon.lua"],

    "elementalType" : "physical",

    "aimOffset" : 0.0,
    "primaryAbilityType" : "sp-slayerspearcombo",
    "primaryAbility" : {

    "scripts" : ["/items/active/weapons/melee/spear/sp-dragonspear5/assistedmeleecombo.lua"],

    "damageConfig" : {
    "damageSourceKind" : "spear",
    "statusEffects" : [ ],
    "knockbackMode" : "facing",
    "timeout" : 0.5
    },

    "stances" : {
    "idle" : {
    "armRotation" : -30,
    "weaponRotation" : -25,
    "weaponOffset" : [0, -1],
    "allowRotate" : true,
    "allowFlip" : true
    },
    "windup1" : {
    "duration" : 0.1,
    "weaponOffset" : [0, -1],
    "armRotation" : 90,
    "weaponRotation" : 45,
    "twoHanded" : true,

    "allowRotate" : false,
    "allowFlip" : true
    },
    "fire1" : {
    "duration" : 0.2,
    "weaponOffset" : [0, 0],
    "armRotation" : -45,
    "weaponRotation" : -90,
    "twoHanded" : true,

    "allowRotate" : false,
    "allowFlip" : true
    },
    "wait1" : {
    "duration" : 0.3,
    "weaponOffset" : [0, -1],
    "armRotation" : -140,
    "weaponRotation" : 30,
    "allowRotate" : false,
    "allowFlip" : true,
    "twoHanded" : true
    },
    "windup2" : {
    "duration" : 0.1,
    "weaponOffset" : [0, -1],
    "armRotation" : -175,
    "weaponRotation" : 90,
    "twoHanded" : true,

    "allowFlip" : true,
    "allowRotate" : true
    },
    "fire2" : {
    "duration" : 0.2,
    "weaponOffset" : [0, 0],
    "armRotation" : 0,
    "weaponRotation" : -90,
    "twoHanded" : true,

    "allowFlip" : true,
    "allowRotate" : false
    },
    "wait2" : {
    "duration" : 0.3,
    "weaponOffset" : [0, -1],
    "armRotation" : -10,
    "weaponRotation" : -90,
    "allowRotate" : false,
    "allowFlip" : true,
    "twoHanded" : true
    },
    "windup3" : {
    "duration" : 0.1,
    "weaponOffset" : [0, -1],
    "armRotation" : -30,
    "weaponRotation" : 140,
    "twoHanded" : true,

    "allowRotate" : false,
    "allowFlip" : true
    },
    "fire3" : {
    "duration" : 0.2,
    "weaponOffset" : [0, 0],
    "armRotation" : 30,
    "weaponRotation" : -30,
    "twoHanded" : true,

    "allowRotate" : false,
    "allowFlip" : true
    },
    "wait3" : {
    "duration" : 0.3,
    "weaponOffset" : [0, 0],
    "armRotation" : -50,
    "weaponRotation" : 90,
    "allowRotate" : false,
    "allowFlip" : true,
    "twoHanded" : true
    },
    "windup4" : {
    "duration" : 0.2,
    "weaponOffset" : [0, -1],
    "armRotation" : -40,
    "weaponRotation" : -180,
    "twoHanded" : true,
    "weaponAngularVelocity": 1080,

    "allowRotate" : false,
    "allowFlip" : true
    },
    "fire4" : {
    "duration" : 0.3,
    "weaponOffset" : [0, 0],
    "armRotation" : 145,
    "weaponRotation" : -90,
    "twoHanded" : false,

    "allowRotate" : false,
    "allowFlip" : true
    },
    "wait4" : {
    "duration" : 0.3,
    "weaponOffset" : [0, -0.5],
    "armRotation" : -135,
    "weaponRotation" : -30,
    "allowRotate" : false,
    "allowFlip" : true,
    "twoHanded" : true
    },
    "windup5" : {
    "duration" : 0.3,
    "weaponOffset" : [0, -1],
    "armRotation" : -150,
    "weaponRotation" : -60,
    "weaponAngularVelocity": 1080,
    "twoHanded" : true,
    "allowFlip" : true,
    "allowRotate" : true
    },
    "fire5" : {
    "duration" : 0.3,
    "weaponOffset" : [0, 1],
    "armRotation" : 0,
    "weaponRotation" : -90,
    "twoHanded" : false,
    "allowFlip" : true,
    "allowRotate" : false
    },
    "wait5" : {
    "duration" : 0.3,
    "weaponOffset" : [0, 0],
    "armRotation" : -30,
    "weaponRotation" : -25,
    "allowRotate" : false,
    "allowFlip" : true,
    "twoHanded" : true
    }
    }
    },
    "altAbilityType" : "sp-dragonlimit",
    "altAbility" : { },

    "learnBlueprintsOnPickup" : [
    "sp-dragonspear5"
    ],

    "critChance" : 2,
    "critBonus" : 8,

    "builder" : "/items/buildscripts/buildunrandweapon.lua"
    }


    Here, we have the animation file. Assuming I can get the elemental change to work, this file should reflect that change by having the swooshes turn to fire, ice, electric, or poison versions in their respective states. Unfortunately at this time, they remain physical.


    {
    "globalTagDefaults" : {
    "paletteSwaps" : ""
    },

    "animatedParts" : {
    "stateTypes" : {
    "blade" : {
    "default" : "physical",
    "states" : {
    "physical" : {
    "properties":{
    "particleEmittersOff" : ["bladefire", "bladeice", "bladeelectric", "bladepoison"]
    }
    },
    "shiftFire" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "fire"
    },
    "fire" : {
    "properties":{
    "particleEmittersOn" : ["bladefire"],
    "particleEmittersOff" : ["bladeice", "bladeelectric", "bladepoison"]
    }
    },
    "shiftIce" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "ice"
    },
    "ice" : {
    "properties":{
    "particleEmittersOn" : ["bladeice"],
    "particleEmittersOff" : ["bladefire", "bladeelectric", "bladepoison"]
    }
    },
    "shiftElectric" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "electric"
    },
    "electric" : {
    "properties":{
    "particleEmittersOn" : ["bladeelectric"],
    "particleEmittersOff" : ["bladefire", "bladeice", "bladepoison"]
    }
    },
    "shiftPoison" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "poison"
    },
    "poison" : {
    "properties":{
    "particleEmittersOn" : ["bladepoison"],
    "particleEmittersOff" : ["bladefire", "bladeice", "bladeelectric"]
    }
    },
    "shiftPhysical" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "physical"
    }
    }
    },
    "handle" : {
    "default" : "physical",
    "states" : {
    "physical" : {},
    "shiftFire" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "fire"
    },
    "fire" : {},
    "shiftIce" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "ice"
    },
    "ice" : {},
    "shiftElectric" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "electric"
    },
    "electric" : {},
    "shiftPoison" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "poison"
    },
    "poison" : {},
    "shiftPhysical" : {
    "frames" : 7,
    "cycle" : 0.5,
    "mode" : "transition",
    "transition" : "physical"
    }
    }
    },
    "swoosh" : {
    "default" : "idle",
    "states" : {
    "idle" : {
    },
    "fire" : {
    "frames" : 3,
    "cycle" : 0.1,
    "mode" : "transition",
    "transition" : "idle"
    },
    "fire2" : {
    "frames" : 3,
    "cycle" : 0.1,
    "mode" : "transition",
    "transition" : "idle"
    },
    "fire3" : {
    "frames" : 3,
    "cycle" : 0.1,
    "mode" : "transition",
    "transition" : "idle"
    },
    "fire4" : {
    "frames" : 3,
    "cycle" : 0.1,
    "mode" : "transition",
    "transition" : "idle"
    },
    "fire5" : {
    "frames" : 7,
    "cycle" : 0.1,
    "mode" : "transition",
    "transition" : "idle"
    },
    "fire6" : {
    "frames" : 7,
    "cycle" : 0.12,
    "mode" : "transition",
    "transition" : "idle"
    },
    "chargedfire1" : {
    "frames" : 3,
    "cycle" : 0.1,
    "mode" : "transition",
    "transition" : "idle"
    }
    }
    }
    },

    "parts" : {
    "blade" : {
    "properties" : {
    "zLevel" : 1,
    "centered" : true,
    "fullbright" : true,
    "offset" : [0.0, 1.2],
    "transformationGroups" : ["weapon"],
    "rotationCenter" : [0, 1.2],
    "damageArea" : [ [-1.7, -2.0], [-1.7, 2.5], [0.5, 2.5], [0.5, -2.0] ]
    },
    "partStates" : {
    "blade" : {
    "physical" : {
    "properties" : {
    "image" : "<partImage>:physical?<directives>?<bladeDirectives>"
    }
    },
    "shiftFire" : {
    "properties" : {
    "image" : "<partImage>:shiftFire.<frame><paletteSwaps>"
    }
    },
    "fire" : {
    "properties" : {
    "image" : "<partImage>:fire"
    }
    },
    "shiftIce" : {
    "properties" : {
    "image" : "<partImage>:shiftIce.<frame><paletteSwaps>"
    }
    },
    "ice" : {
    "properties" : {
    "image" : "<partImage>:ice"
    }
    },
    "shiftElectric" : {
    "properties" : {
    "image" : "<partImage>:shiftElectric.<frame><paletteSwaps>"
    }
    },
    "electric" : {
    "properties" : {
    "image" : "<partImage>:electric"
    }
    },
    "shiftPoison" : {
    "properties" : {
    "image" : "<partImage>:shiftPoison.<frame><paletteSwaps>"
    }
    },
    "poison" : {
    "properties" : {
    "image" : "<partImage>:poison"
    }
    },
    "shiftPhysical" : {
    "properties" : {
    "image" : "<partImage>:shiftPhysical.<frame><paletteSwaps>"
    }
    }
    }
    }
    },
    "handle" : {
    "properties" : {
    "zLevel" : 0,
    "centered" : true,
    "fullbright" : false,
    "offset" : [0, 1.2],
    "transformationGroups" : ["weapon"],
    "rotationCenter" : [0, 1.2],
    "damageArea" : [ [-1.7, -2.0], [-1.7, 2.5], [0.5, 2.5], [0.5, -2.0] ]
    },
    "partStates" : {
    "handle" : {
    "physical" : {
    "properties" : {
    "image" : "<partImage>:physical?<directives>?<bladeDirectives>"
    }
    },
    "shiftFire" : {
    "properties" : {
    "image" : "<partImage>:shiftFire.<frame><paletteSwaps>"
    }
    },
    "fire" : {
    "properties" : {
    "image" : "<partImage>:fire"
    }
    },
    "shiftIce" : {
    "properties" : {
    "image" : "<partImage>:shiftIce.<frame><paletteSwaps>"
    }
    },
    "ice" : {
    "properties" : {
    "image" : "<partImage>:ice"
    }
    },
    "shiftElectric" : {
    "properties" : {
    "image" : "<partImage>:shiftElectric.<frame><paletteSwaps>"
    }
    },
    "electric" : {
    "properties" : {
    "image" : "<partImage>:electric"
    }
    },
    "shiftPoison" : {
    "properties" : {
    "image" : "<partImage>:shiftPoison.<frame><paletteSwaps>"
    }
    },
    "poison" : {
    "properties" : {
    "image" : "<partImage>:poison"
    }
    },
    "shiftPhysical" : {
    "properties" : {
    "image" : "<partImage>:shiftPhysical.<frame><paletteSwaps>"
    }
    }
    }
    }
    },
    "swoosh" : {
    "properties" : {
    "zLevel" : 2,
    "centered" : true,
    "fullbright" : true,
    "transformationGroups" : ["swoosh"],
    "offset" : [1, 0.0],
    "rotationCenter" : [0, 0]
    },

    "partStates" : {
    "swoosh" : {
    "idle" : {
    "properties" : {
    "image" : ""
    }
    },
    "fire" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/spear/swoosh/slayerswoosh<elementalType>.png:<frame>",
    "offset" : [0, 2],
    "damageArea" : [[2, -2], [-3, 4], [4, 2.5], [5, -2]]
    }
    },
    "fire2" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/spear/swoosh/slayerswoosh<elementalType>2.png:<frame>",
    "offset" : [5.0, 0.0],
    "damageArea" : [[-3, 1.0], [1, 1.0], [1, -1.0], [-3, -1.0]]
    }
    },
    "fire3" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/spear/swoosh/slayerswoosh<elementalType>3.png:<frame>",
    "offset" : [0, -2],
    "damageArea" : [[2, 2], [-3, -4], [4, -2.5], [5, 2]]
    }
    },
    "fire4" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/spear/swoosh/slayerswoosh<elementalType>4.png:<frame>",
    "offset" : [-2, -2],
    "damageArea" : [[-4.75, 2.25], [-2.25, 4.75], [2.25, 4.75], [4.75, 2.25], [4.75, -2.25], [2.25, -4.75], [-2.25, -4.75], [-4.75, -2.25]]
    }
    },
    "fire5" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/spear/swoosh/slayerswoosh<elementalType>6.png:<frame>",
    "offset" : [5.0, 0.0],
    "damageArea" : [[-4.5, 1.5], [-4.5, -1.5], [4, 0]]
    }
    },
    "fire6" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/spear/swoosh/slayerswoosh<elementalType>6.png:<frame>",
    "offset" : [5.0, 0.0],
    "damageArea" : [[-4.5, 1.5], [-4.5, -1.5], [4, 0]]
    }
    },
    //charged stab
    "chargedfire1" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/charged3/swoosh.png:<frame>",
    "offset" : [2.5, 0],
    "damageArea" : [[-4.75, 2], [3, 2], [4, 8], [7, 7], [7, -7], [4, -8], [3, -2], [-4.75, -2]]
    }
    }
    }
    }
    }
    }
    },

    "transformationGroups" : {
    "weapon" : {},
    "swoosh" : {}
    },

    "particleEmitters" : {
    "physicalswoosh" : {
    "active" : false,
    "transformationGroups" : ["swoosh"],
    "emissionRate" : 1,
    "burstCount" : 1,
    "particles" : []
    },
    "fireswoosh" : {
    "active" : false,
    "transformationGroups" : ["swoosh"],
    "emissionRate" : 50,
    "burstCount" : 50,
    "particles" : [
    { "particle" : "fireswoosh1"},
    { "particle" : "fireswoosh2"},
    { "particle" : "fireswoosh3"}
    ]
    },
    "electricswoosh" : {
    "active" : false,
    "transformationGroups" : ["swoosh"],
    "emissionRate" : 50,
    "burstCount" : 50,
    "particles" : [
    { "particle" : "electricswoosh1"},
    { "particle" : "electricswoosh2"},
    { "particle" : "electricswoosh2"}
    ]
    },
    "poisonswoosh" : {
    "active" : false,
    "transformationGroups" : ["swoosh"],
    "emissionRate" : 50,
    "burstCount" : 50,
    "particles" : [
    { "particle" : "poisonswoosh1"},
    { "particle" : "poisonswoosh2"},
    { "particle" : "fireswoosh2"}
    ]
    },
    "iceswoosh" : {
    "active" : false,
    "transformationGroups" : ["swoosh"],
    "emissionRate" : 50,
    "burstCount" : 50,
    "particles" : [
    { "particle" : "iceswoosh1"},
    { "particle" : "iceswoosh2"},
    { "particle" : "iceswoosh3"}
    ]
    },
    "bladefire" : {
    "active" : false,
    "transformationGroups" : ["weapon"],
    "offsetRegion" : [-0.5, -3.0, 0.5, 6.0],
    "emissionRate" : 20,
    "particles" : [
    { "particle" : "fireswoosh1"},
    { "particle" : "fireswoosh2"}
    ]
    },
    "bladeice" : {
    "active" : false,
    "transformationGroups" : ["weapon"],
    "offsetRegion" : [-0.5, -3.0, 0.5, 6.0],
    "emissionRate" : 20,
    "particles" : [
    { "particle" : "iceswoosh1"},
    { "particle" : "iceswoosh2"}
    ]
    },
    "bladeelectric" : {
    "active" : false,
    "transformationGroups" : ["weapon"],
    "offsetRegion" : [-0.5, -3.0, 0.5, 6.0],
    "emissionRate" : 20,
    "particles" : [
    { "particle" : "electricswoosh1"}
    ]
    },
    "bladepoison" : {
    "active" : false,
    "transformationGroups" : ["weapon"],
    "offsetRegion" : [-0.5, -3.0, 0.5, 6.0],
    "emissionRate" : 20,
    "particles" : [
    { "particle" : "poisonswoosh1"},
    { "particle" : "poisondust"}
    ]
    }
    },

    "lights":{
    "glow":{
    "color":[100, 100, 100]
    }
    },

    "sounds" : {
    "fire" : [ ],
    "fire2" : [ ],
    "fire3" : [ ],
    "fire4" : [ ],
    "fire5" : [ ],
    "fire6" : [ ]
    }
    }


    This here is one my assistedmelee.lua, I use them for advanced methods like movement and weapon orientation flipping on specific combo steps, or adding a charged attack mechanic in this one's case. Otherwise, it's just a copy of the MeleeCombo.lua that most melee weapons point to. I don't think any of this is relevant to the issue at all, but the activeitem file points to it, so I didn't want anyone being confused.


    -- Melee primary ability
    MeleeCombo = WeaponAbility:new()

    function MeleeCombo:init()
    self.comboStep = 1

    self.energyUsage = self.energyUsage or 0

    self:computeDamageAndCooldowns()

    self.weapon:setStance(self.stances.idle)

    self.edgeTriggerTimer = 0
    self.flashTimer = 0
    self.cooldownTimer = self.cooldowns[1]

    self.animKeyPrefix = self.animKeyPrefix or ""

    self.weapon.onLeaveAbility = function()
    self.weapon:setStance(self.stances.idle)
    end
    end

    -- Ticks on every update regardless if this is the active ability
    function MeleeCombo:update(dt, fireMode, shiftHeld)
    WeaponAbility.update(self, dt, fireMode, shiftHeld)

    if self.cooldownTimer > 0 then
    self.cooldownTimer = math.max(0, self.cooldownTimer - self.dt)
    if self.cooldownTimer == 0 then
    self:readyFlash()
    end
    end

    if self.flashTimer > 0 then
    self.flashTimer = math.max(0, self.flashTimer - self.dt)
    if self.flashTimer == 0 then
    animator.setGlobalTag("bladeDirectives", "")
    end
    end

    self.edgeTriggerTimer = math.max(0, self.edgeTriggerTimer - dt)
    if self.lastFireMode ~= (self.activatingFireMode or self.abilitySlot) and fireMode == (self.activatingFireMode or self.abilitySlot) then
    self.edgeTriggerTimer = self.edgeTriggerGrace
    end
    self.lastFireMode = fireMode

    if not self.weapon.currentAbility and self:shouldActivate() then
    self:setState(self.windup)
    end
    end

    -- State: windup
    function MeleeCombo:windup()
    local stance = self.stances["windup"..self.comboStep]

    self.weapon:setStance(stance)

    self.edgeTriggerTimer = 0

    if stance.hold then
    while self.fireMode == (self.activatingFireMode or self.abilitySlot) do
    coroutine.yield()
    end
    else
    util.wait(stance.duration)
    end

    if self.energyUsage then
    status.overConsumeResource("energy", self.energyUsage)
    end

    if self.stances["preslash"..self.comboStep] then
    self:setState(self.preslash)
    else
    self:setState(self.fire)
    end
    end

    -- State: wait
    -- waiting for next combo input
    function MeleeCombo:wait()
    local stance = self.stances["wait"..(self.comboStep - 1)]

    self.weapon:setStance(stance)

    util.wait(stance.duration, function()
    if self:shouldActivate() then
    self:setState(self.windup)
    return
    end
    end)

    -----INITIATES CHARGED ATTACK----- if holding fire button through a wait stance
    if self.fireMode == "primary" and self.allowHold ~= false then
    self:setState(self.charging1)
    end

    self.cooldownTimer = math.max(0, self.cooldowns[self.comboStep - 1] - stance.duration)
    self.comboStep = 1
    end

    -- State: preslash
    -- brief frame in between windup and fire
    function MeleeCombo:preslash()
    local stance = self.stances["preslash"..self.comboStep]

    self.weapon:setStance(stance)
    self.weapon:updateAim()

    --flip weapon only on specific combo step. remember to use ==
    if self.comboStep == 2 then
    animator.setGlobalTag("directives", "?flipx")
    end

    --flip weapon only on specific combo step. remember to use ==
    if self.comboStep == 3 then
    animator.setGlobalTag("directives", "?flipx")
    end

    util.wait(stance.duration)

    self:setState(self.fire)
    end

    -- State: fire
    function MeleeCombo:fire()
    local stance = self.stances["fire"..self.comboStep]

    --unflip weapon horizontally on specific combo step
    if self.comboStep == 2 then
    animator.setGlobalTag("directives", "")
    end

    --flip weapon horizontally on specific combo step
    if self.comboStep == 3 then
    animator.setGlobalTag("directives", "?flipx")
    end

    --jump only on specific combo step if walking. remember to use ==
    if self.comboStep == 3 and mcontroller.walking() then
    mcontroller.setYVelocity(25)
    end

    --jump only on specific combo step if crouching. remember to use ==
    if self.comboStep == 3 and mcontroller.crouching() then
    mcontroller.setYVelocity(25)
    end

    self.weapon:setStance(stance)
    self.weapon:updateAim()

    local animStateKey = self.animKeyPrefix .. (self.comboStep > 1 and "fire"..self.comboStep or "fire")
    animator.setAnimationState("swoosh", animStateKey)
    animator.playSound(animStateKey)

    local swooshKey = self.animKeyPrefix .. (self.elementalType or self.weapon.elementalType) .. "swoosh"
    animator.setParticleEmitterOffsetRegion(swooshKey, self.swooshOffsetRegions[self.comboStep])
    animator.burstParticleEmitter(swooshKey)

    util.wait(stance.duration, function()
    local damageArea = partDamageArea("swoosh")
    self.weapon:setDamage(self.stepDamageConfig[self.comboStep], damageArea)
    end)

    if self.comboStep < self.comboSteps then
    self.comboStep = self.comboStep + 1
    self:setState(self.wait)
    else
    self.cooldownTimer = self.cooldowns[self.comboStep]
    self.comboStep = 1
    end
    end

    -----CHARGED ATTACK STARTUP-----
    function MeleeCombo:charging1()
    self.weapon:setStance(self.stances.charging1)
    self.weapon:updateAim()

    animator.setGlobalTag("directives", "?flipx")

    status.addEphemeralEffects{{effect = "sp-dragonbreaker", duration = 1.0}}

    configBombDrop = { timeToLive = 0.2}
    world.spawnProjectile("sp-breakthroughexplosion", mcontroller.position(), entity.id(), {(1*mcontroller.facingDirection()), 0}, false, configBombDrop)
    animator.playSound("chargeUp1")

    util.wait(self.stances.charging1.duration, function()
    mcontroller.setVelocity({-6*mcontroller.facingDirection(),0})
    end)

    self:setState(self.charged1)
    end

    -----CHARGED ATTACK 1-----
    function MeleeCombo:charged1()
    self.weapon:setStance(self.stances.charged1)
    self.weapon:updateAim()

    animator.setGlobalTag("directives", "")

    util.wait(self.stances.charged1.duration, function()
    mcontroller.setVelocity({0,0})
    end)

    self:setState(self.chargedattack1)
    end

    function MeleeCombo:chargedattack1()
    self.weapon:setStance(self.stances.chargedattack1)
    self.weapon:updateAim()

    animator.setAnimationState("swoosh", "chargedfire1")
    animator.playSound("fire4")

    util.wait(self.stances.chargedattack1.duration, function()
    mcontroller.setVelocity({100*mcontroller.facingDirection(),0})

    local damageArea = partDamageArea("swoosh")
    self.weapon:setDamage(self.damageConfig, damageArea)
    end)

    self:setState(self.chargefinish)
    end

    -----CHARGE FINISH-----
    function MeleeCombo:chargefinish()
    self.weapon:setStance(self.stances.chargefinish)
    self.weapon:updateAim()

    local position = vec2.add(mcontroller.position(), {2 * mcontroller.facingDirection(), 0})
    configBombDrop = { timeToLive = 0.3}
    world.spawnProjectile(self.chargedProjectileType, position, activeItem.ownerEntityId(), {0, 0}, false, configBombDrop)

    util.wait(self.stances.chargefinish.duration, function()
    mcontroller.setVelocity({10*mcontroller.facingDirection(),0})
    end)

    end

    function MeleeCombo:shouldActivate()
    if self.cooldownTimer == 0 and (self.energyUsage == 0 or not status.resourceLocked("energy")) then
    if self.comboStep > 1 then
    return self.edgeTriggerTimer > 0
    else
    return self.fireMode == (self.activatingFireMode or self.abilitySlot)
    end
    end
    end

    function MeleeCombo:readyFlash()
    animator.setGlobalTag("bladeDirectives", self.flashDirectives)
    self.flashTimer = self.flashTime
    end

    function MeleeCombo:computeDamageAndCooldowns()
    local attackTimes = {}
    for i = 1, self.comboSteps do
    local attackTime = self.stances["windup"..i].duration + self.stances["fire"..i].duration
    if self.stances["preslash"..i] then
    attackTime = attackTime + self.stances["preslash"..i].duration
    end
    table.insert(attackTimes, attackTime)
    end

    self.cooldowns = {}
    local totalAttackTime = 0
    local totalDamageFactor = 0
    for i, attackTime in ipairs(attackTimes) do
    self.stepDamageConfig = util.mergeTable(copy(self.damageConfig), self.stepDamageConfig)
    self.stepDamageConfig.timeoutGroup = "primary"..i

    local damageFactor = self.stepDamageConfig.baseDamageFactor
    self.stepDamageConfig.baseDamage = damageFactor * self.baseDps * self.fireTime

    totalAttackTime = totalAttackTime + attackTime
    totalDamageFactor = totalDamageFactor + damageFactor

    local targetTime = totalDamageFactor * self.fireTime
    local speedFactor = 1.0 * (self.comboSpeedFactor ^ i)
    table.insert(self.cooldowns, (targetTime - totalAttackTime) * speedFactor)
    end
    end

    function MeleeCombo:uninit()
    self.weapon:setDamage()
    animator.setGlobalTag("directives", "")
    end



    Here's the weaponability file, not much to say here, aside from all of the definitions that are needed for the LUA. Of note to me, is the value "damageSourceKind" which you will note I've also attempted to adjust in the LUA file, but to no avail. Defined here is also a "waveProjectileType" which should also change to be non-physical if the weapon's elementalType is altered.


    {
    "animationParts" : { },
    "animationCustom" : {
    "animatedParts" : {
    "stateTypes" : {
    "specialSwoosh" : {
    "default" : "idle",
    "states" : {
    "idle" : {
    },
    "uppercut" : {
    "frames" : 3,
    "cycle" : 0.175,
    "mode" : "transition",
    "transition" : "idle"
    },
    "upfire" : {
    "frames" : 3,
    "cycle" : 0.25,
    "mode" : "transition",
    "transition" : "idle"
    },
    "overhead" : {
    "frames" : 3,
    "cycle" : 0.18,
    "mode" : "transition",
    "transition" : "idle"
    },
    "slam" : {
    "frames" : 3,
    "cycle" : 0.2,
    "mode" : "transition",
    "transition" : "idle"
    },
    "stab" : {
    "frames" : 3,
    "cycle" : 0.2,
    "mode" : "transition",
    "transition" : "idle"
    },
    "rising" : {
    "frames" : 3,
    "cycle" : 0.2,
    "mode" : "transition",
    "transition" : "idle"
    },
    "bladecharge" : {
    "frames" : 1,
    "cycle" : 0.2,
    "mode" : "transition",
    "transition" : "idle"
    },
    "buff" : {
    "frames" : 3,
    "cycle" : 0.15,
    "mode" : "transition",
    "transition" : "idle"
    }
    }
    }
    },
    "parts" : {
    "blade" : {
    "properties" : {
    //determines explosion of slam attack
    "groundSlamPoint" : [0, 3]
    }
    },
    "specialSwoosh" : {
    "properties" : {
    "zLevel" : 2,
    "fullbright" : true,
    "centered" : true,
    "offset" : [2.0, -2.5],
    "transformationGroups" : ["swoosh"],
    "rotationCenter" : [0, 0]
    },

    "partStates" : {
    "specialSwoosh" : {
    "idle" : {
    "properties" : {
    "image" : ""
    }
    },
    "uppercut" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/uppercut/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]]
    }
    },
    "upfire" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/stab/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]],
    "offset" : [4.5, 0]
    }
    },
    "overhead" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/overhead/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]],
    "offset" : [0.0, 3.5]
    }
    },
    "slam" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/slam/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]],
    "offset" : [3.3, 2.9]
    }
    },
    "stab" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/stab/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]],
    "offset" : [4.5, 0]
    }
    },
    "rising" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/rising/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]],
    "offset" : [4.5, -2.0]
    }
    },
    "bladecharge" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/bladecharge/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]],
    "offset" : [1.9, 0.0]
    }
    },
    "buff" : {
    "properties" : {
    "image" : "/items/active/weapons/melee/broadsword/sp-breakthroughblade/swoosh/overhead/swoosh.png:<frame>",
    "damageArea" : [[-5, -2], [-2.5, -3], [1, -3], [4, -1.75], [5, 0.25], [5, 2.25], [4, 3.25], [0, 2.5]],
    "offset" : [0.0, 3.5]
    }
    }
    }
    }
    }
    }
    },
    "sounds" : {
    "upswing" : [ "/sfx/melee/astraltear2.ogg" ],
    "downswing" : [ "/sfx/melee/charge_full_swing1.ogg" ],
    "stabswing" : [ "/sfx/melee/swing_broadsword_electric3.ogg" ],
    "buffsound" : [ "/sfx/npc/boss/guardian_stab.ogg"],
    "explosion" : [ "/sfx/melee/travelingslash_fire1.ogg", "/sfx/melee/travelingslash_fire2.ogg", "/sfx/melee/travelingslash_fire3.ogg" ],
    "chargeup" : [ "/sfx/melee/charge_combo9.ogg" ]
    }
    },

    "ability" : {
    "name" : "Dragon Limit",
    "type" : "sp-dragonlimit",
    "scripts" : ["/items/active/weapons/melee/abilities/spear/sp-dragonlimit/sp-dragonlimit.lua"],
    "class" : "DragonLimit",

    "energyUsage" : 40.0,
    "cooldownTime" : 0.1,

    "projectileType" : "sp-breakthroughexplosion",
    "projectileBaseDamage" : 2.5,
    "projectileOffset" : [0,0],

    "projectileType2" : "sp-breakthroughexplosion",
    "projectileBaseDamage2" : 6.0,
    "projectileOffset2" : [0,0],

    "projectileType3" : "sp-breakthroughexplosion",
    "projectileBaseDamage3" : 3.5,
    "projectileOffset3" : [0,0],

    //Energy Wave values
    "waveProjectileType" : "<elementalType>shockwave",
    "projectileParameters" : {
    "power" : 2.5,
    "knockback" : 25,
    "knockbackMode" : "facing",
    "onlyHitTerrain" : true
    },
    "chargeTime" : 1.5,
    "minChargeTime" : 0.5,
    "shockWaveBounds" : [-0.4, -1.375, 0.4, 0.0],
    "shockwaveHeight" : 1.375,
    "maxDistance" : 8,
    "bothDirections" : true,
    "impactLine" : [ [1.25, -1.5], [1.25, -4.5] ],
    "impactWeaponOffset" : 0.75,

    "upperSpeed" : 65,
    "upperControlForce" : 1600,
    "slamSpeed" : -80,
    "slamControlForce" : 1600,
    "maxSlamTime" : 2.0,
    "spaceSlamTime" : 0.2,
    "slamWinddownTime" : 0.2,
    "dashSpeed" : 80,
    "dashControlForce" : 1600,

    //default state for weapon's animation
    "elementalCycleAnimation" : "physical",

    "damageConfig" : {
    "damageSourceKind" : "spear",
    "baseDamage" : 12,
    "knockback" : [20, 20],
    "timeout" : 0.2,
    "timeoutGroup" : "alt"
    },

    "stances" : {
    //BRANCH
    "activate" : {
    "aimAngle" : 0,
    "duration" : 0.05,
    "armRotation" : -80,
    "weaponRotation" : -50,
    "twoHanded" : false,

    "allowRotate" : false,
    "allowFlip" : false
    },
    //UPPERCUT
    "preupper" : {
    "duration" : 0.10,
    "armRotation" : -90,
    "weaponRotation" : -170,
    "armAngularVelocity" : 0,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "uppercut" : {
    "duration" : 0.20,
    "armRotation" : 45,
    "weaponRotation" : -125,
    "armAngularVelocity" : 200,
    "weaponAngularVelocity" : 300,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "upfreeze" : {
    "duration" : 0.10,
    "armRotation" : 90,
    "weaponRotation" : -200,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    //SLAM
    "preslam" : {
    "aimAngle" : 0,
    "duration" : 0.15,
    "armRotation" : 110,
    "weaponRotation" : -90,
    "armAngularVelocity" : -250,
    "weaponAngularVelocity" : -700,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "slam" : {
    "aimAngle" : 0,
    "duration" : 0.40,
    "armRotation" : 45,
    "weaponRotation" : -225,
    "armAngularVelocity" : 0,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "slamfreeze" : {
    "aimAngle" : 0,
    "duration" : 0.2,
    "armRotation" : 0,
    "weaponRotation" : -180,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    //DASH UP
    "predashup" : {
    "aimAngle" : 0,
    "duration" : 0.1,
    "armRotation" : -90,
    "weaponRotation" : 90,
    "armAngularVelocity" : -125,
    "weaponAngularVelocity" : -125,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "dashup" : {
    "aimAngle" : 0,
    "duration" : 0.3,
    "armRotation" : 45,
    "weaponRotation" : -90,
    "armAngularVelocity" : 0,
    "weaponAngularVelocity" : 0,
    "twoHanded" : false,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "dashupfreeze" : {
    "aimAngle" : 0,
    "duration" : 0.1,
    "armRotation" : 90,
    "weaponRotation" : -200,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    //DASH DOWN
    "predashdown" : {
    "aimAngle" : 0,
    "duration" : 0.1,
    "armRotation" : -90,
    "weaponRotation" : 90,
    "armAngularVelocity" : -125,
    "weaponAngularVelocity" : -125,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "dashdown" : {
    "aimAngle" : 0,
    "duration" : 0.3,
    "armRotation" : -45,
    "weaponRotation" : -90,
    "armAngularVelocity" : 0,
    "weaponAngularVelocity" : 0,
    "twoHanded" : false,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "dashdownfreeze" : {
    "aimAngle" : 0,
    "duration" : 0.1,
    "armRotation" : 90,
    "weaponRotation" : -200,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    //BUFF
    "prebuff" : {
    "duration" : 0.05,
    "armRotation" : -35,
    "weaponRotation" : -40,
    "armAngularVelocity" : 400,
    "weaponAngularVelocity" : 100,
    "twoHanded" : false,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "buffhold" : {
    "duration" : 0.10,
    "armRotation" : 30,
    "weaponRotation" : -30,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "buff" : {
    "duration" : 0.4,
    "armRotation" : 45,
    "weaponRotation" : -45,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    },
    "bufffreeze" : {
    "duration" : 0.1,
    "armRotation" : 45,
    "weaponRotation" : -45,
    "weaponAngularVelocity" : 0,
    "twoHanded" : true,
    "allowRotate" : false,
    "allowFlip" : false
    }
    }
    }
    }


    And here's the weaponability's LUA file. It's divided into multiple sections that come from a flow-chart near the top. Depending on what the player is doing when activating the ability, they will perform different actions.
    Down in the "Buff Section", executed by crouching + r-click, you'll notice the --Elemental Cycle Method-- which makes calls based on the current animation state the weapon is in (physical, fire, ice, electric, poison). These calls are what I believe the issue may be.
    self.elementalType =
    and
    self.damageSourceKind =
    may not be the correct terms I should be using to affect the activeitem file in the way I'm trying to. That, or I am doing this part right, and as I've mentioned, I should be looking for some method of updating the activeitem file once this change occurs, which I think would need to also happen in this file, around that same section.

    I believe it's imperative to change damageSourceKind at this stage for every elemental rotation, to avoid errors of swapping back to physical, as there is no damageSourceKind for "physicalspear", as the game defaults to the terminology "spear" for if it would be non-elemental.


    require "/scripts/util.lua"
    require "/scripts/status.lua"
    require "/scripts/rect.lua"
    require "/items/active/weapons/weapon.lua"

    DragonLimit = WeaponAbility:new()

    function DragonLimit:init()
    self:reset()

    animator.setAnimationState("blade", "physical")
    animator.setAnimationState("handle", "physical")
    self.elementalCycleAnimation = "physical"

    self.cooldownTimer = self.cooldownTime
    end

    function DragonLimit:update(dt, fireMode, shiftHeld)
    WeaponAbility.update(self, dt, fireMode, shiftHeld)

    self.cooldownTimer = math.max(0, self.cooldownTimer - dt)

    if self.weapon.currentAbility == nil
    and self.cooldownTimer == 0
    and self.fireMode == "alt"
    and not status.statPositive("activeMovementAbilities")
    and status.overConsumeResource("energy", self.energyUsage) then

    self:setState(self.activate)
    end
    end

    function DragonLimit:activate()
    self.weapon:setStance(self.stances.activate)
    self.weapon:updateAim()

    status.setPersistentEffects("weaponMovementAbility", {{stat = "activeMovementAbilities", amount = 1}})

    util.wait(self.stances.activate.duration, function()
    return status.resourceLocked("energy")
    end)

    mcontroller.setVelocity({0,0})

    configBombDrop = { timeToLive = 0.2}
    world.spawnProjectile("sp-breakthroughexplosion", mcontroller.position(), entity.id(), {(1*mcontroller.facingDirection()), 0}, false, configBombDrop)

    --ABILITY SELECTION--

    if not mcontroller.walking() and not mcontroller.onGround() then
    self:setState(self.preslam)
    elseif mcontroller.walking() and mcontroller.onGround() then
    self:setState(self.predashup)
    elseif mcontroller.walking() and not mcontroller.onGround() then
    self:setState(self.predashdown)
    elseif mcontroller.crouching() and mcontroller.onGround() then
    self:setState(self.prebuff)
    else
    self:setState(self.preupper)
    end
    end

    --UPPERCUT SECTION--

    function DragonLimit:preupper()
    self.weapon:setStance(self.stances.preupper)
    self.weapon:updateAim()

    animator.setGlobalTag("directives", "?flipx")
    status.addEphemeralEffects{{effect = "sp-dragonleap", duration = 0.5}}

    util.wait(self.stances.preupper.duration, function()
    --return status.resourceLocked("energy")
    end)

    self:setState(self.uppercut)
    end

    function DragonLimit:uppercut()
    self.weapon:setStance(self.stances.uppercut)
    self.weapon:updateAim()

    animator.setAnimationState("specialSwoosh", "uppercut")
    animator.playSound("upswing")

    local position = vec2.add(mcontroller.position(), {self.projectileOffset2[1] * mcontroller.facingDirection(), self.projectileOffset2[2]})
    local params = {
    powerMultiplier = activeItem.ownerPowerMultiplier(),
    power = self:damageAmount2()
    }
    world.spawnProjectile("sp-dummyphoenixexplosion", position, activeItem.ownerEntityId(), {0, 0}, false)
    world.spawnProjectile(self.projectileType2, position, activeItem.ownerEntityId(), {0, 25}, false, params)

    util.wait(self.stances.uppercut.duration, function()
    if math.abs(world.gravity(mcontroller.position())) > 0 then
    mcontroller.controlApproachYVelocity(self.upperSpeed, self.upperControlForce)
    end

    local damageArea = partDamageArea("specialSwoosh")
    self.weapon:setDamage(self.damageConfig, damageArea)
    end)

    self.cooldownTimer = self.cooldownTime
    self:setState(self.upfreeze)
    end

    function DragonLimit:upfreeze()
    self.weapon:setStance(self.stances.upfreeze)
    self.weapon:updateAim()

    status.addEphemeralEffects{{effect = "nofalldamage", duration = 1.0}}

    util.wait(self.stances.upfreeze.duration, function()
    --mcontroller.setVelocity({0,10})
    end)
    end

    --SLAM SECTION--

    function DragonLimit:preslam()
    self.weapon:setStance(self.stances.preslam)
    self.weapon:updateAim()

    status.addEphemeralEffects{{effect = "sp-dragondive", duration = 0.5}}

    animator.setGlobalTag("directives", "?flipx")
    animator.setAnimationState("specialSwoosh", "overhead")

    util.wait(self.stances.preslam.duration, function()
    end)

    self:setState(self.slam)
    end

    function DragonLimit:slam()
    local preSlamPosition = self:slamPosition()
    self.weapon:setStance(self.stances.slam)
    self.weapon:updateAim()
    local postSlamPosition = self:slamPosition()

    animator.playSound("downswing")
    animator.setAnimationState("specialSwoosh", "stab")

    status.setPersistentEffects("groundSlam", {
    {stat = "fallDamageMultiplier", effectiveMultiplier = 0},
    {stat = "invulnerable", amount = 1}
    })

    local lastSlamPosition = self:slamPosition()
    local slamTime = self:inGravity() and self.maxSlamTime or self.spaceSlamTime
    util.wait(slamTime, function(dt)
    if self:inGravity() then
    mcontroller.setYVelocity(self.slamSpeed)
    local newSlamPosition = self:slamPosition()
    if world.lineTileCollision(lastSlamPosition, newSlamPosition) then
    local params = copy(self.projectileParameters)
    params.powerMultiplier = activeItem.ownerPowerMultiplier()
    params.power = params.power * config.getParameter("damageLevelMultiplier")

    animator.playSound("explosion")
    world.spawnProjectile(self.projectileType3, lastSlamPosition, activeItem.ownerEntityId(), {0,0}, false, params)
    self:setState(self.slamfreeze)
    return true
    end
    lastSlamPosition = newSlamPosition
    end

    if mcontroller.onGround() then return true end

    local damageArea = partDamageArea("blade")
    self.weapon:setDamage(self.damageConfig, damageArea)
    end)

    self.cooldownTimer = self.cooldownTime

    util.wait(self.slamWinddownTime)
    end

    function DragonLimit:slamfreeze()
    self.weapon:setStance(self.stances.slamfreeze)
    self.weapon:updateAim()

    animator.setAnimationState("specialSwoosh", "idle")

    --Calls function to activate shockwave
    self:fireShockwave(charge)

    util.wait(self.stances.slamfreeze.duration, function()
    mcontroller.setXVelocity(0)
    end)
    end

    --DASH UP SECTION--

    function DragonLimit:predashup()
    self.weapon:setStance(self.stances.predashup)
    self.weapon:updateAim()

    animator.setGlobalTag("directives", "?flipx")
    status.addEphemeralEffects{{effect = "sp-dragonrush", duration = 0.5}}

    util.wait(self.stances.predashup.duration, function()
    --mcontroller.setVelocity({0,0})
    end)

    self:setState(self.dashup)
    end

    function DragonLimit:dashup()
    self.weapon:setStance(self.stances.dashup)
    self.weapon:updateAim()

    animator.setAnimationState("specialSwoosh", "stab")
    animator.playSound("stabswing")

    util.wait(self.stances.dashup.duration, function()
    if math.abs(world.gravity(mcontroller.position())) > 0 then
    mcontroller.setVelocity({self.dashSpeed*mcontroller.facingDirection(),40})
    end

    local damageArea = partDamageArea("specialSwoosh")
    self.weapon:setDamage(self.damageConfig, damageArea)
    end)

    self.cooldownTimer = self.cooldownTime
    self:setState(self.dashupfreeze)
    end

    function DragonLimit:dashupfreeze()
    self.weapon:setStance(self.stances.dashupfreeze)
    self.weapon:updateAim()

    mcontroller.setVelocity({0,0})

    util.wait(self.stances.dashupfreeze.duration, function()

    end)
    end

    --DASH DOWN SECTION--

    function DragonLimit:predashdown()
    self.weapon:setStance(self.stances.predashdown)
    self.weapon:updateAim()

    animator.setGlobalTag("directives", "?flipx")
    status.addEphemeralEffects{{effect = "sp-dragonrush", duration = 0.5}}

    util.wait(self.stances.predashup.duration, function()
    --mcontroller.setVelocity({0,0})
    end)

    self:setState(self.dashdown)
    end

    function DragonLimit:dashdown()
    self.weapon:setStance(self.stances.dashdown)
    self.weapon:updateAim()

    animator.setAnimationState("specialSwoosh", "stab")
    animator.playSound("stabswing")

    util.wait(self.stances.dashdown.duration, function()
    if math.abs(world.gravity(mcontroller.position())) > 0 then
    mcontroller.setVelocity({self.dashSpeed*mcontroller.facingDirection(),-40})
    end

    local damageArea = partDamageArea("specialSwoosh")
    self.weapon:setDamage(self.damageConfig, damageArea)
    end)

    self.cooldownTimer = self.cooldownTime
    self:setState(self.dashdownfreeze)
    end

    function DragonLimit:dashdownfreeze()
    self.weapon:setStance(self.stances.dashdownfreeze)
    self.weapon:updateAim()

    mcontroller.setVelocity({0,0})

    util.wait(self.stances.dashdownfreeze.duration, function()
    end)
    end

    --BUFF SECTION--

    function DragonLimit:prebuff()
    self.weapon:setStance(self.stances.prebuff)
    self.weapon:updateAim()

    mcontroller.setVelocity({0,0})
    animator.setGlobalTag("directives", "?flipx")
    animator.playSound("chargeup")
    status.addEphemeralEffects{{effect = "sp-elementalcycle", duration = 0.5}}

    util.wait(self.stances.prebuff.duration, function()
    --return status.resourceLocked("energy")
    end)

    self:setState(self.buffhold)
    end

    function DragonLimit:buffhold()
    self.weapon:setStance(self.stances.buffhold)
    self.weapon:updateAim()

    mcontroller.setVelocity({0,0})
    animator.setGlobalTag("directives", "")

    util.wait(self.stances.buffhold.duration, function()
    --return status.resourceLocked("energy")
    end)

    self:setState(self.buff)
    end

    function DragonLimit:buff()
    self.weapon:setStance(self.stances.buff)
    self.weapon:updateAim()

    animator.playSound("buffsound")

    --Elemental Cycle Method--
    if self.elementalCycleAnimation == "physical" then
    animator.setAnimationState("blade", "shiftFire")
    animator.setAnimationState("handle", "shiftFire")
    self.elementalCycleAnimation = "fire"
    self.damageSourceKind = "firespear"
    self.elementalType = "fire"
    else if self.elementalCycleAnimation == "fire" then
    animator.setAnimationState("blade", "shiftIce")
    animator.setAnimationState("handle", "shiftIce")
    self.elementalCycleAnimation = "ice"
    self.damageSourceKind = "icespear"
    self.elementalType = "ice"
    else if self.elementalCycleAnimation == "ice" then
    animator.setAnimationState("blade", "shiftElectric")
    animator.setAnimationState("handle", "shiftElectric")
    self.elementalCycleAnimation = "electric"
    self.damageSourceKind = "electricspear"
    self.elementalType = "electric"
    else if self.elementalCycleAnimation == "electric" then
    animator.setAnimationState("blade", "shiftPoison")
    animator.setAnimationState("handle", "shiftPoison")
    self.elementalCycleAnimation = "poison"
    self.damageSourceKind = "poisonspear"
    self.elementalType = "poison"
    else if self.elementalCycleAnimation == "poison" then
    animator.setAnimationState("blade", "shiftPhysical")
    animator.setAnimationState("handle", "shiftPhysical")
    self.elementalCycleAnimation = "physical"
    self.damageSourceKind = "spear"
    self.elementalType = "physical"
    end
    end
    end
    end
    end

    util.wait(self.stances.buff.duration, function()
    --mcontroller.setVelocity({0,0})
    --local damageArea = partDamageArea("specialSwoosh")
    --self.weapon:setDamage(self.damageConfig, damageArea)
    end)

    self.cooldownTimer = self.cooldownTime
    self:setState(self.bufffreeze)
    end

    function DragonLimit:bufffreeze()
    self.weapon:setStance(self.stances.bufffreeze)
    self.weapon:updateAim()

    util.wait(self.stances.bufffreeze.duration, function()
    --mcontroller.setVelocity({0,0})
    end)
    end

    -- Ground Wave Functions, required for spawning the shockwave properly --
    function DragonLimit:fireShockwave(charge)
    local impact, impactHeight = self:impactPosition()

    if impact then
    self.weapon.weaponOffset = {0, impactHeight + self.impactWeaponOffset}

    local charge = math.floor(1 * self.maxDistance)
    local directions = {1}
    if self.bothDirections then directions[2] = -1 end
    local positions = self:shockwaveProjectilePositions(impact, charge, directions)
    if #positions > 0 then
    animator.playSound("explosion")
    local params = copy(self.projectileParameters)
    params.powerMultiplier = activeItem.ownerPowerMultiplier()
    params.power = params.power * config.getParameter("damageLevelMultiplier")
    params.actionOnReap = {
    {
    action = "projectile",
    inheritDamageFactor = 1,
    type = self.waveProjectileType
    }
    }
    for i,position in pairs(positions) do
    local xDistance = world.distance(position, impact)[1]
    local dir = util.toDirection(xDistance)
    params.timeToLive = (math.floor(math.abs(xDistance))) * 0.025
    world.spawnProjectile("shockwavespawner", position, activeItem.ownerEntityId(), {dir,0}, false, params)
    end
    end
    end
    end

    function DragonLimit:impactPosition()
    local dir = mcontroller.facingDirection()
    local startLine = vec2.add(mcontroller.position(), vec2.mul(self.impactLine[1], {dir, 1}))
    local endLine = vec2.add(mcontroller.position(), vec2.mul(self.impactLine[2], {dir, 1}))

    local blocks = world.collisionBlocksAlongLine(startLine, endLine, {"Null", "Block"})
    if #blocks > 0 then
    return vec2.add(blocks[1], {0.5, 0.5}), endLine[2] - blocks[1][2] + 1
    end
    end

    function DragonLimit:shockwaveProjectilePositions(impactPosition, maxDistance, directions)
    local positions = {}

    for _,direction in pairs(directions) do
    direction = direction * mcontroller.facingDirection()
    local position = copy(impactPosition)
    for i = 0, maxDistance do
    local continue = false
    for _,yDir in ipairs({0, -1, 1}) do
    local wavePosition = {position[1] + direction * i, position[2] + 0.5 + yDir + self.shockwaveHeight}
    local groundPosition = {position[1] + direction * i, position[2] + yDir}
    local bounds = rect.translate(self.shockWaveBounds, wavePosition)

    if world.pointTileCollision(groundPosition, {"Null", "Block", "Dynamic", "Slippery"}) and not world.rectTileCollision(bounds, {"Null", "Block", "Dynamic", "Slippery"}) then
    table.insert(positions, wavePosition)
    position[2] = position[2] + yDir
    continue = true
    break
    end
    end
    if not continue then break end
    end
    end

    return positions
    end

    --Projectile Parameters--

    function DragonLimit:aimVector()
    return {mcontroller.facingDirection(), 0}
    end

    --Ground Projectile Damage
    function DragonLimit:damageAmount()
    return self.projectileBaseDamage * config.getParameter("damageLevelMultiplier")
    end

    --Rising Projectile Damage
    function DragonLimit:damageAmount2()
    return self.projectileBaseDamage2 * config.getParameter("damageLevelMultiplier")
    end

    --Falling Projectile Damage
    function DragonLimit:damageAmount3()
    return self.projectileBaseDamage3 * config.getParameter("damageLevelMultiplier")
    end

    function DragonLimit:slamPosition()
    return vec2.add(activeItem.handPosition(animator.partPoint("blade", "groundSlamPoint")), mcontroller.position())
    end

    --RESET--

    function DragonLimit:reset()
    animator.setGlobalTag("directives", "")
    status.clearPersistentEffects("weaponMovementAbility")
    status.clearPersistentEffects("groundSlam")
    end

    function DragonLimit:uninit()
    self:reset()
    end

    function DragonLimit:inGravity()
    return math.abs(world.gravity(mcontroller.position())) > 0
    end



    My understanding of LUA is patchwork from trial and error, but not super-limited. I understand a good portion of what I'm working with here, and I'm sure I'm doing something very simple wrong. Either I'm calling the method incorrectly, or I need some way to tell the activeitem file to update after changing. Notedly, the tooltip does not change to reflect an elementalType when cycling, which is what led me to think it has something to do with updating the activeitem itself.

    Here's a gif of the weapon in action, showing physical damage and physical swooshes regardless of what state it's in:
    [​IMG]

    Anyways, been smashing my head against this for hours on end, and was hoping someone might have some ideas. Once I get this hiccup out of the way, the rest of the project should fall into place.

    Edit 1:
    Managed to alter the swooshes to accurately change by adding the following to each step of the --Elemental Cycle-- section of dragonlimit.lua:
    animator.setGlobalTag("elementalType", "fire")
    animator.setGlobalTag("elementalType", "ice")
    etc.
    Still no luck on altering the damageSourceKind successfully.
    Tried methods like:
    activeitem.damageSourceKind = "firespear"
    self.weapon.damageSourceKind = "firespear"
    self.primaryAbility.damageConfig.damageSourceKind = "firespear"
    and many variations to either no change or nil value LUA errors. I swear I'm on the cusp of getting it right, and just need a push.

    Edit 2:
    At Rezetrx's recommendation in their reply, applied custom damageConfig method to the util.wait section of the assistedmelee.lua, which allowed for a basic attacks to finally alter their damage type.
    Last hiccup will be altering the shockwave to also change elements properly. Working on that with what I learned from the recent fix. May have to break down and finally learn how to construct a table.

    Edit 3:
    Nevermind, figured that out almost instantly with some simple If/Then commands. Not a perfect solution, but I can't be bothered to learn table commands yet.
     
    Last edited: Feb 22, 2023
  2. Rezetrx

    Rezetrx Void-Bound Voyager

    Setting the propetry self.elementalType within your alt-ability only changes it for within that script. Same goes for self.damageSourceKind
    For the elemental type change, you can instead set the property self.weapon.elementalTyp to the new element. That way, the property is changed/set on the level of the weapon which can then be called from either primary- or alt-ability script.
    For the damageSourceKind you can do a similar approach.

    Alt-Ability (~row 325)
    Code:
    ...
    if self.elementalCycleAnimation == "physical" then
    animator.setAnimationState("blade", "shiftFire")
    animator.setAnimationState("handle", "shiftFire")
    self.elementalCycleAnimation = "fire"
    self.weapon.damageSourceKind = "firespear"
    self.weapon.elementalType = "fire"
    ...
    
    Though for damageSourceKind you have to add another extra. As the primary script uses computeDamageAndCooldowns() to create the damage config for the weapons hits, the damageSourceKind is already loaded. So instead you can overwrite that property when its called upon and that is when the damageArea is created.

    Primary-Ability (~row 158)
    Code:
    ...
    local swooshKey = self.animKeyPrefix .. (self.elementalType or self.weapon.elementalType) .. "swoosh"
    animator.setParticleEmitterOffsetRegion(swooshKey, self.swooshOffsetRegions[self.comboStep])
    -- because the tag <elementalType> in the animationfile does not grab the current value but instead the original one,
    -- we instead straight up overwrite the content of the tag.
    animator.setGlobalTag("elementalType", self.weapon.elementalType)
    animator.burstParticleEmitter(swooshKey)
    
    util.wait(stance.duration, function()
    local damageArea = partDamageArea("swoosh")
    local damageConf = self.stepDamageConfig[self.comboStep]
    -- change to current damageSourcKind or return to the default if there is non set
    damageConf.damageSourceKind = self.weapon.damageSourceKind or "spear"
    self.weapon:setDamage(damageConf, damageArea)
    end)
    ...
    
    Mind you that doing it this way will only temporarly change two properties for your weapon. When the weapon is unequiped or reloaded in any way, elementalType will return back to its original type and self.weapon.damageSourceKind will return nil.
    Also the elementtype in the weapon tooltip will not change either as that too is loaded on weapon creation. (Though I assume there are ways to change that as well)

    There might be other ways to do it, but this approach worked for me in an adaptive sword.
     
  3. sethyuikora

    sethyuikora Void-Bound Voyager

    @Rezetrx That damageConfig stuff is what I was trying to figure out, thanks for the input.
    It was a major help. I worked the rest out at this point more or less.
     
    Last edited: Feb 22, 2023

Share This Page