Jump to content

Instantiate


Recommended Posts

I must be getting my engines mixed up as I thought I was doing an instantiate - maybe PlaceAtMe but I did not use it. I remember working out how to eradicate save bloat with PlaceAtMe but I did not use it.

Looking at CS and OBSE functions it would seem that PlaceAtMe is the only way to 'Instantiate', is this correct?

Link to comment
Share on other sites

As i understand it from the CS Wiki about PlaceAtMe is that we should be restricted by using it for objects we want to keep in game. Wrye bash are also good in finding blots what i have seen. I use it for spawning enemies with my current WIP, to keep the cells clean from conflicts, in case other modder's makes changes in the same dungeons I use. At least i do not dirty them. I port some rats into the dungeon, they spawn the enemies with PlaceAtMe, you kill them, they are gone after 3 days when the cell resets. If some escapes and runs out, no big deal but the limit is 20 PlaceAtMe in game CS Wiki say. I think 1 enemy NPC took off with a test package. I try to track them all and maybe I killed them all. I think so... :wink: I saw in which direction he went and also found it in that package in CSE. I think he was killed by some bandits, those north of Anvil, Highway Rubbers, in that T junction that leads to the Inn and Lord Dred's Farm. I have my house there too, just before that T-junction. As far as i can remember, it is 1 robber there but with MOO, it is 3. Well they took down my escaping enemy. :D They are set to be friendly until you talk to them

 

-Give me your money or... bla bla

 

It is rare a NPC runs off but if they are close to a door they can. But I made sure my enemies in my current project have confidence 100 so you cannot scare them off, well with fear you might succeed. :wink: Honestly, I rarely use fear. I should use it in my new Skyrim play through as my new char is very weak right now. I am to OP in Oblivion to need fear at all. So different to play both really... Use your own judgement with PlaceAtMe. use that 50 times in a cell that do not reset, you will maybe get bloats. I do guess we can spawn more then 20 but the author of that wiki page had to set a limit with a number. In cells that will reset, it should not matter at all. I spawned 400 enemies in my current play though, a rough number. 22 dungeons with 22 enemies in each, divided to all cells... 444 enemies right? My save is fast as lightning still. When I check it for Bloats, I find some enchanted stuff I made and named with a, put in a chest for sale with a trading mod. Not a single word about any NPC. and also 2 NULL objects. I think i am fine honestly.

 

I babble so much... What do you want to spawn with PlaceAtMe and where?

Edited by Pellape
Link to comment
Share on other sites

Thank you for answering my question in detail Pellape, As far as your questions, I should have presented them to start with.

 

The mod is survival based with a significant amount of time underwater, possibly to great depths but I have to work that out.

 

What I need to resolve is static versus procedural placed enemy. Static placement will result in under or overwhelming player opposition. Procedural will allow analysis and calculation of player danger levels.

 

To be honest, I should be asking for people to help me on this mod but they, of course, are too busy with their mod.

 

Maybe I should offer to help on other people's mod's while my Ukraine friends are unable to do anything.

Link to comment
Share on other sites

That sounds like a good idea. :smile:

 

Do test my spawning that my rats do. It does work very great. Another way is to do like Maskar is doing except it is so hard to follow all his nested functions.

 

Lets peek at my rat first:

Scn pekBurglarRatSCR

Short State 
Short TurnToMoveRat
Short SameCellasPlayer
Short InaaPekDummy
Short RatNumber
Short Initiated
Short RatActivated

Float Timer
Float RatSeconds

Ref ME


