AxlDave Posted July 27, 2014 Share Posted July 27, 2014 I am trying to make armour that self-repairs, and enchanted weapons that recharge with every kill. I figure scripting is the best way to accomplish this, though I'm not sure of the commands to use. For the armour, I was thinking of checking the health, and any time it falls below 125% a timer starts which adds 1% health per second. The timer bit I'm okay with, but I don't know how to check for, or add, health - CheckItem.GetHealth didn't work. For the weapon, I'm pretty sure that HasMagicEffect will return whether or not the weapon is enchanted. I also thought I might be able to use how soul gems get filled to recharge the weapon directly. Trouble is, I can't seem to find whatever controls that function. Can anyone offer advice about this, like whether it's possible, how to do it etc? Link to comment Share on other sites More sharing options...
kastano Posted July 27, 2014 Share Posted July 27, 2014 (edited) yourrefitem.getcurrenthealth >but to have that as a percentage (getcurrenthealth/getobjecthealth)*100reference.GetCurrentChargeGetObjectChargei think you must play with some math here likelet requiredcharge := ref.(getobjectcharge-getcurrentcharge) Edited July 27, 2014 by kastano Link to comment Share on other sites More sharing options...
AxlDave Posted July 27, 2014 Author Share Posted July 27, 2014 (edited) Awesome, thanks. So I would need scn BlahBlahBlah short GetCurrentHealthPerc BEGIIN GameMode Set GetCurrentHealthPerc to ( GetCurrentHealth / GetObjectHealth ) * 100if MyItemReference.GetCurrentHealthPerc < 125 Rest Of Script Here is that right? --EDIT-- or would it be Set GetCurrentHealthPerc to ( MyItemReference.GetCurrentHealth / MyItemReference.GetObjectHealth ) * 100if GetCurrentHealthPerc < 125 Edited July 27, 2014 by AxlDave Link to comment Share on other sites More sharing options...
kastano Posted July 27, 2014 Share Posted July 27, 2014 sorry its the last one - it was a quick edit to provide the fuction names i didnt pay attention at the syntax Link to comment Share on other sites More sharing options...
AxlDave Posted July 27, 2014 Author Share Posted July 27, 2014 (edited) No worries, thanks for the help. A further question does arise, is it possible, rather than referencing each individual piece of armour, to make a generic reference in an object script that references whatever object it is a script for? Just thinking it might be more versatile that way. Edited July 27, 2014 by AxlDave Link to comment Share on other sites More sharing options...
kastano Posted July 27, 2014 Share Posted July 27, 2014 (edited) the referencing is for making a single script that you may attouch on every object you want to affectlikeset myitemreferance to getselfotherwise you can put the objectid(the name in cs)also its good to put fquestdelaytime (to a value of 20)because you dont need these scripts to run oftenand after the if to call a functionscript which contains your code(if that is possible) Edited July 27, 2014 by kastano Link to comment Share on other sites More sharing options...
AxlDave Posted July 27, 2014 Author Share Posted July 27, 2014 Nicely done, thanks for the advice man. Link to comment Share on other sites More sharing options...
AxlDave Posted July 27, 2014 Author Share Posted July 27, 2014 (edited) Okay, turns out I need some more advice. Below is the complete script I am currently running, which saves just fine so it must be grammatically correct... however only the "Settings Applied" message shows up, and that only happens once. Even when I damage the armour with a spell. Perhaps there is some basic error I'm not seeing? scn AXLCrusaderRepairScript ref rCrusaderArmour short HealthCurrent short HealthTotal short HealthPercent short OnePercent short OnePercentIncrease float fTimer BEGIN GameMode Message "Settings Applied" set rCrusaderArmour to GetSelf set HealthCurrent to rCrusaderArmour.GetCurrentHealth set HealthTotal to rCrusaderArmour.GetObjectHealth set HealthPercent to ( HealthCurrent / HealthTotal ) * 100 set OnePercent to ( HealthTotal / 100 ) set OnePercentIncrease to ( HealthCurrent + OnePercent ) if HealthPercent == 125 Message "Full Health" RETURN elseif HealthPercent < 125 Message "Low Health" if fTimer > 0 Message "Timer Started" set fTimer to ( fTimer - GetSecondsPassed ) endif if fTimer == 0 Message "Success" rCrusaderArmour.SetCurrentHealth OnePercentIncrease set fTimer to 5 endif endif END Edited July 29, 2014 by AxlDave Link to comment Share on other sites More sharing options...
kastano Posted July 28, 2014 Share Posted July 28, 2014 no its the getselfit seems that doesnt work for items in a containeri ll try to find sth else Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted July 28, 2014 Share Posted July 28, 2014 If the script is running on the Object itself, there is no need for a specific reference.You can simply call "set HealthCurrent to GetCurrentHealth" and it will automatically use the item it is running on.Only functions which require a reference as an input parameter will still need what you determined with GetSelf. I'm not sure you can input those float values from the divisions into short variables, or if the game will rather just round them. It could cause issues though. However, what will 'not' work in this setup is that "fTimer" will ever be "== 0". The likeliness for it to drop "< 0" with the last subtraction is far too high.A check for it having dropped "below zero" instead might be better suited here. And from what I remember all functions like "GetObjectHealth", which are working on the Base Object not a reference,must be called the 2nd way in the syntax: "set HealthTotal to GetObjectHealth rCrusaderArmour".So maybe that's why it seems to not work at all to begin with already. Link to comment Share on other sites More sharing options...
Recommended Posts