Ability for replacing a killed unit with another
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.
Ability for replacing a killed unit with another
Hi, I want to create an ability (probably it was already done) to a unit that when is killed will be replaced with a new one. What i can do? Do I need a "dummy" tag?
Thanks for the help you can give me
Thanks for the help you can give me
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: Ability for replacing a killed unit with another
You are greatly unspecific. You can just use plague, maybe a custom one (check the ABILITY_PLAGUE_TYPE macro in core/macros/abilities.cfg). But I suppose that you want something different, but I can't tell what from your vague question.
Re: Ability for replacing a killed unit with another
Sorry, I'll try to explain.
I want the unit who have the ability, when defeated will create another differnet unit on the hex where it died. It's not a special attack.
Hope I explained well this time
I want the unit who have the ability, when defeated will create another differnet unit on the hex where it died. It's not a special attack.
Hope I explained well this time
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Ability for replacing a killed unit with another
event with name die, filter dead unit (cause if im not wrong this dead unit still exist), kill it and on same place create other one unit which you want.
event names
Something close to this what you have in labirynth of champions, where when you have to fight with 3 lvl mage, after his death are created 2 second lvl mages, after kiling one of them are creating 2 first lvl mages.
event names
Something close to this what you have in labirynth of champions, where when you have to fight with 3 lvl mage, after his death are created 2 second lvl mages, after kiling one of them are creating 2 first lvl mages.
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Re: Ability for replacing a killed unit with another
Thanks for the help! I've found the code! I'll try to adapt it to my needs.
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: Ability for replacing a killed unit with another
This is the result:
Is this right? Anyway I will test it in some days. Before I must create other things to try it
Code: Select all
#define ABILITY_POSSESSION
# When this unit die, another unit will appear in the same place.
[event]
name=die
[unit]
side=$side_number
type=......
x=$x
y=$y
[/unit]
[/event]
#enddef
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: Ability for replacing a killed unit with another
The problem is that you can't put an event directly into an [abilities] tag and still have it be read. You will need code to have it be effectively inserted. It would look something like this special:
note the [+attack] and [+specials] at the end, that puts the processor back where it was when it started reading the ability. Also, you should probably create a dummy ability just so that those playing can see that you have this capability.
Code: Select all
#define WEAPON_SPECIAL_TRAMPLE
[attacks]
id=weapon_special_trample
name= _ "Trample"
description= _ "On offense units with trample will gain two extra strikes and if they kill they will move into the hex of the unit they killed."
apply_to=self
active_on=offense
add=2
[/attacks]
[/specials]
[/attack]
[event]
name=attacker hits
first_time_only=no
[filter_attack]
special=weapon_special_trample
[/filter_attack]
[if]
[not]
[have_unit]
x,y=$x2,$y2
[/have_unit]
[/not]
[then]
[set_variable]
name=experience_earned
value=8
[/set_variable]
[if]
[variable]
name=second_unit.level
not_equals=0
[/variable]
[then]
[set_variable]
name=experience_earned
multiply=$second_unit.level
[/set_variable]
[/then]
[else]
[set_variable]
name=experience_earned
value=4
[/set_variable]
[/else]
[/if]
[kill]
x,y=$x2,$y2
fire_event=yes
[secondary_unit]
x,y=$x1,$y1
[/secondary_unit]
[/kill]
[store_unit]
[filter]
x,y=$x1,$y1
[/filter]
kill=yes
variable=trampler
[/store_unit]
{VARIABLE_OP trampler.experience add $experience_earned}
[unstore_unit]
variable=trampler
x,y=$x2,$y2
[/unstore_unit]
[capture_village]
x,y=$x2,$y2
side=$trampler.side
[/capture_village]
{CLEAR_VARIABLE experience_earned}
[/then]
[/if]
[/event]
[+attack]
[+specials]
#enddef
"There are two kinds of old men in the world. The kind who didn't go to war and who say that they should have lived fast died young and left a handsome corpse and the old men who did go to war and who say that there is no such thing as a handsome corpse."
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Ability for replacing a killed unit with another
Hi !
This is a solution where no special nor ability is needed (but you can define one):
or, if you prefer to keep the same unit:
Hope this helps !
This is a solution where no special nor ability is needed (but you can define one):
Code: Select all
#define ABILITY_IMMORTAL UNIT
# context: unit type or scenarios. Units are immediately replaced if killed.
# UNIT is a SUF (without [filter] tag) defining the able unit (ex: id=Lestiviel or type=Elvish Archer)
[event]
name=die
first_time_only=no
[filter]
{UNIT}
[/filter]
# the kill action is necessary to free the unit position before creating a new one.
# else, the new unit would be created on an adjacent hex.
[store_unit]
[filter]
id=$unit.id
[/filter]
variable=tmp
kill=yes
animate=no
[/store_unit]
# this creates a new unit with no experience
[unit]
type=$tmp.type
side=$tmp.side
x,y=$tmp.x,$tmp.y
[/unit]
{CLEAR_VARIABLE tmp}
[/event]
#enddef
Code: Select all
#define ABILITY_IMMORTAL UNIT
# context: unit type or scenarios. Units are immediately healed if killed.
# UNIT is a SUF (without [filter] tag) defining the able unit (ex: id=Lestiviel or type=Elvish Archer)
[event]
name=last breath
first_time_only=no
[filter]
{UNIT}
[/filter]
[heal_unit]
[filter]
id=$unit.id
[/filter]
amount=full
[/heal_unit]
[/event]
#enddef
HowTos: WML filtering, WML variables
Re: Ability for replacing a killed unit with another
Thanks!
@pyrophorus: it seems more similar to what I want the first solution! Only a question. What is for "tmp"? I thought it was just this way "$x".
@pyrophorus: it seems more similar to what I want the first solution! Only a question. What is for "tmp"? I thought it was just this way "$x".
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: Ability for replacing a killed unit with another
It is just a name of the variable. tmp --> temporary stored. I usually go with "temp" or "temp_store_unit-name" etc, but those are all the same.Dorimen wrote:Only a question. What is for "tmp"? I thought it was just this way "$x".
pyrophorus probably used short one for you not to make a mistake.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Re: Ability for replacing a killed unit with another
Ok! Thanks
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--