Begin GameMode

	Set ME to getself
	Set SameCellasPlayer to ME.getInSaMECell Player
	Set InaaPekDummy to ME.GetInCell aaPekDummy

	
	If ( InaaPekDummy == 1 )
		Set TurnToMoveRat to 0
		Set State to 0
		Set Timer to 0
		
		ME.Disable
		Return
	EndIf

	If ( Initiated == 0 )
		Set RatNumber to SetRatNumberFUN ME
		Set Initiated to 1
		PrintC "Rat %.0f Initiade", Ratnumber
	EndIf
	
	Let RatActivated := PekBookBurglarTrackingQST.RatActivatedArr[RatNumber]
	
	If ( RatActivated == 1 && SameCellasPlayer == 1 )
		Set State to 1
		Let PekBookBurglarTrackingQST.RatActivatedArr[RatNumber] := 0
	EndIf
	
	If ( State == 1 )
		PrintC "%i %n status", ME, ME
		Set Timer to RAND 1 3
		Set State to 2
	EndIf 
	
	If ( State == 2 )
		Set RatSeconds to RatSeconds + GetSecondsPassed
		If ( Timer > RatSeconds )
			Set State to 3
			Set Timer to 0
			Set RatSeconds to 0
			Me.Enable
		EndIf
	Endif
	
	If ( State == 3 )
		Set RatSeconds to RatSeconds + GetSecondsPassed
		If ( RatSeconds > 1 )
			Set RatSeconds to 0
			Set State to 4
		Endif
	EndIf
	
	If ( State == 4 )
		If eval ( Me == PekBurglarRat01 )
			PrintC "Råtta 1 placerade Book Burglar 1"
			PekBurglarRat01.PlaceAtme PekBookBandit0001 1
		ElseIf Eval ( Me == PekBurglarRat02 )
			PrintC "Råtta 2 placerade Book Burglar 2"
			PekBurglarRat02.PlaceAtme PekBookBandit0002 1
		ElseIf Eval ( Me == PekBurglarRat03 )
			PrintC "Råtta 3 placerade Book Burglar 3"
			PekBurglarRat03.PlaceAtme PekBookBandit0003 1
		ElseIf Eval ( Me == PekBurglarRat04 )
			PrintC "Råtta 4 placerade Book Burglar 4"
			PekBurglarRat04.PlaceAtme PekBookBandit0004 1
		ElseIf Eval ( Me == PekBurglarRat05 )
			PrintC "Råtta 5 placerade Book Burglar 5"
			PekBurglarRat05.PlaceAtme PekBookBandit0005 1
		ElseIf Eval ( Me == PekBurglarRat06 )
			PrintC "Råtta 6 placerade Book Burglar 6"
			PekBurglarRat06.PlaceAtme PekBookBandit0006 1
		ElseIf Eval ( Me == PekBurglarRat07 )
			PrintC "Råtta 7 placerade Book Burglar 7"
			PekBurglarRat07.PlaceAtme PekBookBandit0007 1
		ElseIf Eval ( Me == PekBurglarRat08 )
			PrintC "Råtta 8 placerade Book Burglar 8"
			PekBurglarRat08.PlaceAtme PekBookBandit0008 1
		ElseIf Eval ( Me == PekBurglarRat09 )
			PrintC "Råtta 9 placerade Book Burglar 9"
			PekBurglarRat09.PlaceAtme PekBookBandit0009 1
		ElseIf Eval ( Me == PekBurglarRat10 )
			PrintC "Råtta 10 placerade Book Burglar 10"
			PekBurglarRat10.PlaceAtme PekBookBandit0010 1
		ElseIf Eval ( Me == PekBurglarRat11 )
			PrintC "Råtta 11 placerade Book Burglar 11"
			PekBurglarRat11.PlaceAtme PekBookBandit0011 1
		ElseIf Eval ( Me == PekBurglarRat12 )
			PrintC "Råtta 12 placerade Book Burglar 12"
			PekBurglarRat12.PlaceAtme PekBookBandit0012 1
		ElseIf Eval ( Me == PekBurglarRat13 )
			PrintC "Råtta 13 placerade Book Burglar 13"
			PekBurglarRat13.PlaceAtme PekBookBandit0013 1
		ElseIf Eval ( Me == PekBurglarRat14 )
			PrintC "Råtta 14 placerade Book Burglar 14"
			PekBurglarRat14.PlaceAtme PekBookBandit0014 1
		ElseIf Eval ( Me == PekBurglarRat15 )
			PrintC "Råtta 15 placerade Book Burglar 15"
			PekBurglarRat15.PlaceAtme PekBookBandit0015 1
		ElseIf Eval ( Me == PekBurglarRat16 )
			PrintC "Råtta 16 placerade Book Burglar 16"
			PekBurglarRat16.PlaceAtme PekBookBandit0016 1
		ElseIf Eval ( Me == PekBurglarRat17 )
			PrintC "Råtta 17 placerade Book Burglar 17"
			PekBurglarRat17.PlaceAtme PekBookBandit0017 1
		ElseIf Eval ( Me == PekBurglarRat18 )
			PrintC "Råtta 18 placerade Book Burglar 18"
			PekBurglarRat18.PlaceAtme PekBookBandit0018 1
		EndIf
		Set State to 666
		ME.Disable	
	EndIf	

