Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Kartoha
User Avatar
8 years ago
Auto-translated
Kartoha
After this line:

Trigger(OBJECT_CAPTURE_TRIGGER, "gorodSvyat", nil)

Does it work?

It doesn't work.
In reply to Kartoha
User Avatar
8 years ago
Auto-translated
Kartoha
Does the console display any error?

No, everything seems fine. But through trial and error, I found out that function 3 was the problem. I didn't write the trigger correctly there. It seems to be okay now.
In reply to OrnsteinDragonslayer
8 years ago
Auto-translated
OrnsteinDragonslayer
None, everything is clean. But through trial and error, I found out that the faulty function was 3. I didn't write the trigger correctly there. Seems like everything is okay now.
Great!
User Avatar
8 years ago
Auto-translated
function Turma () while (1) do if b == 0 and w == 0 then MessageBox("/Maps/SingleMissions/rework (4)/turmaLOCK.txt"); end if b == 1 and w == 1 and var == 1 then MessageBox("/Maps/SingleMissions/rework (4)/turmaUNLOCK.txt"); SetObjectiveState("suppDruid", OBJECTIVE_COMPLETE); RemoveObject("druid"); RemoveObject("elf1"); RemoveObject("elf2"); RemoveObject("elf3"); RemoveObject("elf4"); RemoveObject("elf5"); RemoveObject("elf6"); RemoveObject("elf7"); RemoveObject("elf8"); MessageBox("/Maps/SingleMissions/rework (4)/unicorn.txt"); OpenCircleFog(198, 64, 0, 2, PLAYER_1) MoveCamera(198, 64, 0, 30, 1.3, 1, 1, 1, 1); sleep(5) PlayObjectAnimation("unicorn", "happy", ONESHOT_STILL); sleep(15) RemoveObject("unicorn"); end if b == 1 and w == 1 and a == 1 then MessageBox("/Maps/SingleMissions/rework (4)/turmaDEAD.txt") end Trigger(OBJECT_TOUCH_TRIGGER, "turma"); break end end; Trigger(OBJECT_TOUCH_TRIGGER, "turma", "Turma" ); ``` Question about complexity. There is an object called "Turma". I need a specific message to appear when it is touched, depending on the conditions specified in the script. My problem is that when it is touched for the first time, everything works fine (the first condition, when b and w == 0), but when b == 1, w == 1, and var == 1, it gives an error. The same happens when b == 1, w == 1, and a == 1. Here is the error: Here are the conditions that set the coefficients: ``` function QochComplete () while (1) do sleep(2); if (Exists('white') == nil) then SetObjectiveState("Qo-ch", OBJECTIVE_COMPLETED); w = 1 break end end end startThread(QochComplete) function QobComplete () while (1) do sleep (2) if (Exists('black') == nil) then SetObjectiveState("Qo-b", OBJECTIVE_COMPLETED); b = 1 break end end end startThread(QobComplete)
In reply to OrnsteinDragonslayer
User Avatar
8 years ago
Auto-translated
OrnsteinDragonslayer
function Turma ()
         while (1) do
         if b == 0 and w == 0 then
            MessageBox("/Maps/SingleMissions/rework (4)/turmaLOCK.txt");
         end
         if b == 1 and w == 1 and var == 1 then
            MessageBox("/Maps/SingleMissions/rework (4)/turmaUNLOCK.txt");
            SetObjectiveState("suppDruid", OBJECTIVE_COMPLETE);
            RemoveObject("druid");
            RemoveObject("elf1");
            RemoveObject("elf2");
            RemoveObject("elf3");
            RemoveObject("elf4");
            RemoveObject("elf5");
            RemoveObject("elf6");
            RemoveObject("elf7");
            RemoveObject("elf8");
            MessageBox("/Maps/SingleMissions/rework (4)/unicorn.txt");
            OpenCircleFog(198, 64, 0, 2, PLAYER_1)
            MoveCamera(198, 64, 0, 30, 1.3, 1, 1, 1, 1);
            sleep(5)
            PlayObjectAnimation("unicorn", "happy", ONESHOT_STILL);
            sleep(15)
            RemoveObject("unicorn");
         end
         if b == 1 and w == 1 and a == 1 then
            MessageBox("/Maps/SingleMissions/rework (4)/turmaDEAD.txt")
         end
Trigger(OBJECT_TOUCH_TRIGGER, "turma");
break
end
end;

Trigger(OBJECT_TOUCH_TRIGGER, "turma", "Turma" );

The question is about complexity. There is an object called "Turma". When touched, a specific message should appear, depending on the conditions specified in the script. My problem is that when touched for the first time, everything is okay (the first condition, when b and w == 0), but when b == 1, w == 1, var == 1, it gives an error. Also, when b == 1, w == 1, a == 1.
Here is the error

The conditions that set the coefficients:
function QochComplete ()
         while (1) do
             sleep(2);
             if (Exists('white') == nil) then
                SetObjectiveState("Qo-ch", OBJECTIVE_COMPLETED);
             w = 1
             break
             end
         end
