Jump to content

Event triggered upon entering a cell


Recommended Posts

I want to have a script that triggers some functions when the Player changes cells. Just to keep it simple, if I wanted to add an Ability to the Player that caused 1000000 gold to be added to the Player's inventory upon entering a cell, what would I have to do? Any help is really appreciated.

Edited by BrotherBob
Link to comment
Share on other sites

Do you want to do this once, for one specific cell, or are you going to want to trigger this multiple times? If just once, I think the least costly way is to set up a trigger box right on top of the door marker so that the player hits it immediately when entering. Have the trigger box add the gold. Game.GetPlayer().AddItem(Gold, 1000000, 0) If you want to do this multiple times, you can get a little fancier and set up a simple quest with the player as a quest alias. Then you can access the OnLocationChange() event. Also, if this is a vanilla cell, I would probably go the quest alias route just to avoid editing a vanilla cell by placing the trigger box.

Link to comment
Share on other sites

Thanks, Ishara. Looks like he does want this to happen multiple times. Sounds interesting, getting millions of septim each time you walk into a room! But yeah, the way to do that is definitely with an onlocationchange() event, which can be accessed via a quest alias placed on the player, as you said. It's not really that resource intensive. Beth uses it in number of ways for the vanilla quests, including the bounty quests. For example, each time you change locations in the vanilla game, the bounty quests look to see if an innkeeper is in the room and then gives them the bounty quest dialogue with the proper hold location info. Cool stuff.

Link to comment
Share on other sites

So, if I create a quest, and create a Player Reference, would I just add the script in the dialogue box for the Player Reference? Since I want it to trigger every time I enter an interior cell, would this work:

Event OnLocationChange(Location akOldLoc, Location akNewLoc)
if Game.GetPlayer().IsInInterior()
;the stuff I need to happen
endif
endEvent
Link to comment
Share on other sites

@IsharaMeradin: You implied on the other thread that I could possibly make what I wanted to happen occur as I walked through the many cells that make up Skyrim. Assuming that I did want this, would removing the above "if" statement allow that to occur. Nevermind, I tested it myself and it works as I would like.

 

@LP1: I've actually just been using the gold as a test to figure out if the script is running. It wasn't, but thanks to you and IsharaMeridan, it is now. The rest of the script actually involves stopping a series of quests and getting the players total bounty and then re-running some of the stopped quests based on that. The part I couldn't figure out was why Event OnCellAttach() wasn't working.

Edited by BrotherBob
Link to comment
Share on other sites

 

 

@IsharaMeradin: You implied on the other thread that I could possibly make what I wanted to happen occur as I walked through the many cells that make up Skyrim. Assuming that I did want this, would removing the above "if" statement allow that to occur.
Possibly. You would have to try it. If it does work, should whatever you want to take place be different than other locations then you would need to have further checks in place. Perhaps comparing the new location and/or old location to specific location properties or reading into a form list of specific locations.

 

OnCellAttach only works for objects and actors placed in that cell via the Creation Kit. Therefore any script running on the player would not process OnCellAttach.

 

Regarding the script snippet you posted earlier above. Yes, you would put the script in the script box on the player reference (aka player alias). Not sure what you mean by dialogue box tho.

Link to comment
Share on other sites

I have one more question. The quests I set to stop and re-run are quests that dynamically add an ability to enemies in the area. The idea is that it makes them have more health. I created an ability that has a magic effect. All I did to create the magic effect was set the Effect Archetype as Peak Value Modifier, the Casting Type as Constant Effect, the Delivery as Self, the Assoc. Item 1 as Health, and checked the Recovery and No Area flags. Weirdly, when I attack affected Actors, their health bar does not appear to go down until I damage them down to their normal health. I'm wondering what I did wrong. Any thoughts?

 

As for my use of "dialogue box", I just use that to refer to every new window that appears in the Creation Kit.

Edited by BrotherBob
Link to comment
Share on other sites

I think the way the health bar is working is the way it's supposed to work given the way you have it set up. By modding their health higher with the active effect, you're setting it above 100%, not raising what the 100% value is. To do the latter, you would probably need to adjust the base actor health rather than add a temporary health buff.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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