Recruit Variation Macro -- and boarding ships.

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
trewe
Translator
Posts: 122
Joined: December 24th, 2012, 5:37 pm
Location: Portugal
Contact:

Re: {ABILITY_REPAIR}

Post by trewe »

can't really follow you, what is it supposed to do?

if the ship should regenerate 5% of their health every turn just include the following where it is defined (unit_type not unit)

Code: Select all

[abilities]
    [regenerate] #<-- the error
        value=5%
        id=whatever
        name= _ "repair"
        female_name= _ "female^repair"
        description= _ "Repair:
The ship will heal itself 5% HP per turn. If it is burning (poisoned), it will remove the fire instead of repairing."
        affect_self=yes
        poison=cured
    [/regenerate]
[/abilities]
your first attempt was right, but it is regenerate instead repair as tag name
What am I doing wrong? Everything is in the core folder, with the others.
create a directory for your mod in userdata, it is safer than modifying core
User avatar
junoslord
Posts: 82
Joined: June 11th, 2012, 3:13 pm
Location: Enveloping your left flank.

Re: {ABILITY_REPAIR}

Post by junoslord »

It worked, thanks. I was just over complicating things for myself.
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."

"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"
User avatar
junoslord
Posts: 82
Joined: June 11th, 2012, 3:13 pm
Location: Enveloping your left flank.

[modify unit] & [not quite sure]

Post by junoslord »

Two quick ones. (Okay, three really-- and a yes/no question.)

First, a few weeks ago you guys helped me with my plague problem (still have a cough) in converting a captured ship into a Prize Ship. I used that with a return event where moving the PS to x,y gives you 50 gold. What I would really like to do though is have it turned back into whatever type of ship it had been. Because the plague can only effect the victim this step (turning it back to the original) is way past me at this point.

Also, to this point: Does the AI understand that when it gets a Prize Ship or has a convoy that moving a certain unit type to x,y will get it good stuff? Gold or ships or troops, or whatever you'd like at that point.

Not really the second one... how do I filter an attack by [move_type] to stop the plague that turns another ship into another ship from turning ground troops on the coast into another ship? That then gets swarmed by other troops because it has 0% defense on land... always a nearby Spearman comes and gets 3 hits, unless there's not one nearby, and 2 units swarm it. (This will often times seriously weaken or even cripple a AI sides defense as they swarm the easy kill.) I'd like the unit to just die, since it mean a crew can sortie ashore, which is historic. I thought a death event by [move_type] set to kill land units would do the trick, but this would run every time a unit dies, which would ruin runtime, wouldn't it?

Okay second, is there a way, in [scenario] or [unit_type] to limit a units movement to a certain terrain type. The wiki only mentions the general terrain types (sand, shallow_water) but not by code. I'm hoping I could do something in scenario to block certain ship types, by move_type, from traveling on certain types of individual terrains so that I can keep big hulled ships out of rivers, but still allow rivers to have deep water for purposes of blocking ground units from wading across.

I think this would go in the prestart and that it would work. Except I know [movement_cost] only takes type=, so it won't work. But it should be possible.

Sorry, this is sloppy, I'm literally doing it now... :roll:

Code: Select all

  [filter]
  move_type=deepwater
  terrain=Ab,Cd                 
[movement_cost]
  movement_points=10
[/m_c]
  [/fil]
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."

"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: [modify unit] & [not quite sure]

Post by 8680 »

junoslord wrote:First, [...]
Also, [...]
Not really the second one... [...]
I recommend making a race for your ships, so that it can be filtered for.

Code: Select all

[race]
    id="ship"
    name= _ "race^Ship"
    plural_name= _ "race^Ships"
    num_traits=2
[/race]
For this complexity, I think it would be better to use events than plague.

Code: Select all

#define ABILITY_SHIP_CAPTURE
[dummy]
    id="ShipCapture"
    name= _ "capture"
    description= _ "capture:
Vessels defeated by this unit are boarded and captured."
[/dummy]
[/abilities]
[event]
    id="ABILITY_SHIP_CAPTURE-die"
    name=die
    first_time_only=no
    [filter]
        race="ship"
    [/filter]
    [filter_second]
        ability="ShipCapture"
    [/filter_second]
    [modify_unit]
        [filter]
            id=$unit.id
        [/filter]
        type="Prize Ship"
        side=$second_unit.side
        hitpoints=10
        [variables]
            oldType=$unit.type
        [/variables]
    [/modify_unit]
    [if]
        [have_unit]
            id=$unit.id
            formula=my_side.is_ai
        [/have_unit]
        [then]
            [modify_unit]
                [filter]
                    id=$unit.id
                [/filter]
                ## If an AI side captures a ship, tell it to move the ship to
                ## these coordinates. The variables should be set in each
                ## scenario, or just replaced with numbers if it’s always the
                ## same location.
                goto_x,goto_y=$PrizeShipGotoX,$PrizeShipGotoY
            [/modify_unit]
        [/then]
    [/if]
[/event]
[+abilities]
#enddef
And a moveto event.

Code: Select all

[event]
    name=moveto
    first_time_only=no
    [filter]
        x,y=$PrizeShipGotoX,$PrizeShipGotoY
        type="Prize Ship"
    [/filter]
    [gold]
        side=$unit.side
        amount=50
    [/gold]
    [modify_unit]
        [filter]
            id=$unit.id
        [/filter]
        type=$unit.variables.oldType
    [/modify_unit]
[/event]
Also, I merged your naval threads.
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Recruit Variation Macro -- and boarding ships.

Post by UnwiseOwl »

I was thinking this would be a weapon special rather than an ability. So there's a boarding 'weapon' which can capture, and more poweful guns or ram or whatever that does the real damage. I've was trying to work out how I'd code it a little last week, but that above is much more elegant than everything I had.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Recruit Variation Macro -- and boarding ships.

Post by 8680 »

It could make more sense as a weapon special, but die events can’t be filtered on those.
Post Reply