Jump to content

Need to call a reference for the weapon which is using the script any


arcane20

Recommended Posts

Get self doesn't seem to work, it only returns the player.

 

Here's the section of code I'm having problems with.

 

(Please not "PistolWeaponnum" Is a global that is why it is not listed)

 

Scn Sciptydoodah

ref ThisPistol

Begin onequip
	set ThisPistol to Getself

;========Debugging=============
	If ThisPistol == Weap10mmPistol
		printc "Thispistol is the correct ref"
	elseif ThisPistol == player
		printc "Thispistol = player"
	else
		printc "Thispistol = something else"
	endif
;=================================

	Set PistolWeaponnum to ListGetFormIndex RealSwitchlist ThisPistol
end

 

This script runs on a weapon. I need to call the weapons ID. As you can see 'getself' doesn't work. Can anyone please help ?

Link to comment
Share on other sites

getself is used on a target... it works to find who/what it (the weapon) hits

 

If that is an object script you don't need to check because forcibly will be the weapon the caller

 

If you need to check if it is equipped, use:

  ...
  Set WeaponREF to ActorID.GetEquippedObject 16
  If WeaponREF == YourWeaponID
    ; do whatever you need here
  ...
  endif

change the parameters and identifiers to actual values. 16 there is for the equipped weapon. I'm translating from my experience with Oblivion CS, adapt if needed for GECK.

 

PS: Where possible avoid creating global variables, you can achieve similar results using variables in quest script. Just be aware there are some pitfalls regarding changing the variables order (the quest variables are stored in saves by their position (their order in the script) and not explicit identifiers).

Edited by nosisab
Link to comment
Share on other sites

I'm not sure what you mean by "forcible will be the weapon the caller"

But anyways GetEquippedObject will do perfectly, Though it's 5 for the weapon in fallout. Still ^_^ You saved me a bunch of headaches and everything works thanks a lot. Kudos to you.

Link to comment
Share on other sites

I'm not sure what you mean by "forcible will be the weapon the caller"

But anyways GetEquippedObject will do perfectly, Though it's 5 for the weapon in fallout. Still ^_^ You saved me a bunch of headaches and everything works thanks a lot. Kudos to you.

By "caller" I mean the script knows that is the object it is attached the caller of the function whenever an explicit calling reference is not given. That's the reason this kind of script is named "reference script".

Edited by nosisab
Link to comment
Share on other sites

Ahh I see what you mean. Unfortunately ListGetFormIndex requires a reference and cannot be used without 1.

I'll try to take on what you said about globals too thanks.

Link to comment
Share on other sites

In this case you are dealing with base objects and not references. A weapon in a container (player in this case) doesn't have a reference, even when it's equipped. GetEquiptObject always returns base objects. A form list that you create in the Geck is a list of base objects. So something like this should be perfectly valid if you want to check a weapon against a list:

scn Sciptydoodah

ref ThisPistol
ref rContainer
short PistolWeaponnum

Begin onequip

set rContainer to GetContainer
if rContainer == player
	set  ThisPistol to GetEquippedObject 5
	Set PistolWeaponnum to ListGetFormIndex RealSwitchlist ThisPistol
	if PistolWeaponnum > -1		;it's in the list
		;Do stuff
	endif
endif

End

Link to comment
Share on other sites

In this case you are dealing with base objects and not references. A weapon in a container (player in this case) doesn't have a reference, even when it's equipped. GetEquiptObject always returns base objects. A form list that you create in the Geck is a list of base objects. So something like this should be perfectly valid if you want to check a weapon against a list:

scn Sciptydoodah

ref ThisPistol
ref rContainer
short PistolWeaponnum

Begin onequip

set rContainer to GetContainer
if rContainer == player
	set  ThisPistol to GetEquippedObject 5
	Set PistolWeaponnum to ListGetFormIndex RealSwitchlist ThisPistol
	if PistolWeaponnum > -1		;it's in the list
		;Do stuff
	endif
endif

End

 

 

Thanks for your reply I had already figured it out but couldn't find this topic =$.

I posted a Similar solution here.

http://www.thenexusforums.com/index.php?/topic/416297-isinlist-function-causing-script-to-hang/page__p__3443016__fromsearch__1#entry3443016

The only difference I'd make is instead of '>-1' Use '!= -1' Just because it's better to be exact.

Kudos to you for replying though ^_^.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...