You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Some relevant information for using nim-tools or nwscript JSON functions on creatures.

The JSON functions will use the save game state of the object when using ObjecToJson (ie an actively spawned creature). To convert from a template to JSON use TemplateToJson. This means some of the fields on the base UTC file are not available on the save game version, and some have altered names.

Fields

Example is from the example ObjectToJson from a spawned NPC.

Most of the values would be sought by first getting the key-value pair, extract the "value" entry then JsonToXXX it. Structs and lists need further loops to extract/change things.

Only one top level one is immediately a value - __data_type.

Key NameJSON Typenwscript TypeExamplenwscript Getnwscript SetDescription and Notes
Ageintint0GetAge
It appears NPCs can have an age, it just defaults to 0. You could use JSON to set it, although age isn't really used by the game.
AmbientAnimStatebyteint0

Instanced information about what animation the creature is doing
AnimationDaydwordint0

Presumably day of the month the animation will end
AnimationTimedwordint0

Presumably milliseconds the animation will end
Appearance_Headbyteint1GetCreatureBodyPartSetCreatureBodyPartHead appearance ID
Appearance_Typewordint1GetAppearanceTypeSetCreatureAppearanceTypeappearance.2da line identifier
AreaIddwordobject1


ArmorClassshortint13GetAC

ArmorPart_RFootbyteint1


BaseAttackBonusbyteint0GetBaseAttackBonus

BodyBagbyteint0

See bodybag.2da for what this integer refers to
BodyBagIddwordobject2130706432 (OBJECT_INVALID)

Presumably if they have a "Lootable corpse" it's the body bag spawned in relation to this creature if they're dead, so the body can be removed if this is. 2130706432 is "invalid object".
BodyPart_Beltbyteint0GetCreatureBodyPartSetCreatureBodyPartNote the bodyparts can be set to armor parts, which are shown if no armor part is covering it.
BodyPart_LBicepbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_LFArmbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_LFootbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_LHandbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_LShinbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_LShoulbyteint0GetCreatureBodyPartSetCreatureBodyPart
BodyPart_LThighbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_Neckbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_Pelvisbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_RBicepbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_RFArmbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_RHandbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_RShinbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_RShoulbyteint0GetCreatureBodyPartSetCreatureBodyPart
BodyPart_RThighbyteint1GetCreatureBodyPartSetCreatureBodyPart
BodyPart_Torsobyteint1GetCreatureBodyPartSetCreatureBodyPart
Chabyteint10GetAbilityScore
Charisma
ChallengeRatingfloatfloat1.0GetChallengeRating
Note the toolset has the default assigned rating plus an adjustment value, which is compiled into a final value in game which this is.
ClassListlistjson
GetClassByPosition
The list contains the json array for a class, level, and their memorised spells and spell school/domain choices. See secondary table below.
Color_Hairbyteint1


Color_Skinbyteint1


Color_Tattoo1byteint1


Color_Tattoo2byteint1


CombatInfostructjson


This contains a number of combat-related pieces of info like weapons equipped, damage dice applicable to certain slots, arcane spell failure etc.. Nothing too exciting.
CombatRoundDatastructstruct


This presumably is only populated in combat - in a save game this would contain things like "I'm currently attacking creature ID xxx"
Conbyteint14GetAbilityScore
Consitution
Conversationresrefstringtestnpc

Dialogue file resref; may be useful with BeginConversation etc.
CreatnScrptFirdbyteint1

Not sure
CreatureSizebyteint3GetCreatureSize
Ususally tied to appearance.2da line
CurrentHitPointsshortint4GetCurrentHitPointsSetCurrentHitPoints
DataMigrationintint1

Not sure, presumably migration from 1.69 data
DeadSelectablebyteint0
SetIsDestroyableSelectable by Dead property of the creature. You can only set this not get it in default nwscript.
DecayTimedwordint5000

Presumably milliseconds to decay corpse. In the toolset you can only use seconds, default is 5, so this is in miliseconds.
Deitycexostringstring
GetDeitySetDeityNot able to be set in the toolset (And likely stripped) but nwscript can set it for PCs and NPCs.
Descriptioncexolocstringjson{ }

Needs testing; probably localised string(s) for description field, so array value 0 would be English.
DescriptionOverrcexostring

GetDescriptionSetDescriptionOverride description presumably when SetDescription is used
DetectModebyteint0

GetDetectMode

GetActionMode

SetActionModeNoting as per usual Elves (which this is) who have "passive == active" detect modes will have this always set to 0.
Dexbyteint14GetAbilityScore
Dexterity.
Disarmablebyteint1GetIsCreatureDisarmable
General disarmable flag on the creature properties.
EncounterObjectdwordobject2130706432 (OBJECT_INVALID)

