Numbl3 Posted April 22, 2015 Share Posted April 22, 2015 (edited) Hello everyone. I'm here requesting for help on a script that I've been working on. It's somewhat like the Prototype Medical Power Armor from Fallout 3 but it doesn't have dialogue and instead of Med X it uses Stimpaks.The help that I request is basically a verification of what am I doing wrong because the script just chews through Stimpaks like there's no tomorrow.Here's the Script ScriptName AStimpakDispenserSCRIPTShort XPAwardShort PowerUpShort InCombatFloat SayTimerBegin OnEquip Player Set PowerUp to 1EndBegin OnUnequip Set PowerUp to 0EndBegin GameMode If Player.GetEquipped 00AAPrototypeMedicalArmor == 1 && Player.IsInCombat == 1 If Player.HasMagicEffect RestoreHealthStimpak == 0 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif ElseIf Player.GetAv PerceptionCondition <= 25 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif ElseIf Player.GetAv LeftMobilityCondition <= 25 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif ElseIf Player.GetAv RightMobilityCondition <= 25 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif ElseIf Player.GetAv LeftAttackCondition <= 25 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif ElseIf Player.GetAv RightAttackCondition <= 25 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif ElseIf Player.GetHealthPercentage <= 0.33 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 EndIf EndIf EndIf If Player.GetEquipped 00AAPrototypeMedicalArmor == 1 && InCombat == 0 If Player.IsInCombat == 1 Set InCombat to 1 EndIf Else If Player.IsInCombat == 0 Set InCombat to 0 EndIf EndIfEndIf anyone could help I will credit you as I'm working on releasing it once I have it fixed up and so on. Edited April 22, 2015 by NumBlacK Link to comment Share on other sites More sharing options...
Fallout2AM Posted April 23, 2015 Share Posted April 23, 2015 - It chews stimpaks, you mean it continuously uses all the stimpaks in your inventory?In your ingestible 00AAStimpak, did you add the effect to restore the mobility/perception/etc conditions? because I guess it could inject stimpaks forever since the condition state is always < to the threshold you setted in your script, since it's never restored.However, on a side note, due to the different mechanics between hardcore mode on and off, I would personally remove those checks and I would keep only the health check. But it's just me. - Just an idea: since that's an object script attached to an armor, what about introducing a timer that will make it cyclical? like injecting a stimpak every 1-2 seconds. - The powerup, XPAward and the SayTimer variables have no meaning in this script, maybe it will be used in some future? Same for the whole last part, the last if /endif block. Link to comment Share on other sites More sharing options...
Numbl3 Posted April 23, 2015 Author Share Posted April 23, 2015 - It chews stimpaks, you mean it continuously uses all the stimpaks in your inventory?In your ingestible 00AAStimpak, did you add the effect to restore the mobility/perception/etc conditions? because I guess it could inject stimpaks forever since the condition state is always < to the threshold you setted in your script, since it's never restored.Yes it just continuously uses all the stimpaks. I'm guessing that it might be the 00AAStimpak effect one. I'm not sure. However, on a side note, due to the different mechanics between hardcore mode on and off, I would personally remove those checks and I would keep only the health check. But it's just me.I was thinking just leaving the leg checks due to limp speed. I am not sure yet. - Just an idea: since that's an object script attached to an armor, what about introducing a timer that will make it cyclical? like injecting a stimpak every 1-2 seconds.I might do that. To be honest the point of it was if the player is below X health it would automatically inject a stimpak. But I guess that a cyclical injection could work too. - The powerup, XPAward and the SayTimer variables have no meaning in this script, maybe it will be used in some future? Same for the whole last part, the last if /endif block.Like I mentioned before, I had based this script on Fallout 3's Prototype Medical Power Armor, so there were sound lines on equip/unequip. As for the powerup and XPAward I have no idea of their use. As for SayTimer, if I'm not wrong, it was used to regulate how often the armor would comment and so on like the Stealth Suit. Link to comment Share on other sites More sharing options...
jazzisparis Posted April 25, 2015 Share Posted April 25, 2015 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif The above segment is the culprit. The condition is evaluated as true as long as there are Stimpaks in the player's inventory, therefore the script will continuously inject a Stimpak until none are left. Link to comment Share on other sites More sharing options...
Aintiarna Posted April 26, 2015 Share Posted April 26, 2015 There are a few problems with the script. First of all using objects and variables with names that start with digits will cause lots of problems. Only use letters. Call it a quirk of the geck. Another issue is this: If Player.HasMagicEffect RestoreHealthStimpak == 0 I've found the HasMagicEffect function to be extremely unreliable, especially with things like stimpaks. It's probably always evaluating as true. The difference between hardcore and normal will also cause problems with statements like that. A much more reliable method would be to use something like GetAV Health but only run the script every few seconds. You also realise that the script is Gamemode and therefore will be going through all those "if" checks every single frame during combat? You'e much better off doing it through a quest with a script processing delay of say 1 second. Do you have Old World Blues? Take a look at NVDLC03AuralStealthsuit and see how it handles the Med-X injection stuff. So lets say it was running in GameMode but in a quest script with a 1 sec processing delay you could introduce a test for Hardcore and not hardcore then inject a stimpak based on GetAV health. Link to comment Share on other sites More sharing options...
Numbl3 Posted April 26, 2015 Author Share Posted April 26, 2015 If Player.GetItemCount Stimpak > 0 Player.CastImmediateOnSelf 00AAStimpak Player.RemoveItem Stimpak 1 Endif The above segment is the culprit. The condition is evaluated as true as long as there are Stimpaks in the player's inventory, therefore the script will continuously inject a Stimpak until none are left. So removing this segment will stop the constant use of the stimpaks then.. Thank you very much for the help JIP. There are a few problems with the script. First of all using objects and variables with names that start with digits will cause lots of problems. Only use letters. Call it a quirk of the geck.I wasn't aware of that, I'll change it to something numberless. Another issue is this: If Player.HasMagicEffect RestoreHealthStimpak == 0 I've found the HasMagicEffect function to be extremely unreliable, especially with things like stimpaks. It's probably always evaluating as true. The difference between hardcore and normal will also cause problems with statements like that. A much more reliable method would be to use something like GetAV Health but only run the script every few seconds. You also realise that the script is Gamemode and therefore will be going through all those "if" checks every single frame during combat? You'e much better off doing it through a quest with a script processing delay of say 1 second. Do you have Old World Blues? Take a look at NVDLC03AuralStealthsuit and see how it handles the Med-X injection stuff. So lets say it was running in GameMode but in a quest script with a 1 sec processing delay you could introduce a test for Hardcore and not hardcore then inject a stimpak based on GetAV health.So you're suggesting creating another script (this time quest based) to just delay the check on the GetAV Health? As for the script using Gamemode, the point of it is basically use stimpaks everytime that the character's Health value drops bellow 33 during combat. If it'll apply outside combat i'm not sure. As for a Hardcore/non-Hardcore check, I'm not sure how I'll fit it in the script. Maybe just after the segment for "if in combat"? Link to comment Share on other sites More sharing options...
Aintiarna Posted April 26, 2015 Share Posted April 26, 2015 if Player.GetEquipped 00AAPrototypeMedicalArmor == 1 && Player.IsInCombat == 1 if IsHardcore == 1 if Player.HasMagicEffect RestoreHealthStimpak == 0 && Player.GetAV Health < 33 ; Hardcore code here. endif else if Player.GetAV Health < 33 ; non hardcore code here. endif endif endif Try something along those lines. I suspect the HasMagicEffect will work in hardcore where stimpaks heal over time, but I'm pretty sure it won't in normal. If you change it to a quest script you can set the processing delay to 0.1 of a second which is still better than 60/sec. Link to comment Share on other sites More sharing options...
Numbl3 Posted April 26, 2015 Author Share Posted April 26, 2015 if Player.GetEquipped 00AAPrototypeMedicalArmor == 1 && Player.IsInCombat == 1 if IsHardcore == 1 if Player.HasMagicEffect RestoreHealthStimpak == 0 && Player.GetAV Health < 33 ; Hardcore code here. endif else if Player.GetAV Health < 33 ; non hardcore code here. endif endifendif Try something along those lines. I suspect the HasMagicEffect will work in hardcore where stimpaks heal over time, but I'm pretty sure it won't in normal. If you change it to a quest script you can set the processing delay to 0.1 of a second which is still better than 60/sec. Will try it thank you very much. Even though this is my first real work with Scripting so far seems good besides a couple tweaks here and there.. Link to comment Share on other sites More sharing options...
Recommended Posts