End	

It will cause a bit of LAG during the spawning, as 18 rats do this at the sane time and sometimes even 22 rats. When they get disabled, they move back ti the dummy cell where they came from and I think the burglars move them or I added it in the rats script as this is not maybe the final version. It can be the quest too. never Mind. It works.

 

So what does Maskar do?

 

He use nested level lists. He copy a monster from the list into RAM and paste it in some way into the game. I was not patient enough to see every stage as I only took a quick peek in his scripts. But the way he do it is very clean and it cause no LAG as far as I have noticed. We cannot add NPC nor creature to a level list in they use low level processing. So when he copied the NPC from the list, he sets them to Low Level Processing before he place them in game.

 

Lets peek at Maskar's notice board. So when a note comes up of a criminal that are on the loose, that criminal will move around, hide in different caves around the area he is hiding in, all in real time, well almost as you know, the further away we are, the slower low level processing will get or almost stand still. I guess it is 5 seconds delay in an objects script if the target is not in the same area as we are, sometimes longer or the script can be in a pause state until we get close. I do not know exactly what is going on honestly. This is what i observed in game. That NPC is copied from the level list, and immediately set to Low level processing and it will move. When the notice board updates where the criminal has been seen, we have to act fast and get there. But we can still get there to late. But mostly the target is there.

 

Good luck reading his scripts and makes something useful from them. But who knows? Maybe you succeed to make a script that will be easier to read than his is? If he did not use so many functions inside functions, nested them so you get so bloody dizzy that you will loose: Where the hell am I, from which script is this function now again?? Well then more modder's would have used his genius way of solving similar stuff. MOO is the cleanest Overhaul ever made. He know what he is doing for sure. I do try to read his scripts to see how he did solve stuff.

 

My burglars are LVL Offset but has no low processing. They do not spawn until you enter the cell where the rats are. They are not set to low level processing as I do not want them to do anything, if I am not in the same cell. Sometimes you will see the rats when they spawn the burglars and disappears as they not always end up at the coordinates I set or do they? Some dungeons have many doors, so I try to avoid placing them so you see them if you enter a dungeon the right way.

 

I try to think the Burglars are rats that transforms into humans if I see it in game, the spawning. What is a burglar anyway? Is he not a bloody rat? A thief is a bloody rat... :wink: I am a bloody rat.

 

The rats can spawn NPC with Low level processing. I need 4 Assassins to spawn in their HQ, with Low Level Processing set. Checking a static placed enemy to respawn? Well it does not work.

 

 

 

In that incomplete script above... A line in the end say: Set state to 666... I think 666 moves the rat back to the dummy cell. I better load CSE and peek at the latest version of the script. As that one works perfect.

Edited by Pellape
Link to comment
Share on other sites

This is the latest version. Before the rat disable it self in the end, it moves out.

Scn pekBurglarRatSCR

Short State 
Short TurnToMoveRat
Short SameCellasPlayer
Short InaaPekDummy
Short RatNumber
Short Initiated
Short RatActivated


Float Timer
Float RatSeconds

Ref ME


Begin OnActivate 

	Message "*poking*"                              ; In case their script stopped to run, which did happen at some point earlier, in an older version
	PrintC "Clicking %i %n", ME, ME
	
End


