Jump to content

Yet another person needing script help


raverbane

Recommended Posts

I am new to modding and can use any help folks can provide.

 

I'm working on a script that uses a hotkey token to summon an npc to fight for the player. After many hours of trial and error. The hotkey function works. The npc will finally follow the player through doors and load screens. The scalable weapon and armor seem to be scaling and the npc actually get dead/unconscious when appropriately damaged. And I figured out how make the quest that will dimiss the NPC.

 

Then I discovered something I didnt want to happen and after several more hours of keyboard banging and web surfing, I cant seem to get around.

 

Here is a copy of the scrip:

 

Scriptname SummonHollyScript

 

BEGIN OnEquip

 

Player.UnequipItem ActivateHolly 0 1

Player.PlaceAtMe Holly

 

END

 

BEGIN OnDrop

 

disable

markfordelete

if ( Player.GetItemCount ActivateHolly < 1 )

Player.AddItem ActivateHolly 1 1

endif

 

END

 

 

Now, the problem is I only want the player to have one Holly out at any one time. As it stands. You can have as many Holly's out as your video card can handle. Hit the hotkey. Poof there is one. Hit it again and another. So on and so forth.

 

It was kinda funny to see over twenty of them running around Quarry Junction blasting away willy-nilly. But, that wasnt my intention.

 

If anyone can clue me in on how to make the script so that the player can only have one Holly at a time. It would be greatly appreciated.

Link to comment
Share on other sites

just gonna use the code /code with brackets for people to read

 

BEGIN OnEquip

Player.UnequipItem ActivateHolly 0 1
Player.PlaceAtMe Holly

END

BEGIN OnDrop

disable
markfordelete
if ( Player.GetItemCount ActivateHolly < 1 )
Player.AddItem ActivateHolly 1 1
endif

END

Link to comment
Share on other sites

Possibly the easiest way would be to just have a global variable which "counts" the number active, an OnLoad block on the NPC increments it, and an OnDeath (probably different, maybe different script, depending on how you remove them) would decrement the counter. The script above which does the summoning then checks against that variable to ensure that there is less than 1 or w/e you want the max to be before summoning.

 

It may still be possible to bug if you can activate the token a number of times before an NPC is loaded, but a simple delay built in that should be able to stop any chance of that (after summoning, a 5s delay must pass before another can be summoned, or something like that, it probably won't go into the above script, I'd need to see the others to suggest where).

 

Using dynamically created references (PlaceAtMe) doesn't leave you with too many other options, it's far from the best choice if you're only dealing with a small number of NPC's. If the max is only going to be one, you could just place it in a cell somewhere, mark it as persistent and use MoveTo, enable/disable instead.I'm not sure if it's possible to have leveled items re-evaluate, but since you're using NVSE it could just as easily be done manually with a form list anyway.

Edited by Skevitj
Link to comment
Share on other sites

Possibly the easiest way would be to just have a global variable which "counts" the number active, an OnLoad block on the NPC increments it, and an OnDeath (probably different, maybe different script, depending on how you remove them) would decrement the counter. The script above which does the summoning then checks against that variable to ensure that there is less than 1 or w/e you want the max to be before summoning.

 

It may still be possible to bug if you can activate the token a number of times before an NPC is loaded, but a simple delay built in that should be able to stop any chance of that (after summoning, a 5s delay must pass before another can be summoned, or something like that, it probably won't go into the above script, I'd need to see the others to suggest where).

 

Using dynamically created references (PlaceAtMe) doesn't leave you with too many other options, it's far from the best choice if you're only dealing with a small number of NPC's. If the max is only going to be one, you could just place it in a cell somewhere, mark it as persistent and use MoveTo, enable/disable instead.I'm not sure if it's possible to have leveled items re-evaluate, but since you're using NVSE it could just as easily be done manually with a form list anyway.

 

Since I am still trying to crawl through modding before I walk. I'm trying to keep things as simple as possible. I have read about the method you described using a cell with a persistent NPC that is simply teleported to the player. From what I meagerly undestand, that doesnt lend itself to scalable items. And that is an important aspect of what I am trying to do. I want the summoned NPC to have the same look and weapon through the entire player level progression. But, to keep things balanced. The power of the items level up as the player does.

 

As far as other scripts. That is the only script I am using. That script summons the NPC and I have a quest for dismissing the NPC.

Edited by raverbane
Link to comment
Share on other sites

How are you doing the scaled items? Just a leveled item in the NPC's inventory?

 

If you're doing it that way, the easiest way would be to attach an onload block to the NPC's script which would determine the level of the NPC and give the appropriate weapon, remove the others. With the weapons to be given just placed in a form list in a similar way to the leveled item. It requires a few NVSE functions, but it relatively simple to implement.

 

That said, if you're dealing with the cleanup properly (disable-> markfordelete on the NPC when removed) placeatme should be fine, and a counter should be sufficient for keeping track of them

Link to comment
Share on other sites

How are you doing the scaled items? Just a leveled item in the NPC's inventory?

 

If you're doing it that way, the easiest way would be to attach an onload block to the NPC's script which would determine the level of the NPC and give the appropriate weapon, remove the others. With the weapons to be given just placed in a form list in a similar way to the leveled item. It requires a few NVSE functions, but it relatively simple to implement.

 

That said, if you're dealing with the cleanup properly (disable-> markfordelete on the NPC when removed) placeatme should be fine, and a counter should be sufficient for keeping track of them

 

Hmm, ok. Thanks! I'll break out my hammer and start banging away at it!

Link to comment
Share on other sites

hopefully this works for you, its designed to make there be only 1 holly and deal with summoning and dismissing her:

 

 

SCN SummonHollyScript

; when the player equips the token holly will be summoned or dismissed, when the player drops the token it will readd itself to their inventory.

BEGIN OnEquip player
Player.UnequipItem ActivateHolly 0 1
if hollyREF.GetDisabled == 1 ; if holly is dismissed and the token is activated, enable and move her to you.
HollyREF.enable
HollyREF.MoveTo Player   
else						 ; otherwise if she is enabled, disable her.
HollyREF.disable 
endif	
; get rid of the placeatme and go with moveto on a reference,
; you need to make a persistant reference of holly by dragging 
; a copy into the render window somewhere in the world and setting 
; it as a persistant reference and naming it hollyREF.  from now on
; this is the only holly, which also opens her up for inventory trading.
END

BEGIN OnDrop ; if the player drops the token, disable and delete it, then add a new one.
disable
markfordelete
if ( Player.GetItemCount ActivateHolly < 1 )
Player.AddItem ActivateHolly 1 1
endif

END

 

 

oh and dont worry about scaling.

more than likely the player is going to want to outfit the npc themselves, and seeing how only certain items are available at certain levels the npc will end up scaling naturally with the player as the better equipment is available and they decide to outfit her with it.

 

if you really really want that control over her equipment yourself and want to deny the player that control you can pretty easily set up a few different equipment lists in formlists and then substitute the formlist name for the objectID with hollyREF.additem formlistID 1 which will add 1 of everything in that list. right before you do that though use hollyREF.removeallitems to clear out her inventory so that the new equipment is all she has to equip.

Edited by angelwraith
Link to comment
Share on other sites

  • Recently Browsing   0 members

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