Much better now!
-) Misspelling: Freindly
-) Misleading "friendly" in many descriptions. All variables have nothing to do with allied players.
This condition does not do anything useful: !!FU&i^dark_enabledForAI^=(FALSE):E;
The whole logics of dark_enabledForAI seems to be unclear.
Check for AI should be done via OW:I(player)/?(isAi:y);
-) ; Jump to the next hero if hero is in the same team with current player
Obvious comment. !!co is jump, the condition is trivial.
-) !!HEi:O?(owner:y);
!!OW:T(owner)/?(heroTeam:y);
Check for NO_OWNER and continue. Do not get team for heroes without owner.
-) Separate break commands from the rest code, they are flow control structures (important things):
-) !!UN:U(OBJ_HERO)/i/-1/?(x)/?(y)/?(z);
That's wrong! UN:U searches for N-th object on adventure map, many heroes are not on adventure map and besides, you already have necessary hero ID.
My congratulations. Your coding skills are improving from day to day!
This script is really modular, clear and reusable.
Thanks a lot
Berserker. I rely on spelling check heavily. Too bad Sublime Text didn't correct the misspelling for me ))))
I struggled with naming the script. The "friendly darkness" is the best result that came out. Friendly - short for "user-friendly". As you see, the new darkness is less annoying, more user-friendly in some ways, makes sense now?
The i^dark_enabledForAi^ is for disabling the new darkness ability for AI players. Stupid AIs don't play well even if the whole map is revealed for them...I wanted to check whether the current player is AI, if yes + i^dark_enabledForAi^ then the function ends.
Corrected the script with your awesome tips! Added some VR:F to prevent issues since I encourage players to edit Settings as they pleased...are they necessary?
(31.05.2021 18:45)fatsawhorse Wrote: [ -> ]Quote:в окне героя заблокировать через !!СМ:R0; действие клика на арте #149,
- сама то беда как раз что я не могу никак определить этот арт. Не вижу нигде ресиверов, которые бы его определили при этом чтобы на нём прошло нажатие левой кнопки мыши! 
Я тебе уже давал ранее такой код в одном из скриптов
Quote:Question: In what scenario would you prefer variables to be announced at the beginning of a function?
Declare function arguments at the top of the function and declare local variables as close to the first usage place, as possible. Thus variable is created in the context of its usage.
Quote:!#VA(x:y) (y:y) (z:y);
These variables can be created on the fly on the first usage:
HE:P?(x:y)/...
We can move
to instructions after declarations. This is a one time operation.
!#VRi^dark_enabledForAi^:F(FALSE)/(TRUE);
...
=>
To my mind, getting two parameters can be joined in the same command and still be readable. Like get isAi and team.
The commend should describe exit condition, usually we calculate something and then exit on condition.
Next, you miss !!HEi:P?(x)/?(y)/?(z); before UN:H
Berserker, great! Totally forgot about the short syntax for boolean after reading the changelog.
Corrected all those. But I just realize I made a serious mistake - The UN:H was wrongly used.
Code:
UN:H
Hide part of the map (round area)
#1 = x
#2 = y
#3 = Level
#4 = Owner (Format E1)
#5 = Radius
Comments:
The shroud will be replaced for all players except the owner.
Thought that was placed for the owner only.
Looks like I have to rewrite
Edit:
done rewriting for now, checking team is not even necessary, your allies will always reveal themselves. Also changed to end of turn trigger - heroes with Darkness will hide himself/herself after moving.
Excellent work!
Invalid. Change to !#FU(dark_RestrainValues):P;
Change to !?FU(OnGameEnter)&i^dark_on^;
Same for other triggers.
Remove, declare vars on the first usage in !!HEi:P?(x:y)/?(y:y)/?(z:y);
Great! Corrected everything. Now it's time to send it to our customer.

But since when do we have the improved boolean support?
Any & variable = (TRUE) can now be written as & variable?
SergOz здравствуйте..
Спасибо за код, но конечно шлем всё же одевается с рюкзака всё равно, но только с центрального (с общего рюкзака), но я по аналогу Вашему попробую заблокировать его в основном рюкзаке и если не получится, то оставлю свой скрипт.
Мой скрипт корявый и он удаляет шлем бессмертия, если он попал уже в командира и снова его отдаёт герою в рюкзак, но как то так и работает, но не по задумке..
Жаль что в тригере !?CM2 нет проверки всех ячеек рюкзака, а только первых пяти и поэтому придётся мне пытаться что-то сделать с этим ресивером !!HE-1:А1/149/?; - здесь можно проверить позицию шлема во всём рюкзаке, но опять же всё проблемно, но думаю как-то можно..
В идеале если бы шлем навести на командирскую ячейку и ячейка заблокируется, но буду пытаться.. Благодарю Вас..
Hi! I'm looking for help with these questions
Wanting to check these at the end of a battle:
1. How to check whether a town was involved in the battle? I know BA:S does something but looks like it won't return the corrected result if the battle happens in a town with no fort (walls).
2. How to get the ID or coordinates of the town involved in the siege battle? Is v998 - v1000 still the best way to do in ERA 3?
Also, Is there a way to check the type of object if we have the coordinates? I guess checking whether v998 - v1000 is a town could help with checking whether the battle was a siege too
Thanks

2. !!BA:P?(x:y)/?(y:y)/?(z:y) or i^battle_x^, i^battle_y^, i^battle_z^
1. Get x/y/z coordinates, decrease x by 1, single UN:U call, check the result, If result is the same as original x/y/z, than it's battle in a town. Check if town has no visitor hero or visitor hero and no monsters in town itself.
Hmm, I doubt a single call of UN:U could work, an example - when you have 2 towns with the same x coordinates but different y.
Code:
Map for Testing
Ultimately, the purpose of the script is only for getting one condition - when the defender of the town wins a battle but with no hero nor creatures left in the town (normally this could only happen when the fight won with summoned units). Any shortcut for this?
Edit: Improved script
Quote: I doubt a single call of UN:U could work
Imagine X/Y/Z battle coordinates.
Assume the previous town search ended at X-1/Y/Z.
Add 1 to (X - 1), check if Map[X][Y][Z] is a town, stop if so. Otherwise continue searching. In the former case we will end at X + DX/Y + DY/Z + DZ coordinate, which is not original X/Y/Z, obviously.