Jump to content

Recommended Posts

Good afternoon everybody!

 

I have a scripting problem. I am trying to make a mod where all the "evil" factions (and later on the rest of them) are split into local factions and personality and conspiracy factions. And link them all up.

My idea is to use StringMaps. But i am not doing it right because i get  error messages in the console telling me of let := operator not getting the result.

So how do i add keys to a StringMap array? The obse documentation explains it but just quickly.

So for example:

Let formid1 := PoliticsBaseFaction

Let ref1 := cloneform formid1

Adding this new faction as a new key to the stringmap, where string1 is the name of the new faction (taken from an .ini or from the name of a local dungeon)

Let TotalFactionList[$string1] := ref1

Let ref2 := TotalFactionList[$string2]

Let number := MetaFactionList[$string2][1]

Set factinreaction ref1 ref2 number

 

But i got errors. And ut only says script and offset so i can not find the line in the scripts. But i do something wrong with the let statements.

Should i use ar_append instead? The obse documentation seem to say that append creates its own key for data you want to add, and i need keynames that is stored as strings in other arrays.

 

I looked at SetBody scripts but its difficult to sort them out.

Thanks in advance!

Link to comment

I don't know if I figure out what you want to do

Something like this?

 

FactionData {

  ParentFaction = formid of banditfaction

  Faction = clone from parent

  Location = Bravil

  Personality = 55

  Relations = array (

    [0] = Blades

    [1] = -75

    [2] = FighterGuild

    [3] = 25

  )

  Conspirative = 0

}

 

Then FactionData would be stored in an array,

Let arRels := ar_List Blades, -75, FightersGuild, 25

Let arData := ar_Map ParentFaction::ref1, Faction::formid1, Location::???, Personality::55, Relations::arRels, Conspirative::0

ar_Append AllFactions arData

 

where you would search like this?

If Eval AllFactions->Faction == formid1

 

(I'm not sure of the code)

Link to comment

But what would be the name of the new key when you ar_append allfactions ardata?

 

I am using a couple of arrays:

One is TotalFactionList, where factions already in game are added by ini. And new ingame created factions (clone of a base faction i make) are added into this list as the game goes on. All keys in this array is the name of the faction, so they are easy to find. For example, bandits in vilverin are added to a new faction called VilverinBandits, based on cell name and "metafaction" (BandiFaction). The script doesnt know its called "VilverinBandits", but when one script sets the factionreaction, it calls this array to get the formid of the cloned form (faction)

 

One arrray is called LocalFactionList, Factiontreelist factiontransferlist. They all use the factionname as keys in their stringmaps.

 

The problem is to make stringmap code work.

I want to append a new faction to a stringmap, the key is unknown, it is created from the name of the local dungeon plus "bandits" or"marauders" etx. But later i will call this key using the array where its stored. So the keyname is known by the engine, its in some variable. How do i add a new key to a stringmap? Because let Array[$stringvariable] := xyz doesnt seem to work

But:

Let variable := ar_size array

Let array[variable] := xyz

Works

Link to comment

Maybe i should post my scripts

This is the basic layout anyway as i dont have my computer:


When the player changes cell, the npcs are checked for faction membership. It is all controlled by ini so the player can change it however he wants


The mod is built on different layers. The first layer is

TotalFactionList, a stringmap that uses as keys the names of existing factions from oblivion.esm and from various mods that you write in the ini, and cloned factions created as you enter a cell with a dungeon or a camp, and factions added by the ini. The values of the keys are the formid.


LocalFactionList where the keys are the name of the dungeon or the camp, and appended to this is the name of the faction, bandits or marauders etc. Key: "Vilverinbandits" Value: 8 (member in this faction)


FactiontreeList, where a member of one faction is added to other factions randomly, that are parts of the same faction (in my mod) So a member of banditfaction will also be a member of Outcast, Adventurer, or Gangster factions.
A member of Gangster faction will be added to Smuggler, None or None. So not all Bandits of Gangster faction will also be of Smuggler faction, just a third of them. Etc etc. These will later decide what quests this certain npc will give to the player.
Keys: "BanditFaction" "Gangster"
Values for banditfaction 0="Gangster" 1="Adventurer" 2="Outcast"
Values for Gangster 0="Smuggler" 1="None" 2="None"

TransferFactionList, where a member of a certain faction will also be in another existing faction. So a member of Thieves Guild of third rank will automatically be a member of BanditFaction. A member of BanditFaction with class speciality magic will automatically be a member of Conjurers
Key "Thieves Guild"
Values: 0="Bandit Faction" 1=3(rank in Thieves Guild) 2=0 (no specialization needed)
Key "Bandit Faction"
Values 0="Marauders" 1=0 (rank in banditfaction) 2=2(magic specialization needed)

All is read from ini files.

But i cannot make it work with keys that are strings, stringmaps.

 

 

Link to comment
  • 7 months later...

It is going there slowly.

 

New problem, very weird:

This line works in one function

let number := pocoFactionsQuest.MetaFactionList[mfmini["key"]][3]

But this line in another function does not work

let number2 := pocoFactionsQuest.MetaFactionList[list1["key"]][3]

 

Both number and number2 are integers, mfmini and list1 are both arrays generated in foreach loops.

I don't know if the scripting engine is buggy or if I am missing something. The loversmods work with all their scripts so there must be something I am missing.

Link to comment
  • 2 weeks later...
On 6/15/2020 at 1:10 AM, kukenmellantuttarna said:

 

Sorry if I'm unrelated, I come from NVSE... which, however, it's pretty similar.

I did have few inconsistencies from time to time, but all I had to do was workarounding with a simplier way to write the script, splitting some parts, for example:

 

Let iKey := List1["key"]

Let number2 := pocoFactionsQuest.MetaFactionList[iKey][3]

 

I can't talk for technical stuff, but my sixth sense would tell me it's more a matter of compiler interpretation of what's written

Link to comment
  • 2 weeks later...
On 6/24/2020 at 5:19 PM, A.J. said:

Sorry if I'm unrelated, I come from NVSE... which, however, it's pretty similar.

I did have few inconsistencies from time to time, but all I had to do was workarounding with a simplier way to write the script, splitting some parts, for example:

 

Let iKey := List1["key"]

Let number2 := pocoFactionsQuest.MetaFactionList[iKey][3]

 

I can't talk for technical stuff, but my sixth sense would tell me it's more a matter of compiler interpretation of what's written

Thanks! I will try that.

I started working on this a while back and now when I am back on it I have noticed that the first tries I made was very "split up" like you say, and those scripts work every time, but my new more compact scripts seem to work in some functions and in others not. It always has to do with stringmaps.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use