Werewolves that change at night.

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

Moderators: Forum Moderators, Developers

Post Reply
Larceny
Posts: 9
Joined: September 23rd, 2011, 3:38 am

Werewolves that change at night.

Post by Larceny » September 23rd, 2011, 3:53 am

For starters, I'm somehow stupid and thusly cannot publish my era. Not that it works, which is why I'm here.
Without further ado, here's the code:

BTW: It works aside from not being able to store the original loyalist/werefolk unit, which results in a total die-off at dawn.

Code: Select all

[event] #this is the transformations
name=new_turn

first_time_only=no

        [store_time_of_day]
            variable=time_of_day
        [/store_time_of_day]

 [switch]
    variable=time_of_day.lawful_bonus # I use lawful bonus 'cuz it works
    [case]
       value=25 # If it's day...
    [store_unit]
        [filter]
		race=werefolk
		type=Beta,Husky,Alpha,Darkwolfe # and you are in werewolf form now...
        [/filter]

        variable=MODIFY_UNIT_store # we store you.
        kill=yes
    [/store_unit]

    {FOREACH MODIFY_UNIT_store MODIFY_UNIT_i}
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.hitpoints # here I attempt to set the new form's HP proportionally to the original's. It's buggy, but it's the least of my worries right now, since it's rather spotty, too.
            value=$($MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.max_hitpoints|/$MODIFY_UNIT_store[$MODIFY_UNIT_i].max_hitpoints|*$MODIFY_UNIT_store[$MODIFY_UNIT_i].hitpoints|)
        [/set_variable]
        [set_variable] # this is the crux of the affair. I cannot set the stored unit within the stored unit to store a unit.
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.variables.wereform
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i]|
        [/set_variable]
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.x # setting it's location...
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i].x|
        [/set_variable]
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.y # setting it's location...
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i].y|
        [/set_variable]
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.side # setting it's side...
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i].side|
        [/set_variable]

        [unstore_unit]
            variable=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform # and finally unstoring the unit stored in the stored unit.
            find_vacant=no
        [/unstore_unit]
    {NEXT MODIFY_UNIT_i}
    {CLEAR_VARIABLE MODIFY_UNIT_store}
    [/case]

    [case]
       value=-25
    [store_unit]                   # This code is virtually identical, simply reversed. The meat is the same.
        [filter]
		race=werefolk
			[not]
			type=Beta,Husky,Alpha,Darkwolfe
			[/not]
        [/filter]

        variable=MODIFY_UNIT_store
        kill=yes
    [/store_unit]

    {FOREACH MODIFY_UNIT_store MODIFY_UNIT_i}
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.hitpoints
            value=$($MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.max_hitpoints|/$MODIFY_UNIT_store[$MODIFY_UNIT_i].max_hitpoints|*$MODIFY_UNIT_store[$MODIFY_UNIT_i].hitpoints|)
        [/set_variable]
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.variables.wereform
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i]|
        [/set_variable]
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.x
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i].x|
        [/set_variable]
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.y
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i].y|
        [/set_variable]
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.side
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i].side|
        [/set_variable]

        [unstore_unit]
            variable=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform
            find_vacant=no
        [/unstore_unit]
    {NEXT MODIFY_UNIT_i}
    [/case]
    [else]
       
    [/else]

 [/switch]
	[clear_variable]
		name=time_of_day
        [/clear_variable]
[/event]

User avatar
doofus-01
Art Contributor
Posts: 3819
Joined: January 6th, 2008, 9:27 pm
Location: USA, the civilized part.

Re: Werewolves that change at night.

Post by doofus-01 » September 23rd, 2011, 4:00 am

Doesn't one of the mainline campaigns do this? Liberty, I think? Sorry I don't remember which scenario, but I think it uses a non-standard "death-squire" or something like that. The Loyalists turn undead at night, then they turn human in daytime. Does that sound familiar to anyone?
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects

User avatar
Boldek
Posts: 576
Joined: April 14th, 2011, 6:37 pm

Re: Werewolves that change at night.

Post by Boldek » September 23rd, 2011, 4:04 am

the scenario 'unlawful orders' has a bunch of soldiers that become undead at sunset. third scenario in campaign liberty. probably best bet for your code.
Guys I never thought I'd come back to this forum after 8 years this is wild

Larceny
Posts: 9
Joined: September 23rd, 2011, 3:38 am

Re: Werewolves that change at night.

Post by Larceny » September 23rd, 2011, 4:18 am

I know. I looked into that, but it's not what I want. They don't have separate units. My code allows for you to have a Peasant that turns level 3 at night, and have proportional health to go with, so you don't have a Peasant with >50 health. Which wouldn't make sense at all.

User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Werewolves that change at night.

Post by zookeeper » September 23rd, 2011, 6:19 am

Code: Select all

        [set_variable] # this is the crux of the affair. I cannot set the stored unit within the stored unit to store a unit.
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.variables.wereform
            value=$MODIFY_UNIT_store[$MODIFY_UNIT_i]|
        [/set_variable]
Ok, a couple of misunderstandings here. Firstly, keys (such as value=) can only take string values. $MODIFY_UNIT_store[$MODIFY_UNIT_i]| cannot resolve to a string, because that variable reference is pointing to a whole tag, not another key. Doing that is, for all intents and purposes, always wrong. Secondly, [set_variable] cannot copy around whole tags anyway, for that you need [set_variables]:

Code: Select all

        [set_variables]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].variables.wereform.variables.wereform
            to_variable=MODIFY_UNIT_store[$MODIFY_UNIT_i] # note the missing $ and the confusingly-named to_variable key
        [/set_variables]

Larceny
Posts: 9
Joined: September 23rd, 2011, 3:38 am

Re: Werewolves that change at night.

Post by Larceny » September 23rd, 2011, 7:06 am

COOL! Thanks. It works now. But the hp is still doing weird things. :x

EDIT: Well, everything works now. I figured it out on my own. WML division (either that or my storing and modifying hitpoints directly) made it so there was no decimal places. So, I just put the division last. :P

If you want the completed code, ask. Else I won't bother.

EDIT: Era is on server (at least for 1.8 [shtupid emoticons]) just search for werewol no other mod applies.

Post Reply