Jump to content

EquipItem() randomly refusing to work?


Pandaman

Recommended Posts

I suspect this isn't something that can actually be fixed, so I was wondering if anyone else ever noticed that scripts sometimes just randomly refuse to work? In the various iterations of the BU script I've been working on, this bug constantly shows up and defies all attempts to understand, fix, or even circumvent it. It's starting to become rather maddening, I must say.

 

When the actor has been poisoned (which will trigger the bug every time) or is being attacked by multiple opponents at once (maybe a 5% chance of triggering the bug), everything in this code will execute except EquipItem. It just skips over it or something.

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    if ((abHitBlocked != true) && (akProjectile == None) && (isProcessing != 1) && (currentStage != numStages))
        if (abPowerAttack == true)
            currentDamage += damageFromPowerAttack
        else
            currentDamage += damageFromNormalAttack
        endif
    endif

    if ((currentStage != numStages) && (currentDamage >= damagePerStage))
        isProcessing = 1
        newStage = currentStage + 1
        if (newStage <= numStages)
            actorRef.EquipItem(DynamicArmorProperty[newStage], false, true)
            actorRef.RemoveItem(DynamicArmorProperty[currentStage], 1, true)
            currentStage = newStage
        endif
        currentDamage = 0
        isProcessing = 0
    endif
endEvent

So I figured I'll get around it by brute forcing it. Hey, if it refuses to equip the armor, all I need to do is put a while statement after the initial EquipItem to just keep trying until it does. Whatever was interrupting that script can go fuck itself, right? Right?

        if (newStage <= numStages)
            actorRef.EquipItem(DynamicArmorProperty[newStage], false, true)
            while(!actorRef.IsEquipped(DynamicArmorProperty[newStage])
                actorRef.EquipItem(DynamicArmorProperty[newStage], false, true)
            endwhile
            actorRef.RemoveItem(DynamicArmorProperty[currentStage], 1, true)
            currentStage = newStage
        endif

Nope. It becomes an endless while loop. Whatever is happening here disables all attempts to equip items during the event, even if the event has passed minutes ago. If I still had hair I'd be tearing it out in frustration.

 

Am I better off just filing this as "Known Issue, Never Gonna Be Fixed"?

 

Edit: whoops, fixed it. Took a look at JosefGrey's original code and realized why he encapsulated the part of the script responsible for swapping out armors with "GoToState("")" and "GoToState("Inactive")". Don't understand how it works, just that it does.

Link to comment

Not sure, some things that came to mind reading this was, try doing this outside of Onhit event, so that onhit event sets some value and another script does the equip and stuff like that.

 

Another thing maybe you could try putting some Utility.Wait(0.1) in there, not sure if the equipitem function blocks or not.

 

Are you sure NPC has the item in inventory? It says it adds if not but I found that to cause some problems.

 

Edit: ok nvm you fixed it :P

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use