Ranged Era

It's not easy creating an entire faction or era. Post your work and collaborate in this forum.

Moderators: Forum Moderators, Developers

mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Ranged Era

Post by mich » February 6th, 2009, 8:16 pm

Hi guys, I have created an era where the units have a real ranged attack.
It's based on part of the mech wars code, but I have worked a lot on it.
I know that probably the game is better without a real ranged attack, but well, it's a different kind of game.
It's based on the default era, and it's not balanced, but it works; you can find it in the 1.4 addon server, let me know what you think and how can I improve it.
It must be quite easy to use the base of the era for others era, but for now a lot of code comments are in italian. I will try to port it on the 1.5, but probably there will be some problem with the new terrain.
And please, report me the bugs (and sorry for my bad english).

User avatar
Turuk
Sithslayer
Posts: 5283
Joined: February 28th, 2007, 8:58 pm
Contact:

Re: Ranged Era

Post by Turuk » February 6th, 2009, 8:31 pm

I downloaded your era to give it a play, and it certainly is interesting. Though, as you pointed out, it does make factions quite unbalanced, as I can use my ranged units to attack melee units (who do not have range to retaliate) from behind my own melee units. Also, the concept is great, but the use of so much right clicking your unit to activate the ability and then right clicking the enemy unit to attack got tedious after a handful of turns. Still, not a bad workaround.
Mainline Maintainer: AOI, DM, NR, TB and THoT.
UMC Maintainer: Forward They Cried, A Few Logs, A Few More Logs, Start of the War, and Battle Against Time

User avatar
mnewton1
Posts: 777
Joined: November 12th, 2008, 4:31 am
Location: On my pretty teal horsey.
Contact:

Re: Ranged Era

Post by mnewton1 » February 6th, 2009, 9:47 pm

I like it!!! I always wanted an era were you could do this. Now with your code I can do this with other units too. But one problem is they can shoot through walls and impassable mountains
Creator of Ageless Era
Check out Frogatto & Friends, it's made by the same people who created The Battle for Wesnoth!

mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: Ranged Era

Post by mich » February 9th, 2009, 1:31 pm

Thanks for trying it.
Yes, I know that there are still some problems (shoot through walls is one of the bigger), but with the current wml (and my actual skill level) it's not so easy to find a workaround.
Now I try to port it to 1.5 (but probably there will be some problem with the current macro for the defense % calculation), then I will try to resolve the remaining problem, but it will not be so easy. And well, now I use a macro taken direcly from Mech Wars for the defense % calculation, I have only added the remaining terrain, but with the use of overlays present in the 1.5 ( for the bridge and some other terrain) probably is better to find another way to do that. Someone has an idea?

panzervb
Posts: 46
Joined: October 28th, 2008, 4:09 am
Location: Malaysia

Re: Ranged Era

Post by panzervb » February 9th, 2009, 3:11 pm

Can I steal your workaround method for artillery use in my era?
19962104.
Author of 1940:European Theatre era.

mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: Ranged Era

Post by mich » February 9th, 2009, 4:57 pm

Yes, you can, it's under GPL. I only hope that you understand how it works, it's not really easy, and a lot of code comments are in italian. If you don't understand how it works feel free to ask. Good luck with your era.

User avatar
TL
Posts: 511
Joined: March 3rd, 2007, 3:02 am

Re: Ranged Era

Post by TL » February 10th, 2009, 5:31 am

If shooting through walls is a problem, here's a quick and dirty way to check for walls in your LOS, assuming a range 2 attack:

Code: Select all

[have_location]
  terrain=Xu,assorted other impassable terrain
  [and]
    x,y=$guy_thats_shooting.x,$guy_thats_shooting.y
    radius=1
  [/and]
  [and]
    x,y=$guy_getting_shot.x,$guy_getting_shot.y
    radius=1
  [/and]
[/have_location]
If you're dealing with an attack range of 3, it's a bit more tricky:

Code: Select all

[have_location]
  terrain=Xu,assorted other impassable terrain
  [and]
    [and]
      x,y=$guy_thats_shooting.x,$guy_thats_shooting.y
      radius=1
    [/and]
    [and]
      x,y=$guy_getting_shot.x,$guy_getting_shot.y
      radius=2
    [/and]
    [or]
      [and]
        x,y=$guy_thats_shooting.x,$guy_thats_shooting.y
        radius=2
      [/and]
      [and]
        x,y=$guy_getting_shot.x,$guy_getting_shot.y
        radius=1
      [/and]
    [/or]
  [/and]
