Jump to content

What is a battle? (battle detection)


Recommended Posts

a nuclear bomb went off somewhere in the map.

That should so be a cheat. I don't endorse nuclear warfare 99% of the time but something like that in the completed game would be epic :D

Not to mention many ancient texts speaking of such weapons (if you believe in/know of the ancient astronomer theory, you know what I mean)

Link to comment
Share on other sites

I think i was wrong, I shouldn't be too complicated.

I've played a few games in the last days and it feels like after a certain point in time you're constantly in a huge battle.

The main thing I was doing was setting rally-points somewhere near the front and keeping the stream of units rolling while keeping a balance between siege weapons, melee soldiers and ranged soldiers.

It would have felt wrong if peace-music started playing at any time during the last ~20 minutes.

This scenario could be easily covered with a kills/time ratio.

However it could be different for campaign missions and for new players who aren't that aggressive ;).

Probably it would still be sufficient to cover most of the situations by having a short-time kill-ratio and another longtime kill ratio.

Let's say 6 kills in 10 seconds are the short-time trigger for small battles in the early game. the battle sound could continue playing for another ~30 seconds when the condition isn't met anymore.

For the lategame we could have another long-term trigger. Let's say 50 kills in 5 minutes.

It would be calculated regularly and if it goes below that threshold, it would switch to peace-music again.

The idea is that it doesn't switch back to peace-music too quickly in the late-game.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

Are there differences between a battle and a raid? I think 10 cavalry archers firing on women isn't a battle, meanwhile a hero + 4 soldiers against a hero + 4 soldiers is a battle. Maybe you guys should make battles take into account if the units involved are economic or military, their ranks, if the soldiers are charging against each other and the percentage of military units present on the conflict to be considered a battle.

Link to comment
Share on other sites

  • 2 weeks later...

How feasible would it be to fade the battle music as you scroll away from the fighting as peace music fades in. Could work vice versa when you scroll towards a battle. If that hasn't been suggested before!

I'm personally against that, partly because it adds complexity to the implementation, but mostly because it would kind of ruin part of the purpose of battle music: to make sure you're aware that a battle is going on. On the other hand it would add to the other purpose: making battles "feel" differently from the rest of the game. But still, most of the time you're in the middle of a battle you'll want to either focus on the battle, or just quickly switching back and forth between economic duties elsewhere/bringing new troops to the fight, so I really don't think having the music fading back and forth would add very much.
  • Like 1
Link to comment
Share on other sites

I'm personally against that, partly because it adds complexity to the implementation, but mostly because it would kind of ruin part of the purpose of battle music: to make sure you're aware that a battle is going on. On the other hand it would add to the other purpose: making battles "feel" differently from the rest of the game. But still, most of the time you're in the middle of a battle you'll want to either focus on the battle, or just quickly switching back and forth between economic duties elsewhere/bringing new troops to the fight, so I really don't think having the music fading back and forth would add very much.

Good points. I guess what I was thinking of would be rather complex (such as the battle music playing to alert you then when you go to the battle and scroll away it fades sort of thing). Maybe it could just get quieter but not stop to add a bit of a 'feel' to it?

Depending on how dramatic the music is personally I would only want it for large battles such as 50+ troops. Smaller fights could have slightly less dramatic music.

Link to comment
Share on other sites

Good points. I guess what I was thinking of would be rather complex (such as the battle music playing to alert you then when you go to the battle and scroll away it fades sort of thing). Maybe it could just get quieter but not stop to add a bit of a 'feel' to it?

Depending on how dramatic the music is personally I would only want it for large battles such as 50+ troops. Smaller fights could have slightly less dramatic music.

I think we'll have a "Your units are being attacked" alarm sound when units are attacked, and only have battle music play during actual battles. Exactly how to define a battle is the main issue though (and the reason for this thread :P ).
Link to comment
Share on other sites

  • 3 weeks later...

I think a separate one would be best for this. It is easy to interface with the existing components so you can still share code.

Alright.

Here is the 'skeleton' of the state machine I intend to use: https://github.com/z...ffae749d150c6d2

How do I get it wired up so exactly one entity with this component is created when the game session begins?

Also, what is the preferred way for it to interact with the sound manager to trigger playback of peace/war music and notification sounds?

Edited by zoot
Link to comment
Share on other sites

