Skip to content

Posts from Scripts for beginners.

4.5 (2 ratings)
#371
Auto-translated

Oh, and one more question, perhaps slightly off-topic. When entering a region, a cutscene should play. But for some reason, it only plays a part of it, specifically one out of seven scenes. However, in other cases, all scenes work normally; the problem only occurs with this one. (In the editor, it plays completely and correctly.)

Script for the problematic one:

function Region4F()
    
    sleep(3)
    StartDialogScene("/MySceneCustom/DialogScene2/DialogScene.xdb#xpointer(/DialogScene)");
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region4",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region4","Region4F");

Scripts for the working ones:

StartDialogScene("/MySceneCustom/StartScene/DialogScene.xdb#xpointer(/DialogScene)");

and

function Region1F ()
    
    sleep(5);
    MessageBox ("/Maps/SingleMissions/MapochkaTEST3/battletext.txt");
    StartCombat ( "RedHeavenHero04", nil, 5, 166, 100, 166, 100, 167, 75, 169, 50, 170, 15, nil);
    StartDialogScene("/MySceneCustom/BattleDialog1Custom/DialogScene.xdb#xpointer(/DialogScene)");
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F");

And yes, thank you for the animation scripts. They work great!

In reply to AngryTapok1337
User Avatar
#372
Auto-translated
AngryTapok1337

Oh, and one more question, perhaps slightly off-topic. When entering a region, a video should play. But for some reason, it only plays a part of it, specifically one out of seven segments. However, in other cases, all scenes work normally; the problem only occurs with this one. (In the editor, it plays completely and correctly.)

Script for the problematic region:

function Region4F()
    
    sleep(3)
    StartDialogScene("/MySceneCustom/DialogScene2/DialogScene.xdb#xpointer(/DialogScene)");
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region4",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region4","Region4F");

Scripts for the working regions:

StartDialogScene("/MySceneCustom/StartScene/DialogScene.xdb#xpointer(/DialogScene)");

and

function Region1F ()
    
    sleep(5);
    MessageBox ("/Maps/SingleMissions/MapochkaTEST3/battletext.txt");
    StartCombat ( "RedHeavenHero04", nil, 5, 166, 100, 166, 100, 167, 75, 169, 50, 170, 15, nil);
    StartDialogScene("/MySceneCustom/BattleDialog1Custom/DialogScene.xdb#xpointer(/DialogScene)");
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F");

And yes, thank you for the animation scripts. They work great!

Hmm, I don't know what could be causing the video problem.
You should thank the developers, not me, for the animation scripts – this script is used in one of the missions featuring Wolfenstein

Мои карты:
Падший рыцарь
Сердце Хаоса

Мои моды:
Визуальные:
Изменение внешнего вида героев-некромантов
Существа-жители и кое-что по мелочи в городах Ордена Порядка, Некрополиса и Инферно

NCF-существа:
Странствующие рыцари
Наемники

In reply to AngryTapok1337
#373
Auto-translated
AngryTapok1337

Oh, and one more question, perhaps slightly off-topic. When entering a region, a video should play. But for some reason, it only plays one part out of seven. However, in other cases, all scenes work normally; the problem is only with this one. (In the editor, it plays completely and correctly.)

Script for the problematic one:

function Region4F()
    
    sleep(3)
    StartDialogScene("/MySceneCustom/DialogScene2/DialogScene.xdb#xpointer(/DialogScene)");
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region4",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region4","Region4F");

Scripts for the working ones:

StartDialogScene("/MySceneCustom/StartScene/DialogScene.xdb#xpointer(/DialogScene)");

and

function Region1F ()
    
    sleep(5);
    MessageBox ("/Maps/SingleMissions/MapochkaTEST3/battletext.txt");
    StartCombat ( "RedHeavenHero04", nil, 5, 166, 100, 166, 100, 167, 75, 169, 50, 170, 15, nil);
    StartDialogScene("/MySceneCustom/BattleDialog1Custom/DialogScene.xdb#xpointer(/DialogScene)");
    Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1",nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"Region1","Region1F");

And yes, thank you for the animation scripts. They work great!

 

 

