Equipping a weapon after being picked up by NPC

Post » Fri Feb 19, 2010 4:28 pm

So I've set up a find package on an NPC to pickup a weapon. Once the weapon is picked up I want the NPC to equip it. The problem is my reference variable is no longer valid as soon as the weapon is picked up so using my invalid reference variable exits the script:
if ( rWeapon.getContainer != rEmpty ); Weapon not on the ground	if ( rActor.getEquipped rWeapon ); This breaks my script because rWeapon is no longer a valid form		rActor.equipItem rWeapon	endifendif

Any ideas how to do this?
User avatar
Loane
 
Posts: 3411
Joined: Wed Apr 04, 2007 6:35 am

Post » Fri Feb 19, 2010 8:01 am

This did the trick:
set rWeaponBase to rWeapon.getBaseObjectif ( rWeapon.getContainer != rEmpty ); Weapon not on the ground	if ( rActor.getEquipped rWeaponBase ); This breaks my script because rWeapon is no longer a valid form		rActor.equipItem rWeaponBase	endifendif

User avatar
Kevin S
 
Posts: 3457
Joined: Sat Aug 11, 2007 12:50 pm

Post » Fri Feb 19, 2010 5:29 pm

Replace if ( rWeapon.getContainer != rEmpty ) with ( rWeapon.getContainer ) in any case - Means the same, requires no extra variables and is slightly faster.
User avatar
daniel royle
 
Posts: 3439
Joined: Thu May 17, 2007 8:44 am

Post » Fri Feb 19, 2010 6:54 am

hehe yeah.. that was stupid of me. Actually I replaced it with:
if ( isFormValid rWeapon == 0 )

Seems to do the same thing since references to picked up weapons are no longer valid
User avatar
Cayal
 
Posts: 3398
Joined: Tue Jan 30, 2007 6:24 pm

Post » Fri Feb 19, 2010 1:10 pm

hehe yeah.. that was stupid of me. Actually I replaced it with:
if ( isFormValid rWeapon == 0 )

Seems to do the same thing since references to picked up weapons are no longer valid

http://cs.elderscrolls.com/constwiki/index.php/HasBeenPickedUp seems more to the point, but fine :)
User avatar
Marcin Tomkow
 
Posts: 3399
Joined: Sun Aug 05, 2007 12:31 pm

Post » Fri Feb 19, 2010 3:03 pm

I tested it once before and it didn't work. I just tested it again and still doesn't work.. perhaps it's because it needs the base ref.
User avatar
cassy
 
Posts: 3368
Joined: Mon Mar 05, 2007 12:57 am

Post » Fri Feb 19, 2010 4:03 pm

I tested it once before and it didn't work. I just tested it again and still doesn't work.. perhaps it's because it needs the base ref.

It'll return true as long as the weapon ref was transferred to a container and the world formID was invalidated. It's called on the world reference.
User avatar
Motionsharp
 
Posts: 3437
Joined: Sun Aug 06, 2006 1:33 am

Post » Fri Feb 19, 2010 11:36 am

hehe yeah.. that was stupid of me. Actually I replaced it with:
if ( isFormValid rWeapon == 0 )

Seems to do the same thing since references to picked up weapons are no longer valid
I think (I kinda http://www.gamesas.com/index.php?/topic/1087872-relz-oblivion-script-extender-obse-0018/page__view__findpost__p__15882001 it actually) they are valid if rWeapon is persistent - correct me if wrong plz
User avatar
Alex [AK]
 
Posts: 3436
Joined: Fri Jun 15, 2007 10:01 pm

Post » Fri Feb 19, 2010 5:17 am

I think (I kinda http://www.gamesas.com/index.php?/topic/1087872-relz-oblivion-script-extender-obse-0018/page__view__findpost__p__15882001 it actually) they are valid if rWeapon is persistent - correct me if wrong plz

http://www.gamesas.com/index.php?/topic/1087872-relz-oblivion-script-extender-obse-0018/page__view__findpost__p__15888458
User avatar
clelia vega
 
Posts: 3433
Joined: Wed Mar 21, 2007 6:04 pm


Return to IV - Oblivion