Jump to content

Spawn a NPC?


Recommended Posts

oh my..... the hunting is begin lol

this is similar to ongoing comic I reading -- Yakusoku no Neverland

Willbur is not argonian !! XD XD

 

 

this is what I thought regarding your last posted script
- how to use the fancy box for code script is like this my friend without the underscore --> [_code_]Text_Here[_/code_]
- syntax GetPackageOffersServices is not reliable by itself, since the actor could change the package differently, so it should be accompanied by syntax GetActorPackages like my previous script
- in this case I'm afraid that is not how you should use SetOwnership like that, I have suggestion below
scn inkeeper1

short rent
short sleephour
short setup

ref rf1
ref rf2
array_var ar1

Begin GameMode
if rent
	if setup
		if GetPCMiscStat 20 != sleephour
			set rent to 0
			set setup to 0
			AnvilCountsArmsRentDoor.SetOpenState 0
			AnvilCountsArmsRentDoor.lock 30
			AnvilCountsArmsRentBed.SetOwnership
		endif
	else
		set sleephour to GetPCMiscStat 20
		set setup to 1
		AnvilCountsArmsRentDoor.unlock	
		AnvilCountsArmsRentBed.SetOwnership
	endif
endif
End

Begin OnDeath
	;Once character A dies, character B is spawned. I would like character b to spawn at a map marker at the entrance to town (anvil)
	Let rf2 := AnvilMapMarkerNEW.PlaceAtMe charB
	;merchant actor must provide merchant container to new guy/gal
	ForEach ar1 <- GetActorPackages
		Let rf1 := *ar1
		if GetPackageOffersServices rf1
			Let rf1 := GetMerchantContainer
			if rf1
				;the getmerchantcontainer command
				rf2.SetMerchantContainer rf1
				;set the owner of the calling script to a reference
				rf1.ClearOwnership
				rf1.SetOwner rf2
				break
			endif
		endif
	loop
End

EDIT : edited script slightly, less variables, more compact. syntax GetSelf removed -- I made a mistake there

Edited by lubronbrons
Link to comment
Share on other sites

you must clear ownership first that makes sense.. and the you are using set owner instead of set ownership, hmm

 

okay i see why you used loop now, in case he has more than one ai package. I am learning a lot.... so you have re-used rf1 a couple times?

 

im not sure why you have to set merchant container when you can set owner because a shopkeeper simply chooses from a chest that he owns

 

anyways thanks , very much =]

 

ps- how do I get the reference of the NPC that uses the script? GetBaseObject will that work?

Link to comment
Share on other sites

To get the npc that uses the script you could use GetSelf

 

Yeah,

We should clear the ownership before assign it to something else or it wouldn't work. This is based on my modding experience

 

Yes,

I did use rf1 for the sake of lightweight memory & compact code

My style of coding is like that, similar to go green campaign that prevent global warming issue :)

I reuse variables that could be reused. I like to keep my code like that, it's efficient, less resources

 

About merchant container,

I believe it is Not enough to set container owner to successor

If we not set successor to support previous merchant container, the successor will not sell any stuffs at all

 

Hmm...

I think I make another mistake

Just before this line --> rf1.SetOwner rf2

Should insert this line before it --> Let rf2 := rf2.GetBaseObject

...because I recall that set ownership syntax need base object rather than reference. If we use set ownership on reference it would Not work..

Link to comment
Share on other sites

Its a lot of commands to remember and little details, it's really cool that you know all that

Scriptname aarmPublicanCountsArmsWilburDEAD

;CellName: AnvilTheCountsArmsPrivateRooms
;Publican: Wilbur
;Room: Straight across from entry door
;Door Ref: AnvilCountsArmsRentDoor



short rent
short rentday
short rentmonth
short cleanup
short setup

short doonce
ref vendorchest
ref successor

begin gamemode


if ( doonce == 0 )    
    Let successor := Getself
    Let vendorchest := CountsArmsWilburChest  ; set vendor inventory chest here
    vendorchest.ClearOwnership
    Let vendorchest := vendorchest.GetBaseObject ;...because I recall that set ownership syntax need base object rather than reference
    vendorchest.SetOwner successor
    set doonce to 1
