I need some help on house ownership

Post » Mon Nov 19, 2012 8:34 am

I've created a house that belongs to a custom faction that the owner is a part of (sole ownership). How do I allow the player to become the owner after killing this NPC? A link to a tutorial or a quick rundown would be much appreciated.
User avatar
Taylrea Teodor
 
Posts: 3378
Joined: Sat Nov 18, 2006 12:20 am

Post » Mon Nov 19, 2012 8:09 am

I believe you can just use http://www.creationkit.com/AddToFaction_-_Actor to add the player to the ownership faction. I've never done it personally, but that should give the player ownership over all items in the cell.
User avatar
Darlene Delk
 
Posts: 3413
Joined: Mon Aug 27, 2007 3:48 am

Post » Mon Nov 19, 2012 10:58 am

Thanks. That sounds exactly what I was hoping for. Now to just figure out how to implement it. :smile: Mainly, how do I trigger the script to activate on the NPC's death? I'm guessing I use an OnDeath event?
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Mon Nov 19, 2012 4:51 pm

Yeah, you should be able to simply use an OnDeath event to add the player into that faction.
User avatar
Claire
 
Posts: 3329
Joined: Tue Oct 24, 2006 4:01 pm

Post » Mon Nov 19, 2012 7:34 am

Thanks again. I happen to know next to nothing about scripting (I've done player activated triggers and that's about it) so it looks like it is time to do some studying.
User avatar
courtnay
 
Posts: 3412
Joined: Sun Nov 05, 2006 8:49 pm

Post » Mon Nov 19, 2012 1:12 pm

Just to be safe, can someone glance over my script to see if everything is correct?

Scriptname DJHermitHouseOwnership extends ObjectReferenceFaction property DJHermitHouse0001Faction autoEvent OnDeath(Actor akKiller)  if (akKiller == Game.GetPlayer())	Game.GetPlayer().AddToFaction(DJHermitHouse0001Faction)  endIfendEvent
User avatar
Darian Ennels
 
Posts: 3406
Joined: Mon Aug 20, 2007 2:00 pm

Post » Mon Nov 19, 2012 5:20 am

Looks good, just put that on the NPC that needs to die for the player to get ownership.

On a minor note, it's more efficient if you make the player a property instead of using Game.GetPlayer. Just add this part:

ObjectReference Property PlayerRef Auto

Click AutoFill so it's directed to the player, then use PlayerRef instead of 'Game.GetPlayer()'. Your script will run faster as a result. :)
User avatar
Sanctum
 
Posts: 3524
Joined: Sun Aug 20, 2006 8:29 am

Post » Mon Nov 19, 2012 10:33 am

Using PlayerRef, I get an error while compiling:
"AddToFaction is not a function or does not exist"

Script:
Scriptname DJHermitHouseOwnership extends ObjectReferenceObjectReference Property PlayerRef AutoFaction property DJHermitHouse0001Faction autoEvent OnDeath(Actor akKiller)  if (akKiller == PlayerRef)	PlayerRef.AddToFaction(DJHermitHouse0001Faction)  endIfendEvent

http://i116.photobucket.com/albums/o22/98LS1TA/script1.jpg
User avatar
Katy Hogben
 
Posts: 3457
Joined: Mon Oct 30, 2006 12:20 am

Post » Mon Nov 19, 2012 4:51 am

Try:
Actor Property PlayerRef  Auto
See if that works

- Hypno
User avatar
Carlos Vazquez
 
Posts: 3407
Joined: Sat Aug 25, 2007 10:19 am

Post » Mon Nov 19, 2012 12:09 pm

Ah, right. AddToFaction is an actor function, so you need to cast the player. Do

(PlayerRef as Actor).AddToFaction(MyFaction).

That should work.

EDIT: Or as Hypno said, you can make the player property actor instead of objectreference. Sorry about that, I totally forgot. :P
User avatar
Susan
 
Posts: 3536
Joined: Sun Jun 25, 2006 2:46 am

Post » Mon Nov 19, 2012 8:28 pm

Yup, changing it to Actor allowed it to compile. Thanks for all the help.

Final script:
Scriptname DJHermitHouseOwnership extends ObjectReferenceActor Property PlayerRef AutoFaction property DJHermitHouse0001Faction autoEvent OnDeath(Actor akKiller)  if (akKiller == PlayerRef)	PlayerRef.AddToFaction(DJHermitHouse0001Faction)  endIfendEvent
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm


Return to V - Skyrim