Jump to content

Get object ID the script is attached to


theimmersion

Recommended Posts

Well, heres the direct issue with the complete script on one of the weapons im trying to mod.

Its always getting the base ID that is giving me problems. -.-#

So the gun has iron sights on top of the scope, so i thought, id make a script to toggle the Has Scope flag on weapon to switch between the iron sights and scope. I aligned the iron sight node in the .nif properly. UGH....

 

int iPOVKey

int iAimKey
int KeyState
ref rWpn
ref rWpnBase
int FlagsMask
begin GameMode
set iAimKey to GetControl 6
set iPOVKey to GetControl 13
if Player.isWeaponOut == 1
set rWpn to Player.GetEquippedObject 5
printC "ref: %n", rWpn
set rWpnBase to rWpn.GetBaseForm ; <- THIS IS WHERE IT FAILS SILENTLY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
printC "ref base: %n", rWpnBase ; <- NEVER GETS CALLED!
if rWpnBase == aaaRailGun
printC "Is the weapon."
if iAimKey == 1
if iPOVKey == 1
set KeyState to 1
else
if KeyState == 1
set FlagsMask to GetWeaponFlags1 aaaRailGun
printC "get flag (%0.f)", FlagsMask
if FlagsMask == 4
SetWeaponFlags1 0, aaaRailGun
printC "change to 0"
else
SetWeaponFlags1 4, aaaRailGun
printC "change to 4"
endif
set KeyState to 0
endif
endif
endif
endif
endif
;set FlagsMask to GetWeaponFlags1 aaaRailGun
;printC "Final flags mask: %0.f", FlagsMask
end
Link to comment
Share on other sites

  • Replies 46
  • Created
  • Last Reply

Top Posters In This Topic

As I read it, the "GetEquippedObject" has already returned the "Base object template" Base-ID. So your silently failing line is because you are attempting to get the Base-ID form of a Base-ID form. "rWpn" is not a "Ref-ID"; merely a "reference variable" holding a Base-ID.

 

This distinction is exactly what I was writing up. (Or I am more confused than ever.)

 

-Dubious-

Link to comment
Share on other sites

Your GetEqObj line, or GetEquippedObject, is already returning the base ID. So you can get rid of the next three lines and use either rWpnBase or rWpn for the entire thing. Actually, it's a little hard to read your script but I think you can get rid of most of the initial portion and replace it with

if player.GetEquippedObject 5 == aaaRailGun

Also, if it weren't giving you the base ID already, it would be returning a reference ID, and that would require the use of GBO, or GetBaseObject, to give you the base ID, whereas GBF, or GetBaseForm, is for levelled actors.

 

Note that ref variables may store both base forms and reference forms. You did seem to know this, but I don't think it can be said too many times.

 

Again, it would be nice to know what this script is attached to and for you to use code formatting when you paste code. You can even use pastebin.com if you like. In fact, for long scripts, it's usually better. but if you want to paste a good chunk of code, code formatting with proper indentation and putting the whole thing in a spoiler tag really makes my life easier and probably anyone else that wants to help you.

 

From the wiki:

Returns the base object of the item equipped in the specified slot

https://geckwiki.com/index.php/GetEquippedObject

 

(Or I am more confused than ever.)

Haha, no, you got it.

Link to comment
Share on other sites

Wait, so GetEquippedObject is returning the base id?!

OMG my brain totally missed:

 

GetEquippedObject Description

Returns the base object of the item equipped

 

I always thought it was returning the instance ref because, well - by logic, its pointed towards an object in world that ins instanced. xD
Thats what probably made me post this topic here. xDDDDD

 

 

Again, it would be nice to know what this script is attached to

This last script i posted is for a weapon but had essentially the same issue as the duffle bag, could not get the base id of the object.

