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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Scripting Examples

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

triggers->callbacks

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

 

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);
    end;  
 
    MessageBox("More troops have risen to join our cause.");
  end;
end;

 

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

 

        BuildInCurrentTown(BUILDING_MAGE_GUILD); 

        BuildInCurrentTown(BUILDING_MAGE_GUILD);

        BuildInCurrentTown(BUILDING_MAGE_GUILD);

        BuildInCurrentTown(BUILDING_MAGE_GUILD);

        BuildInCurrentTown(BUILDING_MAGE_GUILD);

 

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

      end;

    end;

  end;

end;

 

 

 

Comments (0)

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