Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to RedHeavenHero
10 years ago
Auto-translated
RedHeavenHero
Try opening the map with an archiver and editing the map script file with Notepad. The file name is MapScript.lua.

And how do you apply a script to individual creatures? I need to have a dead monster on the map, and it should be impossible to start a battle with it.
User Avatar
10 years ago
Auto-translated
All scripts are written to a single file. There was already a topic about dead monsters. It was something like this:
SetObjectEnabled('name', nil)
PlayObjectAnimation('name', 'death', ONESHOT_STILL)
In reply to RedHeavenHero
10 years ago
Auto-translated
RedHeavenHero
All scripts are written into a single file.
There was already a discussion about dead monsters in the thread. It's something like this:
SetObjectEnabled('name', nil)
PlayObjectAnimation('name', 'death', ONESHOT_STILL)
I opened the map as an archive, and there's no MapScript file. I tried using MapEditorScript, created a file, wrote a script, saved it, went into the map, selected this file in the creature's parameters, in "Script," and nothing happened.
User Avatar
10 years ago
Auto-translated
Bravo1853, in the editor, within the Map Properties Tree, there is a MapScript item – this is the main script for the map and is executed automatically at the start. If it is empty, you need to specify the path to the file or create a new one. Write all the code in this single file; those that are linked in the properties of monsters and other objects are not used in practice. Once you understand how the file works, it is better to edit it using Notepad or MapScriptsEditor, as many users experience crashes when accessing it through the editor.
In reply to Jack_of_shadows
10 years ago
Auto-translated
Jack_of_shadows
Bravo1853, in the editor, within the Map Properties Tree, there's a section called MapScript – this is the main script for the map and it runs automatically when the map starts. If it's empty, you need to specify the path to the file or create a new one. Write all the code in this single file; the ones that are linked in the properties of monsters and other objects are not used in practice. Once you understand how the file works, it's best to edit it using Notepad or MapScriptsEditor, as many users experience crashes when accessing it through the editor.
I created a MapScript.lua file using MSE, added the script to it, and specified the file path. How do I now make a monster on the map be dead?
User Avatar
10 years ago
Auto-translated
Perhaps the monster's name wasn't assigned? Check the "name" field. It should be the same as the name specified in the script. And if, instead of dying, the monster glitches out and flies in all directions, it means it doesn't have the corresponding animation; you should try a different one (it's a 50/50 chance whether it has one or not. Alternative upgrades are more likely to have a connected animation).
In reply to Jack_of_shadows
10 years ago
Auto-translated
Jack_of_shadows
Perhaps the monster's name wasn't assigned? Check the 'name' field. It's the same one that was specified in the script as 'name'. And if, instead of dying, the monster flies in all directions, it means it doesn't have the corresponding animation; you should try a different one (it's 50/50 whether it has one or not. Alternative upgrades are more likely to have a connected animation).
It worked! Yes, I indeed forgot to specify the monster's name. Thank you very much! Another question: how do I remove the skirt from a monster?
User Avatar
10 years ago
Auto-translated
SetObjectEnabled('name', nil);
SetDisabledObjectMode('name', DISABLED_INTERACT);
sleep(1)
SetMonsterSelectionType('name', 0);
This disables interaction, changes the cursor from a sword to a horse, and removes the skirt. The order of the commands is important.
In reply to Jack_of_shadows
10 years ago
Auto-translated
Where should I insert the line?
PlayObjectAnimation('name', 'death', ONESHOT_STILL)
User Avatar
10 years ago
Auto-translated
In conclusion.

Added 4 minutes later
I don't remember exactly, but just in case, I placed the second line after disabling and pausing.
SetObjectEnabled('name', nil)
sleep(1)
SetDisabledObjectMode('name', DISABLED_INTERACT)
SetMonsterSelectionType('name', 0)
PlayObjectAnimation('name', 'death', ONESHOT_STILL)
In reply to RedHeavenHero
10 years ago
Auto-translated
Could you provide information about a script for monster attacks that would play the animation infinitely? I tried the script below, but it didn't work.
function play_anims()
	PlayObjectAnimation("15", "attack", IDLE)
	sleep(3)
end
User Avatar
10 years ago
Auto-translated
Bravo1853, did you at least call the function? Only the code that is not inside a function is executed at startup; everything inside a function is executed when the function is called. And the standard animation names are usually like this:
"attack00", "attack01", "rangeattack", "cast", "specability", "death", "hit", "happy", "idle00"
10 years ago
Auto-translated
How do I set the interval between animation playback? I tried setting the value in `sleep` to more than 1000, but there were no changes. Also, how do I make the animations play in a specific sequence? For example: first `attack`, then `happy`.
User Avatar
10 years ago
Auto-translated
The pause is probably too long. 1000 represents 200 seconds. To ensure the animation plays sequentially, you need to write the animation playback commands in the required order, separating them with pauses if necessary.
In reply to RedHeavenHero
10 years ago
Auto-translated
RedHeavenHero
The pause is probably too long. 1000 is 200 seconds.
To play the animation sequentially, you need to write the commands to play the animation in the required sequence, separating them with pauses if necessary.
The problem is that the pause doesn't seem to be working; with a value of 1000, there's no pause at all. There might be an error in the script itself. Here's the code:
PlayObjectAnimation('03', 'attack00', IDLE)
sleep(50)

Statistics

Welcome our newest member: recijeb