For a single component you need to attach it to the system entity which unfortunately requires a C++ change. The location is:

source/simulation2/Simulation2.cpp:128

Apart from that you can just copy what one of the other system components does, there are files in public/simulation and public/simulation/interfaces.

Your basic design seems ok, but I was wondering if using a full FSM is overkill given that there are only two states. Maybe it would be simpler to not use the FSM?

I'm not sure about the sound manager since I have never used it.

Link to comment
Share on other sites

To me it seems like I'd only really want to hear the battle music when I was starting a large attack I had prepared and moved into place. While I want to be notified of any violence happening to my units, I do't consider it a battle when an enemy band happens upon an army gathering spot.

So maybe it could be based on the user input, like change to battle music when 10 or more units are commanded by the user to attack inside enemy territory (or your opponent launched such an attack inside your territory). Since its just a bonus nicety anyway I hate to see a lot of time being spent agonizing over when certain songs should be played.

Technically you are in a battle as soon as you appear on the map!

Link to comment
Share on other sites

I don't think a lot of agonizing will be needed, we have some good ideas in this thread for how battle vs. peace should be defined.

stwf, how do you recommend the BattleDetection component should trigger the sound manager to play a different track? Is there a particular function to use?

Also, which function should be used for playing attack notifications?

Link to comment
Share on other sites

  • 2 weeks later...

For a single component you need to attach it to the system entity which unfortunately requires a C++ change. The location is:

source/simulation2/Simulation2.cpp:128

Apart from that you can just copy what one of the other system components does, there are files in public/simulation and public/simulation/interfaces.

What am I missing:

https://github.com/zootzoot/0ad/compare/master...51dad1d

When I run it, I get this error and a crash:

ERROR: CXeromyces: Parse error: in_memory_buffer:1: Element interleave is empty
ERROR: RelaxNGValidator: Failed to compile schema

Edited by zoot
Link to comment
Share on other sites

You need at leas an <empty/> element. Also looking at another system component there seems to be another tag. Try adding these elements:

Thanks, I'll try that. (Edit: It worked :))

Also, will this component handle attack notifications?

Yes, that was my intention.

Edited by zoot
Link to comment
Share on other sites

That is odd. How are you testing whether it enters the Init() function? Also just to check the obvious, you have recompiled?

Just for reference I previously made a rough prototype of an attack notification system http://pastebin.com/Tq2nDYK8 . I made this a player component but a system component like you are doing might be better.

Link to comment
Share on other sites

That is odd. How are you testing whether it enters the Init() function? Also just to check the obvious, you have recompiled?

Ah, lol, that is it. I'm too accustomed to making JavaScript-only changes. :crazy:

Just for reference I previously made a rough prototype of an attack notification system http://pastebin.com/Tq2nDYK8 . I made this a player component but a system component like you are doing might be better.

Thanks, I'll try and integrate that code. What is the functional difference between a player component and a system component? Do they both require a C++ change?

Link to comment
Share on other sites

I just posted that code to give one idea for how to implement it, don't feel like to need to use it, only if it is helpful.

Only system components need the C++ change.

All components are part of entities. Most entities are things like trees, units etc. There are some special entities though, these include players, formation controllers and the system entity.

The components that an entity has are defined using the templates. So if there is <Identity>...</Identity> in the template than that entity will have an Identity component. You will find the templates for the unusual entities like players and formations in the templates/special directory. The single exception to this rule is the system entity which has the components defined with the C++ instead, there is only one system entity (there may be other differences, I don't know the fine details of the component system that well).

So if you create a player component there will be an instance of it for each player in the game. Whereas a system component will only have one instance because there is only one system entity.

Link to comment
Share on other sites

I would like to implement this:

For battle detection I think it would be good to use damage rate as a metric to determine when a battle is taking place. So if lots of units are being damaged then it is a major battle. The idea of taking the total army size into account sounds good as well.

What would be a good way to determine damage rate? I figured I might use the OnGlobalHealthChanged() event, but it contains no information about the affected entity. Should I slap a new argument on OnGlobalHealthChanged, or is there a better way?

Edit: Actually, OnGlobalHealthChanged passes a 'msg' object, so adding another property is not a big deal. I'll just do this unless there's any other suggestions.

Edit2: There is no information about who dealt the damage in the Health component, so maybe I have to do something else.

Edited by zoot
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...