Werewolves that change at night.

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

Moderator: Forum Moderators

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

Werewolves that change at night.

Post by Larceny »

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 Director
Posts: 4128
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: Werewolves that change at night.

Post by doofus-01 »

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 »

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 »

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: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Werewolves that change at night.

Post by zookeeper »

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 »

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.
User avatar
Atreides
Posts: 1074
Joined: March 30th, 2019, 10:38 pm
Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off

New and Improved Version 1.2.0 uploaded

Post by Atreides »

I ported this from Wesnoth 1.8 to 1.14/16. Just a quick job buuuut I decided to fiddle with it a little and bam:

NEW & IMPROVED! (What is this? Laundry detergent? Maybe the werewolves got a nice shampooing.) :)
The crappy werewolf sprites have been replaced. (and shampooed)
The night is shorter. (dawn is no longer were-time although it might be Miller-time if you survived the night)
I've worked on this some and the newly added 'Default Werewolf Era' might be balanced. They only get level 0 humans as recruits and a level 1 leader. Costs have been adjusted. Now they are very weak in the day and still monsters at night.
The old era is still there for those with a need to ruthlessly savage some victims, hehehe. Well the victims are now from AoH so they might resist a few seconds longer. <wide grin>
User avatar
Atreides
Posts: 1074
Joined: March 30th, 2019, 10:38 pm
Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off

Werewolf Era for 1.18

Post by Atreides »

Ported to 1.18.

Interesting note: The core loyalist swordsman has new sprites but has lost the Indian Jones-esque sword twirling idle animation. I've kept the original sprite set for those afflicted with Lycanthropy. Old stats (1.8?) too of course.
Post Reply