Why is this not working?

Post » Sat May 28, 2011 5:35 pm

scn H52AssualtRifleBurstScriptShort fireBegin Gamemode	If Player.GetAnimAction == 2 && fire == 0 && Player.GetEquipped H52BurstFire		Player.FireWeapon 556mmBulletProjectile		set fire to 1		PrintToConsole First	EndIf	If fire == 1 && Player.GetEquipped H52BurstFire		Player.FireWeapon 556mmBulletProjectile		Set fire to 2		PrintToConsole Second	EndIf	If fire == 2 && Player.GetEquipped H52BurstFire		Player.FireWeapon 556mmBulletProjectile		Set fire to 3		PrintToConsole Third	EndIf	If fire == 3		Set fire to 0		PrintToConsole Reset	EndIfEnd


The print to console parts work fine, but I lose only 1 ammo and no other projectiles come out. Any idea why?
User avatar
Pete Schmitzer
 
Posts: 3387
Joined: Fri Sep 14, 2007 8:20 am

Post » Sat May 28, 2011 6:15 am

Nevermind, I found the answer.
User avatar
clelia vega
 
Posts: 3433
Joined: Wed Mar 21, 2007 6:04 pm

Post » Sat May 28, 2011 3:06 pm

Nevermind, it's still not working :rolleyes:
User avatar
Michael Russ
 
Posts: 3380
Joined: Thu Jul 05, 2007 3:33 am

Post » Sat May 28, 2011 8:05 am

This is my current script.

scn H52AssualtRifleBurstScriptShort fireBegin Gamemode	If Player.GetAnimAction == 2 && fire == 0 && Player.GetEquipped H52BurstFire		Player.FireWeapon H52BurstFire		set fire to 1		PrintToConsole First	EndIf	If fire == 1 && Player.GetEquipped H52BurstFire		Player.FireWeapon H52BurstFire		Set fire to 2		PrintToConsole Second	EndIf	If fire == 2 && Player.GetEquipped H52BurstFire		Player.FireWeapon H52BurstFire		Set fire to 3		PrintToConsole Third	EndIf	If fire == 3		Set fire to 0		PrintToConsole Reset	EndIfEnd

User avatar
Stay-C
 
Posts: 3514
Joined: Sun Jul 16, 2006 2:04 am

Post » Sat May 28, 2011 1:48 pm

Having entirely redone this, I have achieved burst fire. I had to do this using staged timers, but it worked.
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm

Post » Sat May 28, 2011 6:07 pm

Having entirely redone this, I have achieved burst fire. I had to do this using staged timers, but it worked.


I just saw the post, but the reason it didn't work was because the way your fire variables are staged the entire script will execute in 1 frame. Without a timer to break it up, it will execut in at most 3 frames, which is probably too fast for the effect you are looking for. Using a staged timer is the way to go, good job.
User avatar
Julie Ann
 
Posts: 3383
Joined: Thu Aug 23, 2007 5:17 am

Post » Sat May 28, 2011 4:08 am

Yea, with that script it would file all three rounds in 3 frames, and on a high end machine that gets 40-60 fps, it would be like a minigun firing, and probably look and sound like one shot. So breaking it up with timers would let you see all three separately. :)
User avatar
x_JeNnY_x
 
Posts: 3493
Joined: Wed Jul 05, 2006 3:52 pm

Post » Sat May 28, 2011 4:07 am

If anybody is interested, here is the script.

If Player.GetAnimAction == 2 && isBursting != 1 && Player.GetEquipped H52BurstFire	set iStage to 1	set isBursting to 1EndIfif iStage > 0 && iStage < 4	set iStage to iStage + 1elseif iStage == 4	Player.FireWeapon H52BurstFire	set iStage to iStage + 1elseif iStage > 4 && iStage < 7	set iStage to iStage + 1elseif iStage == 7	Player.FireWeapon H52BurstFire	set iStage to 8elseif iStage > 7 && iStage < 15	set iStage to iStage + 1elseif iStage == 15	set isBursting to 0	set iStage to 16endif


The IsBursting is there to prevent people from bursting once the bursting is over.
User avatar
Jay Baby
 
Posts: 3369
Joined: Sat Sep 15, 2007 12:43 pm

Post » Sat May 28, 2011 3:05 am

That still could be very fast depending on the pc of the person doing it. And its a very weird way to do a script, but I guess if it aint broke don't fix it right?
User avatar
Chloe Lou
 
