Any way to put random variables in the xml code?

Is there anyway to incorporate random elements into the xml code for modding?

For instance I would like to create a spell to summon an npc but I would like it to be random each time.

2,717 views 4 replies
Reply #1 Top

I haven't figured it out yet. Kinda hoping that this is possible so we can do things similar to dice rolls in D&D type games.

Reply #2 Top

XML is not for functionality: http://www.w3schools.com/xml/xml_whatis.asp. It exists to describe / store data. Wait for the Python to start doing things like random variables and if checks.

The only sensible way that "randomness" could be achieved through XML is if the game was expecting an element to have some sort of "probability" attribute.

Reply #3 Top

There are certain places in some of the XML files that use CDATA which is not parsed by the XML document. This seems to be used to make calculations.

Example:

Expression><![CDATA[[AttackerIntelligence] * -1.0]]></Expression

This is from the fireball spell. I wouldn't be surprised if you could insert a python random number generation function here and it would be parsed correctly.

Having said that, I dont know python, but it looks like it uses random.random() as its function to create a random number.

Reply #4 Top

I've tried this on multiple occasions but CANNOT get any code to work.

Here is the code for adding diplomacy based on charisma:

<GameModifier>
      <Target>Player</Target>
      <ModType>Resource</ModType>
      <Attribute>DiplomaticCapital</Attribute>
      -->
  <!-- Use the sovereign's charisma stat to determine how much diplomatic capital they get -->
      <Calculate InternalName = "Value" ValueOwner="PlayerSovereign">
        <Expression><![CDATA[[UnitStat_Charisma]]]></Expression>
      </Calculate>
    </GameModifier>

Doesn't work though. I wish it did, lol.

I've been trying to use this so that the gold per turn from a Merchant would be based on his stats. Thus, as a Merchant levels he'd be getting you more income. It'd do wonders for my traits and abilities mod.