Hello everyone!
My search for answers led me to the forum; I was also in a VK group and found a guide on battle commands. It's more or less clear what to do with hooks. The problem is understanding whether this script even runs. I suspect it doesn't because the simple print statement in the file isn't displayed in the console.
Briefly, here's the goal: The map is designed for faster battles. But it has grown in detail; for example, the first player chooses the stage of the game through dialog boxes (I will rework them later; I found instructions that you can enter choices with a large number of options). Then they explore the map, equip themselves with dropped items, level up, and finally meet in a battle on a special arena. There's a small plot woven into it. I want to add a couple of Easter eggs and traps to the map. For instance, there's a place where, tempted by seemingly unguarded treasures, the player should go. Upon entering the area via a trigger, a script starts, where they are attacked by a Lord or dragons. I haven't figured out how to make two human players and a neutral hero attacking one or the other exist on the same map yet. I read about reserves but am still having some trouble using them. However, so far, only an evening was spent specifically on this, while more questions arise regarding the combat script. There's a simple command "StartCombat" which initiates the battle. It might be enough if I just use dragon attacks. But my idea goes further. I want either the attacking hero or the hero who fell into the trap (the trapped hero) to come under AI control and cast Armageddon 2-3 times against the black dragons. And then the opponent surrenders. Or perhaps there is a command after the battle ends that determines who wins. I also tried delving deeper into this topic, but couldn't find answers, or maybe I wasn't searching properly. In general, for now, I can only implement it with a text pop-up saying something like, "You greedy thief will pay," and that's it. With great difficulty, I managed to figure out how to add a script file in the game, accidentally breaking the link between the mapscript and the map at the same time. I fixed it by opening the necessary file in Notepad and restoring the reference to the map script. At least the error message disappeared, indicating that the script could not be found at the specified path. But it still doesn't run. I don't understand what I'm doing wrong. I've hit a creative dead end.
I would appreciate it if you could explain step-by-step how it works correctly. I am attaching my map draft. Some of the logic is commented out because I was testing the start of the battle right away (it starts when interacting with a skeleton near the starting castle). So, I need advice on how to write the interaction so that StartCombat launches the battle script, where I want to specify casting an area spell and then retreating attackers. Maybe I'm writing something incorrectly in the wrong place or the script file is somehow incomplete. It looks identical to the MapCsript file. In general, there's a clear lack of knowledge here. I tried assigning the Lord directly to player 3 under AI control, but the script didn't recognize him as an opponent in any way, even for a regular battle without additional scripts for casting spells. When creating the additional script file, print from DragonCombat.lua ran, meaning the map can access it. However, I haven't mastered the mechanics of connecting it yet. I'm looking for what's missing.
A separate thank you to everyone who posted instructions online; the map will undergo major changes. I placed some creatures just to test the balance... everything will be corrected and refined repeatedly. I keep track of versions; there are many lines of code! Currently, the DragonCombat.lua file only contains a draft of my idea. I experimented and debugged it on the fly. After a day, I couldn't figure it out, so I came to ask for advice. Before this, I was working on the map for a couple of weeks in the evenings, just watching what you had here. On the map, according to someone's post, there is an implemented parallel infinite turn. The plan is that everything should happen within one day. And I feel like I'll come back here more than once... Based on new information about the possibilities, I have more ideas, and it might become quite interesting with some references. Hello to the grave in the dungeon, then I'll make a bridge (I read how), and then a battle with a creature. And something else near the pyramids, I'll add that too.
Thank you in advance!
P.S. I remembered another question: I struggled for a couple of days searching the forum but didn't find a good way to add Arantir alongside Markal, Giovanni, and Ornella when creating a map. In the map settings, I enabled all heroes from the campaign. Arantir can be added to the map, but not as a starting hero during creation. My idea is to put him in reserve (I haven't figured out how to do this correctly yet) and summon him through dialogue, such as approaching a prison or interacting somehow. I'll figure out how to implement it.
23.03.2024 01:20 upd: I tried doing it as found in this post /topic/at/1225989/.
Step by step, the only difference is in the file name. Is it really necessary? Can't all combat script files in the map have the same name? O_o). Instead of CombatScript, I have DragonCombat. The main difference I noticed is that in the map settings, the full path to the script file was specified, while previously I just entered the name without the path. Encouraged, I went to test again, and the print statement still didn't display any indication that the script had started. On the positive side, I found a way to add available heroes for player 3 to choose from, although there wasn't a Lord among them. But at least I could pull a hero from the reserve, move him nearby, and activate a battle with him. I noticed that the hero's army doesn't appear; only the creatures I specified when calling StartCombat are present. However, neither by setting the script for the hero and the player or AI, nor by specifying the script in the start of the battle, does the unfortunate print message appear, indicating that the game has entered the script.
DeployReserveHero("Inagost", 115, 290, 0);
ChangeHeroStat("Inagost", 0, 90000);
--SetHeroCombatScript('Inagost', pathScript.."DragonCombat.xdb#xpointer(/Script)");
--SetHeroCombatScript(p1heroname[0], pathScript.."DragonCombat.xdb#xpointer(/Script)");
StartCombat(p1heroname[0], "Inagost", 1, 84, 10, pathScript.."DragonCombat.xdb#xpointer(/Script)", nil, nil, nil);
I tried invoking the script like this, commenting out lines 3 alternately and completely without them, and in StartCombat, I put nil and left the path to the script. It doesn't work. I'm lost in guessing where the mistake is. So that I can move forward with developing my ideas.