Posts: 3476
Joined: Sat Nov 04, 2006 2:08 am

Post » Sat May 28, 2011 8:21 am

That still could be very fast depending on the pc of the person doing it. And its a very weird way to do a script, but I guess if it aint broke don't fix it right?


True, it could be very fast.

Anyways, the first two scripts wasn't the problem of it going to fast. I did not lose ammo. So it never fired.

How would you recommend the script then?
User avatar
Ross Zombie
 
Posts: 3328
Joined: Wed Jul 11, 2007 5:40 pm

Post » Sat May 28, 2011 8:22 am

Well with staged timers, which is what I thought you had used. Just set the time between each shot to like .1 seconds so its always about the same speed for everyone, and then you can easily tweak the timing as you wish.
User avatar
Kaley X
 
Posts: 3372
Joined: Wed Jul 05, 2006 5:46 pm

Post » Sat May 28, 2011 6:21 pm

Well with staged timers, which is what I thought you had used. Just set the time between each shot to like .1 seconds so its always about the same speed for everyone, and then you can easily tweak the timing as you wish.


These are staged timers. They just measure in frames.

Anyways, It's working and I won't change them. Way too big of a headache for that :P
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm

Post » Sat May 28, 2011 2:36 am

I suppose you could call these staged timers... just keep in mind its now dependant on framerate, not actual time. Which might now be a bad thing considering almost everything in the game is. Like if your framerate is 5, the entire game goes a tenth the speed it would if your framerate was 50. Character movement and all. So this way if someone has like 2fps they wont miss anything.
User avatar
Ria dell
 
Posts: 3430
Joined: Sun Jun 25, 2006 4:03 pm

Post » Sat May 28, 2011 4:32 am

The aiming also goes one tenth slower. If everything goes slower then there would be no problem.
User avatar
kitten maciver
 
Posts: 3472
Joined: Fri Jun 30, 2006 2:36 pm

Post » Sat May 28, 2011 7:29 am

No, it is still a problem as character speed/turn speed/anim speed is measured in seconds, not frames. Using a frame-by-frame timer is only acceptable for events that need to be triggered actual frames apart, like for example scripts relying on objects that take 1-2 frames to load into the cell, or that can't be called within a few frames of another action taking place.

if(isBursting)   set timer to timer + getsecondspassed   if(timer > 0.05)      Player.FireWeapon H52BurstFire      set timer to timer -0.05      set isBursting to isBursting -1   endifelse   If Player.GetAnimAction == 2 && Player.GetEquipped H52BurstFire      set isBursting to 3      set timer to 0   endifendif
Is a lot neater, more efficient, and easier to edit in future. In the stuff I've done I've replaced GetEquipped with stuff in OnEquip blocks, as otherwise it'll keep checking the player's anim action each frame even if he's not got your gun equipped.

You can rework it so it'll work for NPCs by using a reference for the person firing the gun you find in the equip blocks. Since equip blocks don't fire for NPCs who spawn with the weapon already equipped, you can check for them too.

ref Gunmanshort Equippedshort isBurstingfloat Timerbegin onequipset Equipped to 1set Gunman to getcontainerendbegin onunequipset Equipped to 0endbegin ondropset Equipped to 0set Gunman to 0endbegin gamemodeif(Gunman)   if(Equipped)      if(isBursting)         set timer to timer + getsecondspassed         if(timer > 0.05)            Gunman.FireWeapon H52BurstFire            set timer to timer -0.05            set isBursting to isBursting -1         endif      else         If Gunman.GetAnimAction == 2            set isBursting to 3            set timer to 0         endif      endif   endifelse   set Gunman to getContainer   if(Gunman)      set Equipped to Gunman.getEquipped ThisWeaponID   endifendifend

User avatar
Benji
 
Posts: 3447
Joined: Tue May 15, 2007 11:58 pm

Post » Sat May 28, 2011 7:34 am

Thank you TheTalkieToaster. If/When I will release the whole mod, I will credit you in the credits.
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Sat May 28, 2011 4:35 am

New problem. Burst is not working abymore. I'm certain that I [censored] this up myself however. Also, when I click the 4th button on my message, suddenly I get a CTD.

Here is the script.

