Unit not able to claim towns

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

Rhuvaen wrote:
Darker_Dreams wrote:I was trying to simply run against the terrain the unit was on, then adjacent to. They have to be adjacent before they can be on... so;
Don't do that - you'll be disappointed. The moveto event fires on hexes a unit ends its move on - and it doesn't fire on intervening hexes. So unless the player moves one hex at a time, he won't trigger an "adjacent" event first.
Wait... can I just get the data on the hex moveto targets? No mucking around with arrays, just check the properties of the target hex?
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Post by AI »

let's keep it simple:

Code: Select all

#wmllint: unbalanced-on
#define ABILITY_NO_CAPTURE
    [dummy]
        id=no_capture
        name= _ "no capture"
        description= _ "No capture:
This unit is unable to fully capture villages, though it does drive off the previous owners"
    [/dummy]
[/abilities]
[event]
    name=capture
    [filter]
        ability=no_capture
    [/filter]
    [capture_village]
        x,y=$x,$y
    [/capture_village]
[/event]
[+abilities]
#enddef
#wmllint: unbalanced-off
Rhin
Posts: 29
Joined: January 25th, 2008, 9:28 pm
Location: Buenos Aires, Argentina

Post by Rhin »

Guess that's the answer to your problem...
Anyway you would have to create (or modify) the units that have that ability and add it in _main.cfg ---> [+units]

So, it's still hard work, isn't it?

Correct me if I'm wrong!
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Post by Rhuvaen »

Darker_Dreams wrote:Wait... can I just get the data on the hex moveto targets? No mucking around with arrays, just check the properties of the target hex?
But you're not going to use moveto, right? Not when you have a more specific event at hand (capture).

Really, zookeeper basically spelt it out. In the dev version, you can store all villages into an array with [store_villages]. That stores ownership for you, too (in case you wanted to keep the original owner as per the original idea). The capture event should filter on the ability, as AI's example did.
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

Rhuvaen wrote:
Darker_Dreams wrote:Wait... can I just get the data on the hex moveto targets? No mucking around with arrays, just check the properties of the target hex?
But you're not going to use moveto, right? Not when you have a more specific event at hand (capture).

Really, zookeeper basically spelt it out. In the dev version, you can store all villages into an array with [store_villages]. That stores ownership for you, too (in case you wanted to keep the original owner as per the original idea). The capture event should filter on the ability, as AI's example did.
My work on this is on hold until I can figure out why I can get Wesnoth to recognize that I've made a test-era, but not any of the files in that test-era's directory.
CIB
Code Contributor
Posts: 625
Joined: November 24th, 2006, 11:26 pm

Post by CIB »

Darker_Dreams wrote: My work on this is on hold until I can figure out why I can get Wesnoth to recognize that I've made a test-era, but not any of the files in that test-era's directory.
You need to include any directory explicitly, subdirectories won't be loaded automatically. If the directory is included, either _main.cfg or all .cfg's in the directory should be loaded.
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

CIB wrote:
Darker_Dreams wrote: My work on this is on hold until I can figure out why I can get Wesnoth to recognize that I've made a test-era, but not any of the files in that test-era's directory.
You need to include any directory explicitly, subdirectories won't be loaded automatically. If the directory is included, either _main.cfg or all .cfg's in the directory should be loaded.
I have included the directory and all subdirectories. (Even some I've since emptied to get extra stuff out of the way!) If I leave the .cfg setting it up external to the folder (test_era.cfg) it finds the MP settings in the internal test_era.cfg. If I try to do a _main.cfg it doesn't find it.

At the moment, the entire era consists of the 2 .cfg's (one of which is almost entirely a copy-paste of the Loyalist faction) and an .png in a file folder, that I've made certain is correctly referenced as many ways as possible. This has included checking against the wiki, which is somewhat confusing/lacking some particular details or explanations (especially in the case where something goes wrong!). Also, I've tried comparing against several different eras which are equally confusing because they each do the same things in different ways, plus they generally do several other things too.


It's gotten particularly frustrating, because I had it working, then *something* I did when putting a new unit in to test (actually a unit using code from this discussion- and some other code I hadn't used before) the thing started spitting out errors. I got it to quit giving me errors- by removing the unit with the intent to add it back piece by piece, but it's continued to waver between not being found at all and giving "unexpected character" errors. I finally got it to quit giving errors, but it's just not finding the listed subdirectories.





short answer; if there's one thing that I'm certain of, its that all the subdirectories are listed. What I'm not sure of is if there should be some @, ~, or # included in that (I know I've seen some combination of all those characters working) or if there's some other arcane character I've managed to omit or include incorrectly (\, /, etc) or if I've completely missed the boat on something necessary to make it work.

blah.
sorry for ranting.
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

So, I decided to just go back to cutting into the core units and files.
AI wrote:let's keep it simple:
This displayed the name/disc ok (both if inserted in the unit itself and if added to the abilities file and referenced thus), but it did not prevent the unit from capturing/recapturing the village. The only thing I saw was possibly a (lack of) first_time_only=no in the event... but it still didn't seem to do it.

This might sound insultingly basic, but please recognize that I'm asking because I actually don't know;
x,y=$x,$y
I assume this is intended to pass the x,y of the primary_unit to the [capture_village] function.
1) Does the unit in question remain the primary_unit for this event because it's calling for the event? units are deselected upon receiving their commands, so I assume it's no longer "active."
2) $x,$y calls a stored x,y value, but without defining it will it automatically call the x,y of the primary_unit (or desired unit)- or does something need to be done to store those?


Rhuvaen wrote:
Darker_Dreams wrote:Wait... can I just get the data on the hex moveto targets? No mucking around with arrays, just check the properties of the target hex?
But you're not going to use moveto, right? Not when you have a more specific event at hand (capture).

Really, zookeeper basically spelt it out. In the dev version, you can store all villages into an array with [store_villages]. That stores ownership for you, too (in case you wanted to keep the original owner as per the original idea). The capture event should filter on the ability, as AI's example did.
reading the documentation in the Wiki, it looks like I'll need to make several arrays (an array of arrays?), picking up the villages owned by each team (and none). is there's something (I'm) missing in that description that will make it less intensive.
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Post by AI »

the first_time_only=no was indeed missing.

I haven't tested it, but I don't see anything else wrong with it...
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

AI wrote:the first_time_only=no was indeed missing.

I haven't tested it, but I don't see anything else wrong with it...
Neither do I (which is why I started this exercise, and was asking questions to make sure I understand what you're doing), but when grafted into the vampire bat's .cfg (or the abilities file and the ability grafted into the bat) the thing still zipped over and claimed a town like there was nothing different.
Though, it did swear the whole time it couldn't do anything of the sort so I called it a liar and hit it with a big stick.

(I've found that a vary satisfying feature about working on units- when they don't work like they're supposed to I can call them defective and beat them up for it. It's great stress relief compared to eras, which just sit there and laugh as I fail to find the problem.)
Post Reply