Jump to content

Any safeguard conditions I should add to this rechamber script?


Sweet6Shooter

Recommended Posts

So I've set up a startup script in my mod that rechambers TTW's combat shotgun to 20 ga., and I made this optional script to be added to the weapon's base form, to try to catch any instances where another modder made their own WithAmmo for it and provide the correct ammo.

 

I've had the script check that it's not being added to the player, a companion, or someone that already got their ammo exchanged.

I did the last part using a dud non-playable ammo.

Are there any other conditions that I should check for, to make sure that there's no circumstance where the script becomes an ammo fountain?

 

Script:

scn sDCSCPTOnAddCombatShotgun

ref container
int count

begin onadd
	Container = GetContainer
	if (container != playerref) && (container.GetPlayerTeammate == 0) && (container.getitemcount sDCAmmoDud == 0)
		count = (Container.GetItemCount AmmoList12ga)
		if (count > 0) && (Container.GetitemCount AmmoList20ga == 0)
			container.removeitem AmmoList12Ga 99
			container.removeitem Hull12ga 99
			count = (count * 2)
			Container.additem Ammo20Ga count
			container.additem Hull20Ga75 count
			Container.additem sDCAmmoDud 1
		endif
	endif
end
Link to comment
Share on other sites

So, the script will detect when the shotgun is added to a container, and if there is any 12G ammo already there, it will delete the 12G ammo and add 20G ammo. Why would there already be any 12G ammo in it?

 

Usually ammo is added in a leveled list with the gun, like WithAmmoShotgunCombatNPC. So, it gets added with the gun, and if the gun is added first there won't be any ammo there yet. You could change the leveled lists themselves to use 20G instead, or you could change those leveled lists in a script.

 

What if the container already has another 12G Shotgun in it? Do you still want to delete the 12G ammo?

 

What if a second gun is added and the script runs again? Do you still want to delete all of the 12G shells?

 

Oh and you may want to swap the shotgun with the script with another one without a script. That way it can't run again. Otherwise the script will run "whenever the object is added to anything's inventory." [def]

Edited by GamerRick
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...