Grenade Pitching Machine and other traps

Post » Fri Apr 09, 2010 2:08 pm

I made some changes to a pitching machine to make it lob frag grenades instead of baseballs, to use as a creative defense for a new home base, and it works great. How do I go about to create an option to reset the trap once it has been sprung?

Also I wonder if there is a way to create a trap with the MailDropbox container (the blue one with the flip-lid), that on opening the dropbox spawns a grenade on the lid (to make it appear as though it had been taped to the inside of the lid) instead of opening the container inventory?
User avatar
Taylor Thompson
 
Posts: 3350
Joined: Fri Nov 16, 2007 5:19 am

Post » Fri Apr 09, 2010 9:06 am

While I am unsure as to how to reset the grenade trap, I can help you with the mailbox thing. Now it depends on what you want with it. It will involve making your own custom mailbox object with its own custom script on it. Now you can use the http://geck.gamesas.com/index.php/OnActivate block to start it, then a variable like task, or just make the mailbox be destroyed by the grenade, which can be difficult if its an actual grenade object. I recommend you make it like the trap mailbox's (the residential ones) or the trap computers and such, just it wont be disarmable. Find a good explosion, like maybe just use FragGrenadeExplosion (thats not its actual name, but it should be similiar) then find out what the noise is that it makes when traps are set off. The high pitch kind of whistle noise that starts low and goes up for like a second. Then use this script. I don't know if this would work well with more than one mailbox in existance, but maybe someone else can improve upon my idea.

scn ExplosiveMailboxSCRIPTfloat timershort taskBegin OnActivate Player; Only does it if the player uses it  If task == 0; it only works once	Set task to 1  endifendBegin Gamemode;it runs constantly while not in a menu  If timer > 0	set timer to timer - GetSecondsPassed; the timer counts down  Elseif task == 1	Playsound.Highpitchtrapnoise; put the actual noise name here	Set timer to 3	Set task to 2  Elseif task == 2	MailboxRef.Placeatme FragGrenadeExplosion 1; put your special mailbox's name up front, and the explosion you want at the end	MailboxRef.Disable	Set task to 0; if you used a variable instead of the specific mailbox's name, this would allow it to work on infinite mailbox's just not at once.  endifend

