Jump to content

Help with set crime gold script


shane4244

Recommended Posts

Posted

I need to know if there is a better way to instanly raise the players bounty for the current hold they are in. The script I have works fine does exactly what I want but I don't like all the if statements in it. I've looked at a few other mods and they do the same thing or worse. I'm just wondering if someone knows a cleaner way to do this. here is a small portion of it you can tell how long the if statement is if you think about every hold in skyrim.

 

    If Game.GetPlayer().IsInLocation(WhiterunLocation)
        CrimeFactionWhiterun.SetCrimeGold(WhoreCrimeGold)
        CrimeFactionWhiterun.SetCrimeGoldViolent(1000)

    elseIf Game.GetPlayer().IsInLocation(WhiterunHoldLocation)
        CrimeFactionWhiterun.SetCrimeGold(WhoreCrimeGold)
        CrimeFactionWhiterun.SetCrimeGoldViolent(1000)

    elseIf Game.GetPlayer().IsInLocation(WinterholdLocation)
        CrimeFactionWinterhold.SetCrimeGold(WhoreCrimeGold01)
        CrimeFactionWinterhold.SetCrimeGoldViolent(1000)

    elseif Game.GetPlayer().IsInLocation(WinterholdCollegeLocation)
        CrimeFactionWinterhold.SetCrimeGold(WhoreCrimeGold01)
        CrimeFactionWinterhold.SetCrimeGoldVi

 

 

Posted

i know of no way to gather the needed information dynamicly.

So to keep scripts short (simple loop until you hit the end of the FormLists content) and content easiely modifieable i normaly go with FormLists or Arrays.
FormLists have the advantage of being easy to manipulate even for less experienced modders but are slow, so if speed is a premisse i suggest you go with StorageUtil ... or Papyrus own Array function.

 

As for your script, my array would look like this:
0, WhiterunLocation

1, CrimeFactionWhiterun

2, WinterholdLocation

3, CrimeFactionWinterhold

Loc followed by Fac, always reading 2 entries with each loop.
To make it failsafe, check the array, after building it, if a division by 2 results in a float and if, stop execution.

Posted

i know of no way to gather the needed information dynamicly.

So to keep scripts short (simple loop until you hit the end of the FormLists content) and content easiely modifieable i normaly go with FormLists or Arrays.

FormLists have the advantage of being easy to manipulate even for less experienced modders but are slow, so if speed is a premisse i suggest you go with StorageUtil ... or Papyrus own Array function.

 

Yea speed is what I'm going for thanks for the quick response. I've been going through my scripts here lately just trying to tidy up a bit thanks again.

Posted

No problem.
Would have loved to post code, but this damn tablet turns code into klingon language ... or w/e this is supposed to be.

 

Btw: No matter if you go with FLs or Arrays, you can easily support mods, like Faalskar, or DLCs this way, by using SoftDep and a startup quest for initialization.

Posted

No problem.

Would have loved to post code, but this damn tablet turn code into klingon language ... or w/e this is supposed to be.

 

Btw: No matter if you go with FLs or Arrays, you can easily support mods like Faalskar this way, by using SoftDep and a startup quest for initialization.

 

Lol I had to look up what Faalskar was (I don't actually get to play skyrim much) that would be nice to have crime work in non-vanilla location thanks for the tip.

Posted

P.s.: You will have to clear the FL/Array evertime the game sends Started or Reloaded and then readd everything to make sure newly added mods are being taken into consideration and stuff is not added multiple times.

i forgot to do that and wondered wtf was going on in my script. X'D

 

Atm my script works with a FormList holding the defaults (sole vanilla in my case) which will then be copied into an array, which will hold the new content added by modders, DLCs and/or SoftDep supported mods as well.
So if i need to restore the defaults, i got them right there in the FormList. To restore the default, i use the initialization function with an optional switch which disables SoftDep scanning.

Saves me some code as for the restore functionality it would be a slightly modified copy of the initialization anyway.

Posted

Another solution would be with PapyrusUtil.

 

For example

StorageUtil.SetIntValue(WhiterunHoldLocation, "WG.CrimeGold", 1000)
StorageUtil.SetIntValue(WhiterunLocation, "WG.Crimegold", 1000)

You would need another array to store the locations you added like this

StorageUtil.FormListAdd(None, "WG.CrimeGoldLocations", WhiterunHoldLocation)
StorageUtil.FormListAdd(None, "WG.CrimeGoldLocations", WhiterunLocation)

The difference between FormLists and StorageUtil is marginal but there is one important difference. You can only delete/change entries from FormLists you added per script. FormList entries filled with the Creation Kit can not be deleted or changed. With StorageUtil you could do it w/o those restrictions.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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