tonycubed2 Posted May 12, 2012 Share Posted May 12, 2012 Greetings, This is for my mod Sands of Time. The mod supplies ambushes while sleeping or fasr traveling. Instead of having npcs spawn right next to sleeping player I would like to let them spawn sometimes outside the room. The player will wake up and "Hear a noise". But I cannot find papyrus code to scope out the inn or house and place an xmarker for the npcs to spawn. I need the script to perhaps look for other npcs and place an xmarker there with the move command. Any ideas? Link to comment Share on other sites More sharing options...
VileTouch Posted May 12, 2012 Share Posted May 12, 2012 short of placing the spawn points exactly where you want them by hand in every inn,house,etc... nope anyway, isn't it enough with the hired thugs that come after you for tripping over some vase or taking stuff from dead people's houses or killing wolves?...just sayin' Link to comment Share on other sites More sharing options...
tonycubed2 Posted May 12, 2012 Author Share Posted May 12, 2012 It makes sense in the context of my mod, check it out. I treid teh below, the seond line will not compile... SpawnInCell = Game.GetPlayer().GetParentCell() SpawnInCell.PlaceActorAtMe (Ambushers1, 1) Spawn in cell is a Cell variable deffined as such. Link to comment Share on other sites More sharing options...
fg109 Posted May 12, 2012 Share Posted May 12, 2012 Do you use SKSE functions in your mod? Link to comment Share on other sites More sharing options...
tonycubed2 Posted May 12, 2012 Author Share Posted May 12, 2012 Fg109: No, I do not. While I have it installed I really do not want to force players to use it. I do realize that it makes life harder since basically I need a non existent function. Link to comment Share on other sites More sharing options...
fg109 Posted May 12, 2012 Share Posted May 12, 2012 Static Property COCMarker Auto ;;; Actor Player = Game.GetPlayer() Actor TempActor int Count while !TempActor && (Count < 10) TempActor = Game.FindRandomActorFromRef(Player, 4096.0) if (TempActor == Player) TempActor = None endif Count += 1 endwhile if (TempActor) Debug.Trace("Found an actor within one cell length that's not the player!") TempActor.PlaceActorAtMe(Ambusher1, 1) Return endif ObjectReference MarkerRef = Game.FindClosestReferenceOfTypeFromRef(COCMarker, Player, 4096.0) if (MarkerRef) Debug.Trace("Found a COC marker within one cell length of the player!") MarkerRef.PlaceActorAtMe(Ambusher1, 1) else Debug.Trace("No COC markers or actors found within one cell length of the player.") endif ;;; Link to comment Share on other sites More sharing options...
tonycubed2 Posted May 12, 2012 Author Share Posted May 12, 2012 I Could cry with excitement !!! Will try soon! Link to comment Share on other sites More sharing options...
tonycubed2 Posted May 13, 2012 Author Share Posted May 13, 2012 fg109, you have earned the dubious distinction of co-credit on my mod page! http://skyrim.nexusmods.com/downloads/file.php?id=12452 Works good so far, with needed changes to fit my script. two questions thpugh: What if the player is sleeping outside though? where there is no other npc or coc? Is the best thing to do a outside location test and code the spawns a bit far assuming open space? see example below: and what if the player has a companion or pet? Can they be exempted from the npc check? How would you add that to the code? Thank again!! Tonycubed2 ;do outside distance spawning where spawn1 and 2 are xmarkers and hero is playerwhereA1 = Utility.RandomFloat(-1600,1600)whereA2 = Utility.RandomFloat(-1600,1600)whereB1 = Utility.RandomFloat(-1600,1600)whereB2 = Utility.RandomFloat(-1600,1600)Spawn1.MoveTo(OurHero,whereA1,whereA2,0)Spawn2.MoveTo(OurHero,whereB1,whereB2,0) Link to comment Share on other sites More sharing options...
fg109 Posted May 13, 2012 Share Posted May 13, 2012 You can add in a check for the NPC's rank in CurrentFollowerFaction. Obviously, this method of checking is not very reliable, because it relies on getting random actors around the player. With vanilla papyrus, you can only search for closest or random. If you are willing to use SKSE, GetNumRefs and GetNthRef will let you go through every actor in the cell, without needing to just pull one at random. Link to comment Share on other sites More sharing options...
Recommended Posts