scn H52BurstChangeScriptShort ButtonShort fireInt iStageShort isBurstingShort BurstOKShort AutoOKShort SingleOKShort Chosenref Gunmanshort Equippedfloat Timerbegin onequipset Equipped to 1set Gunman to getcontainerendbegin onunequipset Equipped to 0endbegin ondropset Equipped to 0set Gunman to 0endBEGIN OnAddIf Player.IsSneaking == 1ShowMessage H52BurstFireMSGSet Chosen to 1EndIfENDBEGIN GamemodeSet Button to GetButtonPressedIf Button == -1	ReturnElseIf Button == 0	Set SingleOK to 1	Set BurstOK to 0	Set AutoOK to 0ElseIf Button == 1	Set SingleOK to 0	Set BurstOK to 1	Set AutoOK to 0ElseIf Button == 2	Set SingleOK to 0	Set BurstOK to 0	Set AutoOK to 1ElseIf Button == 3	Player.AddItem H52BurstFireScope 1 1	Player.RemoveItem H52BurstFire 1 1EndIfIf Chosen == 0set BurstOK to 1EndIfIf BurstOK == 1	SetWeaponIsAutomatic 0	SetWeaponMinSpread 0.500	SetWeaponSpread 1.500 	SetWeaponCritChance 0.500	SetWeaponCritDamage 4	SetWeaponAttackAnimation 1	SetWeaponType 6 EndIfif(Gunman)   if(Equipped)      if(isBursting)         set timer to timer + getsecondspassed         if(timer > 0.05)            Gunman.FireWeapon H52BurstFire            set timer to timer -0.05            set isBursting to isBursting -1         endif      else         If Gunman.GetAnimAction == 2            set isBursting to 3            set timer to 0         endif      endif   endifelse   set Gunman to getContainer   if(Gunman)      set Equipped to Gunman.getEquipped H52BurstFire   endifendifIf AutoOK == 1	SetWeaponIsAutomatic 1 	SetWeaponMinSpread 1.500 	SetWeaponSpread 4.000 	SetWeaponCritChance 0.000 	SetWeaponCritDamage 0 	SetWeaponAttackAnimation 8 	SetWeaponType 6 EndIfIf SingleOK == 1	SetWeaponIsAutomatic 0 	SetWeaponMinSpread 0.000 	SetWeaponSpread 0.000 	SetWeaponCritChance 2.500 	SetWeaponCritDamage 8 	SetWeaponAttackAnimation 1 	SetWeaponType 6 EndIfEnd


It is set as an object script and attached to my weapon; H52BurstFire.
User avatar
Blessed DIVA
 
Posts: 3408
Joined: Thu Jul 13, 2006 12:09 am

Post » Sat May 28, 2011 9:17 am

Hmmmm, I don't see code in your script for a 4th button anymore, only a 3rd button:

	ElseIf Button == 3		Player.AddItem H52BurstFireScope 1 1		Player.RemoveItem H52BurstFire 1 1	EndIf


If this is in fact the 4th button, are you missing "Scope" from the RemoveItem command? You may be getting a CTD if you try to remove an item that does not exist.

Luck!

Miax
User avatar
Marquis T
 
Posts: 3425
Joined: Fri Aug 31, 2007 4:39 pm

Post » Sat May 28, 2011 6:11 am

Hmmmm, I don't see code in your script for a 4th button anymore, only a 3rd button:

	ElseIf Button == 3		Player.AddItem H52BurstFireScope 1 1		Player.RemoveItem H52BurstFire 1 1	EndIf


If this is in fact the 4th button, are you missing "Scope" from the RemoveItem command? You may be getting a CTD if you try to remove an item that does not exist.

Luck!

Miax


It is the 4th button, yes. It is a button that swaps my current weapon with the same weapon but with a scope. I have two different EditorIds. It worked before. So I have no idea why it does not work now.
User avatar
Noely Ulloa
 
Posts: 3596
Joined: Tue Jul 04, 2006 1:33 am

Post » Sat May 28, 2011 3:30 am

It is the 4th button, yes. It is a button that swaps my current weapon with the same weapon but with a scope. I have two different EditorIds. It worked before. So I have no idea why it does not work now.


The CTD gives us a clue at least as to the kind of problem - as CTD's will only happen in certain situations. A CTD tells me that your either removing something that no longer exists in your mod, or adding an object that doesn't exist. Or perhaps there is a script on the weapon being added that activates and/or does something? I would examine the weapons being removed/added, load them on the ground and test them thoroughly to make sure you don't have a problem with the weapons themselves.

