Skip to content

Posts from Messages

No ratings yet — be the first to rate!
User Avatar
13 years ago
Auto-translated
:confused: I don't know how to do it... and I couldn't find any relevant topics anywhere... I think I looked, but if I missed something, I'd be grateful for a link. I want it so that when I kill a group of monsters near an artifact from our dragon set with a hero on the map, a message appears (I'm not planning on using videos yet :D) saying that I have cleared the monsters guarding n out of 8 pieces of armor. And when I collect all 8, the hero receives 2 more artifacts +n to each characteristic... Whew :)
User Avatar
13 years ago
Auto-translated
Here's a simple example:

setCount = 0;

function setInfo()
	setCount = setCount+1;
	if setCount == 1 then
		MessageBox(GetMapDataPath()..'count1from8.txt');
	elseif setCount == 2 then
		MessageBox(GetMapDataPath()..'count2from8.txt');
	elseif setCount == 3 then
		MessageBox(GetMapDataPath()..'count3from8.txt');
	elseif setCount == 4 then
		MessageBox(GetMapDataPath()..'count4from8.txt');
	elseif setCount == 5 then
		MessageBox(GetMapDataPath()..'count5from8.txt');
	elseif setCount == 6 then
		MessageBox(GetMapDataPath()..'count6from8.txt');
	elseif setCount == 7 then
		MessageBox(GetMapDataPath()..'count7from8.txt');
	elseif setCount == 8 then
		MessageBox(GetMapDataPath()..'count8from8.txt');
		GiveArtefact("heroname", artifact1Id);
		GiveArtefact("heroname", artifact2Id);
		ChangeHeroStat("heroname", STAT, count);
	end;
end;

Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard1', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard2', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard3', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard4', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard5', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard6', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard7', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard8', 'setInfo');

If anything is unclear, I'll describe everything that happens here in more detail.
P.S. All of this is actually in the "scripts" topic, although you'll have to search for it there for a very long time
User Avatar
13 years ago
Auto-translated
Thank you very much! I understand English quite well, so I understood almost everything.

Added 1 hour and 3 minutes later
Another problem arose: I'm creating a second ghost necromancer, and when I change his special ability in the shared settings, the special ability of the first one also changes. What should I do?:smile45:
User Avatar
13 years ago
Auto-translated
Could the name be changed as well? It essentially needs to be created from scratch, just to avoid the hassle of copying all the information from the old hero. When I created characters for myself, I didn't have any problems.

Added 8 minutes later
And the function also needs to include a check for accuracy:
setCount = 0;

function setInfo(object, hero)
    setCount = setCount+1;
    heroname = hero;
    sleep(5);
    if IsHeroAlive(heroname) ~= true then
        return;
    end;

    if setCount == 1 then
        MessageBox(GetMapDataPath()..'count1from8.txt');
    elseif setCount == 2 then
        MessageBox(GetMapDataPath()..'count2from8.txt');
    elseif setCount == 3 then
        MessageBox(GetMapDataPath()..'count3from8.txt');
    elseif setCount == 4 then
        MessageBox(GetMapDataPath()..'count4from8.txt');
    elseif setCount == 5 then
        MessageBox(GetMapDataPath()..'count5from8.txt');
    elseif setCount == 6 then
        MessageBox(GetMapDataPath()..'count6from8.txt');
    elseif setCount == 7 then
        MessageBox(GetMapDataPath()..'count7from8.txt');
    elseif setCount == 8 then
        MessageBox(GetMapDataPath()..'count8from8.txt');
        GiveArtefact("heroname", artifact1Id);
        GiveArtefact("heroname", artifact2Id);
        ChangeHeroStat("heroname", STAT, count);
    end;
end;

Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard1', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard2', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard3', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard4', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard5', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard6', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard7', 'setInfo');
Trigger(OBJECT_TOUCH_TRIGGER, 'dragonGuard8', 'setInfo');
User Avatar
13 years ago
Auto-translated
The point is that the editor perceives two heroes as a single object with a "split personality :D," and whatever special ability I assign to one, the other also gets, because I simply place a Ghost from Heroes (Scenario) on the map and, in each case, change the primary skill to Necromancy. So, I end up with two Ghosts "for the price of one :D."
User Avatar
13 years ago
Auto-translated
don't do it through the editor; find the path where the hero file is located, open it using an archiver, and copy the file to your map. Then, you can use the editor to specify the path and configure everything you need.
User Avatar
13 years ago
Auto-translated
another question about the script:
do I need to write the line ChangeHeroStat("heroname", STAT, count) four times? i.e., in the first one, stat_attack, in the second, stat_defence, and so on?
User Avatar
13 years ago
Auto-translated
yes, for each stat separately, but if there are many of them and for many heroes, for example, then you can use a loop

stats = {STAT_EXPERIENCE, STAT_ATTACK, STAT_DEFENCE, STAT_SPELL_POWER, STAT_KNOWLEDGE, STAT_LUCK, STAT_MORALE};

for i = 1, length(stats) do
ChangeHeroStat("heroname", stats, count);
end;

something like this

Statistics

Welcome our newest member: recijeb