Never mind, I've solved the problem. I just opened the dialog in the editor, and for some reason, there was only one scene there! Although I definitely saved it, and this thing even played completely on the map once. I have no idea where the other six scenes went.

User Avatar
#374
Auto-translated
Welcome to Heroes 5: as soon as the editor index is rewritten (for example, when a map is opened in the editor), it will completely forget about your scenes, and you will no longer be able to open them without performing some complicated procedures.
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
In reply to AstralLein
#375
Auto-translated
AstralLein
Welcome to Heroes 5: as soon as the editor index is rewritten (e.g., a map is opened in the editor), it completely forgets about your scenes, and you won't be able to open them again without performing some complicated procedures.

Thanks for the explanation regarding the index. But Tapochek isn't stupid; it turns out Tapochek saved the index in a new folder).

 

Everything works now, by the way).

In reply to AstralLein
#377
Auto-translated

AstralLein
Tapochek is great. It didn't occur to me at the time.

Besides, I didn't know about indexes back then.

Thanks for the video guide on "how to make animations in Heroes 5." It explains everything in detail and is very easy to understand.smile01

User Avatar
#378
Auto-translated
Back in my day, there weren't guides like this. There were only fragmented ones that didn't cover these aspects. Sadly...

Ironically, I still don't save indexes. I'm used to making videos "in one go." I should probably change that.
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
User Avatar
#379
Auto-translated

