Need major scripting help.

Post » Fri Sep 17, 2010 12:54 pm

I am trying to set up an area where you hit a switch that game enables your fighting ability (as all but moving and looking are disabled pretty much) and gives you a gun and some ammo. You must then shoot down 5 bottles, using less than or equal to your 10 shots of ammo given to you. If you dont shot all 5 down with the 10 shots you loose, or if you leave the area you lose. It is repeatable until you suceed. Each time you lose its supposed to reset the bottles placement back onto their stands. I have 3 scripts for this. One for the switch you hit, one for the trigger you stand in when doing it (that if you leave it fails you), and one for the bottles your shooting down, to see if they are shot down.

Here is the switches script.

Spoiler
scn PGMQ4Test17C1StartSwitchSCRIPTShort TestOnShort Bottle[censored]Short CheckDelayShort AmmoCountFloat TimerBegin OnActivate	If TestOn == 0 ; if the test isnt already going or done, start it		EnablePlayerControls 0 0 1 0 0 0 0 ; enable fighting		Player.AddItem PGMQ4Test17C132Pistol 1 1		Player.EquipItem PGMQ4Test17C132Pistol 1		Player.AddItem PGMQ4T17C1Ammo32Caliber 10		Set TestOn to 1 ; give the player the gun, equip it, and give them ammo, then set the test to started (teston == 1)	EndIfEndBegin GameMode	If Bottle[censored] == 5 && TestOn == 1 ; if they knock down all 5 bottles and the test is on, complete it		Set TestOn to 2		PlaySound XXXPlaceholderBeep		Set AmmoCount to Player.GetItemCount PGMQ4T17C1Ammo32Caliber		Player.RemoveItem PGMQ4T17C1Ammo32Caliber AmmoCount 1		Player.RemoveItem PGMQ4Test17C132Pistol 1 ; play a 'win' sound, take their gun and remaining ammo, and set the test to complete	ElseIf Player.GetItemCount PGMQ4T17C1Ammo32Caliber == 0 && TestOn == 1 && CheckDelay == 0 ; if the test is on, and they are out of ammo		Set CheckDelay to 1 ; let the timer run		Set Timer to 3 ; allow 3 seconds for flying bottles to settle incase their last shot hits the last bottle, so they dont loose instantly	EndIf	If Timer > 0 && CheckDelay == 1 ; if they are out of ammo and its checking		Set Timer to Timer - GetSecondsPassed	ElseIf Bottle[censored] < 5 && CheckDelay == 1		Set TestOn to 0 ; fail the test and set it to 'not started'		PlaySound OBJBuzzerBell ; play lose sound		Set CheckDelay to 0 ; stop checking if they failed		Set Bottle[censored] to 0 ; reset the score of bottles shot		Player.RemoveItem PGMQ4Test17C132Pistol 1 ; take away the pistol, ammo not neccisary as they are out		PGMQ4T17C1B1.MoveTo PGMQ4T17C1B1Ref		PGMQ4T17C1B2.MoveTo PGMQ4T17C1B2Ref		PGMQ4T17C1B3.MoveTo PGMQ4T17C1B3Ref		PGMQ4T17C1B4.MoveTo PGMQ4T17C1B4Ref		PGMQ4T17C1B5.MoveTo PGMQ4T17C1B5Ref		Set PGMQ4T17C1B1.DoOnce to 0		Set PGMQ4T17C1B2.DoOnce to 0		Set PGMQ4T17C1B3.DoOnce to 0		Set PGMQ4T17C1B4.DoOnce to 0		Set PGMQ4T17C1B5.DoOnce to 0		PGMQ4T17C1B1.Reset3DState		PGMQ4T17C1B2.Reset3DState		PGMQ4T17C1B3.Reset3DState		PGMQ4T17C1B4.Reset3DState		PGMQ4T17C1B5.Reset3DState ; last fiften lines are my attempt at resetting the bottles to sitting on their little stands properly, not succesfull fully	EndIfEnd


Everywhere it says Bottle[censored], it should says Bottles*hit (without the *) but the S and Hit make it censore it. -_- The bottles dont reset properly. They go to the right place, but are tipped over, or take like 3 hits before they move...

Here is the triggers script.

