Author Topic: Coding  (Read 9434 times)

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Coding
« Reply #50 on: 28 March 2010, 23:09:37 »
Still, as I said, compared to a "standard" approach, that does create a rather complex XML tree because you still need to include all unit types. It would be ideal if you could somehow adapt the way it works so that adding a new unit doesn't require the addition of so many lines of XML - but doing THAT, as I said, may require a new approach to the logic used in the code as well.
What I had thought of a long time ago was something similar to an approach used in web site design.  Instead of defining all of the styles for each page individually, you can just link it to an external stylesheet, and thus have several pages using the same styles.  When you add something to the CSS, it updates it for all of the pages that reference it.  Since XHTML and XML are closely-related, I'd imagine this wouldn't be that hard to do (not a coder here, so don't shoot me :-X).

The significance here is that instead of referring to each individual unit, you could refer to that tag group.  This way, if there's a Hill Giant unit and your peasant has an animation where he gets squished by it, then if I add another unit (say, a Frost Giant) and they both refer to the "giant" tag group, then it could automatically use that same animation for the new unit.  I think something like this is vital if we want this feature to work when we start mixing and matching our factions.  This is similar to the "attack sub-type" idea I referred to above, but with much broader implications and (I think) more useful.  This would have implications not only on what's being discussed in this thread, but also in attack effects and damage types.

Let's suppose we have a giant zombie unit.
Code: [Select]
<unit-tags><!-- this is a hypothetical parameter for linking a unit to an external tag file -->
<tag path="../../../tags/giant.tag"/>
<tag path="../../../tags/undead.tag"/>
</unit-tags>

Then let's suppose we have another unit, say some kind of priest with a "holy word" attack.
Code: [Select]
<!-- attack skill stuff goes here -->
<efficacy><!-- this is a hypothetical parameter for determining what kinds of units will be affected more/less by an attack effect -->
<tag path="../../../tags/undead.tag" effect-multiplier="1.5"/>
<tag path="../../../tags/demonic.tag" effect-multiplier="2"/>
<tag path="../../../tags/angelic.tag" effect-multiplier="0"/>
</efficacy>
<!-- this means that whatever his special attack does, it will be more powerful against undead and demonic units, but useless against angelic ones -->
Code: [Select]
<!-- in the die skill -->
<default-animation path="models/fall_over_and_bleed.g3d"/>
<variations="true"/>
<variation>
<tag path="../../../tags/giant.tag"/>
<attack type="crushing"/>
<animation path="models/smooshed.g3d"/>
</variation>
<!-- if he is killed by a unit that is in the giant tag group using a crushing attack, he will use his smooshed animation -->
<!-- 2nd, 3rd, .. nth variations go here -->

So, in this case the unit tag affects the death animation of the victim, and also could have other properties.  For example:
Code: [Select]
<!-- in undead.tag -->
<damage-multipliers>
<damage-multiplier attack="arcane" value="1.5"/>
<damage-multiplier attack="piercing" value=".5"/>
</damage-multipliers>
<!-- units with the undead tag will be hurt more by arcane and less by piercing -->
In this way, the tag would function as sort of a permanent GAE-style "effect" on the unit.  In fact, effects could also apply temporary tags.  How would this be useful?  First of all, if you wanted two units to have a similar attack effect, you could have both of them refer to an external tag.  Also, because of this, attacks could be more or less useful in combination.  For example, let's use that Frost Giant I referred to earlier.  Let's say he has two attacks, "freezing breath" and "icebreaker".
Code: [Select]
<!-- in frost_giant.xml, in the freezing breath skill -->
<effects>
<applied-tags><!-- this is a hypothetical parameter for applying a tag to the target -->
<tag path="../../../tags/frozen.tag"/>
</applied-tags>
</effects>
<!-- when the frost giant uses his freezing breath, the target gains the "frozen" tag -->
Code: [Select]
<!-- in frozen.tag -->
<effects>
<multipliers>
<move-speed value=".5"/>
</multipliers>
</effects>
<!-- units with the frozen tag, whether specified in their own xml or because of an attack, will move at half speed -->
Code: [Select]
<!-- frost_giant.xml, in the icebreaker skill -->
<!-- yadda yadda goes here -->
<efficacy>
<affects-only value="true" path="../../../tags/frozen.tag"/><!-- hypothetical tag that means the effect will only be applied to targets of a certain type -->
</efficacy>
<!-- this means he can only use his icebreaker attack on frozen units -->

Edit: Did some more commenting in the code to explain better.
« Last Edit: 28 March 2010, 23:35:07 by John.d.h »

Fluffy203

  • Guest
Re: Coding
« Reply #51 on: 28 March 2010, 23:28:14 »
I like the tag idea it is very nice in my opinion and css is good too btw =)

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Coding
« Reply #52 on: 28 March 2010, 23:36:29 »
What I'm imagining is something halfway between website design and Battle for Wesnoth. ;D

