kefka95 Posted November 25, 2014 Share Posted November 25, 2014 I'm writing a script for an MCM menu in which I want to verify whether a given location is cleared. I know that within the Location script there is an IsCleared() function that would accomplish this. However, I don't know how to "get" the location in the first place. For example, in SKSE, there is a GetQuest() function that retrieves a quest with a given ID. I can't find an equivalent for locations. There's a GetLocation() function, but it doesn't work in the same way as the GetQuest() function. It seems to run off of a given LocationAlias, but I don't know then how to get the location alias into my code in a useable way. In short, I guess I don't fully understand how all these things fit together. To put it simply, if I wanted to verify whether Bleak Falls Barrow (for example) is cleared, how would I get at the Bleak Falls Barrow location object in order to run the IsCleared() function? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 26, 2014 Share Posted November 26, 2014 If you know the exact location you want to check, use a location property. Then run the IsCleared() function on it. Example usage (passed compilation test, thus location as a property is verified):ScriptName SomeScriptOnAMapFlagActivator Extends ObjectReference Location Property SomeArea Auto Event OnActivate(ObjectReference akActionRef) If SomeArea.IsCleared() Debug.Notification("Location already cleared") Else Debug.Notification("Location not cleared") EndIf EndEventIf you do not know the exact location.... then I'm not sure. Link to comment Share on other sites More sharing options...
kefka95 Posted November 26, 2014 Author Share Posted November 26, 2014 Thanks for the reply. I added a location property named BleakFallsBarrow in CK, and set the value to BleakFallsBarrowLocation (selected from a dropdown, so I couldn't have typed it wrong). However, when I run the IsCleared() function from that property, it always returns False, which is not correct. It compiles fine, but doesn't return the correct result. I'm using the code below:Debug.MessageBox(BleakFallsBarrow.IsCleared())I'm sure I'm just doing something wrong, but can't figure out what. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 26, 2014 Share Posted November 26, 2014 MessageBox takes a string. IsCleared() returns a bool value. I don't think it is intended to work the way you have it. Perhaps try:If BleakFallsBarrow.IsCleared() Debug.MessageBox("Bleak Falls Barrow has been cleared") Else Debug.MessageBox("Bleak Falls Barrow has not been cleared") EndIf Link to comment Share on other sites More sharing options...
kefka95 Posted November 26, 2014 Author Share Posted November 26, 2014 Unfortunately that method produces the same result (ie, it states it's not cleared). For what it's worth, I believe my original test should work as well - a bool should implicitly convert to a string (I've done that same thing for other tests and had it work okay). Out of curiosity, does the IsCleared() function work correctly if you run it on your own game? I'm wondering if it's just an issue with my particular setup. Don't know why it would be, but stranger things have happened. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 26, 2014 Share Posted November 26, 2014 Honestly, I've never had a reason to use it. A good question would be, did Bethesda use it or did they arrange things to use only the GetLocationCleared condition function? Link to comment Share on other sites More sharing options...
kefka95 Posted November 26, 2014 Author Share Posted November 26, 2014 Yeah, I'm at a bit of a loss on this one. I tried using the SetCleared() function as well, and it didn't appear to do anything either. I've googled these functions enough to believe that they do work (ie, other people seem to have used them successfully). I'm sure there's just some other "thing" somewhere that I'm not doing quite right. If I could get this to work it would allow me to add some cool functionality to my mod (well, cool to me at least), but I'm striking out so far. Link to comment Share on other sites More sharing options...
Terra Nova Posted November 26, 2014 Share Posted November 26, 2014 On 11/25/2014 at 11:49 PM, kefka95 said: I'm writing a script for an MCM menu in which I want to verify whether a given location is cleared. I know that within the Location script there is an IsCleared() function that would accomplish this. However, I don't know how to "get" the location in the first place. For example, in SKSE, there is a GetQuest() function that retrieves a quest with a given ID. I can't find an equivalent for locations. There's a GetLocation() function, but it doesn't work in the same way as the GetQuest() function. It seems to run off of a given LocationAlias, but I don't know then how to get the location alias into my code in a useable way. In short, I guess I don't fully understand how all these things fit together. To put it simply, if I wanted to verify whether Bleak Falls Barrow (for example) is cleared, how would I get at the Bleak Falls Barrow location object in order to run the IsCleared() function?You can pull a location alias in a script the same way for any other type. LocationAlias property myLocAlias auto ; other uses myLocAlias.GetLocation() ; or myLocAlias.Clear() ; if optional ; or myLocAlias.ForceLocationTo(NewLocation) ; same as ForecRefTo() Ok so isCleared() appears to not work as it should. Another way you can try is to check if the boss of the area is dead. This is what sets all dungeons to cleared status the first time, and they set off the sound effect each time after words. Link to comment Share on other sites More sharing options...
kefka95 Posted November 27, 2014 Author Share Posted November 27, 2014 Thanks Terra Nova, I think I did finally get this figured out. Mostly I think I just misunderstood how the function worked. I copied a post I made on the Bethesda forums below: Quote Just to follow up, I think I finally solved the mystery of IsCleared(). After much testing (this was driving me nuts), it appears that IsCleared() checks if the dungeon is currently cleared (not whether it's ever been cleared). In other words, if you test it shortly after clearing the dungeon, it will return TRUE. However, when the dungeon repopulates and the boss respawns, it will go back to returning FALSE until the boss is killed again. So IsCleared() will not necessarily always return the same result as what you see on the world map marker. Link to comment Share on other sites More sharing options...
Terra Nova Posted November 27, 2014 Share Posted November 27, 2014 Excellent. I'll be sure to add that info to the function's page on the wiki. Link to comment Share on other sites More sharing options...
Recommended Posts