Citizens, create and store Dialog Scenes in a folder named data. I've edited scenes created in the data folder countless times, and nothing has ever been lost. Oh, and here's a guide on how to properly launch the Dialog Scene editor (sometimes it doesn't save changes): open the editor, open any map (not through Open Resource), close the map (just Close, without closing the editor), and then open the Dialog Scene through Open Resource. That way, everything will definitely be saved).

Ah yes, and most importantly! Always keep the folder containing the scene open, and keep an eye on the DialogScene.xdb file. Make changes to the map, save it – if the last modified date updates, it means everything is okay. That's pretty much it.

Всякое/карты:

Добавление недостающей музыки гномам

#380
Auto-translated

Hello again. I need some scripting help once more.

Here's the situation: I've divided the map into two parts, connected by a garrison. After the garrison, I've placed a region and prevented the AI from entering it. I'd like the region to be removed after a certain amount of time, allowing the AI to proceed.

 

Also, if anyone knows, could you tell me how to implement the appearance of caravans with troops every month, and have them travel directly to a city? Yes, just like in the final mission of the Arantir campaign.

 

Thank you in advance.

In reply to AngryTapok1337
User Avatar
#381
Auto-translated
AngryTapok1337

Hello again. I need help with scripting once more.

The situation is as follows: I divided the map into two parts, which are connected by a garrison, and set up a region after it, which I prohibited the AI from entering. I would like the region to be removed after a certain amount of time, so that the AI can continue.

 

Also, if anyone knows, please tell me how to implement the appearance of caravans with troops every month, and have them travel directly to the city. Yes, just like in the final mission of the Arantir campaign.

 

Thank you in advance.

First, check the SetRegionBlocked function. Second, use CreateCaravan.
Нет войне.
In reply to AngryTapok1337
User Avatar
#382
Auto-translated
AngryTapok1337
I would like the region to be removed after some time, so that the AI can continue.

SetRegionBlocked("region name", nil, PLAYER_number of the player for whom the region should be unlocked);

AngryTapok1337
Please tell me how to implement the appearance of caravans with troops every month, so that they go directly to the city.

Basically, take the script from that very mission by Arantir, copy and paste it, removing everything that is not needed and substituting your own parameters. It is important to remember a couple of things about the caravan: It spawns only on an empty point; it delivers creatures only to cities (the spawn point is assigned to the point where the city is located), otherwise, write a "dummy" script, like it goes to some point near the desired object (say, a garrison), is removed (RemoveObject), and then the object (in our case, the garrison) is filled with creatures through AddObjectCreatures; yes, the caravan spawns empty, and it will be deleted when the turn of the player to whom it belongs ends if it is not filled with creatures; it is filled and cleared using object interaction commands, i.e., AddObjectCreatures/GetObjectCreatures/RemoveObjectCreatures. Also, the IsObjectExists check and the SetObjectRotation command work on it:

CARAVAN = "caravan"; --let's give the caravan a starting name for use in the function

function respawn_caravan()
if (GetDate( DAY_OF_WEEK ) == 5) then --day of the week on which we will spawn the caravan (you can change it to another date trigger)
car = CARAVAN..GetDate(DAY); --I can't say what the trick was in naming the caravan by the game day, maybe without this the respawn would break. Let's leave it as it is, because why touch what already works correctly, right?
CreateCaravan(car, PLAYER_1, GROUND, 130, 1, GROUND, 136, 14 ); --here is the caravan spawn itself: caravan name, who it belongs to, whether it spawns on the ground or underground, x y spawn points, on the ground or underground, the point to which it goes, x y destination points. The destination point is either an empty place or a city (technically, the caravan does not deliver creatures anywhere else)
sleep(4);
SetObjectRotation(car, 180); --let's turn the caravan so that it looks in the other direction
AddObjectCreatures(car, CREATURE_BONE_DRAGON, 4); --we fill the caravan with creatures, otherwise it will be deleted at the end of the turn of the player to whom it belongs
AddObjectCreatures(car, CREATURE_WIGHT, 8);
AddObjectCreatures(car, CREATURE_LICH, 12);
AddObjectCreatures(car, CREATURE_VAMPIRE, 20);
AddObjectCreatures(car, CREATURE_MANES, 36);
AddObjectCreatures(car, CREATURE_WALKING_DEAD, 60);
AddObjectCreatures(car, CREATURE_SKELETON, 80);
OpenCircleFog(130, 1, 0, 4, 1); --let's open the area of the map around the caravan spawn point so that we can then shift the camera and show the caravan
sleep(4);
MoveCamera(130, 1, 0, 30, 1, 3.14, 0, 0, 1); --let's shift the camera to the caravan spawn point to show the player that reinforcements have arrived
end;

end;

Trigger(NEW_DAY_TRIGGER, "respawn_caravan")

Всякое/карты:

Добавление недостающей музыки гномам

In reply to Азгалор
#383
Auto-translated
Azgalor

SetRegionBlocked("region name", nil, PLAYER_player number for whom to unlock);

Basically, take the script from that Arantir mission, copy and paste it, remove everything unnecessary, and substitute your own parameters. It's important to remember a couple of things about the caravan: It only spawns on an empty tile; it only delivers creatures to cities (the spawn point is set to the location of the city), otherwise, you need to create a "dummy" that makes it look like it's going to a point near the desired object (say, a garrison), then it's removed (RemoveObject), and then the object (in our case, the garrison) is filled with creatures using AddObjectCreatures; yes, the caravan spawns empty and is removed when the player's turn ends if it's not filled with creatures; it's filled and emptied using object interaction commands, i.e., AddObjectCreatures/GetObjectCreatures/RemoveObjectCreatures. Also, the IsObjectExists check and the SetObjectRotation function work on it:

CARAVAN = "caravan"; --let's give the caravan a starting name for use in the function

function respawn_caravan()
if (GetDate( DAY_OF_WEEK ) == 5) then --day of the week on which the caravan will spawn (you can change it to another date trigger)
car = CARAVAN..GetDate(DAY); --I can't say what the point was in naming the caravan after the game day, maybe without this the respawn would break. Let's leave it as is, because why mess with something that already works correctly, right?
CreateCaravan(car, PLAYER_1, GROUND, 130, 1, GROUND, 136, 14 ); --the caravan spawn itself: caravan name, who it belongs to, whether it spawns on the ground or underground, x y spawn point, on the ground or underground, destination point x y. The destination point is either an empty space or a city (technically, the caravan doesn't deliver creatures anywhere else)
sleep(4);
SetObjectRotation(car, 180); --rotate the caravan so it faces the other way
AddObjectCreatures(car, CREATURE_BONE_DRAGON, 4); --fill the caravan with creatures, otherwise it will be removed at the end of the player's turn
AddObjectCreatures(car, CREATURE_WIGHT, 8);
AddObjectCreatures(car, CREATURE_LICH, 12);
AddObjectCreatures(car, CREATURE_VAMPIRE, 20);
AddObjectCreatures(car, CREATURE_MANES, 36);
AddObjectCreatures(car, CREATURE_WALKING_DEAD, 60);
AddObjectCreatures(car, CREATURE_SKELETON, 80);
OpenCircleFog(130, 1, 0, 4, 1); --open the map area around the caravan spawn point so that we can then move the camera and show the caravan
sleep(4);
MoveCamera(130, 1, 0, 30, 1, 3.14, 0, 0, 1); --move the camera to the caravan spawn point to show the player that reinforcements have arrived
end;
end;

Trigger(NEW_DAY_TRIGGER, "respawn_caravan")

 

 

Thank you very much for the code! Question - is it possible to implement this with a condition? That is, so that the function starts executing only after the quest is completed?

In reply to AngryTapok1337
User Avatar
#384
Auto-translated
AngryTapok1337
Thank you very much for the code! Question - is it possible to implement this with a condition? I.e., so that the function starts executing only after the quest is completed?
Try this:
	if ( GetDate( DAY_OF_WEEK ) == 5 ) and ( GetObjectiveState("quest") == OBJECTIVE_COMPLETED ) then

Всякое/карты:

Добавление недостающей музыки гномам

#385
Auto-translated

In general, the code doesn't work. I suspect (actually, I'm pretty sure) that I, like any other programmer, made a mistake somewhere. The resulting function is:

 

CARAVAN = "caravan"



function respawn_caravan()
    if GetObjectiveState("NaydiSuhestv1") =~ OBJECTIVE_COMPLETED then
              return
    end
    if (GetDate( DAY_OF_WEEK ) == 5) then
        car = CARAVAN..GetDate(DAY)
        CreateCaravan(car, 1, GROUND, 173, 68, GROUND, 156, 159 )
        sleep(4)
        SetObjectRotation(car, 180)
        AddObjectCreatures(car, CREATURE_BONE_DRAGON, 4)
        AddObjectCreatures(car, CREATURE_WIGHT, 8)
        AddObjectCreatures(car, CREATURE_LICH, 12)
        AddObjectCreatures(car, CREATURE_VAMPIRE, 20)
        AddObjectCreatures(car, CREATURE_MANES, 36)
        AddObjectCreatures(car, CREATURE_WALKING_DEAD, 60)
        AddObjectCreatures(car, CREATURE_SKELETON, 80)
        OpenCircleFog(173, 68, 0, 4, 1)
        sleep(4)
        MoveCamera(173, 68, 0, 30, 1, 3.14, 0, 0, 1)
    end
end

Trigger(NEW_DAY_TRIGGER, "respawn_caravan")

 

Moreover, as soon as I added it to the code, the entire code stopped working altogether. I'm more than sure that someone who understands scripts has already spotted my mistake. Please explain what's wrong here.





Added 32 minutes ago

I removed the additional condition, and it still doesn't work.

 

The result is:

 

CARAVAN = "caravan"



function respawn_caravan()
    if (GetDate( DAY_OF_WEEK ) == 2)  then
        car = CARAVAN..GetDate(DAY)
        CreateCaravan(car, PLAYER_1, GROUND, 173, 68, GROUND, 156, 159 )
        sleep(4)
        SetObjectRotation(car, 180)
        AddObjectCreatures(car, CREATURE_BONE_DRAGON, 4)
        AddObjectCreatures(car, CREATURE_WIGHT, 8)
        AddObjectCreatures(car, CREATURE_LICH, 12)
        AddObjectCreatures(car, CREATURE_VAMPIRE, 20)
        AddObjectCreatures(car, CREATURE_MANES, 36)
        AddObjectCreatures(car, CREATURE_WALKING_DEAD, 60)
        AddObjectCreatures(car, CREATURE_SKELETON, 80)
        sleep(4)
    end
end

Trigger(NEW_DAY_TRIGGER, "respawn_caravan")

 

Perhaps the problem is that the caravan simply can't reach the city? Although the road seems to be open.