Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
8 years ago
Auto-translated
You're approaching the task from the wrong angle. Combat functions are well-described in Novik's scripting guide, if needed.
- when the only stack of the defending side moves, it does something.
It's simple here:
function DefenderUnitMove(unit)
  -- for example, cast a spell:
  UnitCastGlobalSpell(unit, 'SPELL_NAME');
  return not nil
end
- when any stack of the attacking side dies, ghosts appear on the defending side.
There might be some nuances:
function AttackerUnitDeath(unit)
  -- haven't checked, it might work like this:
  local x, y = GetUnitPosition(unit);
  AddCreature(side, type, quantity, x, y);
end
You just need to place these functions in the combat script; they will be automatically called when the corresponding event occurs.
In reply to Jack_of_shadows
8 years ago
Auto-translated
Ugh, I hate that the script system only saves with a closed map. As a result, my script with the castle was deleted. I won't be able to upload it, but I'll look for part of the script in the "Elements of Unity" map again. This stupid editor crashes at the most inappropriate moments:(
8 years ago
Auto-translated
AstralLin, could you perhaps help me with my script?
User Avatar
8 years ago
Auto-translated
My scripts usually work, but they are quite cumbersome and specific.

Added 2 minutes ago
Doubtful... I'm almost finished with the map... I'll finish this battle with the Lich and this dialogue with three answer options, and the map will be almost ready. The landscape is 100% complete; these functions are the last among the additional quests, and only the main storyline (functions) remains.

Added 1 minute ago
The transformation and restructuring script is complex... in my opinion... I've been working on this for so long...
In reply to AstralLein
8 years ago
Auto-translated
There is a clear example of transformation in the map “Ambassador” by RedhavenHero.
User Avatar
8 years ago
Auto-translated
For me, this map is like a manual:D I learned a lot from it in the beginning.

Transformation is easy. It only requires one command in the script. The difficulty lies in everything else.
In reply to Годрикова впадина
8 years ago
Auto-translated
It's quite challenging, I've written about 200 lines of scripts, ranging from easy to medium difficulty, and now I need to write this particular script. I've been struggling with it for about 2 weeks, without any success. I think this script will be around 60 lines long. So far, I'm only having good results with the animation of the holy word.
User Avatar
8 years ago
Auto-translated
I currently have about 420 lines. But that's not the end, plus the combat script.

Added 2 minutes later
And in general, scripts are a fascinating thing. It's much more interesting than creating landscapes.
In reply to AstralLein
8 years ago
Auto-translated
They are certainly interesting, but complex.
I think I can make the videos even more interesting.

Added 2 minutes later
I think I'll start by creating scripts so that creatures on the map attack the air. I'll put that script on the back burner, as it's either the most complex script on my map or almost the most complex.
User Avatar
8 years ago
Auto-translated
1. function SkullEndFinal(player, answer) if answer == 1 then Trigger(OBJECT_TOUCH_TRIGGER, "HutSkullQuest", "SkullPusty") MessageBox (path.."endend.txt") sleep(2) RemoveArtefact(heroichik, 83) SetPlayerResource(PLAYER_1, 6, GetPlayerResource(PLAYER_1, 6) + 60000) SetPlayerResource(PLAYER_1, 2, GetPlayerResource(PLAYER_1, 2) + 50) sleep(2) SetObjectiveState("SkullQuest", OBJECTIVE_COMPLETED) elseif answer == 2 then Trigger(OBJECT_TOUCH_TRIGGER, "HutSkullQuest", "SkullPusty") MessageBox (path.."endend.txt") sleep(2) RemoveArtefact(heroichik, 83) ChangeHeroState(heroichik, 4, 5) sleep(2) SetObjectiveState("SkullQuest", OBJECTIVE_COMPLETED) elseif answer == 3 then Trigger(OBJECT_TOUCH_TRIGGER, "HutSkullQuest", "SkullPusty") MessageBox (path.."endend.txt") sleep(2) RemoveArtefact(heroichik, 83) AddHeroCreatures(heroichik, CREATURE_DEMILICH, 45) sleep(2) SetObjectiveState("SkullQuest", OBJECTIVE_COMPLETED) end end With options 1 and 3, everything works as expected, but with option 2, it throws an error. The error occurs at ChangeHeroState(heroichik, 4, 5). 2. spells = {SPELL_MASS_WEAKNESS, SPELL_MASS_SLOW, SPELL_MASS_CURSE, SPELL_UNHOLY_WORD} How can I make it cast a random spell?
In reply to AstralLein
8 years ago
Auto-translated
I'm still far from being able to write scripts like yours:(

Added 31 seconds later
How did you learn to write such complex scripts?
User Avatar
8 years ago
Auto-translated
Well, this function will create 3 structures that are almost identical.
User Avatar
8 years ago
Auto-translated
When choosing options 1 and 3, everything works as expected, but option 2 produces an error.

The error occurs at ChangeHeroState(heroichik, 4, 5).
There is no such function; it exists without the "e" at the end.
spells = {SPELL_MASS_WEAKNESS, SPELL_MASS_SLOW, SPELL_MASS_CURSE, SPELL_UNHOLY_WORD} How can I make it cast a random spell?
In the most general case:
random_spell = spells[random(1, length(spells))];
However, if this is in combat, there is no function implemented that returns a random number (combat and overworld scripts have different sets of functions). You either need to write it yourself or use, for example, the lualib.lua library by RedHeavenHero (search the forum). I used the library.
User Avatar
8 years ago
Auto-translated
Here is the base code. What exactly needs to be added to make it work? diff = GetDifficulty() + 1 UnitCastGlobalSpell(unit, SPELL_MASS_SLOW); function DefenderUnitMove(unit) UnitCastGlobalSpell(unit, SPELL_UNHOLY_WORD); SummonCreature(DEFENDER, CREATURE_MUMMY, 15 * diff) return not nil end function AttackerUnitDeath(unit) SummonCreature(DEFENDER, CREATURE_GHOST, 50 * diff) end Added 49 seconds later The boss, who used to be a Yeti, casts the spells. Added 1 minute later A random summoning point is acceptable.
User Avatar
8 years ago
Auto-translated
You either need to write it yourself or use, for example, the lualib.lua library by RedHeavenHero (search the forum). I used the library.
Speaking of this. The Echo of the Void map features a better pseudo-random number generator (PRNG) than lualib, so I recommend taking it from there.

Statistics

Welcome our newest member: recijeb