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

Unit not able to claim towns

Post by Darker_Dreams »

Various discussions of bats and blitz-claims of towns lead me to wonder if it was possible to make units unable to claim towns... I've got another idea for a unit for which the inability to claim towns would be both interesting and appropriate...

so, is this possible?
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Post by Ken_Oh »

Yes, in a number of ways depending on the exact desired outcome, this is very possible.
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

I'm not seeing anything in the macros file or searching that would indicate how this could be done...
any suggestions?
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Post by AI »

you can assign village ownership through WML, and villages are only captured by moving *into* a village.

So, you should be able to make this an ability, I'm just not sure if you can *not* have the move into the village take up all your remaining MP.
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

AI wrote:you can assign village ownership through WML, and villages are only captured by moving *into* a village.
*blinks and goes to check again*

I see how to set starting villages in the scenarios, but I don't see a "give village" in either the wiki nor any of the scenarios I can think of. I don't really want to go line by line through every scenario I've got in hopes someone used it somewhere I've forgotten or haven't gotten to, do you happen to know where that tag would be used?

AI wrote:So, you should be able to make this an ability, I'm just not sure if you can *not* have the move into the village take up all your remaining MP.
I couldn't care less about that part- you can move through a village without stopping, so I assume if you're targeting it with movement you're planning on stopping for healing or otherwise.
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Post by AI »

# [capture_village] changes the ownership of a village.

* side the side that takes control of the village. If not given, the village will become neutral.
* x, y the location of the village.


add a moveto event that filters on terrain and all that's missing is whoever owned the village previously.
Rhin
Posts: 29
Joined: January 25th, 2008, 9:28 pm
Location: Buenos Aires, Argentina

Post by Rhin »

Another idea:

Instead of placing normal villages, just place the image as an item.
Then, whenever only the leader (or whatever you wanna use) stands on that item (tile, use moveto with the x,y filter), you modify the terrain tile into a village. That way, villages will only be captured when you want it to happen.

Another way of doing the same:

If you want to keep the village defense properties (60% of protection), but not the healing and income bonus, you can create a terrain that looks like a village (use aliasof when creating it, and disable healing and income), that way you will have the defense but not the other bonuses.
And when the leader (or whatever you use) reaches that tile, you change the terrain into a real village and give the player control of it (there is more than one tag to make this happen, check the wiki).

Hope this helps ;D
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Post by appleide »

If the side has no leader then the units of that side are unable to capture villages. Just don't let them have a leader, if it is convenient to do so.
Why did the fish laugh? Because the sea weed.
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

I don't want *all* the units to be unable to capture. I'm just considering a category of units which would be unlikely to "hold" a village or which are useful, but pariah among civilizations and unlikely to "conqure" the village. It's a unit *type* that I can see used across several scenarios.

-thus, I want the feature as an "ability" of the unit, not the scenario.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

What you need to make certain units (unit x) unable to capture villages is:

1. A side turn event which stores all villages into a variable and also records the info on who controls each village, every side turn (or at least on every side turn of every side which has unit x). The bold part is the annoying one; you'll have to create a big nested [if] checking whether the owner is side 1, if it's side 2, if it's side 3, etc.

2. A capture event for when unit x captures a village. Retrieve the previous owner side (or 0 if none) from the variables recorded in step 1. and set it as the village owner.

That's the best possible way according to my knowledge. Full undoability of moves except when unit x captures a village (since canceling the capture does necessarily invalidate undo).
User avatar
Darker_Dreams
Posts: 608
Joined: February 1st, 2008, 5:26 pm

Post by Darker_Dreams »

zookeeper wrote:What you need to make certain units (unit x) unable to capture villages is:

1. A side turn event which stores all villages into a variable and also records the info on who controls each village, every side turn (or at least on every side turn of every side which has unit x). The bold part is the annoying one; you'll have to create a big nested [if] checking whether the owner is side 1, if it's side 2, if it's side 3, etc.

2. A capture event for when unit x captures a village. Retrieve the previous owner side (or 0 if none) from the variables recorded in step 1. and set it as the village owner.
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;
All I have to do is an array for the location and owner of the adjacent villages, when it finds any (in case the unit finds itself on a map has closely packed villages).
Because it checks current hex first, if it finds that it's on a village, it references the array from the previous hex, finds out who owned the village, and gives it back.
While I can filter for villages, I haven't yet found how to determine ask if a village is claimed or not- then I have to figure out arrays. (I am sooo not a programmer.)
This does, of course, happen for each step- so possibly too intensive.

Alternately, it only has to array the hexes of villages within it's movement radius- not the whole map before it moves.


It'd be easier to make the unit simply unclaim the village. I assume that I'd just have to do
[capture_village]
x,y
side=0
[/capture_village]
(unless there's some other "null" value for village ownership?)

Of course, I still have to figure out how to make the unit tell the macro where it is currently.


zookeeper wrote:That's the best possible way according to my knowledge. Full undoability of moves except when unit x captures a village (since canceling the capture does necessarily invalidate undo).
I was thinking about something similar to that, but I thought full undoability simply allowed the action to be undone, didn't force it. Even if it did force it, while that might be useful to prevent entry, it wouldn't allow a unit to move in and sit there.


Question on the [capture_village] tag- I obviously haven't gotten everything together to make something to test- but the [capture_village] is listed as a scenario tag. Will this make the game choke, or are the pieces to WML fairly interchangable?
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient »

you're making this a lot harder than it is, zook.
the capture event already detects if you are truly making a capture :roll:
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Post by Rhuvaen »

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.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Sapient wrote:you're making this a lot harder than it is, zook.
the capture event already detects if you are truly making a capture :roll:
Well, I am using a capture event to detect if the unit is making a capture, am I not? I just can't reset the village back to the original owner in the capture event, because the information about the previous owner is nowhere to be found unless I've stored it earlier.

That said, I wouldn't indeed need anything more than a single capture event if the unit always removed all ownership of the village it moves into (except own/friendly villages, I guess), instead of doing nothing, which is what my way does (move into enemy village and the enemy doesn't lose control of it).
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Post by AI »

removing control wouldn't be a bad idea and you won't remove your own ownership since that doesn't generate a capture event.

if it's not strong enough to hold it, maybe it is strong enough to chase out the mayor?
Post Reply