Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
7 years ago
Auto-translated
Okay, fine (I'm just too lazy to write everything out, and I'm having some issues with the script on the map myself). 2) Create a region and change the Priority to something suitable. **(I haven't tested this!)**, and you can also set the priority to -1 for other objects. The result is approximately this: - Hmm... something in the region, hey you helmet-heads, we have guests. - OK! Whatever, there's an enemy!
In reply to DarkLordax
User Avatar
7 years ago
Auto-translated
DarkLordax
Okay, fine (I'm just too lazy to write everything out, and I'm having some issues with the script on the map).

2) Create a region and change the Priority to something suitable (I haven't tested this!), and you can also set the priority to -1 for other objects.

The result is roughly this:
- Hmm... something in the region, hey you helmet-heads, we have guests.
- OK! Whatever, there's an enemy!
Is this priority a script or a function?
User Avatar
7 years ago
Auto-translated
There should be a function called SetAIPlayerAttractor, but there is SetAIHeroAttractor (well, it's a script, I understand!).
One is for a specific hero, the other is just for the player.
Here's something else:

DoNotGiveTurnToPlayerAIIfNoTownsAndActiveHeroes
should be in the script file.
In reply to DarkLordax
User Avatar
7 years ago
Auto-translated
DarkLordax
So, what's wrong here!

function pobor1()
if GetObjectiveState("SQ1", 1) ==OBJECTIVE_UNKNOWN then
SetObjectiveState("SQ1", OBJECTIVE_ACTIVE, 1);
MessageBox("Maps/SingleMissions/C1W1/poborQ1.txt", "nothing");
if IsObjectExists("pobornik1") ==false then
if IsObjectExists("pobornik2") ==false then
if IsObjectExists("pobornik3") ==false then
SetObjectiveState("SQ1", OBJECTIVE_COMPLETED, 1);
SetObjectEnabled("dwellquest1", true);
SetObjectOwner("dwellquest1", 1);
Trigger(OBJECT_TOUCH_TRIGGER, "dwellquest1", nil)
end;
end;
end;
elseif GetObjectiveState("SQ1", 1) ==OBJECTIVE_ACTIVE then
if IsObjectExists("pobornik1") ==false then
if IsObjectExists("pobornik2") ==false then
if IsObjectExists("pobornik3") ==false then
MesageBox("Maps/SingleMissions/C1W1/poborEND.txt", "nothing");
SetObjectEnabled("dwellquest1", true);
SetObjectOwner("dwellquest", 1);
SetObjectiveState("SQ1", OBJECTIVE_COMPLETED, 1);
Trigger(OBJECT_TOUCH_TRIGGER, "dwellquest1", nil)
end;
end;
end;
end
end
Trigger(OBJECT_TOUCH_TRIGGER, "dwellquest1", "pobor1")

The almighty console writes ERROR attempt to call a nil value. But where is this nil value!

In short, everything works only if all three enemies (pobornik) are killed before taking the quest; then it will be completed! If you take the quest first, then some nil value pops up!

I wouldn't recommend ever using the word false! It's unlikely that the problem is in it, although who knows, but besides errors in the console, false and true haven't caused anything else for me.

Added 1 minute ago
Using these two words is fundamentally incorrect. There is nil, 0, 1, etc. It already depends on the script command.

Added 52 minutes ago
How can I give a hero Perfect Necromancy?
In reply to AstralLein
7 years ago
Auto-translated
AstralLein
How can I give a hero the Perfect Necromancy skill?

1. Amulet of Mastery
2. In the editor, set the hero's PrimarySkillMastery to MASTERY_EXTRA_EXPERT.
Unfortunately, it won't work through GiveHeroSkill. (At least, it didn't work for me).
User Avatar
7 years ago
Auto-translated
I mean, give it as a reward for completing a quest. Using a script.

Added 33 seconds later
There was a map where they did something similar...
In reply to AstralLein
7 years ago
Auto-translated
AstralLein
I mean, give it as a reward for completing a quest, using a script.

As an alternative: give the player an Amulet, and if their Necromancy skill is below Expert, increase it using GiveHeroSkill.
User Avatar
7 years ago
Auto-translated
Does GiveHeroSkill increase the skill level?
In reply to AstralLein
7 years ago
Auto-translated
AstralLein
Does GiveHeroSkill increase the skill level?

Yes. But it is not possible to raise a racial skill to perfection using it.
User Avatar
7 years ago
Auto-translated
Ugh. I guess I'll have to give out the artifact after all... what a pain... but the whole point was to train 3 heroes in advanced necromancy and get Perfect Necromancy for Arantir.
In reply to AstralLein
User Avatar
7 years ago
Auto-translated
AstralLein
I wouldn't recommend ever using the word "false"! It's unlikely that the issue is related to it, although who knows, but besides the errors in the console, "false" and "true" haven't caused me any other problems.

Added 1 minute ago
Using these two words is fundamentally incorrect. There are "nil," 0, 1, etc. It depends on the scripting command.

Added 52 minutes ago
How can I give a hero the "Perfect Necromancy" skill?
I had a similar problem: MesageBox(One s)!
In reply to DarkLordax
User Avatar
7 years ago
Auto-translated
DarkLordax
I had this problem: MesageBox(One s)!

Ah, a well-known issue with typos.
7 years ago
Auto-translated
There's a problem: here's the code:
function portal(hero)
if GetObjectOwner(hero) == 1 then
if GetObjectiveState("tom") == OBJECTIVE_UNKNOWN then
MessageBox(path.."tom1.txt")
end
if GetObjectiveState("tom") == OBJECTIVE_ACTIVE then
QuestionBox(path.."tom2.txt",'Dragon("'..hero..'")')
end
end
end

Trigger(OBJECT_TOUCH_TRIGGER, "portal","portal")

function Dragon(hero)
local week = ceil(GetDate(DAY) / 7)
sleep(3)
--
StartCombat(hero,nil,3,84, diff * week, 84, diff * week, 84, diff * week,nil,'BattleResult',nil,nil)
end
Everything works fine, but... (see the screenshot) What could be causing this? I just want the console to be clean and not display an error.
Attachments 1
1 file attached • Total size: 28.0 KB
In reply to AlekseyS
User Avatar
7 years ago
Auto-translated
AlekseyS
There is a problem: here is the code
function portal(hero)
if GetObjectOwner(hero) == 1 then
if GetObjectiveState("tom") == OBJECTIVE_UNKNOWN then
MessageBox(path.."tom1.txt")
end
if GetObjectiveState("tom") == OBJECTIVE_ACTIVE then
QuestionBox(path.."tom2.txt",'Dragon("'..hero..'")')
end
end
end

Trigger(OBJECT_TOUCH_TRIGGER, "portal","portal")

function Dragon(hero)
local week = ceil(GetDate(DAY) / 7)
sleep(3)
--
StartCombat(hero,nil,3,84, diff * week, 84, diff * week, 84, diff * week,nil,'BattleResult',nil,nil)
end
Everything works fine, but... (see screenshot)

What could be causing this? I just want the console to be clean and not display an error.

This is due to calling the callback with a parameter. By default, the scripting engine simply adds two parentheses (and parameters, in some cases) to the name and executes the resulting code. If you call the callback with custom parameters, the executable code will look like this:
'Dragon("'..hero..'")()'
that is, after calling the Dragon function, the result returned from it will be called, and since the function does not return anything, an error occurs when trying to call nil.

It can be fixed by adding two hyphens:
QuestionBox(path.."tom2.txt",'Dragon("'..hero..'")--')
then the executable code will look like this:
'Dragon("'..hero..'")--()'
that is, the extra parentheses will be commented out.
In reply to RedHeavenHero
7 years ago
Auto-translated
RedHeavenHero
This is due to the callback being called with a parameter. By default, the scripting engine simply adds two parentheses (and parameters, in some cases) to the name and executes the resulting code. If you call the callback with custom parameters, the code to be executed will be something like this:
'Dragon("'..hero..'")()'
that is, after calling the Dragon function, the result returned from it will be called, and since the function returns nothing, an error occurs when trying to call nil.

It can be fixed by adding two minus signs:
QuestionBox(path.."tom2.txt",'Dragon("'..hero..'")--')
then the code to be executed will look like this:
'Dragon("'..hero..'")--()'
that is, the extra parentheses will be commented out.

It helped, thank you.

Statistics

Welcome our newest member: recijeb