Skip to content

Scripts for beginners.

#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?