Spoiler
scn PGMQ4Test17C1EndTriggerSCRIPTShort AmmoCountBegin OnTriggerLeave ; if they leave the area	If PGMQ4Test17C1StartSwitchRef.TestOn == 1 ; if the test is going		Set PGMQ4Test17C1StartSwitchRef.TestOn to 0 ; stop the test, play lose sound remove gun, remaining ammo, and reset bottles and score		PlaySound OBJBuzzerBell		Set PGMQ4Test17C1StartSwitchRef.CheckDelay to 0		Set PGMQ4Test17C1StartSwitchRef.Bottle[censored] to 0		Player.RemoveItem PGMQ4Test17C132Pistol 1		PGMQ4T17C1B1.MoveTo PGMQ4T17C1B1Ref		PGMQ4T17C1B2.MoveTo PGMQ4T17C1B2Ref		PGMQ4T17C1B3.MoveTo PGMQ4T17C1B3Ref		PGMQ4T17C1B4.MoveTo PGMQ4T17C1B4Ref		PGMQ4T17C1B5.MoveTo PGMQ4T17C1B5Ref		PGMQ4T17C1B1.Reset3DState		PGMQ4T17C1B2.Reset3DState		PGMQ4T17C1B3.Reset3DState		PGMQ4T17C1B4.Reset3DState		PGMQ4T17C1B5.Reset3DState ; again attempt at resetting bottles		Set AmmoCount to Player.GetItemCount PGMQ4T17C1Ammo32Caliber		Player.RemoveItem PGMQ4T17C1Ammo32Caliber AmmoCount 1	EndIfEnd


And last here is the script on the empty soda cans.

Spoiler
scn PGMQ4T17C1SodaBottleSCRIPTShort DoOnceBegin GameMode	If DoOnce == 0		If GetPos Z < 1910 ; if they fall below their stand (roughly 1910 on the z axis)			Set PGMQ4Test17C1StartSwitchRef.Bottle[censored] to PGMQ4Test17C1StartSwitchRef.Bottle[censored] + 1 ; set the score to score + 1			Set DoOnce to 1 ; dont set the score to + 1 more than once, this is reset in the switch and trigger scripts above to 0, so if some fell they are reset		EndIf	EndIfEnd 


Pretty much I got it somewhat working. But I think I did it in a really complicated manner. Can anyone suggest a simpler way to achieve this? Or a better way to write my scripts? Also the things that arent working are, the bottles dont reset to the right postion. Should I just add a set angle x, y and z to them to they stand up straight? Also, I will be setting up this whole scenario 6 times total, this being the first. Can I make any of these scripts more generic so I can, for example, just throw in a Linked ref instead of a specific script and reference? I tried using GetLinkedRef on the bottles to set the score up one, but it was no good.

Please ask any questions necissary to help, like if I need to clerify anything. I need to get this working first thing tomorrow morning, then do the other 5 scenarios of it. Thanks sooo much for any help!!!!

Gunmaster95
User avatar
Sebrina Johnstone
 
Posts: 3456
Joined: Sat Jun 24, 2006 12:58 pm

Post » Fri Sep 17, 2010 6:42 pm

I can suggest you look at this mod of mine. It has a 'shooting range' with a variety of things you shoot. It also rewards experience when it is shot based on your distance from it, a timer is then set, and a few seconds later the shot item goes back to the stand.
http://www.fallout3nexus.com/downloads/file.php?id=13632

I use the 'OnHit' block on this coffee kettle:
scn LC1TargetKettleScriptfloat timershort doMefloat myDistbegin OnHit	if doMe == 0		set doMe to 1		set timer to (( getRandomPercent / 20 ) + 2.5 )		set myDist to GetDistance player		if myDist > 1105			RewardXP 2		elseif myDist > 605			RewardXP 1		endif	endifendbegin GameMode	if doMe == 1		if timer > 0			set timer to timer - GetSecondsPassed		else			set doMe to 0			setPos X -1496			setPos Y 3216			setPos Z 5540			setAngle X 0			setAngle Y 0			setAngle Z 270		endif	endifend

User avatar
Quick draw II
 
Posts: 3301
Joined: Thu Nov 08, 2007 4:11 pm

Post » Fri Sep 17, 2010 2:42 pm

Well, that looks like a great idea. I was going to use an OnHit block right off the bat, but the wiki said it did not work on items... So I tried something else... This makes it SO much simpler. Thanks WillieSea, I'll come back if I cant get it working, though now its about 1000x simpler. Thanks. :D
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Fri Sep 17, 2010 7:08 pm

Well that worked great for the first one. However, for the second, it doesnt appear to register a hit. I think its because I am using a miss launcher. Does the OnHit block not register explosions as hits? If not I can come up with something else to do for it, but I would like to know if thats the problem.

EDIT: Nevermind, I fixed it. Its all good. :)
User avatar
jess hughes
 
Posts: 3382
Joined: Tue Oct 24, 2006 8:10 pm


Return to Fallout 3