In the first pages of this topic i moved to a weapon to clear mind and (our country saying) let the devils have a play, then refreshed go back and try to fix it. I havent posted any code for the backpacks at first because it was in absolute chaos of small bits and pieces and comments and lots of other debug code. I could not just copy paste it because that. I instead copy pasted the general functions that were in essence working up to the point where they brake and stop working. For this weapon script however i had in mind id need to post it if there were strange issues so i was a bit more careful in writing it.

I must admit, im surprised and glad FNV still gets support with new mods as well as here. I mean, id move on to FO4 but my laptop barely runs FNV so...
THANKS GUYS! You save our butts big time, many time! xD

Link to comment
Share on other sites

Whoo, forgot. Now that i got that sorted out found a new problem, toggling the Has Scope flag does not make the weapon use iron sights, the "Don't use iron sights" flag is not ticked so thats odd. Its like still behaving like a scoped weapon only with the missing scope overlay. Also, apparently, i have to re-equip the weapon for the change in flags to actually take effect. Any way to force the game to re-evaluate or must i use a blitz un-equip-re-equip?

 

This is the working script:

scn aaaRailGunSCRIPT
int iPOVKey
int iAimKey
int KeyState
ref rWpn
ref rWpnBase
int FlagsMask


int keyRMB ; 257
int keyF   ; 33


begin GameMode
; Replced with hardcoded keys because the control approach didnt work.
  if IsKeyPressed 257 != keyRMB
    set iAimKey to IsKeyPressed 257
  endif
  if IsKeyPressed 33 != keyF
    set iPOVKey to IsKeyPressed 33
  endif


  if Player.isWeaponOut == 1
    ; ToDo: fix this instead of hardcoded keys.
    ;set iAimKey to GetControl 6
    ;set iPOVKey to GetControl 13


    set rWpnBase to Player.GetEquippedObject 5
    if rWpnBase == aaaRailGun
      if iAimKey == 1
        if iPOVKey == 1
          set KeyState to 1
        else
          if KeyState == 1
            set FlagsMask to GetWeaponFlags1 aaaRailGun
            if FlagsMask == 4
              SetWeaponFlags1 0, aaaRailGun
              printC "WpnF change to 0"
              ; NEEDS SOME RE-EVAL CODE HERE
            else
              SetWeaponFlags1 4, aaaRailGun
              printC "WpnF change to 4"
              ; NEEDS SOME RE-EVAL CODE HERE
            endif
            set FlagsMask to GetWeaponFlags1 aaaRailGun
            printC "Current weapon flag: (%0.f)", FlagsMask
            set KeyState to 0
          endif
        endif
      endif
    endif
  endif
end
Edited by theimmersion
Link to comment
Share on other sites

Never done anything like that but if unequipping and reëquipping fixes it, a good old-fashioned Update3D tends to sort it out (tongue in cheek reference to Update3D being added by NVSE and then not working for a bit and then being fixed by JIP LN not all that long ago; but none of that makes it any less indispensable).

 

You may want to keep this page bookmarked or something:

https://geckwiki.com/index.php/Complete_List_of_Function_in_Fallout_New_Vegas

 

I use it to search for functions with my browser's find function. (I also made it and the typo galls me interminably.)

 

I asked you several times are you using JIP LN. I forgot to think about that and probably advised you with a lot of scripting functions that require it, so be aware of that if my suggestions don't compile.

 

I must admit, im surprised and glad FNV still gets support with new mods as well as here. I mean, id move on to FO4 but my laptop barely runs FNV so...

Glad to help. I'll be here at least until my mod is finished. But I've never been able to stay away from New Vegas, so I may find myself staying at the forum as well. Also, if you want my opinion, Fallout 4 is fun as a post-apocalyptic exploration shooter, and I really mean that, but it doesn't deliver any of what most New Vegas fans like about this game, so I wouldn't worry. Dialogue, story, choices, classic Fallout lore -- none of that is there. Great level design, though.

Link to comment
Share on other sites

"I asked you several times are you using JIP LN"

