[Modding Reference] - State of Decay XML Function Library

Discussion in 'PC Mods' started by ZephyrWarrior, Sep 28, 2015.

  1. ZephyrWarrior

    ZephyrWarrior Got Your Back

    Hey everyone, since there aren't any developer tools or resources available for this great game, I figured I'd make my own.

    Welcome to the library. If UL thinks this is worthy of a sticky, I'd be honoured.

    {} = Predictions, untested, possibly entirely erroneous.

    SubFunctions are used between the openning and closing tags of their parent functions.

    -------------------------
    Types of Data:
    Variable: Parameter="My.Boolean.Variable" | Parameter="My.Integer.Variable"
    Boolean: Parameter="true" | Parameter="false"
    Integer: Parameter="4" | Parameter = "0" | Parameter = "21"
    Float: Parameter="3.14" | Parameter="50.25" | Parameter="1.01"
    String: Parameter="Hello, my name is Joe." | Parameter="Would you kindly not eat my brains?"
    ID: Parameter="Mine_Homemade_Fire" | Parameter="Firecracker"
    -------------------------

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

    Variable Manipulation
    Note: Define all non-local variables in rtsdata.xml to be safe if you want them to be persistent!
    Note: All Non-0 values should evaluate to true and 0 should evaluate to false, if you use an integer in a boolean function.
    -------------------------
    -------------------------


    Function Name: RTSStat_SetBool (Typically An Action Output)

    Code:
    <RTSStat_SetBool DurationCancellable="" OutputAmount="true" OutputDuration="5h" OutputId="My.Boolean.Variable" PauseWhenOffline="" />
    Summary: Sets a variable to a boolean value.

    Parameter - DurationCancellable []:
    Parameter - OutputAmount []:
    Parameter - OutputDuration []:
    Parameter - OutputId []:
    Parameter - PauseWhenOffline []:

    ----

    Function Name: RTSStat_Set (Typically An Action Output)

    Code:
    <RTSStat_Set DurationCancellable="" OutputAmount="1" OutputDuration="" OutputId="My.Integer.Variable" PauseWhenOffline="" />
    
    Summary: Sets a variable to an integer value.

    Parameter - DurationCancellable []:
    Parameter - OutputAmount []:
    Parameter - OutputDuration []:
    Parameter - OutputId []:
    Parameter - PauseWhenOffline []:

    ----

    Function Name: RTSStat_Copy (Typically An Action Output)

    Code:
    <RTSStat_Copy DestID="My.Target.Variable" SourceID="My.Source.Variable" />
    
    Summary: Copies a variable to another variable.

    Parameter - DestID []:
    Parameter - SourceID []:

    ----

    Function Name: RTSStat_Add (Typically An Action Output)

    Code:
    <RTSStat_Add DurationCancellable="" OutputAmount="1" OutputDuration="" OutputId="My.Integer.Variable" PauseWhenOffline="" />
    
    Summary: Adds a value to a variable.

    Parameter - DurationCancellable []:
    Parameter - OutputAmount []:
    Parameter - OutputDuration []:
    Parameter - OutputId []:
    Parameter - PauseWhenOffline []:

    ----

    Function Name: RTSStat_MultiplyAdd (Typically An Action Output)

    Code:
    <RTSStat_MultiplyAdd MultiplyBy="MyFirst.Integer.Variable" OutputAmount="2" OutputId="MySecond.Integer.Variable" PauseWhenOffline="" />
    
    Summary: Multiplies a variable by a value, then add the result to another variable.

    Parameter - MultiplyBy []:
    Parameter - OutputAmount []:
    Parameter - OutputId []:
    Parameter - PauseWhenOffline []:

    ----

    Function Name: Compare (Typically An Action Input)

    Code:
    <Compare CompareOp="LessThan" InputId1="MyFirst.Integer.Variable" InputId2="MySecond.Integer.Variable" />
    
    Summary: Compares two values, evaluates to true if "InputID1 is CompareOp InputID2".
    Parameter - CompareOp []:
    Parameter - InputId1 []:
    Parameter - InputId2 []:

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

    Facilities
    -------------------------
    -------------------------


    Function Name: /libs/class*/rts/facilities.xml -> <RTSData> -> <Facilities> -> Facility

    Code:
    
    
    Summary: Defines a facility for the game.

    Parameter - FacilityFlags []:
    Parameter - FacilityId []:
    Parameter - StatusWantBool []:

    SubFunction Name: <VariantSet> -> Variant
    Summary: Sets the description of the vehicle in the vehicles list.
    Parameter - Flags [ID (Separate By Commas If Multiple)]:
    Parameter - VariantId []:

    ExtraSubFunction Name: Model

    ExtraSubFunction Name: ShellModel

    ExtraSubFunction Name: DescriptionText
    Parameter - Flags [ID (Separate By Commas If Multiple)]:
    Parameter - Notes []:
    Parameter - Text []:

    ExtraSubFunction Name: FacilityIcon
    Parameter - Name []:
    Parameter - Id []:

    ExtraSubFunction Name: NameText
    Parameter - Flags [ID (Separate By Commas If Multiple)]:
    Parameter - Notes []:
    Parameter - Text []:

    ExtraSubFunction Name: Actions
    Summary: See Section - "Actions"

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

    Vehicles
    -------------------------
    -------------------------


    Function Name: /libs/class*/contentmanager/vehicles.xml -> <VehicleData> -> VehicleDef

    Code:
    <VehicleDef AccelerationRating="0.2" DurabilityRating="0.6" EntityClass="PickUpOld" HandlingRating="0.4" Id="PickUpOld" InventorySlotCount="6" MapIcon="VEHICLE" SeatCount="4" TopSpeedRating="0.4" Weight="2" IconId="109">
      <Description Text="Old and reliable, these pickups continue to be a favorite of the farmers who count on them every day. Slow but steady. Room for two in front and two in the bed."/>
      <DisplayName Text="Old Pickup"/>
    </VehicleDef>
    
    Summary: Defines a vehicle for the game.

    Parameter - AccelerationRating [Float (0.2 - 1.0, increments of 0.2)]: Determines the vehicle's acceleration rating when viewing the vehicles list. UI only. No empirical change.
    Parameter - DurabilityRating [Float (0.2 - 1.0, increments of 0.2)]: Determines the vehicle's durability rating when viewing the vehicles list. UI only. No empirical change.
    Parameter - EntityClass [ID]: {Determines the model of the vehicle.}
    Parameter - HandlingRating [Float (0.2 - 1.0, increments of 0.2)]: Determines the vehicle's handling rating when viewing the vehicles list. UI only. No empirical change.
    Parameter - Id [ID]: {Determines the model of the vehicle.}
    Parameter - InventorySlotCount [Integer (1-12)]: Determines the number of inventory slots the vehicle has for storage. A value greater than 12 will result in the UI only displaying 12, functionality unknown. {A value of 0 will likely result in no functional storage.}
    Parameter - MapIcon [ID]: Determines the icon to display for the vehicle on the map (StringID). Typically you want to use "VEHICLE".
    Parameter - SeatCount [Integer (2 - 6)]: Determines the number of functional seats in the vehicle. {Declaring more seats than the model supports may bork things in weird ways, or cap out at the model's definition.}
    Parameter - TopSpeedRating [Float (0.2 - 1.0, increments of 0.2)]: Determines the vehicle's top speed rating when viewing the vehicles list. UI only. No empirical change.
    Parameter - Weight [Integer (0 - 2) {Float?}]: Determines how likely it is for the given vehicle to spawn in place of a random vehicle on the map, or via radio vehicle delivery actions.
    Parameter - IconId [Integer]: Determines the icon to display for the vehicle on the map (NumericID). Typically you want to use "109".

    SubFunction Name: Description
    Summary: Sets the description of the vehicle in the vehicles list.
    Parameter - Text [String]: Determines the description of the vehicle in the vehicles list.

    SubFunction Name: DisplayName
    Summary: Sets the name displayed when you mouse over the vehicle on the map.
    Parameter - Text [String]: Determines the name displayed when you mouse over the vehicle on the map.
     
    Last edited: Oct 11, 2015
    tobu24 and Bob Crees like this.
  2. ZephyrWarrior

    ZephyrWarrior Got Your Back

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

    Actions
    -------------------------
    -------------------------


    Function Name: <Actions> -> Action

    Code:
    
    
    Summary: An action is the term State of Decay uses for a function. Anything from crafting to facility bonuses.
    Parameter - ActionFlags [ID (Separate By Commas If Multiple)]:
    Parameter - ActionId []:
    Parameter - ActionType []:
    Parameter - ExecuteTimeStandard []:
    Parameter - OutputDelayTime []:
    Parameter - PauseWhenOffline []:
    Parameter - WantDelay []:
    Parameter - WantDelayEnd []:
    Parameter - WantDelayStart []:
    Parameter - WantOdds []:
    Parameter - WantScene []:

    SubFunction Name: DescriptionText
    Summary:
    Parameter - Flags [ID (Separate By Commas If Multiple)]:
    Parameter - Notes []:
    Parameter - Text []:

    SubFunction Name: RTSActionIcon
    Summary:
    Parameter - Name []:
    Parameter - Id []:

    SubFunction Name: NameText
    Summary:
    Parameter - Flags [ID (Separate By Commas If Multiple)]:
    Parameter - Notes []:
    Parameter - Text []:

    SubFunction Name: Actors
    Summary: See Section - "Action Actors"

    SubFunction Name: Alts
    Summary: See Section - "Alts System"

    SubFunction Name: <Effects> -> Effect
    Summary:

    SubFunction Name: Inputs
    Summary: See Section - "Action Inputs"

    SubFunction Name: Outputs
    Summary: See Section - "Action Outputs"

    SubFunction Name: <Wants> -> WantList
    Summary: Sets the list to use to source any wants the action will require.
    Parameter - WantList []: Determines the list to use to source any wants the action will require.

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

    Action Actors
    -------------------------
    -------------------------


    Function Name: Player
    Code:
    
    
    Summary:

    ----

    Function Name: Character
    Code:
    
    
    Summary:

    SubFunction: ErrorText

    ----

    Function Name: HomeSite
    Code:
    
    
    Summary:

    SubFunction: ErrorText

    ----

    Function Name: Enclave
    Code:
    
    
    Summary:

    ----

    Function Name: Building
    Code:
    
    
    Summary:

    ----

    Function Name: TagPoint
    Code:
    
    
    Summary:

    ----

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

    Action Inputs
    -------------------------
    -------------------------


    Function Name: CheckBool
    Code:
    <CheckBool InputFlags="" InputId="My.Boolean.Variable" Invert="">
      <ErrorText Flags="" Notes="" Text="This is an error!" />
    </CheckBool>
    
    Summary: Checks a boolean variable and reds out the action if the variable is not correct.
    Parameter - InputFlags [ID (Separate By Commas If Multiple)]: Determines any extra flags to apply to the check.
    Flag - HideAction: If the check fails, the action is hidden from the journal.
    Parameter - InputId [String]: Determines the variable to check.
    Parameter - Invert [Boolean]: Determines whether to apply "if" or "if not" logic to the check.

    SubFunction Name: ErrorText
    Summary: During a Check or CheckBool, this determines the sticky note to the left if the check fails. Omitting this SubFunction will remove the sticky note.
    Parameter - Flags [ID (Separate By Commas If Multiple)]: Determines any extra flags to apply.
    Parameter - Notes [String]:
    Parameter - Text [Boolean]: Determines the message displayed on the sticky note if the check fails.

    ----

    Function Name: Check
    Code:
    <Check InputAmount="1" InputFlags="" InputId="My.Integer.Variable">
      <ErrorText Flags="" Notes="" Text="This is an error!" />
    </CheckBool>
    
    Summary: Checks an integer variable and reds out the action if the variable is not correct.
    Parameter - InputAmount [String]: Determines the amount to compare to the variable during the check.
    Parameter - InputFlags [ID (Separate By Commas If Multiple)]: Determines any extra flags to apply to the check.
    Flag - HideAction: If the check fails, the action is hidden from the journal.
    Parameter - InputId [String]: Determines the variable to check. To change from "if" to "if not" logic, lead the variable name with a "!".

    SubFunction Name: ErrorText
    Summary: During a Check or CheckBool, this determines the sticky note to the left if the check fails. Omitting this SubFunction will remove the sticky note.
    Parameter - Flags [ID (Separate By Commas If Multiple)]: Determines any extra flags to apply.
    Parameter - Notes [String]:
    Parameter - Text [Boolean]: Determines the message displayed on the sticky note if the check fails.

    ----

    Function Name: Facility_CheckBuilt
    Code:
    
    
    Summary:

    ----

    Function Name: Facility_CanBuild
    Code:
    
    
    Summary:

    ----

    Function Name: Spend
    Code:
    <Spend InputAmount="5" InputFlags="Required" InputId="Family.Influence" />
    
    Summary: Spends a resource, influence, etc.
    Parameter - InputAmount [String]: Determines the amount to spend.
    Parameter - InputFlags [ID (Separate By Commas If Multiple)]: Determines any extra flags to apply to the check.
    Flag - Required: {This resource is required in order to activate the action.}
    Parameter - InputId [String (Family.Influence, Stockpile.Ammo, Stockpile.Food, Stockpile.Fuel, Stockpile.Materials, Stockpile.Medicine)]: Determines the type of resource to spend.

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

    Action Outputs
    Note: Console_Command is not listed because it has no relevance to modders. We have no access to the developer console at the moment.
    -------------------------
    -------------------------


    Function Name: ExecuteAction
    Code:
    <ExecuteAction ActionId="AnotherAction" />
    
    Summary: Executes another action.

    Parameter - ActionId []: Determines the action to execute.

    ----

    Function Name: EventTrigger
    Code:
    <EventTrigger Event="My.Event" />
    
    Summary: Executes an event.

    Parameter - Event []: Determines the event to trigger.

    ----

    Function Name: EventRewardStat
    Code:
    
    
    Summary:

    ----

    Function Name: Com_Give
    Code:
    <Com_Give ActorIndex="" AmmoPercentage="100" Count="1" GiveFlags="" Name="Item" />
    
    Summary: Creates an item.

    Parameter - ActorIndex []: {Determines what character will recieve the item.} Leave empty to add the item to the community stockpile.
    Parameter - AmmoPercentage [{Integer}]: Determines the amount of ammunition present in a firearm, rounding methods unknown. Leave as "100" for non-firearm items.
    Parameter - Count [Integer]: Determines the number of the given item to add.
    Parameter - GiveFlags [ID (Separate By Commas If Multiple)]: Determines any extra flags to apply to the giving of the item.
    Parameter - Name [ID]: Determines the item to add.

    ----

    Function Name: Display_Text
    Code:
    <Display_Text Flags="" Notes="" Text="Warning!" Type="Warning" />
    
    Summary: Displays text on the screen. Can be used for debugging purposes.

    Parameter - Flags [N/A]: No known use.
    Parameter - Notes [N/A]: No known use.
    Parameter - Text [String]: Determines what the text will say.
    Parameter - Type [String (Warning)]: Determines what type of text to display. The only known variant is "Warning", everything else tested has resulted in the default text in the top right.

    ----

    Function Name: UI_PlaySound
    Code:
    <UI_PlaySound AllowOverlap="false" Sound="sounds/sound:path:here"/>
    
    Summary: Plays a sound.

    ----

    Function Name: EventLog
    Code:
    
    
    Summary: Adds an event to the journal, with an optional notification in the top right.

    ----

    Not yet doccumented:
    Achievement
    Actor_AddExpertisePoints
    Actor_AddToFamily
    Actor_AddTrust
    Actor_EvolveTraits
    Actor_GiveMatchingAmmo
    Actor_GiveTrait
    Actor_InventoryWipe
    Actor_JoinEnclave
    Actor_Kill
    Actor_SetAsPlayer
    Actor_TeleportTo
    AvatarAsset
    BuildingDiscover
    ChangeState
    Display_ArcGoalText
    Enclave_ClaimSite
    Enclave_Give
    Enclave_StatSet
    Enclave_StatSetBool
    EventAddEffect
    EventAddEffectNpc
    Facility_Destroy
    Facility_SetAdvisor
    Fate_PlayCard
    Hint_Show
    Mission_Create
    NextMap
    RespawnPointOverride
    Scene_ScenePlay
    VM_SpawnVehicleAtTagPoint

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

    Alts System
    -------------------------
    -------------------------


    In order to introduce an element of randomization to you actions, you will have to use the "Alts" system.

    The most basic method to this is to first make an action which will trigger the others. Let's use a crafting action as an example.

    The primary action we will name "TestAction" and it will contain the inputs to the crafting (Spend functions, etc.), and will contain a series of "Alt" functions in its "Alts" section. Feel free to change the icons, name, etc. But leave Effects empty for now.

    Code:
    <Action ActionFlags="" ActionId="TestAction" ActionType="" ExecuteTimeStandard="10s" OutputDelayTime="0.0" PauseWhenOffline="">
      <RTSActionIcon Name="" Id="" />
      <NameText Flags="" Notes="" Text="" />
      <Actors />
      <Alts>
        <Alt AltId="TestActionResult1" AltOdds="50.0" />
        <Alt AltId="TestActionResult2" AltOdds="50.0" />
        <Alt AltId="TestActionResult3" AltOdds="100.0" />
      </Alts>
      <Effects />
      <Inputs>
        <Spend InputAmount="5" InputFlags="Required" InputId="Family.Influence" />
      </Inputs>
      <Outputs />
    </Action>
    
    The secondary actions will contain no inputs, only outputs.

    Code:
    <Action ActionFlags="" ActionId="TestActionResult1" ActionType="" ExecuteTimeStandard="10s" OutputDelayTime="0.0" PauseWhenOffline="">
      <RTSActionIcon Name="" Id="" />
      <NameText Flags="" Notes="" Text="" />
      <Actors />
      <Alts />
      <Effects />
      <Inputs />
      <Outputs>
        <Com_Give ActorIndex="" AmmoPercentage="100" Count="1" GiveFlags="" Name="Food" />
    </Action>
    <Action ActionFlags="" ActionId="TestActionResult2" ActionType="" ExecuteTimeStandard="10s" OutputDelayTime="0.0" PauseWhenOffline="">
      <RTSActionIcon Name="" Id="" />
      <NameText Flags="" Notes="" Text="" />
      <Actors />
      <Alts />
      <Effects />
      <Inputs />
      <Outputs>
        <Com_Give ActorIndex="" AmmoPercentage="100" Count="2" GiveFlags="" Name="Food" />
    </Action>
    <Action ActionFlags="" ActionId="TestActionResult3" ActionType="" ExecuteTimeStandard="10s" OutputDelayTime="0.0" PauseWhenOffline="">
      <RTSActionIcon Name="" Id="" />
      <NameText Flags="" Notes="" Text="" />
      <Actors />
      <Alts />
      <Effects />
      <Inputs />
      <Outputs>
        <Com_Give ActorIndex="" AmmoPercentage="100" Count="3" GiveFlags="" Name="Food" />
    </Action>
    
    Now it is important to note that AltOdds does not translate directly to common percentage. The game runs each check sequentially and then abandons the rest once one evaluates true.
    So the series of odds "50, 50, 100" would actually be equal to "50%, 25%, 25%". Remember to always give the last alt an odds of 100 unless you want the possibility of no outputs occurring.

    In summary, the primary action contains what the player will see before they execute it, and the secondary actions contain the results. Thus, you should put relevant journal entries under each secondary action.
     
    Last edited: Oct 11, 2015
  3. ZephyrWarrior

    ZephyrWarrior Got Your Back

    Reserved for when this inevitably gets long enough to require more posts.
     
    Last edited: Oct 11, 2015
  4. ZephyrWarrior

    ZephyrWarrior Got Your Back

    Reserved for when this inevitably gets long enough to require more posts.
     
  5. ZephyrWarrior

    ZephyrWarrior Got Your Back

    Reserved for when this inevitably gets long enough to require more posts.
     

Share This Page