Skip to content

Scripts for beginners.

#391
Auto-translated

Azgalor
As soon as I launched the map, I was immediately greeted with an error about a missing region, RegionFight7, which is referenced in 2 lines within the RegionFight2F function. I commented them out, restarted the map, and now I get an error with the caravan when I try to turn it. The sleep(4) is in the wrong place; it should be before SetObjectRotation (like in the code I originally sent). You posted it in the previous message with the note "This is what I got." Because of this, the game doesn't have time to load the caravan, and then it immediately tries to turn it, breaking the script because it's trying to affect an object that technically doesn't exist on the map yet (it works like with DeployReserveHero). Also, set the rotation angle to -90, because it turns to face the corner of the map

Everything works now, thank you very much!smile

 

I'll leave the code here, just in case someone needs it.

 

CARAVAN = "caravan"

function respawn_caravan()
    if (GetDate( DAY_OF_WEEK ) == 5) and ( GetObjectiveState("NaydiSuhestv1") == OBJECTIVE_COMPLETED ) then
        car = CARAVAN..GetDate(DAY)
        CreateCaravan(car, PLAYER_1, GROUND, 173, 68, GROUND, 156, 159 )
        sleep(4)
        SetObjectRotation(car, 240)
        AddObjectCreatures(car, CREATURE_CHAMPION, 5)
        AddObjectCreatures(car, CREATURE_LONGBOWMAN, 75)
        AddObjectCreatures(car, CREATURE_VINDICATOR, 50)
        AddObjectCreatures(car, CREATURE_ZEALOT, 15)
        sleep(4)
        MessageBox ("/Maps/SingleMissions/ZimaMap1v2NoScriptsNoQuests/Rally.txt")
    end
end