Sorry, forgot to answer. Well, im using anything it needs for something to work as best as possible. So yes, i look at NVSE and as a required update patch for FNV, and JIP cuz i use mods that require that too.
Yeah, i saw the FO4 tragics, but mods can fix it i guess. Which is at some point wondering, why the game is 60+ $ when modders at this point do more work then Beth. Should be 40$ honestly. xD
But i digress, thanks for the link! Will come in handy. Will try with Update3D and see what happenes. But still, even if it updates, might still behave like it has a scope but without the layout. Perhaps i should try make 2 rail guns and switch between them. Hopefully equip/unequip functions is fast enough to to avoid jerkyness, will probably require Update3D as well.

BTW, DO NOT PREVIEW FEV creature with Geck PU. -.-#

Edited by theimmersion
Link to comment
Share on other sites

On the scope issue ... are you trying to add a scope to the rail gun ? If so ... what you need to do is unpack the BSA that holds those , and place them in the loose file folders.

Then in geck after flagging it "has scope" you click the edit button , and navigate to where you dropped the .nifs

 

This tool will unpack FNV for you even though it says Fo3

 

https://www.nexusmods.com/fallout3/mods/34

 

Within the "Fallout - Meshes.bsa" look in Meshes/Interface/Hud and you will see 11 scope.nif files.

So just choose the whole Hud file and extract it to a destination folder.

Then take the interface folder and drop it in your Meshes folder in your Data folder of the game location.

Now you will be able to give any gun one of those scopes.

 

At least I'm pretty sure it will work like that , since I've never done it with NV just fo3.

How accurate one scope and gun combination might be ?... IDK ^shrug^ ... I know there were issues in F03 , even the vanilla ones.

 

Add edit : As long as you keep the folder structure that the BSA had ... once you assign the file path to the weapon in Geck. You can delete the loose files and it will find them in the archive. Hence no need to package them for your mod download.

Link to comment
Share on other sites

Sorry, forgot to answer. Well, im using anything it needs for something to work as best as possible. So yes, i look at NVSE and as a required update patch for FNV, and JIP cuz i use mods that require that too.

That's how I think of it as well. JIP LN is almost the only way to get inventive mods out for a game this old, and everyone should be using NVAC anyway, which requires NVSE. Also, JIP LN fixes a fair few bugs just by being installed.

 

Speaking of which, you still here, Dubious? NVSR is reputedly fixed for Windows 10 starting with the 1803 update. I have 1709 with NVSR back in and haven't crashed yet, though the majority of my sessions are short as they're just mod-testing, and I have no graphical mods anymore. Thought you'd want to know that if you didn't already.

 

BTW, DO NOT PREVIEW FEV creature with Geck PU. -.-#

There's a lot of stuff like that. I accidentally clicked on I think it was Details instead of Set Active File, and it just froze for ten minutes and then I force-closed it. Wonderful world of modding, haha.

 

I forgot to think about what you were even trying to do, haha. Mktavish's suggestion is probably what I should have said from the beginning, now that I realise you're probably just trying to add a scope to something.

 

BUT WORD OF CAUTION: DO NOT UNPACK BSA IN GAME FOLDER. BSAopt at least will look as if it's unpacking only your specified files but will unpack everything and overwrite all your mods as well as unpacking all your hair and making it look funny (hair needs to be in a BSA to look correct, and it's worse with facial hair). Mktavish's linked utility may avoid this problem that BSAopt has, but be cautious.

Link to comment
Share on other sites

Yes Never unpack into the Game folder ... sorry I didn't stress that.

But yes the Fo3 archive utility will only unpack what you have highlighted ... but yet preserve the folder structure they are found in.

 

And another thing occurred to me , that you are not trying to add a scope , but get the rail gun to use the Iron sites animation. Which this is part of the first person model object. So would need to add that to the .nif. via nifskope i guess ?

 

And then it occurred to me that the rail gun is not an NV asset ... which means you pulled it from Fo3 ???

And no ... those vanilla .nifs did not have iron sites.

 

And then it should be mentioned that you cannot publish an NV mod with Fo3 unique assets.

 

If that is infact what you are trying to do ?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...