• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Dokkio Sidebar applies AI to make browsing the web faster and more productive. Whenever you open Sidebar, you'll get an AI summary of the web page and can ask any question you like about the content of the page! Try Dokkio Sidebar for free.


Scripting Examples

This version was saved 6 years, 6 months ago View current version     Page history
Saved by Kert
on November 23, 2016 at 3:08:28 am


Give hero spells and skill at map start


This script will, at the start of the map, find the first hero of the first player, and give him the Fireball spell, 10 points in knowledge, 100 spellpoints, and Expert Wisdom.


function OnMapStart()
  player = GetPlayer(0);
  hero = GetHero(player, 0);

  GrantSpell(hero, SPELL_FIREBALL);
  SetPrimarySkill(hero, PRIMARY_SKILL_KNOWLEDGE, 10);
  SetSpellPoints(hero, 100);  
  SetSecondarySkill(hero, SECONDARY_SKILL_WISDOM, 3);


Give all player's heroes new troops at the start of the week


On Day 1 of every week after the first, this script will give all heroes belonging to the first player 50 skeletons, accompanied by a flavorful message.


function OnNewDay(month, week, day) 
  if day == 1 and not (week == 1 and month == 1) then
    player = GetPlayer(0);
    for i=0, GetNumHeroes(player)-1 do
      hero = GetHero(player, i);
      GrantArmy(hero, CREATURE_SKELETON, 50);
    MessageBox("More troops have risen to join our cause.");


Build special building when artifact is brought to town


When a hero brings the Mage's Ring of Power to the town named "Sorrow's End", this script will take away the artifact and build a "super Mage's Guild," consisting of a level 5 Mage guild with extra spells available at each level. It also makes sure the top level has some good spells.


function OnTownOpen(name)

  if name == "Sorrow's End" then

    town = GetCurrentTown();

    if HasVisitingHero(town) then

      hero = GetVisitingHero(town);

      if HasArtifact(hero, ARTIFACT_MAGES_RING_OF_POWER) then

        TakeArtifact(hero, ARTIFACT_MAGES_RING_OF_POWER);

        MessageBox("The Mage's Ring fits easily in the keyhole of the sealed library door. Inside lie shelves packed with tomes.");








        SetNumGuildSpells(t, 0, 4); 

        SetNumGuildSpells(t, 1, 4);

        SetNumGuildSpells(t, 2, 4);

        SetNumGuildSpells(t, 3, 4); 

        SetNumGuildSpells(t, 4, 4);


        SetGuildSpell(t, 4, 0, SPELL_DIMENSION_DOOR);

        SetGuildSpell(t, 4, 1, SPELL_SUMMON_WATER_ELEMENTAL);

        SetGuildSpell(t, 4, 2, SPELL_SUMMON_EARTH_ELEMENTAL);

        SetGuildSpell(t, 4, 3, SPELL_RESURRECT_TRUE);








Comments (0)

You don't have permission to comment on this page.