Sleep spell troubles

Post » Wed Jun 20, 2012 11:00 am

So, I have a package I'm attacking to all of my actors that makes them go to sleep. Trouble is, you have to summon a bed for this to work. Here's how I'm trying to do that (and I'm eventually going to use an invisible bed on the floor)

   if Mage.GetFactionRank(DnDMageLevel) as int ==6	  int SleepCounter = 0	  int lvl6dam = Utility.RandomInt(2,8)	 ; hitactor.DamageAV("Health", lvl6dam)	  while SleepCounter <= 5	  		 Sleepcounter = SleepCounter + 1		 duration = duration + Utility.RandomInt(1,4)	  endwhile	  duration = duration/5   if d20roll >= akTarget.GetFactionRank(DnDSavingThrows) as int	  float height = akTarget.GetHeight()ObjectReference BedInstantiation = akTarget.PlaceAtMe(ImaginaryBed as Form)float BedHeight = BedInstantiation.GetHeight()float BedYPos = BedInstantiation.GetPositionY()float BedXPos = BedInstantiation.GetPositionX()float BedZPos = BedInstantiation.GetPositionZ()BedInstantiation.SetPosition(BedXPos, (BedYPos - BedHeight), BedZPos)	  ModDnDStat.ModStat(DnDSleepStatus, hitactor, 0, 1, duration)   endIfendIf

But unfortunately, the error log is telling me that BedInsantiation is a None type for some reason. Anyone know why?
User avatar
..xX Vin Xx..
 
Posts: 3531
Joined: Sun Jun 18, 2006 6:33 pm

Post » Wed Jun 20, 2012 9:25 pm

Placeatme will return non when it cannot create anything, but that should not be a problem for the compiler, right?
Have you tried specifically casting placeatme(ImaginaryBed) as objectreference (It should return this natively, but who knows)?
User avatar
Kara Payne
 
Posts: 3415
Joined: Thu Oct 26, 2006 12:47 am

Post » Thu Jun 21, 2012 12:44 am

It's not a problem for the compiler.. it'll compile, but the log is what really tells us whether a script is messed up or not.

Advice to everyone new to scripting: Don't be fooled by the compiler. Always check the logs..
User avatar
Tanya
 
Posts: 3358
Joined: Fri Feb 16, 2007 6:01 am

Post » Wed Jun 20, 2012 11:10 pm

Did you forget to set ImaginaryBed?
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Wed Jun 20, 2012 11:07 pm

I did not forgot to set ImaginaryBed, but it is an ObjectReference. The page for placeatme on the wiki says that it can't place other ObjectReferences, but I cast it as a form so I was hoping it would work. Anyone have an idea how to place an ObjectReference?
User avatar
kennedy
 
Posts: 3299
Joined: Mon Oct 16, 2006 1:53 am

Post » Thu Jun 21, 2012 1:53 am

akTarget.PlaceAtMe(ImaginaryBed.GetBaseObject()) 

Why not just use the base object instead of the object reference though?
User avatar
Ellie English
 
Posts: 3457
Joined: Tue Jul 11, 2006 4:47 pm


Return to V - Skyrim