Looking further down in the script, I note the block:
	If BurstOK == 1		SetWeaponIsAutomatic 0		SetWeaponMinSpread 0.500		SetWeaponSpread 1.500		SetWeaponCritChance 0.500		SetWeaponCritDamage 4		SetWeaponAttackAnimation 1		SetWeaponType 6	EndIf


Odd thing is I can't find Any reference to these in the GECK Wiki, but do they apply to the player's Equipped weapon? If so, are you not removing that equipped weapon and replacing it with one in inventory? (to which these commands would then have no target and may cause the CTD?)

Lastly, when the player hits Option 4 and the weapons are swapped, do you need to keep going through the rest of the script? Or can you return right at that point? even if not, I would put a return in there to see if the Add/Remove works okay as a test.

Miax
User avatar
R.I.p MOmmy
 
Posts: 3463
Joined: Wed Sep 06, 2006 8:40 pm

Post » Sat May 28, 2011 9:31 am

You're removing the item the script is running on. You can only remove an item from within its own script with the command RemoveMe. TBH though the whole thing needs restructuring because it's really, really, inefficient- the autoOk and singleOk blocks for example are being called /every frame/, regardless of whether or not the gun has already had its stats set, or whether it's even equipped.
You've got the autoOk/singleOk blocks as separate ifs when they can't both be true so they should be elseifs.
Your button code is checking every button, every frame and as a result is killing the entire script because except for the one frame in which the player selects a button, button will be -1 and the script will Return on the very second line.
The PC can only change fire mode by dropping the gun and picking it back up again, which isn't very practical.

I'm currently on a tiny netbook, but I'll rewrite it to be somewhat more functional when I can get to a PC.
User avatar
Romy Welsch
 
Posts: 3329
Joined: Wed Apr 25, 2007 10:36 pm

Post » Sat May 28, 2011 4:51 pm

The CTD gives us a clue at least as to the kind of problem - as CTD's will only happen in certain situations. A CTD tells me that your either removing something that no longer exists in your mod, or adding an object that doesn't exist. Or perhaps there is a script on the weapon being added that activates and/or does something? I would examine the weapons being removed/added, load them on the ground and test them thoroughly to make sure you don't have a problem with the weapons themselves.

Looking further down in the script, I note the block:
	If BurstOK == 1		SetWeaponIsAutomatic 0		SetWeaponMinSpread 0.500		SetWeaponSpread 1.500		SetWeaponCritChance 0.500		SetWeaponCritDamage 4		SetWeaponAttackAnimation 1		SetWeaponType 6	EndIf


Odd thing is I can't find Any reference to these in the GECK Wiki, but do they apply to the player's Equipped weapon? If so, are you not removing that equipped weapon and replacing it with one in inventory? (to which these commands would then have no target and may cause the CTD?)

Lastly, when the player hits Option 4 and the weapons are swapped, do you need to keep going through the rest of the script? Or can you return right at that point? even if not, I would put a return in there to see if the Add/Remove works okay as a test.

Miax


The functions are from FOSE. And they apply to the equipped weapon or a parameter. I'll try adding some parameters.
User avatar
MISS KEEP UR
 
Posts: 3384
Joined: Sat Aug 26, 2006 6:26 am

Post » Sat May 28, 2011 5:29 pm

You're removing the item the script is running on. You can only remove an item from within its own script with the command RemoveMe. TBH though the whole thing needs restructuring because it's really, really, inefficient- the autoOk and singleOk blocks for example are being called /every frame/, regardless of whether or not the gun has already had its stats set, or whether it's even equipped.
You've got the autoOk/singleOk blocks as separate ifs when they can't both be true so they should be elseifs.
Your button code is checking every button, every frame and as a result is killing the entire script because except for the one frame in which the player selects a button, button will be -1 and the script will Return on the very second line.
The PC can only change fire mode by dropping the gun and picking it back up again, which isn't very practical.

I'm currently on a tiny netbook, but I'll rewrite it to be somewhat more functional when I can get to a PC.


Ah, I didn't know that. Thanks.

I know it's highly inefficient, but I just wanted it working.

And I really appreicate all the effort you put into this TheTalkieToaster.
User avatar
Cat
 
Posts: 3451
Joined: Mon Dec 18, 2006 5:10 am

Post » Sat May 28, 2011 12:57 pm

Just an update to tell you guys that I have got it all working :) Thank you for the assistance all.
User avatar
Lily
 
Posts: 3357
Joined: Mon Aug 28, 2006 10:32 am


Return to Fallout 3