Begin GameMode
	
	Set ME to getself
	Set SameCellasPlayer to ME.GetInSameCell Player
	Set InaaPekDummy to ME.GetInCell aaPekDummy

	
	If ( InaaPekDummy == 1 )
		Set TurnToMoveRat to 0
		Set State to 0
		Set Timer to 0
		
		ME.Disable
		Return
	EndIf

	If ( Initiated == 0 )
		Set RatNumber to Call SetRatNumberFUN ME
		Set Initiated to 1
		PrintC "Rat %.0f Initiade", Ratnumber
	EndIf
	
	Let RatActivated := PekBookBurglarTrackingQST.RatActivatedArr[RatNumber]
	
	If ( RatActivated == 2 )
		ME.Disable
		Let PekBookBurglarTrackingQST.RatActivatedArr[RatNumber] := 0
		Set RatActivated to 0
	EndIf
	
	If ( RatActivated == 1 ) && ( SameCellasPlayer == 1 )
		Me.Enable
		Set State to 1
		Let PekBookBurglarTrackingQST.RatActivatedArr[RatNumber] := 0
		Set RatActivated to 0
	EndIf
	
	If ( State == 1 )
		PrintC "%i %n status", ME, ME
		Set Timer to RAND 1 3
		Set State to 2
		Set RatSeconds to 0
	EndIf 
	
	If ( State == 2 )
		Set RatSeconds to RatSeconds + GetSecondsPassed
		If ( RatSeconds > 10 )
			Set RatSeconds to 0
		EndIf
		
		If ( Timer < RatSeconds )
			Set State to 3
			Set Timer to 0
			Set RatSeconds to 0
			Me.Enable
		EndIf
	Endif
	
	If ( State == 3 )
		Set RatSeconds to RatSeconds + GetSecondsPassed
		If ( RatSeconds > 1 )
			Set RatSeconds to 0
			Set State to 4
		Endif
	EndIf
	
	If ( State == 4 )
		If eval ( Me == PekBurglarRat01 )
			PrintC "Råtta 1 placerade Book Burglar 1"
			PekBurglarRat01.PlaceAtme PekBookBandit0001 1
		ElseIf Eval ( Me == PekBurglarRat02 )
			PrintC "Råtta 2 placerade Book Burglar 2"
			PekBurglarRat02.PlaceAtme PekBookBandit0002 1
		ElseIf Eval ( Me == PekBurglarRat03 )
			PrintC "Råtta 3 placerade Book Burglar 3"
			PekBurglarRat03.PlaceAtme PekBookBandit0003 1
		ElseIf Eval ( Me == PekBurglarRat04 )
			PrintC "Råtta 4 placerade Book Burglar 4"
			PekBurglarRat04.PlaceAtme PekBookBandit0004 1
		ElseIf Eval ( Me == PekBurglarRat05 )
			PrintC "Råtta 5 placerade Book Burglar 5"
			PekBurglarRat05.PlaceAtme PekBookBandit0005 1
		ElseIf Eval ( Me == PekBurglarRat06 )
			PrintC "Råtta 6 placerade Book Burglar 6"
			PekBurglarRat06.PlaceAtme PekBookBandit0006 1
		ElseIf Eval ( Me == PekBurglarRat07 )
			PrintC "Råtta 7 placerade Book Burglar 7"
			PekBurglarRat07.PlaceAtme PekBookBandit0007 1
		ElseIf Eval ( Me == PekBurglarRat08 )
			PrintC "Råtta 8 placerade Book Burglar 8"
			PekBurglarRat08.PlaceAtme PekBookBandit0008 1
		ElseIf Eval ( Me == PekBurglarRat09 )
			PrintC "Råtta 9 placerade Book Burglar 9"
			PekBurglarRat09.PlaceAtme PekBookBandit0009 1
		ElseIf Eval ( Me == PekBurglarRat10 )
			PrintC "Råtta 10 placerade Book Burglar 10"
			PekBurglarRat10.PlaceAtme PekBookBandit0010 1
		ElseIf Eval ( Me == PekBurglarRat11 )
			PrintC "Råtta 11 placerade Book Burglar 11"
			PekBurglarRat11.PlaceAtme PekBookBandit0011 1
		ElseIf Eval ( Me == PekBurglarRat12 )
			PrintC "Råtta 12 placerade Book Burglar 12"
			PekBurglarRat12.PlaceAtme PekBookBandit0012 1
		ElseIf Eval ( Me == PekBurglarRat13 )
			PrintC "Råtta 13 placerade Book Burglar 13"
			PekBurglarRat13.PlaceAtme PekBookBandit0013 1
		ElseIf Eval ( Me == PekBurglarRat14 )
			PrintC "Råtta 14 placerade Book Burglar 14"
			PekBurglarRat14.PlaceAtme PekBookBandit0014 1
		ElseIf Eval ( Me == PekBurglarRat15 )
			PrintC "Råtta 15 placerade Book Burglar 15"
			PekBurglarRat15.PlaceAtme PekBookBandit0015 1
		ElseIf Eval ( Me == PekBurglarRat16 )
			PrintC "Råtta 16 placerade Book Burglar 16"
			PekBurglarRat16.PlaceAtme PekBookBandit0016 1
		ElseIf Eval ( Me == PekBurglarRat17 )
			PrintC "Råtta 17 placerade Book Burglar 17"
			PekBurglarRat17.PlaceAtme PekBookBandit0017 1
		ElseIf Eval ( Me == PekBurglarRat18 )
			PrintC "Råtta 18 placerade Book Burglar 18"
			PekBurglarRat18.PlaceAtme PekBookBandit0018 1
		EndIf
		Set State to 666
		ME.Moveto PekBookQuestRatXRef
		ME.Disable	
	EndIf	

