patchBattle for Wesnoth - Patches: patch #3943, Set initial unit facing direction...

Show feedback again

patch #3943: Set initial unit facing direction based on map location

Submitted by:  David Mikos <coffee>
Submitted on:  Sun Jun 16 03:55:16 2013  
Priority: 3 - LowStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Sat Jun 22 15:29:15 2013, comment #5:

Please excuse me, that should have been fifteen, not nine, collections mentioned in my preceding comment. My bad. (I might have taken an analogy to D&D's alignment system a bit too far. :) )

J Tyne <jamit>
Project Member
Sat Jun 22 14:53:33 2013, comment #4:

Hmm... actually, the complexity of this is not bad, if you take a less controlling approach. I've attached a file with a simpler implementation that you might want to consider. Instead of grouping hexes into nine collections, I gave each hex its own set of probabilities for what directions it might face. On the surface, this probably sounds more complex since there are more possibilities, but this allows a calculation instead of a branching assignment.

(Note: If my patch was intended for committing instead of demonstrating, I should have given my new function appropriate header comments.)

(file #18153)

J Tyne <jamit>
Project Member
Sat Jun 22 14:19:32 2013, comment #3:

I had tried that in-game with the new dwarf fighters a while ago, but just to be sure, I tried it again, and also looked at the skeletons. I think it works well facing the recruiter. shrug Maybe I just have no eye for this sort of thing, but it certainly is not as obvious as you seem to think it is.

"Basically facing the center of the board" does not mean "actually facing the center of the board". I read what you described, including the part where you stuck "ALL" in the middle of your table. It's still basically facing the center of the board.

Finding the current threat sounds even more complex code-wise. How much gain are we really getting from all this complexity?

Slowing down the game better not be an issue. With all the time available during a recruit, if you were slowing down the game with this, you would be doing something terribly wrong. I was talking about simplicity, not efficiency. Simpler code is easier to maintain. As for complexity, what you did is not detached from all the important code -- it's right smack in the middle of place_recruit(), alongside the important code. (Hint: introducing new functions to call from within existing functions is often better than expanding existing functions into monster routines.)

J Tyne <jamit>
Project Member
Tue Jun 18 09:51:28 2013, comment #2:

You really have to try that in game with the new skeletons and dwarf fighters to see that it really wouldn't work well facing the recruiter.

I did not actually make it so that the units face the middle of the map, because in the middle it is a random direction and it gets more constrained to face the other side of the board the more you get to one of the edges or corners.

After speaking with Fabi on IRC it seems like it might be good to use this a a fallback (and also for initial leader facing directions) and for new recruits to face where the current most threat is (so enemy units, but not a goblin if there is a fire dragon, etc.).

The patch as it is though does a bit I think to make the MP maps feel a bit nicer to play (than current random initial facings). Recruitment placings is just one niceness that is not necessary, but would not slow down the game much or really introduce too much complexity I think -- it is pretty much detached from all the important code.

David Mikos <coffee>
Project Member
Sun Jun 16 22:42:46 2013, comment #1:

I don't have time to look at the patch at the moment, but I had a thought about the design. Would it be simpler (and just as nice) to have recruits and recalls initially face the recruiter/recaller instead of basically facing the center of the board?

Just a thought about keeping the codebase simple. As I said, I have not looked at the implementation yet, so maybe it would not be any simpler.

J Tyne <jamit>
Project Member
Sun Jun 16 03:55:16 2013, original submission:

Now that the dwarvish fighter and skeleton and other units are set to have multiple facing directions, I thought it would be nice if the initial facing directions on recruit were more directed.

Attached is a patch that sets the initial facing diretion on recruit like so:

If you imagine the board split into parts, the intial facing directions would be like so after applying the patch:




Where multiple direction choices are chosen randomly.

The idea is that if you are playing at the bottom of the map your units should be initially facing north and in the middle they could go be facing any which way, etc.

David Mikos <coffee>
Project Member


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by jamit (Posted a comment)
  • -unavailable- added by coffee (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat Jun 22 14:53:33 2013jamitAttached File-=>Added simpler.patch, #18153
    Sun Jun 16 03:55:16 2013coffeeAttached File-=>Added 2013.06.16_recruit_unit_facing_direction_based_on_map_location.patch, #18096
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup