"If" statements (or the equivalent) in the XMLs, and other questions.

How to check if a condition is met.

Hi Elemental modders,

 

I'd really like to get into the moding process, and I'd like to create class-dependent ability trees for champions. Now, here's the thing: I need the game to check if the hero has access to the ability (pre-requisite are mets) before making it available. How can I do that? And more generally, are there the equivalent of "if" statements in the XML tags the game is using?

Also, I'd like to create two things:

-an item with a particle effect from the effect editor. Is there a way to do this without blender/3DS-fu?

-an ability which triggers at random/has a random duration. Is there a way to do this?

-where are the champion classes defined?

(By the way, is there a "grep" equivalent in windows? I tire looking at the files one by one to see if what I'm looking for is there :/).

6,367 views 19 replies
Reply #1 Top

Good questions, I look forward to seeing it resolved.

I don't believe that there are any random triggers for abilities... but I could be wrong. Let me know if there is because that'd be great for some interesting personality traits (gambler, glutton).

I don't believe there is such a thing as a "champion class". It's declared in the NPC file but doesn't appear to have an effect as far as I can tell. Hopefully they'll have a function in the future or can be modded.

I have absolutly no idea how to do IF statements. I'm struggling with my own problem as to how to get champions to have their skills bonuses (like the merchant's gold) based on their attributes (charisma, intelligence, and wisdom). I just don't know how to get those values or put in the equation.

Also, how do you add passive experience per turn to heroes? I have no idea.

I have many of the same questions as you. Good luck!

Reply #2 Top

I think frogboy said that they have plans to move alot of hardcoded stuff out to Python for people to be able to edit. That's probably what you would need to be able to do if like statements or have the gold produced be based on other stats. Because XML is just a data format and can only do what the interpreter understands. If the interpreter doesn't have any mechanism for understanding a reference to one statistic in another section then there's simply no way to do it with the XML.

Reply #3 Top

XML is not procedual. You can't have ifs, loops, cases, whiles, procedures or macros. A procedual language (Python) that reads the XML can make desicions based on the markup text.

 

Now note that you can embed scripts of python inside the xml, but you are completely dependent on the semantics of the procedual code that reads your xml.

Reply #4 Top

XML is not procedual.
End of quote

It doesn't have to be. The semantics can still be described; it's just up to the engine to process and evaluate it.

Reply #5 Top

Quoting MrManny, reply 4

XML is not procedual.
It doesn't have to be. The semantics can still be described; it's just up to the engine to process and evaluate it.
End of MrManny's quote

 

If you're talking about a preprocessor, that takes the role of a procedual language that transforms a document as I stated.

If you're talking about including tags like :

<if (reference or test is true>

..

tags

..

<else>

other tags

</if>

or something similar

 

Then xml wouldn't represent a "document" with information but a  file that needs to be processed to determine what it represents.

This isn't the goal or the role of XML and even though it can be done it would add extreme complexity into the tools and libraries that use XML:

XML parser, DTD, Schemas, Validation, Data binding, etc, even if the conditional tests could be evaluated on the simple scope of the same single XML file.

 

 

 

Reply #6 Top

Which is why we need Python access! :grin:

Reply #7 Top

Please realize that python access also opens the pandoras box.

 

The modding of EwoM with python isn't easy and bulletproof. Mistakes and lack of understanding of how the game works internally will cause it to crash hard. This isn't like making a Heroes III map or a SC map, where the game has a complete suite of internal error checking to warn you or prevent you from breaking the game as you mod the stuff.

Reply #8 Top

"Behold the story of a lone adventurer named Sarudak who, despite the warnings of maniakos, unleashed a hoard of demons upon the lands while searching for a lost treasure called 'Python'. Forever since that day our Kingdom has been ravaged by their anger and violence."

Can't wait to see this pandora's box! Python access, please.

Reply #9 Top

Muahahahaha!!!! }:)

Reply #11 Top

Ok, you can certainly calculate stuff in an XML file. I don't know about doing IFs but see this code:

      <Calculate InternalName = "TroopMultiplier" ValueOwner="CastingUnit">
        <Expression><![CDATA[[TroopCount]*-1]]></Expression>
      </Calculate>
      <Calculate InternalName = "Value" ValueOwner="CastingUnit">
        <Expression><![CDATA[[UnitStat_Attack]*[TroopMultiplier]]]></Expression>
      </Calculate>

That's how the game calculates or calculated archers attack. But where do those values come from? How does it work?

Reply #12 Top

You certainly can use bolean logic in XML. It depends how the processor interprets it. Most web based content these actions are used, however, for elemental the game might not understand it.

Reply #13 Top

XML is designed to describe data. It is not meant for if checks.

Reply #14 Top

I found these lines of codes looking through Techs_Amarian.xml file in the Data>English folder. Its worth noting that these lines of code have been commented out.

 <!--<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[5*[UnitStat_Charisma]]]></Expression>
      </Calculate>
    </GameModifier>-->

I've tried to modify it several ways to see if I can get it to work for giving me research and all my numerous attempts failed. Maybe someone else can make use of it, you can find this code in line 2749 of the above mentioned file. Maybe ValueOwner="PlayerSovereign" is invalid or something now? Blah idk I tried a shit load of stuff.

Also you can find some examples on how to calculate data in XML looking in the Strategic spells files. FOr example Stoneskin which is in the CoreSpells_EarthStrategic.XML or something like that. THis would be so much easier if a nice dev dropped off some hints xD.

Reply #15 Top

Quoting Civfreak, reply 14
THis would be so much easier if a nice dev dropped off some hints .
End of Civfreak's quote

The devs are probably sleeping right now, trying to make up for lost sleep v_v Hopefully they'll be back soon |-)

Reply #16 Top

XSLT is another thing, in XSLT you use an XML document and XSL transformation code, to produce another document. An XSLT processor is used like a "compiler" on the inputs.

XSLT is XML like only in terms of it syntax, i.e. it uses markups, and only on the fact that it accepts XML as its input.

 

What lies inside the tags <Expression> ... </Expression> isn't part of XML and that was the intended design. It could be java, it could even be C++, a cooking recipe, a DNA sequence,  anything goes there and XML is oblivious about it, as long as it follows the proper XML textual form: encoding, escapes etc...

 

So no matter how good you are in XML, unless you know what the things inside the tags mean and how they can be used, you can't do anything and you just waste your time guessing every step on the way.

Reply #17 Top

I also look forward to this answer. This will be a great tool for moders!

Reply #18 Top

Maniakos is correct.  XML "describes data".  That's all it does.  XML can be used by other things like XSL or Python or even .net to provide scripts to process, but XML by itself is not a programming language.  It is a document.

 

Reply #19 Top

Absolutely, but what do you think that Elemental is doing with the XML? It is interpreting it. So in this case, it plays the same role as an XSL processor or anything else similar in reading the document. So it is all down to what XML elements and attributes it expects, and if it has an 'if' statement, either as part of the XML or as part of the Calculate/Expression element body. For that, we would need the Dev's input :D