Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Onpackagestart script not working. Why?


lonewolf_kai
 Share

Recommended Posts

Why is this Onpackagestart script not working?

I'm trying to force an NPC to cast a spell based on his stealth skill. In this scripit, AASWsearch is the name of the Find package I have made, which should start as soon as the NPC is enabled. SWAS1 is the NPC ref id. AASWstealth is the spell's editor id. Here's the script:

Begin Onpackagestart AASWsearch

If (SWAS1.Getbaseav Sneak == 200)

Cast AASWstealth SWAS1

Endif

End

Link to comment
Share on other sites

If its not the script, it may be 'where' you placed the script. Or it could be how the object you placed the script on is set up. That means you would need to check with the AI packages thread, or the thread that controls where you placed the script.

As for the script itself, if the 'base stat' is not EXACTLY 200, it will never cast the spell.

You might want to check up on the GetBaseAV command, specifically the notes. This can be a very tricky function to use.

I myself would use GetAV instead, like so:

If SWAS1.GetAV Sneak >= 200

Link to comment
Share on other sites

If its not the script, it may be 'where' you placed the script. Or it could be how the object you placed the script on is set up. That means you would need to check with the AI packages thread, or the thread that controls where you placed the script.

As for the script itself, if the 'base stat' is not EXACTLY 200, it will never cast the spell.

You might want to check up on the GetBaseAV command, specifically the notes. This can be a very tricky function to use.

I myself would use GetAV instead, like so:

If SWAS1.GetAV Sneak >= 200

I placed it on the NPC itself, perhaps that is where the fault lies. I did test the NPC's sneak base to be sure it was set at 200 and it is.

Link to comment
Share on other sites

I am not sure if a 'begin OnPackageStart' will run on an NPC script. Perhaps a quest would be better if this is a 'one time' thing.

You might also consider making it '>=' instead of '=='.

Thank you good sir. I was also beginning to think it might've been the block start as well.

Link to comment
Share on other sites

I could use a Gamemode block:

ref DoOnce10

Begin Gamemode

If (SWAS1.Getbaseav Sneak == 200) && (DoOnce10 == 0)

Set DoOnce to 1

Cast AASWstealth SWAS1

Endif

End

Now I need this to be repeatable, so I would use an OnDeath block (which also happens to disable the NPC) and this block would set the DoOnce back to 0. While the NPC is disable, he is brought back to another cell.

Now, since the spell casting block is a Gamemode block, would the block keep running while the NPC is disabled in the other cell?

EDIT: Could I place a third condition in there for Getdisabled?

If (SWAS1.Getbaseav Sneak == 200) && (DoOnce10 == 0) && (Getdisabled == 0)

Edited by lonewolf_kai
Link to comment
Share on other sites

Hmm OnPackageStart is used repeatedly on NPCs in the vanilla game, and I've used OnPackageDone on NPCs. It might be the conditions for your AI package that are the holdup. I would add a message as the first entry in your OnPackageStart block and another in your IF block, should help us track down where things are going wrong. If neither message shows when the NPC is enabled you could type SWAS1.evp into the console and it will tell you which package he's currently running.

Good Luck,

WT

Link to comment
Share on other sites

Hmm OnPackageStart is used repeatedly on NPCs in the vanilla game, and I've used OnPackageDone on NPCs. It might be the conditions for your AI package that are the holdup. I would add a message as the first entry in your OnPackageStart block and another in your IF block, should help us track down where things are going wrong. If neither message shows when the NPC is enabled you could type SWAS1.evp into the console and it will tell you which package he's currently running.

Good Luck,

WT

The package conditions might be the problem. As far as which package he's running, I currently have only one on him. The package he runs has a "Must complete" flag so I'm wondering if that is why he ignores the script block.

My other "fix" also didn't work either. I'm now beginning to think I need the spell cast right before he is enabled.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...