Redid post, easy to read, need help scripting m16a2 to fire

Post » Mon Jun 18, 2012 11:11 pm

So you all know, this is best I could do, I am a Marine Veteran with some ptsd disability issues so please be gentle and helpful :wink:

First I want to say thanks to the creator of Dwemer Rifle on the steam workshop because his gave me the ammo pic's and sounds and that someone can make a weapon that looks like a gun and fires rounds. Ok, so I have made it to where I can input an m16a2 that fires ammo rounds like a bow. Unlike the Dwemer Rifle, mine is all physical with no magic. Unfortuntately when i use an animation like staff, I can see my guy holding it but I can't fire. I use bow animation and i can fire a bullet just like a bow... problem is I fire just like a bow (meaning get a 'arrow' from 'quiver' and pull back on 'string' and fire, how long to hold makes distance) plus you don't see the m16a2. I would like it to be just like a real m16a2. When I attach the defaultfireweaponscript below I basically make an auto-firing turret in the shape of a m16a2. It seems like the fire burst and long burst, and the automatic flags, plus the disable animations don't work. If they did, it doesn't seem to effect using m16a2 like a bow, nor does the fixed distance or making the distance min far out. I would like it to be, you hold the attack button and it just keeps firiing like auto fire, or even semi-auto... not single just like a bow. I was thinking maybe if the below would work, i could hold the m16a2 like a staff, but it would still fire the ammo when i attack... but I would like it to work only when i use the attack button, and have it rapid fire, or at the least fire a burst of 3 bullets and like can fire really fast after that. figure altering this script below would make it easiest way... I have no experience scripting or even modding... just several days of messing with autocad 3ds max, nifskope, notepad++, video tutorials, just so i could get the weapon and ammo set up to work albeit not perfectly but at least as a 'bow' any help would be much appreciated

Spiler contains the script
Spoiler
Scriptname defaultFireWeaponScript extends ObjectReference  {Script for firing projectiles from FireWeaponMarker-The default setting is to fire whatever weapon/ammo you choose infintely, every 4-6 seconds, if the marker is enabled-If you just want it to fire once then set MinWaitTime to 0.0, MaxWaitTime to 0.1, and TimesFired to 1}import utilityimport weaponimport debug;---------------------------;--Hidden Properties;---------------------------int Property TimesFired Auto Hidden{How many times i've already fired}bool Property Looping auto hidden{If true I should keep firing}float Property WaitTimer Auto hidden{Rand wait time generated based on the Min and Max wait times};---------------------------;--Editable Properties;---------------------------int Property TimesToFire = -1 Auto{Maximum number of times you want this to fire once it's enabled. (-1 = until disabled)}float Property MaxWaitTime = 6.0 auto{Maximum wait between refire, Default = 6.0}float Property MinWaitTime = 4.0 auto{Minimum wait between refire, Default = 4.0}weapon Property WeaponType Auto{Type of weapon you want to fire, (ie. "HuntingBow")}ammo Property Ammotype Auto{Type of ammo you would like to fire, (ie. "IronArrow")}quest Property myQuest Auto{Quest you want to check the stage of}int Property StageToStartFire = -1 Auto{Stage of myQuest you want to start firing at}int Property StageToStopFire = -1 Auto{Stage of myQuest you want to stop firing at (-1 = until disabled)}Event OnLoad()	; I'm loaded, or have been enabled, so start the fire loop	Looping = TRUE	GoToState("FireLoop")endEVENTEvent OnUnload()	; I've been unloaded, or disabled.  Stop firing	Looping = FALSE	GoToState("Waiting")endEVENTauto state Waiting	; The state I hang out in while I'm waiting for something to happen.endstatestate FireLoop	EVENT OnBeginState()		While(Looping)			;trace(self + "I'm looping...")			; Set up what our next wait time will be before firing			waitTimer = randomFloat(MinWaitTime, MaxWaitTime)				wait(waitTimer)						if (myQuest)				; There is a quest set, lets see if it's running				if (myQuest.IsRunning())					; There is a quest running, lets see if we should be firing					if (myQuest.GetStage() >= StageToStopFire)						;trace(self + " The done stage has been hit.  No longer going to fire.  Also dropping out of loop")						; The quest is at the stop firing stage, so don't fire						Looping = False					elseif (myQuest.GetStage() >= StageToStartFire)						;trace(self + " The correct stage is set, I'm going to fire.")						; The quest isn't at the stop firing stage yet, but is at the firing stage, so see if we are enabled							if (self as ObjectReference).IsEnabled()								; We're enabled, start firing								;trace(self + " is firing.")								WeaponType.fire( self as objectReference, Ammotype)	;I'm enabled so fire.								TimesFired += 1							else								; We're not enabled, so don't fire							endif							if (TimesToFire != -1)								; There is a fire limit set, check to see if we've reached it								;trace(self + "  has a firing limit of " + TimesToFire + " and has fired " + TimesFired + " so far.")								if (TimesFired == TimesToFire)									; We've reached our fire limit, stop firing									;trace(self + " has reached it's firing limit of " + TimesToFire + ".  Stopping fire and while loop.")									Looping = False								endif							endif					else						;trace(self + " Has a quest but the start/stop stages aren't set yet.")					endif					else					; The quest isn't running, wait for a bit then check again					wait(8)				endif							else				; There's no quest set so I'm just going to continue without worrying about quests/stages				if (self as ObjectReference).IsEnabled()					; I'm enabled, so I'm going to fire					WeaponType.fire( self as objectReference, Ammotype)					TimesFired += 1				else					; I'm not enabled, so I'm going to stop firing					Looping = False				endif				if (TimesToFire != -1)					; I have a firing limit set, lets see if I've reached it					if (TimesFired == TimesToFire)						; I've reached my limit, stop firing						Looping = False					endif				endif			endif					endWhile				; I'm no longer in the fireloop, time to wait	goToState("Waiting")	endEventendstate		Action[] Property Fire  Auto  
User avatar
Danger Mouse
 
Posts: 3393
Joined: Sat Oct 07, 2006 9:55 am

Post » Tue Jun 19, 2012 2:58 am

Ok, i think I know a way, but um don't know how to execute it. Looking at the silverperk that is a constant effect, I think something like that but making it be the quick shot (altered for faster) would help the speed. Also think something like a constant magical effect or adding another perk that makes the weapon fire the ammo, if i have ammo left... I'm sure there is a way to script or do it, but at the moment I have no idea. I can't come up with the solution via scripts unless i can copy and paste it ;)
User avatar
Skrapp Stephens
 
Posts: 3350
Joined: Mon Aug 06, 2007 5:04 am


Return to V - Skyrim