Recognizing when an Energy Weapon is equipped

Post » Fri Aug 06, 2010 9:18 pm

Hey guys,

I'm having trouble scripting a minimum skill requirement for Energy Weapons. I've been able to do this just fine with other types of weapons, by using GetWeaponAnimType, in a quest script. But energy weapons is not a separate category.
So I looked at the FOSE commands and found the GetWeaponType command, which has type 4 (OneHandPistolEnergy) and type 7 (TwoHandRifleEnergy), so I thought I was all set.

But I cannot seem to get this to work. I'm guessing that I'm missing some little piece of information again (of that I'm doing this all wrong).

Begin GameMode	if player.GetActorValue EnergyWeapons < 25 && (Player.GetWeaponType == 4 || Player.GetWeaponType == 7)		DisablePlayerControls 0 0 1 0 0	Endif	if player.GetActorValue EnergyWeapons >= 25 || (Player.GetWeaponType != 4 && Player.GetWeaponType != 7)		EnablePlayerControls 1 1 1 1 1 1 1	EndifEnd

User avatar
Yvonne Gruening
 
Posts: 3503
Joined: Mon Apr 23, 2007 7:31 pm

Post » Fri Aug 06, 2010 10:15 am

I think you need to pass the weapon object to that function. Try using "http://fose.silverlock.org/fose_command_doc.html#GetEquippedObject 5" to get the actual weapon and then pass it to your function.
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Fri Aug 06, 2010 1:44 pm

I think getWeaponSkill (also fose) is better suited for what you're trying to do, unless you want to make a distinction between 1 or 2 handed weapons. (Quick c&p from a script where I was using this:)
set weapon to player.getEquippedObject 5set weaponSkill to getWeaponSkill weapon; Small Gunsif weaponSkill == 41; Big Gunselseif weaponSkill == 33; Energy Weaponselseif weaponSkill == 34

User avatar
Stephanie Nieves
 
Posts: 3407
Joined: Mon Apr 02, 2007 10:52 pm

Post » Fri Aug 06, 2010 10:56 pm

Thanks sooo much!

I'll give your suggestions a try and see if I can get my script functioning.


EDIT: My script is now working perfectly! :dance:

Thanks again for the help with this!
User avatar
Princess Johnson
 
Posts: 3435
Joined: Wed Feb 07, 2007 5:44 pm

Post » Fri Aug 06, 2010 8:38 pm

My script is now working, but I have one tiny little issue that I would like to fix before I release this.

With pistols, this works perfect . . . even when your skills are too low to use the weapon, you can still draw it, but it instantly gets re-holstered (which is awesome!).
But with rifles and anything that is 'holstered' on your back, you can only draw the weapon once, and then it just remains fixed on your back and you cannot draw it again.

My concern is that players are not going to understand why their weapon will now longer draw (even though I have a popup message . . . but it only pops up when you first switch to a weapon that is beyond your abilities).
Is there any way to enable a non-usable back-holstered weapon to be drawn and re-holstered in the same way as the hip-holstered pistols?

If not, is there any way to disable the ability to fire a weapon (instead of disabling the player's fighting controls)?

This is what I have working so far:

ref Weaponfloat WeaponSkillBegin GameMode	set weapon to player.getEquippedObject 5	set WeaponSkill to getWeaponSkill weapon		if player.isweaponout == 1 		if player.GetActorValue EnergyWeapons < 20 && WeaponSkill == 34 ; Energy Weapons			DisablePlayerControls 0 0 1 0 0 			ShowMessage ArwenEnergyWeapDisabled						Elseif player.GetActorValue SmallGuns < 30 && Player.GetWeaponAnimType == 6 ; two-handed Automatic weapons			DisablePlayerControls 0 0 1 0 0 ; Player.UnEquipItem weapon 1 			ShowMessage ArwenAutoWeapDisabled		Elseif player.GetActorValue Endurance < 6 && WeaponSkill == 33 ; Big Guns			Player.drop weapon 1			ShowMessage ArwenBigGunDisabled		Endif	EndifEnd

User avatar
Katie Samuel
 
Posts: 3384
Joined: Tue Oct 10, 2006 5:20 am

Post » Fri Aug 06, 2010 2:40 pm

Is there any possible connection between "only show popup once" and "can only draw weapon once" ? I see no code to check that the message has been displayed before in your posted script, could they be related? I obviously know nothing about the rest of your script so if I am talking nonsense, just ignore me :D

As for alternatives, perhaps you can do something with Jamming or Reload to make it look like the player is struggling with the weapon? Although I think jamming actually fires a shot at the end, but maybe that can be changed.

Regards,
The Nonsense Factory
User avatar
adam holden
 
Posts: 3339
Joined: Tue Jun 19, 2007 9:34 pm

Post » Fri Aug 06, 2010 9:08 pm

It sounds like the controls are not correctly re-enabled for 2 handed weapons. That part seems to be missing from the script you pasted, so I assume it's done somewhere else?

(Edit)
I gave it a quick try and it seemed to be working:
ref weaponref lastWeaponshort notifyfloat weaponSkillBegin GameMode; No weapon drawn?if player.isWeaponOut == 0	returnendifset weapon to player.getEquippedObject 5set WeaponSkill to getWeaponSkill weaponset notify to (weapon != lastWeapon)set lastWeapon to weaponif player.GetActorValue EnergyWeapons < 20 && WeaponSkill == 34; Energy Weapons	DisablePlayerControls 0 0 1 0 0	EnablePlayerControls 0 0 1 0 0	if notify == 1		set notify to 0		ShowMessage ArwenEnergyWeapDisabled	endif	returnElseif player.GetActorValue SmallGuns < 30 && Player.GetWeaponAnimType == 6; two-handed Automatic weapons	DisablePlayerControls 0 0 1 0 0	EnablePlayerControls 0 0 1 0 0	if notify == 1		set notify to 0		ShowMessage ArwenAutoWeapDisabled	endif	returnElseif player.GetActorValue Endurance < 6 && WeaponSkill == 33; Big Guns	Player.drop weapon 1	if notify == 1		set notify to 0		ShowMessage ArwenBigGunDisabled	endif	returnEndifEnd


(Next edit :()
Forgot the line set lastWeapon to weapon
User avatar
Nick Swan
 
Posts: 3511
Joined: Sat Dec 01, 2007 1:34 pm

Post » Fri Aug 06, 2010 2:33 pm

It sounds like the controls are not correctly re-enabled for 2 handed weapons. That part seems to be missing from the script you pasted, so I assume it's done somewhere else?

What I posted is pretty much my entire working script (although I do plan on adding more).

Adding 'EnablePlayerControls 1 1 1 1 1 1 1' doesn't seem to change anything. And any hip-holstered weapon works just fine. For instance, a laser pistol will be drawn and instantly re-holstered, while a laser rifle will remain fixed on the back whenever I try to draw it. And is I switch to any usable two-handed weapon, it works just fine.

EDITED: Oops, I replied while you were still posting your code. Thanks! I'll give it a try immediately. :)

Your changes have fixed everything. It works perfect now! Thanks so much for your help!
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm


Return to Fallout 3