Imrinfected Posted April 8, 2010 Share Posted April 8, 2010 label 5 if equipshieldaq == 1 else set shield to getequippedobject 13 set equippedshield to getfirstref 70 1 1 if equippedshield label 4 set equippedshieldholder to equippedshield.getcontainer set equippedshieldbaseob to equippedshield.getbaseobject if equippedshieldbaseob == shield if equippedshieldholder == player messagebox "GOT SHIELD!" set equipshieldaq to 1 goto 5 else set equippedshield to getnextref goto 4 endif endif endif endif set equippedshieldhealth to equippedshield.getequippedcurrenthealth 13 if equippedshieldhealth == 0 player.unequipitem equippedshield playsound3d shieldbreak endif All of the variables not shown here are defined elsewhere. This is a block of a script I'm working on that removes your shield if it's broken.. But it doesn't work. I have no idea what the problem is. It causes the game to either crash, or the entire script to not work, and when it's the latter, I constantly hear the shieldbreak sound over and over again, but no other part of the script runs. I never see a message box saying "GOT SHIELD!" so I know it doesn't get that far, but when I put a message box everywhere else, it did show. It would get to at least the if equippedshield part, but then suddenly go nowhere. I've tried removing the top part of the script and just using the bottom part, but it doesn't work either. At this point I'm completely baffled. It doesn't unequip the shield, but it plays the shield breaking sound. If I put a messagebox thing there, it doesn't show it, but plays the sound over and over again, even when the if statement isn't true. Is there some function I'm using that doesn't work? Am I using something wrong? I am totally frazzled. EDIT: Also, how might I make a script run every frame without using a token of some sort? Right now it's running with a gamemode object script on an inventory item, and I can't help but think there's a more efficient way to do it that won't clutter the inventory, or risk the player removing something they need. I tried using a quest script and setting the delay time low(0.01), but it's not as reliable as it needs to be. EDIT: Solved! I rewrote it. This is the script that handles unequipping the shield when it's broken now. set equippedshield to player.getequippedobject 13 if equippedshield != 0 if isarmor equippedshield set basehealth to getobjecthealth equippedshield set currenthealth to player.getequippedcurrenthealth 13 set percentage to currenthealth / basehealth if percentage == 0 player.unequipitem equippedshield player.playsound3d deflectshieldbreak endif endif endif Link to comment Share on other sites More sharing options...
razorpony Posted April 8, 2010 Share Posted April 8, 2010 set equippedshieldhealth to equippedshield.getequippedcurrenthealth 13 Try changing that to player.getequippedcurrenthealth 13 -Razorpony Link to comment Share on other sites More sharing options...
Imrinfected Posted April 8, 2010 Author Share Posted April 8, 2010 set equippedshieldhealth to equippedshield.getequippedcurrenthealth 13 Try changing that to player.getequippedcurrenthealth 13 -RazorponyJust tried that. It fixed the problem with the bottom if statement always running, but when the shield is broken, and it does run, it doesn't do what it should. No sound is played, no object is unequipped, and the rest of the script stops working. Something with the functions in that statement maybe, I must have did something wrong. Playsound3d maybe? I'll try setting it to player.playsound3d, since it probably needs something to play it from. Assuming that does fix the problem, I'm guessing the shield doesn't get unequipped because it's not getting the shield, which doesn't make sense, since I'm pretty sure the script for getting that should work. It's especially confusing, because even if it doesn't get the reference, it shouldn't prevent the entire script from working, it should just fail to unequip it. I know some other functions can screw stuff up if they're botched, but I don't remember this being one of them. Two problems solved, one to go. EDIT: Setting playsound3d to player.playsound3d and moving it above player.unequipitem equippedshield made it play the sound when the shield broke. I hear it over and over indefinitely, but the rest of the script does not run. Evidently the script will try to run, and get to the player.unequipitem equippedshield part, where it fails, and starts over If I remove player.unequipitem equippedshield, the rest of the script below that runs great. Since unequipping the broken item is the entire point of the script however, it doesn't really help me, and I still can't figure out what could be stopping it from working, stopping the rest of the script from working, and why the right reference isn't located. Link to comment Share on other sites More sharing options...
DagonTheranis Posted April 8, 2010 Share Posted April 8, 2010 Have you defined equipshieldaq? Link to comment Share on other sites More sharing options...
Imrinfected Posted April 8, 2010 Author Share Posted April 8, 2010 Have you defined equipshieldaq?No, I did that further down. Since it's not defined, it should run the script, making it defined once the right shield is found, then goto 5 returns it to before that if statement, where it passes it and doesn't run the script, since it's then defined. Link to comment Share on other sites More sharing options...
DagonTheranis Posted April 8, 2010 Share Posted April 8, 2010 I wonder if there's a way to find the script that OB runs for a shield breaking normally. Link to comment Share on other sites More sharing options...
Imrinfected Posted April 9, 2010 Author Share Posted April 9, 2010 I wonder if there's a way to find the script that OB runs for a shield breaking normally.What would be the point of that? Link to comment Share on other sites More sharing options...
Recommended Posts