[/have_location]
(Disclaimer: I am quite severely sleep-deprived and am prone to mistakes on conditional filters this complex even when well rested, so this may not work as written, but the concept is there. Longer ranges are going to be tricky; you can extend this method for ranges >3 but it will fail at certain angles at longer ranges and I'm too tired to come up with a fix.)

panzervb
Posts: 46
Joined: October 28th, 2008, 4:09 am
Location: Malaysia

Re: Ranged Era

Post by panzervb » February 10th, 2009, 1:11 pm

Okay now I have to ask:
How does this system works? Can you send me a sample piece of code? I don't have 1.4.7 of Wesnoth here.
19962104.
Author of 1940:European Theatre era.

mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: Ranged Era

Post by mich » February 11th, 2009, 10:05 am

panzervb wrote:Okay now I have to ask:
How does this system works? Can you send me a sample piece of code? I don't have 1.4.7 of Wesnoth here.
I'm working for the 1.5 port, probably you will find it on the addon server tomorrow. Then if you are interested in the use of the code in your era, I will try to explain you how to use it, but as you can see my english is not really fluent.


@TL: thanks for the code. In the past I have thought to do something similar, but there is a problem in some positions
<attachment removed>
As you can see sometimes there are 2 ways. Maybe I can handle it, with some [if] to take care of the different cases, but I have always postpone it. Well, after the release of the 1.5 version it's time to look at it. Thanks again for the code, probably I will use a modified version of it.

--edit: ok, the simplest way to handle that case is to simply use a [not], so if there is a hex that is not wall it's ok, but what about this?
<attachment removed>
Here there are 3 ways, all blocked. Maybe I can find a solution (I already have an idea), but it will not be so easy.

--edit2: Well, I have solved the problem, so I have removed the attachments. Wait tommorrow for the new version (for 1.5).

mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: Ranged Era

Post by mich » February 12th, 2009, 12:37 pm

Version 0.3.2 is out (for 1.5 only).
I have fixed the shoot through walls problem and ported all the code to 1.5, so enjoy the new release and report me the bugs.

@panzervb: if you are still interested in use this code in your era, just PM me.

Velensk
Multiplayer Contributor
Posts: 3987
Joined: January 24th, 2007, 12:56 am

Re: Ranged Era

Post by Velensk » February 16th, 2009, 12:19 am

There seems to be a bug that makes the elven dexterous trait apply itself twice when ranged attacking. A dexterous elf ranged attacking an orcish grunt deals 7 damage and a non-dexterous archer deals 5.
"There are two kinds of old men in the world. The kind who didn't go to war and who say that they should have lived fast died young and left a handsome corpse and the old men who did go to war and who say that there is no such thing as a handsome corpse."

mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: Ranged Era

Post by mich » February 16th, 2009, 8:31 am

Velensk wrote:There seems to be a bug that makes the elven dexterous trait apply itself twice when ranged attacking. A dexterous elf ranged attacking an orcish grunt deals 7 damage and a non-dexterous archer deals 5.
You are right, but this happens only in the 1.5 version. In 1.4 the ${UNIT_STORED}.attack[$attack_number].damage variable is always 5 (for an elvish archer), and I have to use a macro to apply the dexterous trait. In 1.5 it's seems that if a unit has the dexterous trait, it has the variable modified, so my macro is no more needed. I have removed it and now it works in the right way, but before releasing the new version I will look if the others modifiers work correctly, cause in 1.5 I haven't done all the tests (time of day, leadership, resistances, slow, etc..).
Thanks for the bug report.

--edit: Version 0.3.3 is out. That problem is fixed now, and you can no longer shoot througth others units. Enjoy.

Retributive
Posts: 47
Joined: February 20th, 2009, 12:45 pm
Location: Bordeaux, FRANCE.

Re: Ranged Era

Post by Retributive » February 25th, 2009, 1:08 pm

Hi, mich.
I just downloaded and installed your Ranged Era, and its amazing, excellent work.

I was wondering if it was possible to include it in a regular campaign scenario (outside multiplayer game), and how this could be done (if possible).
I also noticed that if you have an unit with a ranged attack that is not recruited (but created in the scenario file, using the "Long" unit type or not), it doesn't get that ranged attack ability (I'm using Wesnoth 1.4.7 stable, maybe it works in a more recent one).

Please, let me know about that...
Thanks for your concern.

Friendly yours,
Retributive.

mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: Ranged Era

Post by mich » February 25th, 2009, 5:33 pm

Hi Retributive.
Retributive wrote:I was wondering if it was possible to include it in a regular campaign scenario (outside multiplayer game), and how this could be done (if possible).
Yes, it's possible, you have only to put all the file in the macro folder inside your addon, same things with the ../units/missile folder. You have also to copy the units file, or you have to change some macro to add new units support. The movetype file is also necessary (it's the projectiles movetype). After that you have only to put same macro in your scenario (look at the era file for the macros needed).
Retributive wrote:I also noticed that if you have an unit with a ranged attack that is not recruited (but created in the scenario file, using the "Long" unit type or not), it doesn't get that ranged attack ability (I'm using Wesnoth 1.4.7 stable, maybe it works in a more recent one).
Yes, the problem is that I don't know a simple way to put variables inside a unit, so I use a start and a recruit event. But if you create a unit with wml, there is no event, so some variables are not set properly. So you have only to set those variables in the event where the unit is created. At the moment there is not a simple macro to put inside your event, but I can change this in the future. So you have to use something like this