endif

    
if ( rent == 1 )
    
    if ( setup == 0 )
        set rentday to GameDay
        set rentmonth to GameMonth
        set setup to 1
        AnvilCountsArmsRentDoor.unlock    
        AnvilCountsArmsRentBed.SetOwnership

    else
    
        if ( GameDay != rentday )
            set cleanup to 1
        elseif ( GameMonth != rentmonth )
            set cleanup to 1
        endif
    endif

    if ( Player.GetinCell AnvilTheCountsArms == 0 )
        if ( Cleanup ==1 )
            set Cleanup to 2
        endif
    endif



    if ( Cleanup == 2 )
    
        set rent to 0
        set setup to 0
        set rentday to 0
        set rentmonth to 0
        set cleanup to 0
        AnvilCountsArmsRentDoor.SetOpenState 0
        AnvilCountsArmsRentDoor.lock 30
        AnvilCountsArmsRentBed.SetOwnership aaWilbur ;changed name from Wilbur
    endif
endif

End

i just put this on aaWilbur (char B)-- so I wrote the start of this script so I could use the codebox, and also because.... so what happened was I played oblivion today and gained like 50 skill points and I had already killed Wilbur... so when I load my most recent save the replacement inkeeper is already there and he has no inventory because I have now deleted the aaWilbur's chest from the mod... so now I need to switch the chest over to aaWilbur (charB) him because Wilbur (charA) already dead LOL. I dont know if this script will work but I will try it maybe there is a console command I can use also HAHA

 

hmm didnt work =[

Edited by masternoxx
Link to comment
Share on other sites

The way chests are put in Oblivion, many have the same base object, then they are put into the game, and then their REF name is changed. So maybe it is not a good idea to change him to the owner of the base object, because that chest is probably used for hundreds of references? Hmm not sure there

Link to comment
Share on other sites

quote : "Its a lot of commands to remember and little details, it's really cool that you know all that"
>>> it's not really cool as you think... scripting modding experience means == a bunch of trial & errors :tongue:
anyway glad this little me could be any help
Okay, this is what I thought regarding your last script (oh my... the script is growing, let me shrink it~)
here's my suggestion, now using template format, should makes your life easier
scn aarmPublicanCountsArmsWilburDEAD
short rent
short sleephour
short setup

short doonce

ref theOwner
ref theBed
ref theDoor
ref theChest

ref rf1

Begin OnDeath
	;Once character A dies, character B is spawned. I would like character b to spawn at certain location
	AnvilMapMarkerNEW.PlaceAtMe theOwner ;change REF map marker!
End
begin gamemode
if !doonce
	set doonce to 1
	;easy template
	Let theOwner := aaWilbur ;change the BASE OBJECT successor NPC! reminder base object ok?!
	Let theBed := AnvilCountsArmsRentBed ;change the REF bed inn!
	Let theDoor := AnvilCountsArmsRentDoor ;change the REF door inn!
	Let theChest := CountsArmsWilburChest  ;change the REF merchant container!
	
	theChest.ClearOwnership
	theChest.SetOwner theOwner
endif
if rent
	if setup
		if GetPCMiscStat 20 != sleephour
			set rent to 0
			set setup to 0
			theDoor.SetOpenState 0
			theDoor.lock 30
			theBed.SetOwnership
		endif
	else
		set sleephour to GetPCMiscStat 20
		set setup to 1
		theDoor.unlock
		theBed.SetOwnership theOwner
	endif
endif
End

 

in short... for each NPC you should only focus on this 6 lines of code

scn aarmPublicanCountsArmsWilburDEAD

	AnvilMapMarkerNEW.PlaceAtMe theOwner ;change REF map marker!
	Let theOwner := aaWilbur ;change the BASE OBJECT successor NPC! reminder base object ok?!
	Let theBed := AnvilCountsArmsRentBed ;change the REF bed inn!
	Let theDoor := AnvilCountsArmsRentDoor ;change the REF door inn!
	Let theChest := CountsArmsWilburChest  ;change the REF merchant container!
Edited by lubronbrons
Link to comment
Share on other sites

  • Recently Browsing   0 members

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