Posts from Scripts
I tried swapping objects 1 and 3, but left the code as is.
It was like this:
first player = object "1"
second player = object "2", and so on.
The 3rd player and the 3rd object, and so on up to the 8th, didn't work.
Now it's like this:
the first player touches object "3" and everything works.
the third player touches object "1" and doesn't work.
This means the code is correct and works for all 8 functions.
It seems the problem is with the player number - it works for 2 players, but not for 6.
I'll have to abandon the great idea of a bonus that the human player can choose.
Added 28 minutes later
Well, if you look at the DialogBox code, you can assume that the problem is with the use of GetCurrentPlayer there. TalkBox expects the first argument to be not the player number, but its filter. For the 1st and 2nd player, the filter is equal to the number, but not for 3+. Therefore, it probably only works for the first two players. If the problem is this, then the solution would be to wrap the first argument of DialogBox - GetPlayerFilter(GetCurrentPlayer())
I tried swapping object 1 with object 3, but I left the code the same.
It was like this:
first player = object "1"
second player = object "2", and so on.
The 3rd player and the 3rd object, and so on up to 8, didn't workNow it's like this:
the first player touches object "3" and everything works.
the third player touches object "1" and doesn't work.
This means the code is correct and works for all 8 functions.
It seems the problem is with the player number - it works for 2 players, but not for 6.
I'll have to abandon the cool idea of a bonus that the player can choose (((
Added 28 minutes later
I added the filter retrieval, everything works now, thank you.
For all functions that are named ...BoxForPlayers, the argument for the player ID works strangely. Player 1 = 1, Player 2 = 2, Player 3 = 4, Player 4 = 8, Player 5 = 16, Player 6 = 32, Player 7 = 64, Player 8 = 128. I'm not sure about the last 2, I only checked for 6 players.
For all functions that are named ...BoxForPlayers, the argument for the player ID works strangely. Player 1 = 1, Player 2 = 2, Player 3 = 4, Player 4 = 8, Player 5 = 16, Player 6 = 32, Player 7 = 64, Player 8 = 128. I'm not sure about the last two; I only checked for 6 players.
This is a bitmask, so that the same message can be displayed for multiple players at once. For example, if you need it for players 1, 3, and 5, you can pass PLAYERFLT_1 + PLAYERFLT_3 + PLAYERFLT_5.
Good evening, I wanted to use a script to give a hero mana, similar to the "Secret Advantage" skill, so that it would ignore the hero's maximum mana. I tried using ChangeHeroStat(), but it didn't work. The funny thing is, when I first started working on the map, I actually managed to implement ignoring the maximum mana, but I needed it to go up to the maximum, and now it's the other way around, and I can't remember how I did it. I found a solution on the forum on how to give a hero up to 300 mana using ChangeHeroStat(), but as I mentioned above, it didn't work.
Good evening, I wanted to give a hero mana through a script, like with the "Secret Advantage" skill, so that it ignores the hero's maximum mana. I tried using ChangeHeroStat(), but it didn't work. The funny thing is that when I just started working on the map, I actually managed to ignore the maximum mana, but I needed it to go up to the maximum, and now it's the other way around, and I can't remember how I did it. I found an answer on the forum on how to give a hero mana up to 300 using ChangeHeroStat(), but as I wrote above, it didn't work.
Possible solution: temporarily add Knowledge to the hero, and after increasing the amount of mana, return the Knowledge to its previous value. Example:
ChangeHeroStat("Deleb", STAT_KNOWLEDGE, 10)
ChangeHeroStat("Deleb", STAT_MANA_POINTS, 100)
ChangeHeroStat("Deleb", STAT_KNOWLEDGE, -10)
I quickly checked it through the console. Yes, it works, the mana remains above the maximum value. For now, I'll do it this way; maybe someone knows how to do it with a single command.
Possible solution: temporarily add Knowledge to the hero, and after increasing the amount of mana, return the Knowledge to its previous value. Example:
ChangeHeroStat("Deleb", STAT_KNOWLEDGE, 10)
ChangeHeroStat("Deleb", STAT_MANA_POINTS, 100)
ChangeHeroStat("Deleb", STAT_KNOWLEDGE, -10)
I quickly checked it through the console. Yes, it works, the mana remains above the maximum value. For now, this is how it's done; perhaps someone knows how to do it with a single command.
In my mod, health points are technically implemented as a hero's mana, and there is no such problem. ChangeHeroStat increases the mana pool beyond what the hero's knowledge allows.
Hello, I have a simple task: create a script in the map editor that, for example, grants X experience to any hero who kills a neutral creature.
However, I can't seem to implement it. What's the error here?
GetPlayerHeroes(0);
SetGameVar(whotoup, 0);
whotoup = GetPlayerHeroes(0);
ChangeHeroStat(whotoup[0], 0, 999999999)
Good afternoon, I have a simple task: to create a script in the map editor that, for example, when a neutral creature is killed, any hero who does it receives X experience.
But I can't seem to implement it. What's the error here?
GetPlayerHeroes(0);
SetGameVar(whotoup, 0);
whotoup = GetPlayerHeroes(0);
ChangeHeroStat(whotoup[0], 0, 999999999)
You can achieve a simpler result with workarounds, but if you need precise logic, so that ANY hero receives experience for defeating a SPECIFIC stack, and not a total number of creatures, here's my idea:
Give a name to the unit on the map. For example, UnitExp
function FightUnitExp(hero, unit)
while isObjectExists(hero) == not nil and isObjectExists(unit) == not nil do
sleep(5)
end
if isObjectExists(unit) == nil then
ChangeHeroStat(hero, 0, 999999999)
end
end
Trigger(OBJECT_TOUCH_TRIGGER, "UnitExp", "FightUnitExp")
Right away, two silly questions:
How do I assign this name to a unit?
Where should I add this script? To the unit itself? If so, should it be a script or a combat script?
Two silly questions right away)
How do I give a unit this name?
Where should I add this script? To this unit? If so, is it a script or a combat script?
The name is added to the Name parameter of the unit in the map editor. I've attached a screenshot; the area is highlighted in green.
The script goes into the general script for the map.
Added after 1 minute
I see, and is this trick compatible with the heroes5.5 mod? Because it has its own scripts too.