Fluffy203

  • Guest
Re: Coding
« Reply #53 on: 28 March 2010, 23:42:54 »
what is the battle of wesnoth?

-Archmage-

  • Moderator
  • Dragon
  • ********
  • Posts: 5,887
  • Make it so.
    • View Profile
    • My Website
Re: Coding
« Reply #54 on: 28 March 2010, 23:55:38 »
Don't go off-topic...

Battle for Wesnoth
Egypt Remastered!

Proof: Owner of glest@mail.com

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Coding
« Reply #55 on: 29 March 2010, 00:21:52 »
As far as this discussion is concerned, it's a game that has a system for tagging unit types and abilities that is similar to the system I'm proposing.  For example, units can be tagged as undead, an elf, or a skirmisher unit, and all of these have various effects.  Additionally, special effects (like from attacks) are usually defined separately from the unit, and referenced in the unit's WML (their equivalent to XML).  This allows the unit types, abilities, etc., to be reused more easily.

Fluffy203

  • Guest
Re: Coding
« Reply #56 on: 29 March 2010, 00:38:31 »
I want to go off topic it is my topic and i want to know what it is lol

-Archmage-

  • Moderator
  • Dragon
  • ********
  • Posts: 5,887
  • Make it so.
    • View Profile
    • My Website
Re: Coding
« Reply #57 on: 29 March 2010, 00:41:09 »
What Battle for Wesnoth is?

Click the link on this post. :)
Egypt Remastered!

Proof: Owner of glest@mail.com

Fluffy203

  • Guest
Re: Coding
« Reply #58 on: 29 March 2010, 01:31:06 »
Thank you =) and i liked a good turn based strategy  :D

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Coding
« Reply #59 on: 29 March 2010, 09:47:34 »
What I had thought of a long time ago was something similar to ...
... instead of referring to each individual unit, you could refer to that tag group.
<snip/>
Brilliant.  :thumbup:

I might change the 'variations' (the name at least) and how there are specified slightly, but this is gold. Thanks for taking the time to think this out properly John!
Glest Advanced Engine - Code Monkey

Timeline | Downloads

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Coding
« Reply #60 on: 13 April 2010, 08:46:21 »
Bump.  Just wondering if anyone is actually planning on working on this. :look:

silnarm

  • GAE Team
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Coding
« Reply #61 on: 13 April 2010, 09:09:37 »
Indeed, I plan to,
#11 multiple skill animations

That's been slotted in for 0.3.1 based on when I think I can get around to it. If someone else can get it done earlier, that'd be great, but for myself I have some more 'under the hood' work to do, and then I have to apply the mega-patch ;) for 0.3.0, that's the only reason it's slated for 0.3.1. If someone wants to get it done earlier, I'm available and happy to provide assistance should it be needed.

Cheers.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

Fluffy203

  • Guest
Re: Coding
« Reply #62 on: 13 April 2010, 11:12:34 »
im still trying to tackle this beast

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Coding
« Reply #63 on: 13 April 2010, 18:50:29 »
Cool.  That's all I wanted to hear. 8)
Quote from: trac ticket #11
update: do what John said
lol Love the explanation there. :thumbup:

Fluffy203

  • Guest
Re: Coding
« Reply #64 on: 13 April 2010, 21:02:53 »
can't beat that  :thumbup:

jda

  • Guest
Re: Coding
« Reply #65 on: 26 April 2010, 03:42:46 »
That's been slotted in for 0.3.1 based on when I think I can get around to it. If someone else can get it done earlier, that'd be great, but for myself I have some more 'under the hood' work to do, and then I have to apply the mega-patch ;) for 0.3.0, that's the only reason it's slated for 0.3.1.
"Mega-patch"? What's that? Is it in any way related to MegaGlest?

 

anything