I wanted to create the typical experience mechanism for a hero where the condition is “object has an action (attack)” and the effect is “change variable Exp by 1” in loop.
This always work when it’s a scenario where the hero needs to survive but how to make it work when the hero can die and return but it’s technically not anymore the unit you selected for the attack condition.
I thought you could simply set the generic unit type but no you need a specific unit to work and when that unit dies it doesn’t work anymore.
Use the Modify Attribute effect to tweak the unit’s stats instead of the “Change Object xxxx” effect. Modify Attribute always keep track of the modified stats, IDs etc, and do not cause the Objects to be unaffected by technologies and the like.
So if you make the unit gain say, 1 attack every level of XP, you’d use Modifiy Attribute => Attack (Add 1) and specify the type of attack: 4 is melee, 3 is ranged (same for Armour, 4 is base melee, 3 is base pierce).
The issue here is that the unit that I set for the “object has an action” condition can die (she’s an heroine respawning) and once she’s dead I can’t set her unit as a condition because it’s not yet present in the scenario editor. Don’t know if it’s clear, it’s a bit hard to explain.
In short I can’t use the “object has an action” if not for a specific unit to gain experience, not for a type of units.
The modify attribute works fine, no problems with that.
Ah yes I see, the Object Has Action condition forces to select an object (which is a bit restrictive indeed).
In that case I don’t think there’s any way currently to pull this off, unfortunately.
I wish they could make the trigger work even without selecting a specific object, also because you can select a type of unit (at first I thought it was enough indeed!)
Yes, I’m not sure if this is intented for this effect to force you to select a specific object, or if that’s just the game’s limitation.
One last thing! I can’t change the unit visibility properly through the specific modify attribute. If I set it to 1 the unit is only visible through the fog but not when it moves in the unexplored black zone.
What I’d like to do is to make that specific type of enemy units to be visible like they’re yours, so through the fog and even exploring if they walk in the black.
I hope that was clear, thank you really for all the help, I won’t bother you again for a while!
You could possibly try setting the attribute to 2, for visible if alive. I’m not sure it’ll be any different, but it could help potentially.
Thanks I’ll let you know!
After testing: if you put value 0 visibility is normal.
If you put 3 it becomes invisible but your units attack it if it’s in “sight”.
If you put 1, 2 or 4 it’s visible only through the fog but not as if it’s your unit.
So it’s either a bug or I’m doing something wrong. If someone else can test it we could know.
Why not read this article?
I know it’s very late to answer, but anyway.
I have an idea: maybe you can make that heroine immortal. When she’s about to die (I don’t know how you could do that but I have a few ideas), you can teleport her somewhere inaccessible for the player and make her come back. Either simulate a death then a resuscitation, or an injury then a come back after a healing, or whatever imagination fits your needs.
Like that, your unit wouldn’t die at all in the game and thus the Has Action trigger wouldn’t loose the link with the unit.
EDIT: I think it’s an interface limitation, because when I read a documentation about AoE II Editor scripting, it seems that the original function doesn’t require a selected object specifically. It explicitly says that you can indicate a class of object and not necessarily a precise object.
You can look there for more details: Functions - AoE2DE UGC Guide.
The fact that the hero needs to remain alive to gain experience can be an incentive for the player to not just throw him in whatever battle cause he will respawn anyway so in the end I made a virtue of necessity. Thank you for the answer anyway, that can be a useful workaround!
Yeah right, I think it’s a good point that she can still come back, just losing her XP.
It still can be interesting not to lose the XP in some situations, I guess, everything depends on the lore and the balance we want.
For the “resuscitation”, I just got a precise idea: teleporting the one about to die, create a clone at the exact same place where the original have been teleported from, then kill the clone. I don’t know what it’ll look like, but I want to try just for the test.
EDIT :
Well. I just began to try but realized an issue: we can’t “save” an area. So I thought “if only we could have variables who can represent an area”, and it made me think that we can store area coordinates into variables, though. Then my idea is to retrieve the (falsely) dying unit coordinates (the one we’re about to teleport) and use it to define an area.
I don’t know yet whether it’s possible to retrieve the coordinates of a unit but I do know that we can define an area thanks to coordinates in the Editor interface (when we select an area, it shows the coordinates, which we can edit). But the interface doesn’t permit to use variables to define any area (e.g. : the “Create Object” Effect requires to set an area by point-and-clicking with the mouse).
So my conclusion is that I have no solution to create a clone on the (unpredictable) dying area using the interface, but by using scripts, I’m convinced it’s possible and probably not that hard to do. I’m not into AoE II Editor scripting yet, but one day I will, and maybe I’ll remember that thing I wanna try ^^
I think it should be possible with xs script but I try to use it the least I can cause I’m no expert.
Without scripting what you could do maybe is to teleport the unit once hp are like 1 or something (set 1 hp as invincibility threshold just to be sure the hero doesn’t die accidentally). Then make an object spawn in the form of the hero corpse to simulate death and after a certain time make the hero teleport back to your TC or something.
In the pure technical point of view, I don’t understand in this situation the difference between create a clone and kill it, and spawn a corpse. Either case, you need the unpredictable die location, and you can’t set a location with “Create Object” in another way than to point and click in the Editor, before the game begins.
For scripting, I found some websites with tutorials and docs. I share it there in case someone reading this is interested:
I’m a programmer, but I also prefer to use the interface as much as possible for now, so I can understand common people do too.
I’m not sure but maybe you can simply set the creation location of the corpse to the hero unit. That way it should spawn wherever the hero is.
If this doesn’t work you could create a garrisoned object (which is a copy of the hero unit) inside the hero, eject and kill it at the moment your main hero reaches 1 hp, just before teleporting. If the player looks closely may notice the trick but they would notice the teleportation anyway, that’s what we have to work with.
I like your ideas, so I tested. But I don’t find a way to make it work.
Set Location to a unit:
I tried selecting a unit to Set Location, but it actually selects the location just below the unit. Then, if the unit moves, and even if it’s killed before spawning the clone, the clone spawns at the starting location of the original unit, not where the original unit actually is. I suppose teleporting will do the same.
Garrison/Unload:
I never imagined we could garrison anything into a unit like a hero or a soldier, that’s very good to know !
It’s not possible via the classical interface, though (without using triggers). When you create a unit on, let’s say, a tower, it garrisons it into the tower (until it’s full, then it doesn’t do anything unless you delete a garrisoned unit). You can’t do this on a unit: it just colors in red the unit to be placed, and does nothing when you click.
So I’m trying to garrison with the “Create Garrisoned Object” Effect, and it works as soon as you use Modify Attribute before, to add a Garrison Capacity to the unit you want to simulate death with (it adds it to all instances of that unit though: you can’t modify that attribute to one unit specifically).
1. But then the issue comes when you want to Unload. The “Unload” Effect requires to Set Location somewhere, and now we’re faced with the same problem as at start.
2. Similar issue with the “Kill Object” Effect.
- If you define a unit to kill via the Object List combo box (e.g.: Bandit), it’ll kill every instances of that unit (every Bandit existing will die), thus your original hero(oine) will die, as much as the clone.
- You can either set an area or set objects to kill, but you can’t Set Area an area you don’t know where it’ll be yet, and you can’t Set Objects that will be created by an Effect and thus doesn’t exist yet (and I don’t know how we can create a garrisoned object into an object that hasn’t a garrison capacity in the first place).
I tried this anyway by setting arbitrary locations at start, and it works. That’s the whole issue: in practice, we don’t know the death location before it happens.
Also, it’s visually visible: you have to put a delay between the unload and the teleport, because even you first Unload the clone unit and then Teleport Object the original unit, the Unload happens after the Teleport and both are teleported. I wondered if it was the Teleport Object that teleported both clone and original units after the Unload, but I checked twice that I did use “Set Objects” and left anything else unused, and I even tried again with a different unit for the “clone” (a Beserk) being garrisoned into the “original” unit (a Bandit), and it’s the same: they’re both teleported, despite setting “Bandit” (and thus not Berserk) in the Object List combo box into the Teleport Object.
I consider it a bug, because Effects should happen one after the other. You shouldn’t have to get a second trigger with a >= 2s Timer as a Condition, Trigger activated by the first one that teleports. I have to put 2s because it actually wait one second less than indicated - another bug, I guess - and you can’t put a timer for less than one second (being able to do a 0.1s Timer would be nice).
More bugs and fun:
For the “Teleport Object” Effet, even if I only select “Bandit” in the Object List combo box without setting any object or any area (I set a location though), it works. I don’t know how the editor understood what Bandit had to be teleported since I had classically (without triggers) created several other bandits (it was for another test in the same test scenario). I suppose it has taken the last object used for that Effect or something like that.
The funniest thing happened when I tried to teleport without even indicating any unit in the Object List combo box. Important precision: I had also created a town center and two villagers (and a watch tower) for yet another test. So, I just set a location for the “Teleport Object” Effect and that’s all, so it should do nothing because the Editor shouldn’t know what to teleport. But it freaking did !? And not the bandit, It teleported the town center and a villager, but not even properly: the town center is physically teleported, but only some very small parts are. At the new location, the Town Center is almost invisible, and at the old location, it seems to still be there. But physically, it has been teleported because if I create a Villager, it appears from the new Town Center location. The weirdest thing is that the hitbox is cloned: I can click on the Town Center and use it like usual either at the old or the new location.
Off-topic observation: the Condition “Object Has Action” doesn’t work most of the time with the “Train” Unit AI Action. I wanted to use it for a tutorial campaign I just began for AoE II DE: RoR but it didn’t work. So I tested on AoE II because I had the intuition it was something to do with adding female villagers on the AoE II ported version of AoE I (AoE I - original or DE - has no female villagers, unlike AoE II DE: RoR).
Aaaaand it works like once in ten attempts. On AoE II DE, it doesn’t work most of the time, but from time to time, rarely, it works. On the RoR DLC (AoE II DE ported version of AoE I), it seems it doesn’t work at all.
This editor is so buggy. It has less than a week that I try to do things, and I’ve already faced so many bugs, maybe 6 or more (I also met some interface bugs).
I just remembered that the first time I read this topic, I had thought about a solution simpler than anything we talked about: use variables to store XP.
I was really interested to simulate a false death instead of actually let it die and create it again, just by curiosity, just for the experience.
But if you just want to keep XP when your unit dies, you can store the XP into a variable, in the same Trigger that adds XP to your hero (when they kill a unit, for example). Then, when your unit dies and you re-create it, you can also re-add all the stats thanks to the stored value in your variable.
Using variables is mostly easy. You can even rename it, and that helps a lot to understand what you’re doing.
I think you need to use “ungarrison” which is a different task from “unload” which you use for transport ships. Ungarrison is for buildings and doesn’t need a location, just select the hero as if he was a building.
As for the teleport issue it may work if you use a unit different from the hero to garrison inside the hero and reskin it to look like that hero. That way you don’t need to know the location and the teleport effect will teleport the hero but the unit inside will stay there and die once ungarrisoned. Real problem would be how you hide that unit from the UI of the player and prevent them to ungarrison it from the hero beforehand…
Yeah welcome to “solve the game’s issues without being paid for it”!
Indeed that’s what I do. Problem is once it respawn the hero will retain the stats he accumulated through experience before dying but won’t be able to accumulate more cause the “object has action” unit is dead.