End

I cannot find which script checks if the rat state is 666 but I do think I set that number to make the rats to do nothing at all. Just stand still in the dummy cell until a call function from the quest script sets the state on a rat to ... No ... It sets its state to 1 when the player enter the same cell. Then the timer starts

 

Why do I have a timer? Well to let the dungeon update first. Settle down a bit, when FPS is high, then the rat spawns the NPC, cause some LAG that goes away as soon as the rats left. It will take some time for the burglars to wake up. I do that with update3d and evp ones in their own scripts.

 

Well the burglars use this script. I want them to be disabled when they fot looted. They do all have more items than 3 in their inventory. If they gets looted, they have less than 3 and then I want them to go away with a magic effect and a sound, just for fun and it looks cool. Then my pets stops to loot them, as they check corpses. I use scripts that disable and auto loot everything, well NPC's and creatures.

 

Never mind that. This is the Burglar script:

Scn PekBookBurglarsDungeonSCR

Short Cell 
Short Looted
Short Burglars
Short BurglarsKilledBonus
Short Inactivate
Short State 
Short RatMoved
Short Initiated
Short RatNumber

Float Seconds

Ref Me
Ref RatRef
Ref EmptyRef

Begin GaMeMode 

	If ( State == 0 )
		Set State to 20 
	EndIf

	Set Me to Getself
	Set Looted to Me.GetNumItems
	Set EmptyRef to 0

	If ( State == 10 )
		Set Cell to PekBurglarRat02.GetInCell aaPekDummy
		Let PekBookQST.BurglarsRessed += 1
		Set Burglars to PekBookQST.BurglarsRessed
		PrintC "%.0f Looted. %n är i Dummy = %.0f", Burglars, RatRef, Cell 
		Set State to 20
	ElseIf ( State < 10 )
		Let State += 1
	EndIf

	If ( Inactivate )
		Return
	EndIf
	
	If ( Me.GetDead )
		If ( Ratmoved == 0 )
			If Eval ( Ratref != EmptyRef )
				;RatRef.MoveTo Me
				RatRef.Disable
			EndIf
			Set RatMoved to 1
		EndIf
		
		If ( Looted < 3 )
			If ( Me.GetDead )
				pme STRP
				Set BurglarsKilledBonus to PekBookQST.BurglarsKilledBonus 
				Set PekBookQST.BurglarsKilledBonus to BurglarsKilledBonus + 1
				Set BurglarsKilledBonus to PekBookQST.BurglarsKilledBonus
				PrintC "%n is looted and bonus = %.0f", Me, BurglarsKilledBonus
			EndIf

			playsound SPLMysticismFail
			If Eval ( Ratref != EmptyRef )
				Set RatNumber to Call SetBurglarNumberFUN Me
				RatRef.Moveto PekBookQuestRatXRef
				Call PekSimpleRatMoveToaaPekDummyFun Me
				Let PekBookBurglarTrackingQST.RatActivatedArr[RatNumber] := 1
			Endif
			Set Inactivate to 1
			Set State to 1

		EndIf
	Else

		Set State to 20

		If ( Initiated == 0 )
			If ( Me.getInSameCell player )
				Set Seconds to Seconds + GetSecondsPassed
				If ( Seconds > 3 && Seconds < 4 ) 
					Set RatRef to Call PekBurglarInitiateItselfFun Me
					Set Initiated to 1
				EndIf
			EndIf
		EndIf
	Endif

	
End
 
I used to have the burglars in my dummy cell, but they are not stored there any longer as that is how I started this, by placing them in that dummy cell, testing what was possible and not. The rats place them in game from scratch. All referenes to my dummy cell in this last script has no function really as it is a rest fron the past. It does not break anything, so I was lazy and kept it - So pointless really. :wink: The rats it refers to was tracking rats, to allow me to track the burglars, so I could see them on the map. It really not work to well, so I flushed it. That script could need a clean up a sunny day... Somewhere later...

 

When you completed the quest or whenever you feel like it, you will get a bonus from my Librarian. So each burglar updates the bonus in the quest and the Librarian checks the quest and gives the bonus to the player.

Edited by Pellape
Link to comment
Share on other sites

  • Recently Browsing   0 members

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