kreekgod Posted July 19, 2013 Share Posted July 19, 2013 i have been trying and trying to make this simple mod on my own, and i just cant do itthe scripts i write just dont work, they compile fine, but fail to do what i want them too, or anything at allthis might be due to near total lack of scripting/code writing abilityparticularly in defining and modifying variables anyway, this is what ive been trying to makea simple item that can be carried in the inventorywhen you have it in your inventory (it could be activated to toggle it on or off)first, it takes away a drained energy cell, or drained microfusion cell, or drained electron charge packthen, after a set amount of time (somewhere between 1 and 10 minutes) , it gives you back the corrisponding ammo on a 1-1 basisthen it will repeat untill you have no more depleted energy cells of any sortthe order of which cells get picked first should be, microfusion cells, energycells and then electron charge packsit should charge 1 depleted cell at a timethe net effect is, it will slowly recharge your depleted energy cells over time, thus justifying the 1 - 1 ammo return over the recipie based 3 or 4 - 1this is the script i have so far... it does not work, i have commented useing ;scriptname krkcellchargescriptfloat timer ; i have no idea how these workshort cell ; i copied them from other scriptsint isactivated ; they are probally the main reason its not workingBegin onEquip ;item currently a consumeable, aparently this is the use return player.additem krkcellcharger 1 ;this is supposed to give a replacement activator when you use and thus destory the first, it doesnt if isactivated == 0 set isactivated to 1 ;first run turns on set timer to 0 ;timer based script isnt working Activate else set isactivated to 0 ; second run turns off set timer to 0 endifendbegin gamemode If isactivated == 1 if timer < 60 ; timer should be set to 1 min this is for debugging, origonally it was 10 minutes if timer < 1; elseif Timer < 2 ; drained cell working order, mfc first then sec then ecp if Player.GetItemCount DrainedMicrofusionCell > 0 player.RemoveItem DrainedMicrofusionCell 1 set cell to 1 elseif Player.GetItemCount DrainedSmallEnergyCell > 0 player.RemoveItem DrainedSmallEnergyCell 1 set cell to 2 elseif Player.GetItemCount DrainedElectronChargePack > 0 player.RemoveItem DrainedElectronChargePack 1 set cell to 3 else ; to reset the timer if you dont have any drained cells set cell to 0 set timer to 0 Endif Endif Else if cell == 1; ; after timer, return useable ammo based on depleted cell player.AddItem AmmoMicrofusionCell 1 set cell to 0 elseif cell == 2 player.AddItem AmmoSmallEnergyCell 1 set cell to 0 elseif cell == 3 player.AddItem AmmoElectronChargePack 1 set cell to 0 endif Set timer to 0 ;reset timer to start again Endif EndifEndany help getting this to work would be apreciated Link to comment Share on other sites More sharing options...
jazzisparis Posted July 19, 2013 Share Posted July 19, 2013 This should do what you want:1. Create a new Misc Item, set its ID to DrainedAmmoChargerItem. Set the rest of the options to whatever you like. This is going to be the actual charger item the player carries in his inventory.2. Create a new Quest, set its ID to DrainedAmmoChargerQuest, put a check in the Start Game Enabled box, then set Script Processing Delay to 1.03. Create a new Script, set Script Type to Quest, and use this code: scn DrainedAmmoChargerQuestScript float fChargeTimer ref rDrainedItem ref rChargedItem begin GameMode if player.GetItemCount DrainedAmmoChargerItem ; Verifies the player carries the charger item. if fChargeTimer == 0 if player.GetItemCount DrainedMicrofusionCell set rDrainedItem to DrainedMicrofusionCell set rChargedItem to AmmoMicroFusionCell set fChargeTimer to 40 elseif player.GetItemCount DrainedSmallEnergyCell set rDrainedItem to DrainedSmallEnergyCell set rChargedItem to AmmoSmallEnergyCell set fChargeTimer to 30 elseif player.GetItemCount DrainedElectronChargePack set rDrainedItem to DrainedElectronChargePack set rChargedItem to AmmoElectronChargePack set fChargeTimer to 20 endif if fChargeTimer ; Timer was set, meaning the player does carry a draind item - remove it. player.RemoveItem rDrainedItem 1 1 endif elseif fChargeTimer > 0 ; Timer is running. set fChargeTimer to fChargeTimer - GetSecondsPassed else ; Timer expired, charging is complete - add the charged item. set fChargeTimer to 0 player.AddItem rChargedItem 1 1 endif elseif fChargeTimer ; The charger item was removed while charging was in progress - give back drained item. set fChargeTimer to 0 player.AddItem rDrainedItem 1 1 endif end 4. Finally, return to DrainedAmmoChargerQuest and from the Script dropbox, select DrainedAmmoChargerQuestScript. Link to comment Share on other sites More sharing options...
kreekgod Posted July 20, 2013 Author Share Posted July 20, 2013 thanks alot for the helpthis works very nicely, it does what i wanted, and i like that you can adjust the timer per itemthis script also looks like it can be expanded or adapated to exchange other items, should the need ever ariseone thing though, it plays a little flat, i think it could do with a message informing you that something is eather being charged, or done being charged... however, too many messages might also get very annoying... perhaps ill take a look at it laterwhile im terrible at writing fresh code, i can sometimes adapt scripting after going through it... sometimes...would you mind if i uploaded a working version for others to use? ill ofcorse give credit where its due, unless youd rather upload it yourself Link to comment Share on other sites More sharing options...
jazzisparis Posted July 20, 2013 Share Posted July 20, 2013 too many messages might also get very annoying...I agree. would you mind if i uploaded a working version for others to use? ill ofcorse give credit where its due, unless youd rather upload it yourselfIt was your idea (which is great, btw), so it's only right that you should upload it. Link to comment Share on other sites More sharing options...
kreekgod Posted July 25, 2013 Author Share Posted July 25, 2013 alright, spent a few days testingadded messagesand uploadedhttp://newvegas.nexusmods.com/mods/51077/? Link to comment Share on other sites More sharing options...
Recommended Posts