Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Jewily
User Avatar
7 years ago
Auto-translated
Jewill
Thank you. By the way, do you know if it's possible to give a hero of one class perks from another class (GiveHeroSkill can grant a skill of the first level, but it refuses to grant abilities) using only scripts? Or do you need to change something in GameMechanics in the hero's structure?[/QUOTE]
I'm not entirely sure how GiveHeroSkill works, but it can be used to grant and increase skills. Regarding perks, it seems to only grant perks that the hero can learn right now, and it must be a racial skill for the hero.
I might be wrong, but it seems that you can only set foreign skills with perks in the editor.
In reply to 32MeTpa
User Avatar
7 years ago
Auto-translated
Thank you, as I understand from testing, GiveHeroSkill works exactly as you described. That is, it only provides perks that are available based on the hero's race.
User Avatar
7 years ago
Auto-translated
Hello, everyone. Please help me with some advice – how can I use a script, and which one specifically, to create the following situation: create a monster-NPC, give it a scripted name and title. When interacting with it, a dialogue is initiated, based on which, we are offered a quest (!), which can be declined with the possibility of taking it later, or accepted. Upon completing the quest and interacting with it again, a reward is given, and the NPC disappears. Thank you in advance...
User Avatar
7 years ago
Auto-translated
Hello everyone. Is it possible to implement a check that, if a specific player is controlled by AI, the map script is simply not executed, but if it's a human player, then it is executed? It seems to be done through DoFile and creating several additional Lua files, but I don't know how to implement it specifically. Maybe someone can help?
In reply to Jewily
User Avatar
7 years ago
Auto-translated
Jewill
Hello everyone. Is it possible to implement a check so that if a specific player is controlled by AI, the map script is simply not executed, but if it's a human player, then it is executed. It seems to be done through DoFile and creating several additional Lua files, but I don't know how to implement it specifically. Maybe someone can help?
You can create other Lua files next to MapScript.lua (or in another folder, the main thing is to write the correct path later) and write scripts in them. To execute the scripts written there, you need to write in MapScript:
doFile('script.lua')
Accordingly, to prevent them from being executed if the player is a computer, you can make a check:
if IsAIPlayer(PLAYER_..) == 0 then
doFile('script.lua')
end;
Here, 0 means the player is human, and 1 means the player is a computer.
User Avatar
7 years ago
Auto-translated
How do you access a specific value in an array of heroes? For example, how do you access the third hero using GetPlayerHeroes?
User Avatar
7 years ago
Auto-translated
I have a question regarding AdvMap: is it possible to darken certain areas? I would like to implement something.

Added 4 minutes later
Vladislav A-V
Hello, esteemed colleagues. Please help me with some advice: how can I use a script, and which one specifically, to create the following situation: create a monster-NPC, give it a scripted name and title. When interacting with it, a dialogue is initiated, based on which, we are offered a quest (!), which can be declined with the possibility of taking it later, or accepted. Upon completing the quest and interacting with it again, a reward is given, and the NPC disappears. Thank you in advance...
I think that if there is free space on the map that no one can see (it could be in a Dungeon), you can place as many of these NPCs as you want, even a hundred, in one cell (it's better to place them in different cells, otherwise it lags), and simply move them to the desired locations. This is easier and you won't need to configure Rotation in the scripts, as it usually doesn't configure correctly (it resets to 0).
In reply to Jewily
User Avatar
7 years ago
Auto-translated
Jewill
How do you access a specific value in a linear array? For example, how do you access the 3rd hero using GetPlayerHeroes?
Also, just like with any other array with indices:
heroes = GetPlayerHeroes(1);
hero = heroes[3];
However, you need to keep in mind that in this function, the numbering starts from 0, i.e., to access the 3rd hero, you need to write heroes[2].
DarkLordax
I have a question regarding AdvMap. Is it possible to darken certain areas? I would like to implement something.
It's not entirely clear what you need. If you want to darken the lighting, it won't be possible to do it in specific areas; you can only change the global lighting using a script. For example, when crossing a region. If you're talking about the fog of war, it's not possible to darken already revealed areas. You can only prevent the revealing of new areas using the SetWarfogBehaviour function.
7 years ago
Auto-translated
Guys, I need some help. I want to create a quest where one hero has debuffs on initiative and attack up to a certain level in battle. The question is: after the battle, these debuffs are removed, but how can I make them reappear immediately after the battle?
User Avatar
7 years ago
Auto-translated
so try this:
Trigger(COMBAT_RESULTS_TRIGGER, 'CombatResult')

function CombatResult(fight_id)
local winner = GetSavedCombatArmyHero(fight_id, 1)
if winner == 'desired_hero' then
reapply the penalties
end
end
User Avatar
7 years ago
Auto-translated
A question for AI experts, which concerns the game mechanics more than the scripts themselves, but also includes them: If the landscape of the map is modified during the game using scripts, does the AI react normally to these changes? Or are the calculations of possible actions on the map performed at the beginning, and by changing something drastically (for example, paths of movement), can the AI's logic be broken?
In reply to KioM
User Avatar
7 years ago
Auto-translated
KioM
A question for AI experts, which concerns more the game mechanics than the scripts themselves, but also them:

If the landscape of the map is modified during the game using scripts, does the AI react normally to these changes? Or are the calculations of possible actions on the map performed at the beginning, and by changing something drastically (for example, paths of movement), can you break the logic of the AI?

I haven't noticed any changes in the AI. Just note that the area is now impassable.
7 years ago
Auto-translated
There is a problem: ``` function IsDjezebetDead() SetObjectiveState("obj1",OBJECTIVE_COMPLETED) SetObjectiveState("alive",OBJECTIVE_COMPLETED) sleep(10) SetObjectRotation(Edward,55) SetObjectPosition(Edward,19,76,0,0) SetObjectPosition(C1,21,77,0,0) SetObjectPosition(C2,22,74,0,0) SetObjectPosition("mage",20,74) StartAdvMapDialog(0) startThread(End) end function End() StartDialogScene(path.."S3/DialogScene.xdb#xpointer(/DialogScene)") sleep(5) Win() end ``` After defeating the hero, a dialog should start, followed by a cutscene, but instead, the victory is immediately registered (i.e., neither the dialog nor the cutscene plays). What is the problem?
In reply to AlekseyS
User Avatar
7 years ago
Auto-translated
AlekseyS

After defeating the hero, a dialogue should start, followed by a cutscene, but instead, the victory is immediately recorded (i.e., neither the dialogue nor the cutscene plays). What's the problem?
It's possible that the victory is automatically recorded upon completing the quest. If you move
SetObjectiveState("obj1",OBJECTIVE_COMPLETED)
SetObjectiveState("alive",OBJECTIVE_COMPLETED)
to the place of Win(), it will probably work. Or, you can delve into the quest settings to prevent victory from being recorded upon their completion.
In reply to 32MeTpa
7 years ago
Auto-translated
32MeTpa
It's possible that completing the quest automatically registers a victory. For example, if you replace
SetObjectiveState("obj1",OBJECTIVE_COMPLETED)
SetObjectiveState("alive",OBJECTIVE_COMPLETED)
with Win(), it will likely work. Or, you could delve into the quest settings to prevent a victory from being registered upon their completion.


Thank you. That's exactly what happened... The victory was being registered because of the second quest, even though both quests have the same parameters.

Statistics

Welcome our newest member: recijeb

Users Online 3 users 1380 guests