Deleted2746547User Posted October 10, 2015 Share Posted October 10, 2015 Working on a couple of different scripts to do different things but this one in particular I need to figure out now:1. Trying to figure the best way at this: I have a mod that allows you to build a base and assign guards/clothing, etc. Whenever you build/construct a new structure, items are pulled from a "Base Storage".What I'm trying to do, is that when guards run out of ammo - it is also pulled from one location. That way, you don't have to run to each and every guard when they run out of ammo. Link to comment Share on other sites More sharing options...
Ladez Posted October 10, 2015 Share Posted October 10, 2015 You could attach a script like below to the guards.Maybe another blocktype like OnCombatStart is a better choice as GameMode runs every frame, but it's really just for demonstration. Note that it uses NVSE functions. Doing it without NVSE would require a lot of hard coding if you want the script to be dynamic and work with all weapons/ammo. ScriptName GuardRefillAmmoScript ref rActor ref rAmmo Begin GameMode set rList to rActor.GetWeaponAmmo set rAmmo to ListGetNthForm rList 0 If rActor.GetItemCount rAmmo == 0 rActor.AddItem rAmmo 30 BaseStorageREF.RemoveItem rAmmo 30 EndIf End Link to comment Share on other sites More sharing options...
Deleted2746547User Posted October 11, 2015 Author Share Posted October 11, 2015 You could attach a script like below to the guards. Maybe another blocktype like OnCombatStart is a better choice as GameMode runs every frame, but it's really just for demonstration. Note that it uses NVSE functions. Doing it without NVSE would require a lot of hard coding if you want the script to be dynamic and work with all weapons/ammo. ScriptName GuardRefillAmmoScript ref rActor ref rAmmo Begin GameMode set rList to rActor.GetWeaponAmmo set rAmmo to ListGetNthForm rList 0 If rActor.GetItemCount rAmmo == 0 rActor.AddItem rAmmo 30 BaseStorageREF.RemoveItem rAmmo 30 EndIf EndThat's pretty awesome. Thank you. Question.. how would you include a message if an NPC tried to pull ammo and there wasn't any. As a way of reminding you to put more in. THANK YOU AGAIN btw.. my coding skills are pretty limited and I'm trying to do a lot with this mod. I really appreciate the help. Link to comment Share on other sites More sharing options...
Ladez Posted October 11, 2015 Share Posted October 11, 2015 You could do something like this, but it has the potential to become spammy if you have more than a few guards. Alternatively you could attach a similar script to the container itself, or have a quest script running which checks the container every few seconds. ScriptName GuardRefillAmmoScript ref rActor ref rAmmo ref rSelf short iCount Begin GameMode set rList to rActor.GetWeaponAmmo set rAmmo to ListGetNthForm rList 0 set rSelf to GetSelf If rActor.GetItemCount rAmmo == 0 ; storage has run out of ammo, show warning If BaseStorageREF.GetItemCount rAmmo == 0 MessageEx "%n has run out of ammo." rSelf ; NPC has taken last ammo from storage, show warning ElseIf BaseStorageREF.GetItemCount rAmmo < 30 MessageEx "%n has taken the last ammo." rSelf Set iCount to BaseStorageREF.GetItemCount rAmmo rActor.AddItem rAmmo iCount BaseStorageREF.RemoveItem rAmmo iCount ; storage is sufficiently full Else rActor.AddItem rAmmo 30 BaseStorageREF.RemoveItem rAmmo 30 EndIf EndIf End Link to comment Share on other sites More sharing options...
Deleted2746547User Posted October 19, 2015 Author Share Posted October 19, 2015 You could attach a script like below to the guards. Maybe another blocktype like OnCombatStart is a better choice as GameMode runs every frame, but it's really just for demonstration. Note that it uses NVSE functions. Doing it without NVSE would require a lot of hard coding if you want the script to be dynamic and work with all weapons/ammo. ScriptName GuardRefillAmmoScript ref rActor ref rAmmo Begin GameMode set rList to rActor.GetWeaponAmmo set rAmmo to ListGetNthForm rList 0 If rActor.GetItemCount rAmmo == 0 rActor.AddItem rAmmo 30 BaseStorageREF.RemoveItem rAmmo 30 EndIf EndI think you're right about it probably getting spammy. Would this version be the better option do you think? Link to comment Share on other sites More sharing options...
Ladez Posted October 19, 2015 Share Posted October 19, 2015 I'm not advocating either as a finished solution, they're just examples to help you or another potential scripter get started. :) Link to comment Share on other sites More sharing options...
Deleted2746547User Posted October 20, 2015 Author Share Posted October 20, 2015 It'll take me forever to figure that out.. thanks for the suggestion though :) Link to comment Share on other sites More sharing options...
Recommended Posts