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

  • Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.


Scripting Examples

Page history last edited by kristo605@... 2 years, 5 months ago Saved with comment

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);






Override right-click text on the world map


This script will replace the tooltip text for a specific campfire with "Gathering."


     function GetTooltipText(locationType, x, y)
          if locationType == LOCATION_CAMPFIRE and x == 5 and y == 15 then
               return "Gathering";
               return TOOLTIP_DEFAULT;




Comments (0)

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