Good evening. Please help, I'm having trouble... I created a multiplayer map for 2 players, and there are additional Castles for these 2 players (at least, they were of the same Faction... until I put heroes in them to guard them, I had to add a 3rd computer player.
I would like the 3rd computer player to:
1) stay and guard the Castles inside and use spells!
2) not leave
3) not buy an army
4) the Castles should be of the same Faction as the ones that spawned for players 1 and 2.
5) the AI shouldn't waste time on its turn.
6) and not buy heroes
I wrote down everything I could find in mapscript at the beginning, and checked them (using print)... and the last 2 turned out to be completely non-functional...
* EnableHeroAI("Freyda", nil); works
*SetHeroLootable('Freyda', nil); works
*EnableAIHeroHiring(3, 'Castle1', nil); works, although it raises doubts since there were no errors
* BlockTownGarrisonForAI( 'Castle1', isBlocked ); - gives an error: value was NIL when getting global with name 'isBlocked'
*DoNotGiveTurnToPlayerAIIfNoTownsandactiveheroes (3, true) ;- gives an error: value was NIL when getting global with name 'DoNotGiveTurnToPlayerAIIfNoTownsandactiveheroes'
7) So that at the start of the game, everything is blocked for the 3rd player (race, hero, starting bonus)
And the last script function is written correctly like this: DoNotGiveTurnToPlayerAIIfNoTownsAndActiveHeroes, not as you have it.
Next, point by point:
1. Simply immobilize the computer in the Castle using the EnableHeroAI function, and prevent it from hiring other heroes using the EnableAIHeroHiring function. Attach a trigger to touching the Castle, and in the function called by this trigger, enter EnableHeroAI(nHeroName, true); and disable the trigger. This trick is needed because I'm not sure if a non-working computer hero will be able to participate in defending against a Castle siege. Whether the computer will use spells is up to Elrath, not the scripts. But you can download the mega AI mod.
2. A non-working computer hero will not run anywhere.
3. It's banal, a cheat, and not entirely rational, but brilliant: we won't waste your time unnecessarily studying scripts and set the computer to 0 gold using the function SetPlayerStartResources(PLAYERID, wood, ore, mercury, crystals, sulfur, gems, 0);
And then in the script:
function NewDayCheck()
SetPlayerResource(1,6,0);
...
end;
Trigger(NEW_DAY_TRIGGER, "NewDayCheck");4. I haven't seen a function that returns the race of a Castle. I have no ideas for now.5. At the beginning of my answer, I wrote the correct formatting for the function. But keep in mind that as long as the computer controls at least 1 Castle, it will take its turn no matter what.
6. See point 1.
7. In the map, go to Map Properties Tree => Players => + => Player ID => The StartBonus line is responsible for the bonus, CanChangeBonus => set it to false so that it cannot be changed. Next, CanBeHumanPlayer set it to false. Then go to Map Properties => Players Properties => Select the player, in MainHero select the main hero, TOWN_TYPE set to the desired race. Done.
File, save.
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________