Skip to content

Posts from Current questions and answers regarding the map editor.

5.0 (12 ratings)
User Avatar
14 years ago
Auto-translated
where does ChangeResouce come from? There is SetPlayerResouce
Change|Set doesn't add resources to the player, but sets them, so it should be done like this:
function regF ()
SetAmbientLight (0, "Tu", true, 5);
delta = GetPlayerResource(1, 5);
SetPlayerResource(1, 5, delta+10);
end;
Trigger (REGION_ENTER_AND_STOP_TRIGGER, "reg", "regF");
In reply to KioM
User Avatar
14 years ago
Auto-translated
KioM
Where does ChangeResource come from? Is there a SetPlayerResource?
ChangeResource: Changes the amount of a specified resource for the player who owns the specified hero. A "floating" message appears from this hero, indicating the resource change.
playerID: Player ID
resourceKindID: Resource type ID
quantity: Amount (cannot be a negative value)
heroName: Hero name
User Avatar
14 years ago
Auto-translated
antonag07 is right, it is clearly stated here that you should give 10 crystals. Sulfur has code 4 (or SULFUR, to avoid confusion).
In reply to Олегарх
User Avatar
14 years ago
Auto-translated
Oligarch
ChangeResource Changes the amount of a specified resource for the player who owns the specified hero. A "flying" message appears from this hero, indicating the resource change.
playerID Player ID
resourceKindID resourceKindID Resource type ID
quantity Amount (cannot be a negative value)
heroName Hero name

Where did you get this from? I don't have these functions in the official manuals.
User Avatar
14 years ago
Auto-translated
When creating a map, I encountered the following problem:
If you give a creature resources/an artifact, you receive them after killing it. But if it joins your army, you don't get them. Is it possible to obtain the artifact/resources only AFTER the creature joins your army, without killing it (this doesn't fit the scenario)? If it's a script, could you please share the code? :smile45:
User Avatar
14 years ago
Auto-translated
Bulletin, `

function MonsterFunction(hero)
    Trigger(OBJECT_TOUCH_TRIGGER, 'Monster', nil);
    -- artifact
    GiveArtefact(hero, itemId);

    -- resource
    gold = GetPlayerResource(PLAYER_1, GOLD);
    SetPlayerResource(PLAYER_1, GOLD, gold+your amount);
end;

Trigger(OBJECT_TOUCH_TRIGGER, 'Monster', 'MonsterFunction');

in the monster's properties, give it a script name and set it so that it always joins.
User Avatar
14 years ago
Auto-translated
complains that the functions MonsterFunction (monster replaced with the script name of the unit footman) and ItemId are undefined.
From the error, I only understood that I need to give an ID to the artifact. All IDs are in the file from the developers, which I don't have. But I don't quite understand what to do with the monster.

function footmanFunction(hero)
Trigger(OBJECT_TOUCH_TRIGGER, 'footman', nil);
GiveArtefact(hero, itemId);
end;
Trigger(OBJECT_TOUCH_TRIGGER, 'footman', 'footmanFunction');
In reply to KioM
User Avatar
14 years ago
Auto-translated
KioM
where did you get this from? I don't have these functions in the official manuals.
This is from a manual by ValexAV. And crystals are just an example.

Ah, okay, it worked now.
function regF()
sulfur=GetPlayerResource(1, 4);
if sulfur>=3 then
SetPlayerResource(1, 4, sulfur-10);
end;
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "reg", "regF");

Added 57 minutes later
In the World of Enroth map, there was an object - a UFO. How do I place it on the map?
14 years ago
Auto-translated
You place any hero on the map, then in the properties tree, click on "Shared." A new window will open, and there you can choose the desired object from the list of heroes (it will have the word "UFO" in its name).
User Avatar
14 years ago
Auto-translated
Vestnik, everything was replaced correctly, only the artifact ID was used instead of itemId ;) ... oh yes, very often you also need to additionally declare parameters inside the function, like this:
function MonsterFunction(hero)
    myHero = hero; -- additionally added the hero variable
    Trigger(OBJECT_TOUCH_TRIGGER, 'Monster', nil);
    -- artifact
    GiveArtefact(myHero, 53); -- added as an example the ID of an artifact (in this case, the Tear of Ashi)

    -- resource
    gold = GetPlayerResource(PLAYER_1, GOLD);
    SetPlayerResource(PLAYER_1, GOLD, gold + your amount);
end;

Trigger(OBJECT_TOUCH_TRIGGER, 'Monster', 'MonsterFunction');
User Avatar
14 years ago
Auto-translated
I copied the code, pasted it into the monster. I changed the function name, but nothing happened. I checked the case sensitivity (C++ is just as case-sensitive, so there are no problems with that). Do comments affect the script's functionality? Can you upload a table with item IDs, because my build doesn't have either the official manual or the table.
User Avatar
14 years ago
Auto-translated
You don't need to put this script into a monster; instead, put it in MapScript.lua.
In reply to Ment
User Avatar
14 years ago
Auto-translated
How to edit a message after winning?
In reply to Олегарх
14 years ago
Auto-translated
Oligarch
How do you edit a message after winning?

What do you mean? Do you want to edit the message after completing a mission and write something like "This is a real victory - not a defeat!" in it?
Well, what prevents you from creating a text file and writing what you think is necessary in it? You can do the same procedure for the message about losing ("This is your shameful defeat - not a victory!").

Statistics

Welcome our newest member: recijeb