Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Олегарх
User Avatar
14 years ago
Auto-translated
h=1;
while h==1 do
x, y = GetObjectPosition("Hero2");
MoveHeroRealTime("Hero3", x+1, y, -1);
end;
end;
sleep is needed within the loop.
In reply to Ment
User Avatar
14 years ago
Auto-translated
Ment
sleep is needed within the loop.
And where should I insert it?
In reply to Олегарх
User Avatar
14 years ago
Auto-translated
Oligarch
What is SetStandState actually used for?

apparently, it is used to store information that is later used in scripts (I haven't found any other use for it). It's like SetObjectiveState, which we assign to a player, and then a task is activated/completed for them, and then we check its state with if GetObjectiveState ... and perform some actions. The same applies to SetStandState, only it doesn't change anything in the game, but simply sets a number, by checking which, various conditions can be performed in scripts.

Added 2 minutes ago

while 1 do
 x, y = GetObjectPosition("Hero2");
 MoveHeroRealTime("Hero3", x+1, y, -1);
 sleep(20);
end;

or even like this:

while 1 do
  if IsObjectExists("Hero2") == true then
    x, y = GetObjectPosition("Hero2");
    MoveHeroRealTime("Hero3", x+1, y, -1);
  else return;
  end;
  sleep(10);
end;

P.S. This probably needs to be moved to the "Scripts" topic
In reply to KioM
User Avatar
14 years ago
Auto-translated
I already wrote there, and then for some reason I wrote here.
Oh, it worked! You just need to block the space around the NPC so that it doesn't go anywhere, and then it works.
In reply to Олегарх
User Avatar
14 years ago
Auto-translated
Oligarch
You just need to block the space around the NPC so it can't move anywhere, and it works.

In what sense?
In reply to KioM
User Avatar
14 years ago
Auto-translated
KioM
In what sense?
He can move far away from the hero after you press "end turn," and then he won't have enough movement points to get close to the main character.
In reply to Олегарх
User Avatar
14 years ago
Auto-translated
Oligarch
He can move far away from the hero after pressing "end turn," and then he won't have enough movement points to be near the main character.

Then you can add before MoveHeroRealTime:
ChangeHeroStats("Hero3", 7, 3500);

In general, I advise you to take a look at how it's done in the developers' campaigns, in the first mission of the Hammers of Fate, if I'm not mistaken, Laszlo follows Frida... They created an in-script function to check the distance, so the heroes constantly stay close to each other.
In reply to KioM
User Avatar
14 years ago
Auto-translated
SetStandState, GetStandState, GetStandStatesCount -
script operations for working with objects on the map of type AdvMapStandShared (e.g., TieruHut). To create your own stand, you need to:
1) place the Objects\All-Terrain objects\Tieru's Dwelling object on the map.
2) in the ObjectPropertiesTree, in the Shared graph, click on ...(ellipsis).
3) in the left part of the window that appears, right-click, select NewObject, and name your object.
4) choose a model, animation, effect, and impassable tiles for the stand.
5) in the States graph, select a new model and animation for the modified stand, and in StatesChanges, select which visual and sound effects will be played.
_____
You can create multiple stand states (as desired) and change them using SetStandState(objectName, newStateID).
User Avatar
14 years ago
Auto-translated
Yeah, there are plenty of examples in the original game too, but as far as I remember, there wasn't real-time movement; they moved during their turn.
In reply to KioM
User Avatar
14 years ago
Auto-translated
KioM
then you can add before MoveHeroRealTime
ChangeHeroStats("Hero3", 7, 3500);

in general, I advise you to take a look at how it is done in the developers' campaigns, in the 1st mission of the Fortress, if I'm not mistaken, Laslo follows Frida... They made an in-script function to check the distance, so the heroes constantly stay close to each other.
thank you. it's Stat, not Stats. Does anyone know how many movement points a hero has by default?
14 years ago
Auto-translated
Does anyone know how many movement points a hero has by default?
3500 if there is no "Logistics" or other bonus effects.
In reply to antonag07
User Avatar
14 years ago
Auto-translated
Oligarch
Does anyone know how many movement points a hero has by default?

2500 - without logistics, 2749 - initial logistics, 2999 - developed, 3249 - masterful.
Also, the Traveler's Boots give +25% to movement points on top of everything...

P.S. I managed to get a maximum of 4661 movement points, logistics + boots + stables.
In reply to KioM
User Avatar
14 years ago
Auto-translated
KioM
2500 - without logistics, 2749 - initial logistics, 2999 - developed, 3249 - advanced.
Also, the Traveler's Boots give +25% to movement points on top of everything...

P.S. I managed to get a maximum of 4661 movement points, logistics + boots + stables.
Thank you. I just had an idea:
ChangeHeroStats - add movement points
MoveHeroRealTime - the hero moves towards the main hero
ChangeHeroStats - completely remove movement points.
This way, when the "end turn" button is pressed, the hero will stay in place.
User Avatar
14 years ago
Auto-translated
To keep him in place, you can simply disable his AI: EnableHeroAI
In reply to Олегарх
User Avatar
14 years ago
Auto-translated
Oligarch
Thank you. I just had an idea:
ChangeHeroStats - add movement points
MoveHeroRealTime - the hero moves towards the main hero
ChangeHeroStats - completely remove movement points.
This way, when the "end turn" button is pressed, the hero will stay in place.

For this, it's not necessary to know the exact number of movement points; you can use GetHeroStat and variables:
start = GetHeroStat("Hero3", 7);
ChangeHeroStat("Hero3", 7, start+3500);
MoveHeroRealTime(...); -- (this function is not modal! I tried to make it modal once, and the game crashed :))
sleep(20);
startThread(end);

function end()
end = GetHeroStat("Hero3", 7);
ChangeHeroStat("Hero3", 7, -end);
end;

and no extra numbers ;)

Statistics

Welcome our newest member: recijeb