Jump to content

[LE] How to get current hold / county


Urakhah

Recommended Posts

Hello everyone,

 

I want to write a mod which shows me the county, I'm currently in. There must already be something available - the game already detects, where we are when committing a crime.

 

I would like to know, which script handles this functionality of detecting the current county when i.e. hitting a guard

 

Maybe someone can point me in the right direction, that would be awesome!

 

Greetings

Patrick

Link to comment
Share on other sites

CW

 

  Faction PROPERTY CrimeFactionHaafingar  auto
  Faction PROPERTY CrimeFactionReach      auto
  Faction PROPERTY CrimeFactionHjaalmarch auto
  Faction PROPERTY CrimeFactionWhiterun   auto
  Faction PROPERTY CrimeFactionFalkreath  auto
  Faction PROPERTY CrimeFactionPale       auto
  Faction PROPERTY CrimeFactionWinterhold auto
  Faction PROPERTY CrimeFactionEastmarch  auto
  Faction PROPERTY CrimeFactionRift       auto


Faction FUNCTION GetCrimeFactionForHold(Location loc)    ; loc = HoldLocaton
;----------------------------------------------------
; {Returns the normal crime faction for the hold}
;;    Log("CWScript", "GetCrimeFactionForHold(" + HoldLocation + ")")

; same function you will found inside:
;   "DLC1RadiantScript.psc"
;   "GenericLocCrimeFactionObjRef.psc"
;   "WECrimeFactionAliasScript.psc"

faction fac

    IF     (loc == HaafingarHoldLocation)
                                                    fac = CrimeFactionHaafingar
    ELSEIF (loc == ReachHoldLocation)
                                                    fac = CrimeFactionReach
    ELSEIF (loc == HjaalmarchHoldLocation)
                                                    fac = CrimeFactionHjaalmarch
    ELSEIF (loc == WhiterunHoldLocation)
                                                    fac = CrimeFactionWhiterun
    ELSEIF (loc == FalkreathHoldLocation)
                                                    fac = CrimeFactionFalkreath
    ELSEIF (loc == PaleHoldLocation)
                                                    fac = CrimeFactionPale
    ELSEIF (loc == WinterholdHoldLocation)
                                                    fac = CrimeFactionWinterhold
    ELSEIF (loc == EastmarchHoldLocation)
                                                    fac = CrimeFactionEastmarch
    ELSEIF (loc == RiftHoldLocation)        
                                                    fac = CrimeFactionRift
;    ELSE
;;        log("CWScript", " WARNING: GetCrimeFactionForHold(" +loc+ ") found an unexpected location that isn't a known hold.", 2, true, true)    
    ENDIF

;;    log("CWScript", "GetCrimeFactionForHold(" +loc+ ") RETURNING: " +fac)
    RETURN fac
ENDFUNCTION


FUNCTION ClearHoldCrimeGold(Location loc)    ; loc = HoldLocaton
;----------------------------------------
; also called by
;    "QF_CWAttackCity_0004F8BF.psc"
;    "QF_CWFunctions_0002BFAE.psc"
;;    Log("CWScript", "ClearHoldCrimeGold(" +loc+ ") clearing crime gold.")

    faction fac = GetCrimeFactionForHold(loc)                ; fac = crimeFaction

IF ( fac )
    fac.SetCrimeGold(0)
    fac.SetCrimeGoldViolent(0)
ELSE
    Debug.Trace(self+" WARNING: ClearHoldCrimeGold() - unexpected location found.. " +loc)
ENDIF
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

@ReDragon2013, that's for returning the faction associated with a hold, but not for getting which hold you're in. For that, you can use:

  If PlayerRef.IsInLocation(ReachHoldLocation) 
        Debug.Notification("We're in the Reach.")
  Elseif PlayerRef.IsInLocation(HjaalmarchHoldLocation) 
       Debug.notification("We're in  Hjaalmarch") 
  Endif

Ect...

Link to comment
Share on other sites

Guys thank you so much! I'm gonna try this in the next days!

 

--------------------------------------------------------------------------------------------

 

Edit / Update:

I investigated the two approaches and will share my results.

 

Approach 1: CrimeFactions

 

I figured out that NPCs get a CrimeFaction attached in their base object settings. Even if the NPC is placed in another hold, attacking him adds a bounty to the hold he has the CrimeFaction for. So i.e. Faendal has the CrimeFactionWhiterun attached. If I place him in Eastmarch and hitting him, I get bounty in Whiterun, althoug I am in Eastmarch.
The script is not suitable for me since I don't want the crime faction of an NPC.

Approach 2: isInLocation(...)

 

This only works, if the cell has a location attached to it. For the many "Wilderness" cells this is false. They have NONE Location attached, so no way fetching the location there.

 

Conclusion

 

I would have to manually add a location to every "Wilderness" cell to really be able to fetch the current hold from every spot on the map. Thank you very much, you helped me understanding the game enginge a little more again!

Edited by Urakhah
Link to comment
Share on other sites

  • Recently Browsing   0 members

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