Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
13 years ago
Auto-translated
Can static objects be removed using the RemoveObject function?
User Avatar
13 years ago
Auto-translated
You can set the IsRemovable property to true for these statics.
In reply to RedHeavenHero
User Avatar
13 years ago
Auto-translated
RedHeavenHero
Instead of UnitCastAimedSpell(unit,spell,target), use startThread(UnitCastAimedSpell,unit,spell,target). The error will remain, but it won't affect the script's further execution.

StartThread doesn't seem to work; it appears that you can't start multiple threads during combat.
In reply to Spectral
User Avatar
13 years ago
Auto-translated
Spectral
StartThread doesn't work; it seems you can't start multiple threads during combat.
You can. The developers used startThread in \data.pak\Maps\Scenario\A2C3M2\A2C3M2_InitialCombatScript.lua.
What does the console say?
In reply to RedHeavenHero
User Avatar
13 years ago
Auto-translated
RedHeavenHero

What does the console say?

value was NIL when getting global 'startThread'
attempt to call a nil value
In reply to Spectral
User Avatar
13 years ago
Auto-translated
Spectral
value was NIL when getting global 'startThread'
attempt to call a nil value
That's strange... The screenshot shows an example. Everything works, there are no errors.
Attachments 1
1 file attached • Total size: 224.9 KB
In reply to RedHeavenHero
User Avatar
13 years ago
Auto-translated
RedHeavenHero
That's strange... The screenshot shows an example. Everything works, there are no errors.
Maybe there's a mod here that adds this feature? Because the Haven faction has different shields.
And where is this screenshot from?
User Avatar
13 years ago
Auto-translated
No. It's just an NCF file; it only adds creatures (although I'm not sure).
In reply to Spectral
User Avatar
13 years ago
Auto-translated
Spectral
Could there be a mod that adds this feature? Because the Haven faction has different shields.
And where is this screenshot from?
Unlikely. But still, take a look at that developer script (campaign "Escape to Salvation", mission "The Veil Falls", when Lorenzo attacks Zehir). There is a startThread, but there are no errors.
It was present in the combat scripts even in the original.

Added after 39 seconds
Warrior777
No. It's just an NCF, it only adds creatures (although I don't know :D).
Yes, that's it.
User Avatar
13 years ago
Auto-translated
Does anyone know if this structure will work:
if (condition 1) then (instruction 1)
elseif (condition 2) then (instruction 2)
elseif (condition 3) then (instruction 3)
else (condition 4) then (instruction 4)

In other words, can you use if-elseif-else to write more than three conditions,
or am I misunderstanding the language, and can everything be done more simply?:confused:

All manuals seem to limit this structure to a maximum of three conditions, and I don't know if there's something like Pascal's case of here.
User Avatar
13 years ago
Auto-translated
Yeah, just put "end" at the end, and it should work. I'm not sure about the "case" statement, maybe it exists. If it does, it's probably some kind of hybrid between Pascal and C syntax.
User Avatar
13 years ago
Auto-translated
Thank you.
I checked it.
It works.
User Avatar
13 years ago
Auto-translated
To be honest, I'm not very familiar with battle scripts; half of them aren't even in the official manual. Can anyone help me out?:
a) How do you determine if your hero is defending or attacking? (IsAttacker works very strangely)
b) What UnitName should I specify? Is it the name of the unit given to it on the map, or the script name?
c) How do you make a hero cast a spell at the beginning of the battle or in sync with another action (like Frida's Divine Retribution or Leto's Plague)?
I would appreciate it if you could provide some small examples, if possible, because I won't be able to figure it out otherwise.
Thank you in advance.
In reply to Heroist
User Avatar
13 years ago
Auto-translated
Heroist
To be honest, I don't really understand battle scripts. Half of them aren't even in the official manual. Can anyone help me with the following:
a) How do I determine if my hero is defending or attacking? (IsAttacker works very strangely)
b) What UnitName should I specify? Is it the name of the unit as it appears on the map, or the script name?
c) How do I make a hero cast a spell at the beginning of the battle or in sync with another action (like Frida's Divine Retribution or Leto's Plague)?
I would appreciate it if you could provide some small examples, as I won't be able to figure it out otherwise.
Thank you in advance.
a)
if GetHeroName('defender-hero') == 'hero name' then
--hero is defending
elseif GetHeroName('attacker-hero') == 'hero name' then
--hero is attacking
else
--not participating
end
b) If unitName is in the arguments, then the unit names are determined by the GetAttackerCreatures or GetDefenderCreatures functions, which return an array. 'attacker-hero' and 'defender-hero' can also be unit names.
c) UnitCastAimedSpell, UnitCastGlobalSpell, UnitCastAreaSpell.
The arguments are described in sufficient detail in the manual (HOMM5_Script_Functions.pdf).
In reply to Heroist
User Avatar
13 years ago
Auto-translated
`UnitName` is assigned when any function is called, for example:
function Attacker(Defender)CreatureDeath(unitName)

each time an attacking (or defending) stack of creatures is destroyed, this function is called; the `unitName` parameter is the destroyed stack.
function Attacker(Defender)CreatureMove(unitName) - is called when the turn is passed to the attacking (or defending) stack of creatures; `unitName` is this stack.

I don't know which function to use to cast at the beginning of the battle.
`Prepare()` is called when preparing for battle; `Start()` - I don't know, either after `Prepare()` or before it.

approximately like this:
function Start()
hero = GetAttacker(Defender)Hero
UnitCastAreaSpell(hero, spellID, X, Y)
end

Statistics

Welcome our newest member: recijeb