There is some way (I'm not sure so I wont try to tell you how) to set the mailbox's number (the XX123958 type thing) as a variable, then instead of MailboxRef use that variable, so it works for any mailbox, one at a time. (So just don't put two within 3 seconds run of eachother) This will make it so when you activate it, it goes Peewww!!!! 3 seconds later, BANG! it explodes and is gone. I hope this at least helps you get started, as I am sure theres a better way that a more experienced scripting can point out.
User avatar
FoReVeR_Me_N
 
Posts: 3556
Joined: Wed Sep 05, 2007 8:25 pm

Post » Fri Apr 09, 2010 7:24 pm

Having a look at the script for the pitching machine ("TRAPPitchingMachineScript", see below), it is split into the following sections:
  • When first loaded, initialise variables that control state, ammunition, and rate of fire
  • When activated, if the trap is armed, either trigger it or (if the player activated it) initiate the skill check for disarming the trap
  • If the player can disarm the trap, check if they want to do so and, if they do, disarm the trap and award experience
  • If the trap has been triggered, fire balls regularly until there are none left (controlled by variables set up previously)
The state of the trap is controlled mostly by the variables "isArmed" and "isFiring". When the trap is set up, "isArmed" is set to 1, and "isFiring" is set to 0. When the trap is activated, "isArmed" is set to 0, and if the trap has not been disarmed "isFiring" is set to 1. When the trap runs out of ammunition, "isFiring" is set to 0.

If you want to re-arm the trap once it has been triggered, you'll need to allow the player to set the "isArmed" variable back to 1, and you'll also need to set "ballcount" to a positive value in order to give the trap more ammunition to use.

Here's the vanilla script:
scn TRAPPitchingMachineScript;This script runs the pitching machine.short skillPassed			;check to see if the player has activated the trap. 1=activated, 0=not activatedshort button			;0 = disarm, 1 = don't disarmshort isArmedshort isFiringshort rewardXPOnceshort XPForDisarmfloat fireIntervalshort ballcountshort windUp		;check to see if it is starting upshort init;========================================begin onLoad	if init == 0		setStage NQlvl 1		set skillPassed to 0		set isFiring to 0		set isArmed to 1		set ballcount to 12			;number of balls to shoot -12		set fireInterval to 0.50	;about 20 frames		set init to 1	endifend;========================================;========================================begin onActivate	if isArmed == 1		if getActionRef == player			if player.getAV repair >= NQlvl.TRAPPitchingSkillReq		;This var is set when the NQlvl stage is set to 1				ShowMessage TrapPitchingDetectMsg				;do you want to take the grenades?				set skillPassed to 1;			else				ShowMessage TrapLowSkillRepairMsg NQlvl.TRAPPitchingSkillReq			endif		else			set isFiring to 1			set isArmed to 0			playgroup left 1	;startup animation			;			set windup to 1		endIf	endifend;============================================begin gameMode	if skillPassed == 1				;don't run stuff in game mode unless recently activated		set button to getButtonPressed		;grab the button state, you don't know when this will be set		if button > -1			;if a valid response is received start doing stuff			if button == 1				ShowMessage TrapDisarmMsg				set isArmed to 0		;disarm the trap				if rewardXPOnce == 0					if NQlvl.TRAPPitchingSkillReq< getGS iLockLevelMaxVeryEasy						set XPForDisarm to 0					elseif NQlvl.TRAPPitchingSkillReq< getGS iLockLevelMaxEasy						set XPForDisarm to TrapXPRewardVeryEasy					elseif NQlvl.TRAPPitchingSkillReq< getGS iLockLevelMaxAverage						set XPForDisarm to TrapXPRewardEasy					elseif NQlvl.TRAPPitchingSkillReq< getGS iLockLevelMaxHard						set XPForDisarm to TrapXPRewardAverage					elseif NQlvl.TRAPPitchingSkillReq< getGS iLockLevelMaxVeryHard						set XPForDisarm to TrapXPRewardHard					else						set XPForDisarm to TrapXPRewardVeryHard					endif					set rewardXPOnce to 1					rewardXP XPforDisarm				endif			endif			set skillPassed to 0	;stop running stuff		endif	endif	if isFiring == 1		if ballcount > 0		;check to make sure there are enough balls			;wait, fire			if fireInterval > 0				set fireInterval to fireInterval - GetSecondsPassed			else				playgroup forward 0			;looping run animation				set ballcount to ballcount -1				FireWeapon TrapBaseball				set fireInterval to 0.5			endif		else			set isFiring to 0			playgroup right 0					;end animation, ends looping sound.		endif	endifend
Note that the "windUp" variable is not used anywhere, so feel free to delete it entirely.

Cipscis

EDIT:

With respect to the mailbox script, a http://www.cipscis.com/fallout/tutorials/staged_timers.aspx will work well for that, as Gunmaster95 suggested. Instead of using explicit reference syntax to specify which reference to call http://geck.gamesas.com/index.php/PlaceAtMe and http://geck.gamesas.com/index.php/Disable on, you should just use implicit reference syntax to call them on the scripted reference, i.e.
Disable; instead ofMailboxRef.Disable

If you want the mailbox to still open when activated, you'll probably need to use http://geck.gamesas.com/index.php/PlayGroup in order for it to play the animation. Play around with it in the console to determine which group to use - my guess is "Forward". You'll also need to use http://geck.gamesas.com/index.php/SetPos if you want the grenade to appear in the correct location - http://geck.gamesas.com/index.php/PlaceAtMe will simply create it in a nearby "safe" area.

Cipscis
User avatar
Ebou Suso
 
Posts: 3604
Joined: Thu May 03, 2007 5:28 am

Post » Fri Apr 09, 2010 3:20 pm

Gah, see I'm still a noobie with this stuff :P I did not know simply using commands in their basic syntax would call them on the scripted ref. That is actually really helpful -_- Thanks Cipscis :D
User avatar
Love iz not
 
Posts: 3377
Joined: Sat Aug 25, 2007 8:55 pm


Return to Fallout 3