I made a m16a2 that can fire bullets but, i need help with s

Post » Tue Jun 19, 2012 9:19 am

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.

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
Haley Cooper
 
Posts: 3490
Joined: Wed Jun 14, 2006 11:30 am

Post » Tue Jun 19, 2012 12:19 am

Hey uhh, I can't help you persay, but I can suggest something. First, wrap your script segment in code tags.
My Code
Also, make your font the default font of the default size, that one is far harder to read and people may see it and immediately turn around and leave. Also, check out the thread on how to ask for scripting help, as following those directions will help us help you: http://www.gamesas.com/topic/1347469-how-to-ask-for-scripting-help/
User avatar
Amy Cooper
 
Posts: 3400
Joined: Thu Feb 01, 2007 2:38 am


Return to V - Skyrim