This presumably is "if I was spawned from an encounter, this is what object to tell I've died when I die". It likely is used to validate GetIsEncounterCreature but there is no usual way to get this object.
Equip_ItemListlistjson


List of equipped items, eg; your crossbow in your hand. Rather large and involved array.
Experiencedwordint0

May be copied from PCs with ObjectToJson, needs testing. NPCs do not usually have experience obviously.
FactionIDwordint4
ChangeToStandardFaction(for 1 - 4)This is the internal faction ID. Faction IDs apart from the base 4 are generated on starting the module but shouldn't change after that, and are otherwise not retrievable.
FamiliarNamecexostringstring
GetFamiliarName
PCs get the option of setting this during levelup, NPCs do not (it's stripped from the toolset UTC generated files). You can workaround setting this by spawning the familiar then using SetName on it.
FamiliarTypeintint0GetFamiliarCreatureType
Index into hen_familiar.2da but cannot be set in toolset (it's stripped) but NPCs can validly have one.
FeatListlistjson


Current feats the creature has. Not sure if it is altered on levelup and down or what.
FirstNamecexolocstringjson → json first value 0 → stringTestNPC (After checking array)

The creatures first name, localised array though so you need to parse the entry to get the language ID you need. Note GetName gets FristName + " " + LastName, although conversations can generate tokens which are only the first name.
FootstepTypeintint-1GetFootstepTypeSetFootstepTypeNo need for JSON, although interestingly it defaults to -1 apparently if not set (so it auto looks up the right value from appearance.2da I guess)
FortSaveThrowcharint1GetFortitudeSavingThrow
Fortitude Saving Throw.
Genderbyteint0GetGender
Finally you might be able to do a belt of gender swap (with NPCs at least!)
Golddwordint0GetGoldGiveGoldToCreature, TakeGoldFromCreature
GoodEvilbyteint100GetGoodEvilValueAdjustAlignmentGood/Evil alignment value.
HitPointsshortint4

This is Max Hit Points - constitution bonuses apparently, so the base rolls of the creatures levelups (like d4 = 4 for this Wizard) plus additional HP from the UTC file. See MaxHitPoints for the "true" maximum hit points.
Intbyteint16GetAbilityScore
Intelligence value
Interruptablebyteint1

Is the "No Interrupt" flag on the creature blueprint.
IsCommandablebyteint1GetCommandableSetCommandableCommandable flag, note the engine commonly sets this (effects, functions the game does) a lot.
IsDMbyteint0GetIsDM
Probably would break things if you flag an NPC as a DM. Or it'll ignore it.
IsDestroyablebyteint1
SetIsDestroyableCan only set this not get this in nwscript; it stops DestroyObject from running on the creature, and helps with lootable/raisable corpses.
IsImmortalbyteint0GetImmortalSetImmortalImmortality flag
IsPCbyteint0GetIsPC
If they are a PC. Not sure if DM possession messes with this.
IsRaiseablebyteint1
SetIsDestroyableAllows raising of this creature via. EffectRessurection presumably. Can't get this only set it in default nwscript.
ItemListlistjson


All the items in their inventory with all sorts of arrays for properties and everything else. Likely even in a small inventory to be the majority of the json. Also in nwscript you can edit items very easily so little use for this.
LastNamecexolocstringjson → json first value 0 → string""

The creatures last name, localised array though so you need to parse the entry to get the language ID you need. Note GetName gets FristName + " " + LastName, although conversations can generate tokens which are only the last name.
LawfulChaoticbyteint0GetLawChaosValueAdjustAlignmentLawful/Chaos alignment value.
Listeningbyteint0
SetListeningCan only set if they're listening not get if they are. Applies to listening strings used by the AI mainly.
Lootablebyteint0GetLootableSetLootableIs the "Leaves Lootable Corpse" setting in the toolset, but can be set (before their killed) via. nwscript
MClassLevUpInbyteint0

Not sure, something to do with multiclassing
MasterIDdwordobject2130706432 (OBJECT_INVALID)GetMasterAddHenchman and othersThe master object. There are like other fields to classify the creature.
MaxHitPointsshortint5GetMaxHitPoints
This appears to be HitPoints + Constitution bonuses/penalties.
MiscVisualsstructjson


Contains HiLite colour info and Mouse Cursor info. See SetObjectHiliteColor and SetObjectMouseCursor
MovementRatebyteint4GetMovementRate
Index into creaturespeed.2da - see Creature Movement.
NaturalACbyteint0

Will be added onto the AC of the creature (See ArmorClass for the total). Presumably is equal to the amount set in the toolset on the creature properties. Not sure if altered by levelups in Dragon Disciple etc.
NoPermDeathbyteint0

Is the "No Permanent Death" option in the toolset on a creature. Will stop them exploding from damage/death, but otherwise does not affect DestroyObject.
OverrideBABbyteint0
SetBaseAttackBonus / RestoreBaseAttackBonusUnlike what the function and name mentions it actually is the amount of base attacks granted to a creature with the function SetBaseAttackBonus.
PM_IsPolymorphedbyteint0

Are they under the effect of EffectPolymorph. Presumably has additional fields when polymorphed.
PerceptionListlistjson


A list of active things the creature perceives, so a list of objects they can see/hear.
Phenotypeintint0GetPhenoTypeSetPhenoTypeCreatures phenotype
Plotbyteint0GetPlotFlagSetPlotFlagPlot flag
PortraitIdwordint36GetPortraitIdSetPortraitIdIndex into portraits.2da.
PregameCurrentshortint5

No idea but matches MaxHitPoints
Racebyteint1GetRacialType
racialtypes.2da line ID, may allow changing racial type (but you'd need to manually alter some of the other bits - such as stats, feats, etc.)
RefSaveThrowcharint3GetReflexSavingThrow
Reflex Saving Throw

ScriptAttacked

ScriptDamaged

ScriptDeath

ScriptDialogue

ScriptDisturbed

ScriptEndRound

ScriptHeartbeat

ScriptOnBlocked

ScriptOnNotice

ScriptRested

ScriptSpawn

ScriptSpellAt

ScriptUserDefine

resrefstring
GetEventScriptSetEventScriptThe scripts the creature uses
SitObjectdwordobject2130706432 (OBJECT_INVALID)

Must be used with ActionSit of course.
SkillListlistjson
GetSkillRank
List of all skills (at least at the time of saving in case skills.2da changes later) along with their ranks in JSON lists/structs. Presumably this is the "Live" rank thus including all relevant bonuses (ability scores etc.) and penalties.
SkillPointswordint0

Presumably the amount of skill points "leftover" from levelups, not applicable to NPCs mind you only PCs.
SoundSetFilewordint110

The index into soundset.2da of the soundset the creature is using. It gets set to 65535 if it is blanked out on the UTC, thus invalid.
StartingPackagebyteint10

Used in LevelUpHenchman if CLASS_TYPE_INVALID is passed in, and is a line in packages.2da
StealthModebyteint0GetActionModeSetActionModeIf the creature is in stealth mode or not
Strbyteint10GetAbilityScore
Strength
Subracecexostringstring""GetSubRaceSetSubRaceSubrace is a text field pretty much unused by the game by default (it's not even shown on the character sheet).
TagcexostringstringTestNPCGetTagSetTagTags are used to identify objects or find them with GetObjectByTag.
Tail_Newdwordint0GetCreatureTailTypeSetCreatureTailTypeCreature tail type
TemplateResRefresrefstringtestnpcGetResRef
Creatures resref which should point to the UTC file it was spawned from
VisualTransformstructjson
GetObjectVisualTransformSetObjectVisualTransformVisual transform info (scaling, translation etc.)
WillSaveThrowcharint3GetWillSavingThrow
Will saving throw
Wings_Newdwordint0GetCreatureWingTypeSetCreatureWingTypeCreature wing type
Wisbyteint12GetAbilityScore
Wisdom

XOrientation

XPosition

YOrientation

YPosition

ZOrientation

ZPosition

floatfloatX, Y coordinates, or radian based orientation

GetLocation

JumpToLocation

SetFacing

These obviously get overriden if you are spawning in a creature object with JsonToObject.

ZPosition isn't used (creature snaps to the walkmesh) but was "envisioned to be used".

The orientation is set as a facing in GFF blueprints.

__data_typespecialstringUTC

Only value that isn't a type/value pair. Straight string.
fortbonusshortint0

Fortitude saving throw bonus, presumably the toolset field, not sure if XXXSavingThrow has the grand total or this is added on dynamically.
refbonusshortint0

Reflex saving throw bonus, presumably the toolset field, not sure if XXXSavingThrow has the grand total or this is added on dynamically.
willbonusshortint0

Will saving throw bonus, presumably the toolset field, not sure if XXXSavingThrow has the grand total or this is added on dynamically.

ClassList

This is part of the ClassList json part and is one of the more interesting part of the JSON. It will contain what spells are memorised and any class-specific options (eg; domains chosen or wizard spell school chosen).

Example JSON

See TestNPC from game.json

  • No labels