Skip to content
#3541
Auto-translated
Thank you very much. I copied the scripts from my own map and the error was as you described – now I will try to add a target for the spell.

Added 4 minutes ago
P.S. Yes, everything finally works. Thanks again.

Added 3 minutes ago
Hottabych, thank you too. I'll try to carefully study your manual, but for now, I don't understand much of it – it's something like magic).

Added 5 hours 31 minutes ago
Gentlemen, I have a new question for you – as always, one might say. How do I pass information about my hero's level to combat mode? Here is what is written in this topic: https://forum.heroesworld.ru/showthread. ... page=247 "You can save the hero's level in a global game variable using SetGameVar and get its value in battle using GetGameVar"(c) ------------------------------------------------------------- In MapScript, I write: path = '/'..GetMapDataPath() main_hero = 'Raelag' SetHeroCombatScript('Raelag', path.."CombatScript.xdb#xpointer(/Script)"); SetGameVar("LevR", 1); print("We set LevR to be a Set Game Var"); LevR = GetHeroLevel('Raelag'); print("LevR is set as an identifier of Raelag's level"); function ProbaF() -- I only write it to check that LevR works correctly - and it does. if LevR < 20 then print("level is less than 20"); else print("level is 20 or more"); end; end; Trigger(OBJECT_TOUCH_TRIGGER, "Proba", "ProbaF" ); ------------------------------------------------------------- In CombatScript, I write: function Start() Level_R = GetGameVar("LevR") + 0; print("Level_R is set as an identifier of Raelag's level in combat and depends on LevR through Set and Get Game Var"); if GetHeroName(GetAttackerHero()) == 'Raelag' then print("if the hero is the attacker"); local mana = GetUnitManaPoints(GetAttackerHero()); SetUnitManaPoints(GetAttackerHero(), 200); repeat sleep(1) until GetUnitManaPoints(GetAttackerHero())==200; sleep(1); if Level_R < 20 then print("if the level is less than 20, then"); for i, creature in GetDefenderCreatures() do startThread(UnitCastAimedSpell, GetAttackerHero(), 4, creature); print("we cast ice block"); SetUnitManaPoints(GetAttackerHero(), mana); print("we restore mana"); end; else print("if the level is 20 or more"); for i, creature in GetDefenderCreatures() do startThread(UnitCastAimedSpell, GetAttackerHero(), 5, creature); print("we cast a ball"); SetUnitManaPoints(GetAttackerHero(), mana); print("we restore mana"); end; end; ------------------------------------------------------------- But Raelag stubbornly casts not a ball, but an ice block, even though he is level 20! And the console says that he is less than level 20. That is, CombatScript simply does not see GetGameVar? Or it sees it – because Raelag casts – but why doesn't it see if Level_R < 20 then? How can I let combat mode know that the hero is already level 20? And one more question - how do you all insert such colorful scripts here? It's hard to figure out my monotonous mess, I need to format it differently.