Code: Select all

[event]
      name=......
      [unit]
            type=...
            ........
            ........
            [variables]
                  tiro_pronto=0
            [/variables]
      [/unit]
      [store_unit]
            [filter]
                x=...
                y=...
            [/filter]
            variable=temp_unit_variable
       [/store_unit]
       {SET_DISTANCE temp_unit_variable}
       [clear_variable]
              name=temp_unit_variable
       [/clear_variable]
[/event]  
This is not tested, so maybe there are some errors, but the idea is there. For more info you can look at the SET_DISTANCE (in set_distance.cfg) and SET_RANGED_ERA_VARIABLES (in set_variables.cfg) macros. And yes, I have to change the "tiro_pronto" variable name to something in english, but at the moment I have not much time to work on this. If I remember correcly, this is the only variable with an italian name.

And yes, if you want you can also set all the variables inside the [variables] tag (look at the set_distance macro to see what are the others variables needed).

The only differece from the 1.4 and 1.5 version is the impossibility to shoot througt walls and others units (in 1.5).
Let me know if you have others problems, and thanks for trying this era.
Last edited by mich on February 26th, 2009, 12:13 pm, edited 1 time in total.

Retributive
Posts: 47
Joined: February 20th, 2009, 12:45 pm
Location: Bordeaux, FRANCE.

Re: Ranged Era

Post by Retributive » February 26th, 2009, 11:49 am

Hi, again.
It still doesn't work for me, here is what I did:
My campaign:
in userdata\data\campaigns\my_campaign\

_main.cfg
scenarios\01_my_first_scenario.cfg
images\misc #your images\misc folder
macros #your macros folder
movetypes #your movetypes folder
units #your units folder (and all its subfolders)
My _main.cfg file:

Code: Select all

[campaign]
    id="My_Campaing"
    name= _ "My Campaing"
    first_scenario="01_my_first_scenario"
    define="MY_CAMPAIGN"
[/campaign]

#ifdef MY_CAMPAIGN

[binary_path]
    path="data/campaigns/My_Campaign"
[/binary_path]

[+units]
       {@campaigns/My_Campaign/units}
	{@campaigns/My_Campaign/units/elves}
	{@campaigns/My_Campaign/units/humans}
	{@campaigns/My_Campaign/units/wose}
	{@campaigns/My_Campaign/units/merfolk}
	{@campaigns/My_Campaign/units/saurians}	
	{@campaigns/My_Campaign/units/drakes}
	{@campaigns/My_Campaign/units/undead}
	{@campaigns/My_Campaign/units/bats}
	{@campaigns/My_Campaign/units/orcs}
	{@campaigns/My_Campaign/units/goblins}
	{@campaigns/My_Campaign/units/nagas}
	{@campaigns/My_Campaign/units/trolls}
	{@campaigns/My_Campaign/units/dwarves}
	{@campaigns/My_Campaign/units/gryphons}
	{@campaigns/My_Campaign/units/missile}
[/units]

    {@campaigns/Aventure_en_cours/movetypes}
    {@campaigns/Aventure_en_cours/macros/}
    {@campaigns/Aventure_en_cours/scenarios}

#endif
My first Scenario: 01_my_first_scenario.cfg

Code: Select all

[scenario]
...
{SET_RANGED_ERA_VARIABLES}
{SET_RANGED_ERA_MENU}
{LOAD_HELP_MENU}
{LEADER_DIE}
...
[/scenario]
I got both the "Help" and the "use ranged attack" menuitems, when I use the "use ranged attack" item I got the can-shoot-from-afar sprite on the top-right of the unit, but I don't have the "fire" menuitem when I right-click on a potential target.
Maybe I misplace your 4 macros calls)...

Edit:
Yes, the problem is that I don't know a simple way to put variables inside a unit, so I use a start and a recruit event. But if you create a unit with wml, there is no event, so some variables are not set properly. So you have only to set those variables in the event where the unit is created. At the moment there is not a simple macro to put inside your event, but I can change this in the future. So you have to use something like this
I simply replace your "recruit" event with a "select" event (after all, units are selected before acting), and your menuitems appears also with WML created units (but still can't shoot at target)...
Last edited by Retributive on February 26th, 2009, 6:47 pm, edited 3 times in total.

Post Reply