EarthCake's problems
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.
Re: EarthCake's problems
Thanks!
Re: EarthCake's problems
Unmounting units:
I have few loyal mounted units, and I want to make them "ground" units on same tile when they lose all hp. In example, if they are horsemen, I want to make them spearmans, but to make them keep xp. Same as knight -> Pikeman. Is that possible?
I have few loyal mounted units, and I want to make them "ground" units on same tile when they lose all hp. In example, if they are horsemen, I want to make them spearmans, but to make them keep xp. Same as knight -> Pikeman. Is that possible?
Re: EarthCake's problems
Yes.
Either die event and create new unit based on old one, or last breath and change old unit into new unit.
Either die event and create new unit based on old one, or last breath and change old unit into new unit.
Re: EarthCake's problems
Note that Knight max_xp > Pikeman max_xp, so it's possible for the dying Knight to have more experience than Pikeman's max_XP.
Re: EarthCake's problems
How do I make them keep the same name, traits, and to appear at same tile?
Re: EarthCake's problems
Use transform_unit.
Re: EarthCake's problems
Code: Select all
[unit]
type=Pikeman
name=$unit.name
x,y=$x1,$y1
# The unit has almost been killed, so assume they start with no moves. Might also want attacks=0.
moves=0
side=$unit.side
experience=$unit.experience
# having animate=yes will make the unit appear as if it was recruited, see if it looks right
animate=yes
[/unit]
Re: EarthCake's problems
There us some problem with lua:
Here is code for "Unmounting.cfg":
Code: Select all
<Lua error>
game_error: creating unit with an empty type field
stack traceback:
[C]: in local 'cmd'
lua/wml-utils.lua:145: in field 'handle_event_commands'
lua/wml-flow.lua:6: in function <lua/wml-flow.lua:5>
Code: Select all
[event]
name=last breath
first_time_only=no
[set_variables]
name=unmounting
mode=replace
to_variable=unit
[/set_variables]
[if]
[variable]
name=unmounting.id
equals=Horseman
[/variable]
[then]
[set_variable]
name=horseman
value=Spearman
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=unmounting.id
equals=Cavalryman
[/variable]
[then]
[set_variable]
name=cavalryman
value=Swordsman
[/set_variable]
[/then]
[/if]
[unit]
side=1
type=$horseman
x=$unmounting.x
y=$unmounting.y
id=$unmounting.id
name=$unmounting.name
facing=$unmounting.facing
moves=2
hitpoints=14
[modifications]
[insert_tag]
name=trait
variable=unmounting.modifications.trait[0]
[/insert_tag]
[insert_tag]
name=trait
variable=unmounting.modifications.trait[1]
[/insert_tag]
[/modifications]
[/unit]
[unit]
side=1
type=$cavalryman
x=$unmounting.x
y=$unmounting.y
id=$unmounting.id
name=$unmounting.name
facing=$unmounting.facing
moves=2
hitpoints=14
[modifications]
[insert_tag]
name=trait
variable=unmounting.modifications.trait[0]
[/insert_tag]
[insert_tag]
name=trait
variable=unmounting.modifications.trait[1]
[/insert_tag]
[/modifications]
[/unit]
[/event]
That only transforms horseman into next level and then kills him (but very probably I screwed something with the code).
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: EarthCake's problems
What are the values of
$horseman
and $cavalryman
just before the [unit] tags start?99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: EarthCake's problems
Pentarctagon wrote: ↑May 10th, 2019, 6:24 pm What are the values of$horseman
and$cavalryman
just before the [unit] tags start?
$horseman
= Spearman$cavalryman
= SwordsmanCode: Select all
[set_variable]
name=cavalryman
value=Swordsman
[/set_variable]
Code: Select all
[set_variable]
name=horseman
value=Spearman
[/set_variable]
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: EarthCake's problems
And it prints that if you add:EarthCake wrote: ↑May 10th, 2019, 6:43 pmPentarctagon wrote: ↑May 10th, 2019, 6:24 pm What are the values of$horseman
and$cavalryman
just before the [unit] tags start?$horseman
= Spearman
$cavalryman
= Swordsman
Code: Select all
[set_variable] name=cavalryman value=Swordsman [/set_variable]
Code: Select all
[set_variable] name=horseman value=Spearman [/set_variable]
Code: Select all
[message]
message=$cavalryman
[/message]
[message]
message=$horseman
[/message]
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: EarthCake's problems
Those tags are not reached, so both variables are undefined.
Also, while this might work but it looks dodgy.
Also, while this might work but it looks dodgy.
Code: Select all
[set_variables]
name=unmounting
mode=replace
to_variable=unit
[/set_variables]
Re: EarthCake's problems
Ah, value needs to be
About code mentioned up, I copied that from SotA (thanks octalot!) and it works there.
Horseman
and Cavalryman
?About code mentioned up, I copied that from SotA (thanks octalot!) and it works there.
Re: EarthCake's problems
You're comparing unmounting.id to "Horseman", that's never going to be equal. You meant to compare unmounting.type.
Re: EarthCake's problems
I assumed you had already solved the "prevent the unit from dying when it reaches 0HP" part and was asking only about the "change the unit's type preserving its other attributes" part.
In any case, a
last breath
event that does [modify_unit] hitpoints=...
would prevent the unit from dying, after that you can do [transform_unit]
to change its type.