New to Papyrus, If cell IsLoaded

Post » Wed Feb 08, 2017 4:55 am

I am trying to wrap my head around this new papyrus system as I used to work with the old construction kit a lot.



My problem is I am trying to find a way to have a statement return true if the player is near a certain a cell but the IsLoaded thingy is not working for me. The name of the cell I want to check for is SCHLocation. Maybe I am not referencing the cell correctly or maybe the Isloaded thing is not working correctly in special edition.



The main idea behind this script is to have one spell that will teleport the player to my house location and place a marker and their departure point, assuming they are out of combat and not in an interior space. Then when they want to return they can use the same spell to teleport back to where they first cast the spell if the spell is used near the house location.



Here is my current code:



Scriptname SCHteleport extends activemagiceffect
{SCHTeleport script}

ObjectReference Property SCHRecallMarker Auto

ObjectReference Property SCHHomeMarker Auto

Cell Property SCHLocation Auto

Event OnEffectStart(Actor target, Actor caster)
Cell CurCell = caster.GetParentCell()
bool CasterCom = caster.IsInCombat()
if (SCHLocation.IsLoaded())
caster.MoveTo(SCHRecallMarker)
else
if (CurCell.IsInterior())
Debug.Notification("This spell does not work indoors.")
elseif (CasterCom == 1)
Debug.Notification("This spell does not work while in combat.")
else
SCHRecallMarker.MoveTo(caster)
caster.MoveTo(SCHHomeMarker)
endif
endif
EndEvent
User avatar
Johanna Van Drunick
 
Posts: 3437
Joined: Tue Jun 20, 2006 11:40 am

Post » Tue Feb 07, 2017 10:34 pm

Check out the mark and recall mods. They do something similar to what you want. isLoaded is not really needed.

User avatar
jeremey wisor
 
Posts: 3458
Joined: Mon Oct 22, 2007 5:30 pm

Post » Tue Feb 07, 2017 2:43 pm

The cell will only be loaded if the player is close to it, so you'd be limiting the range of this spell. Is that really the intent?



Also, if you declare a variable as bool, just test it with "if varname" rather than "if varname == 1", it's false if it's zero, but the true value is not necessarily 1.

User avatar
Cody Banks
 
Posts: 3393
Joined: Thu Nov 22, 2007 9:30 am

Post » Tue Feb 07, 2017 5:32 pm

Thanks for the help so far. To answer a few questions: Yes, I have looked at the mark and recall mods. I scryed most of the mechanics of how to do this from them. Even got a few different methods and ideas but most of them rely on having a popup menu to dictate the action of the spell or two spells, one for recall and the other for teleport. I want this spell to be purpose built to work all in one spell and just for this specific instance.



Also I changed the variable to your better format. I was just lazy and whipped it out in a way that was logical at the time. The indoor and combat checks work well, my main problem is the IsLoaded function. This spell is meant to be for only one purpose and ONLY work within the confines of my area. However, it will let you return to the area you were previously.


Can anyone provide an example of how the IsLoaded thingy is to be used when you have one specific cell in mind? I looked up the wiki documentation for it but I am still having trouble using it correctly. I would post the link for it but the forum will not allow it.

User avatar
carley moss
 
Posts: 3331
Joined: Tue Jun 20, 2006 5:05 pm

Post » Tue Feb 07, 2017 4:12 pm

IsLoaded isn't what you would use to check if the player is in a location or near it.




Looking at the code it looks like you simply want to check "if CurCell == SCHLocation" or you might just do a distance check compared to the home marker "if caster.GetDistance(SCHHomeMarker) < 5000" instead.

User avatar
Christie Mitchell
 
Posts: 3389
Joined: Mon Nov 27, 2006 10:44 pm

Post » Tue Feb 07, 2017 6:55 pm

That was exactly what I needed. Thanks!
User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm


Return to V - Skyrim