end

startThread(QochComplete)

function QobComplete ()
         while (1) do
               sleep (2)
               if (Exists('black') == nil) then
                  SetObjectiveState("Qo-b", OBJECTIVE_COMPLETED);
               b = 1
               break
               end
         end
end

startThread(QobComplete)
         
GetHeroName is a function that caused the error - it's from the combat script, so the error should be looked for in the combat script.
Regarding the script itself: it's not clear why there is a loop; the trigger is written incorrectly - there is no function name or nil.
In reply to RedHeavenHero
User Avatar
8 years ago
Auto-translated
RedHeavenHero
GetHeroName - this function caused an error in the combat script, so the error should be looked for in the combat script.
Regarding the script itself: it's unclear why there's a loop; the trigger is written incorrectly - it's missing a function name or is nil.

Thank you, I've fixed it.
User Avatar
8 years ago
Auto-translated
I want to summon the hero "Sarge" from the reserve, but the console gives an error saying that the hero does not belong to any player. Basically, the question is, why is he different from the other 10 reserved heroes?
Also, just in case, I'll post the code from which he is summoned.

function TheEnd()
while (1) do
sleep(2);
if (Exists("Zehir") == nil) and (Exists("Eruina") == nil) then
SuperTheEnd()
break
end
end
end

function SuperTheEnd()
DeployReserveHero("Sarge", 14, 134, GROUND)
sleep(2)
EnableHeroAI("Sarge", nil)
sleep(2)
StartAdvMapDialog(8)
sleep(25)
Win()
end

(I split it into 2 functions because I was trying to somehow fix and change the code so that it would work. In the end, it doesn't work in either function, or in both).
User Avatar
8 years ago
Auto-translated
Hmm. Which player has him in reserve? The game can sometimes lag due to the number of heroes reserved by a single player.
In reply to AstralLein
User Avatar
8 years ago
Auto-translated
AstralLein
Hmm. Which player has him in reserve? The game can sometimes lag due to the number of heroes reserved by a single player.

Unreserving extra heroes doesn't solve the problem. The hero is in reserve for player 2.
8 years ago
Auto-translated
There's a problem: I instructed Erling to go to point 15, 9, and if he can't go there for some reason, then to 121, 22, but if something prevents him from reaching the point, let's say a hero with a large army, he just runs back. How can I make it so that he runs to point 15, 9 no matter what?
The function is written using NEW_DAY_TRIGGER.
if GetDate(DAY) == DayErlingAttack and ErlingAttack == 1 then
DeployReserveHero(Erling,RegionToPoint("Erling_deploy"))
sleep(5)
local x, y = 15, 9
if CanMoveHero(Erling,x,y,0) then
MoveHero(Erling, x, y,0)
elseif CanMoveHero(Erling,121,22) then
MoveHero(Erling, 121, 22,0)
end
startThread(ErlingUpgrade)
end
end
User Avatar
8 years ago
Auto-translated
Firstly, it’s worth disabling the AI for the hero. Secondly, it’s better to create a separate function that will check if the turn of the desired player has arrived and initiate the hero’s movement, as the trigger for a new day is not quite suitable for this.
In reply to Gerter
8 years ago
Auto-translated
Gerter
First, you should disable the AI for the hero. Second, it's better to create a separate function that will check if the turn of the desired player has arrived and then start moving the hero, because the trigger for a new day is not quite suitable for this.

Even so, if something prevents him from moving, he will now just stand still. I wrote the function using startThread:
function ErlingMove()
local x, y = 15, 9
if CanMoveHero(Erling, x, y, 0) then
MoveHero(Erling, x, y, 0)
end
end
User Avatar
8 years ago
Auto-translated
prevents passage = is the required cell inaccessible? then it's logical that it doesn't move, right?

try something like this:
function ErlingMove()

while 1 do
if(GetCurrentPlayer() == 'player number to which Erling belongs') then
if CanMoveHero(Erling, 15 , 9, 0) then
MoveHero(Erling, 15, 9, 0)
elseif CanMoveHero(Erling, 121, 22, 0) then
MoveHero(Erling, 121, 22,0)
end
end
sleep(2)
end
end
In reply to Gerter
8 years ago
Auto-translated
Gerter
hinders progress = is the required cell inaccessible? Then it's logical that it doesn't move, right?

try something like this:
function ErlingMove()

while 1 do
if(GetCurrentPlayer() == 'player number to which Erling belongs') then
if CanMoveHero(Erling, 15 , 9, 0) then
MoveHero(Erling, 15, 9, 0)
elseif CanMoveHero(Erling, 121, 22, 0) then
MoveHero(Erling, 121, 22,0)
end
end
sleep(2)
end
end

If my hero blocks his path, then he just stands still. This is the only problem. I tried your function, but the problem remains.

Statistics

Welcome our newest member: recijeb