Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
New Server | HOMM1: info forum | HOMM2: info forum | HOMM3: info forum | HOMM4: info forum | HOMM5: info forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 5 - Modders Workshop > Thread: Heroes 5 Modding: Map Scripting
Thread: Heroes 5 Modding: Map Scripting This thread is 4 pages long: 1 2 3 4 · «PREV / NEXT»
WindBell
WindBell


Hired Hero
posted September 14, 2009 03:37 PM

Quote:
Quote:

I have tried DefenderHeroMove(sUnitName),but find that it acts oddly.If I return nil , AI take the control and do something as usual. But if I return not nil, AI hero always perfoms a "Defend" action which makes the ATB to 0 which nearly half the number of actions of the AI hero significantly for a Mass Haste takes only 0.5 ATB . Is it a bug or did I do something wrong?


Well it works as it should, but the functions you placed inside this function before return should also be called. Does script ignores them? What functions did you put there?


I write one for a barbarian hero:

funtion DefenderHeroMove(heroName)
local result = nil
if ( GetUnitManaPoints( heroName ) >= 10) then
UnitCastGlobalSpell(heroName, SPELL_WARCRY_BATTLECRY)
result = not nil
end
return result
end

And AI always cast Battlecry and defends at one action.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
PvP
PvP

Tavern Dweller
posted September 14, 2009 04:11 PM
Edited by PvP at 16:14, 14 Sep 2009.

Quote:
Quote:
Quote:

I have tried DefenderHeroMove(sUnitName),but find that it acts oddly.If I return nil , AI take the control and do something as usual. But if I return not nil, AI hero always perfoms a "Defend" action which makes the ATB to 0 which nearly half the number of actions of the AI hero significantly for a Mass Haste takes only 0.5 ATB . Is it a bug or did I do something wrong?


Well it works as it should, but the functions you placed inside this function before return should also be called. Does script ignores them? What functions did you put there?


I write one for a barbarian hero:

funtion DefenderHeroMove(heroName)
local result = nil
if ( GetUnitManaPoints( heroName ) >= 10) then
UnitCastGlobalSpell(heroName, SPELL_WARCRY_BATTLECRY)
result = not nil
end
return result
end

And AI always cast Battlecry and defends at one action.


That is what i was talking about, you may make this battle harder by adding some scripted actions to enemy hero (like the battle cry you mentioned, you may add as much actions to him as you want) without . Sure in your example battle probably becomes easier, but:

1. You may return nil as the result so enemy hero woudn't lose his turn after function call.

2. You may add some "logic" to the action of AI hero. Like  making him cast certain powerfull spells with certain probability each turn or such. Using scripts you can get some info about creature types, their numbers and position in combat. And having the idea about mission details (you may transfer to combat what skills and spells player hero has through global variables for instance) you may decide what your hero would do.

3. By the way have you tried giving him some powerfull skill like academy ultimate or tons of stats and troops? (he is a Boss after all). As far as i remember this aproach worked perfectly well in the Year of Fire Tears (not sure it's exact name) campaign to make boss a really tought guy there.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
WindBell
WindBell


Hired Hero
posted September 15, 2009 03:01 AM
Edited by WindBell at 03:13, 15 Sep 2009.

Quote:
Quote:
Quote:
Quote:

I have tried DefenderHeroMove(sUnitName),but find that it acts oddly.If I return nil , AI take the control and do something as usual. But if I return not nil, AI hero always perfoms a "Defend" action which makes the ATB to 0 which nearly half the number of actions of the AI hero significantly for a Mass Haste takes only 0.5 ATB . Is it a bug or did I do something wrong?


Well it works as it should, but the functions you placed inside this function before return should also be called. Does script ignores them? What functions did you put there?


I write one for a barbarian hero:

funtion DefenderHeroMove(heroName)
local result = nil
if ( GetUnitManaPoints( heroName ) >= 10) then
UnitCastGlobalSpell(heroName, SPELL_WARCRY_BATTLECRY)
result = not nil
end
return result
end

And AI always cast Battlecry and defends at one action.


That is what i was talking about, you may make this battle harder by adding some scripted actions to enemy hero (like the battle cry you mentioned, you may add as much actions to him as you want) without . Sure in your example battle probably becomes easier, but:

1. You may return nil as the result so enemy hero woudn't lose his turn after function call.

2. You may add some "logic" to the action of AI hero. Like  making him cast certain powerfull spells with certain probability each turn or such. Using scripts you can get some info about creature types, their numbers and position in combat. And having the idea about mission details (you may transfer to combat what skills and spells player hero has through global variables for instance) you may decide what your hero would do.

3. By the way have you tried giving him some powerfull skill like academy ultimate or tons of stats and troops? (he is a Boss after all). As far as i remember this aproach worked perfectly well in the Year of Fire Tears (not sure it's exact name) campaign to make boss a really tought guy there.


Thanks for you advices. It is really helpful and works well.

However , in my simple example , the enemy hero will act twice at the same time ( one cast Battle Cry and then defend) ,which is not logical in the battle. though I can use it by return nil it actually increase the diffculty. Can I remove the enemy hero's defend action ?

By the way , where can I get this map? It looks like that what you mentioned is not the offical campaign -The day of fire.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
PvP
PvP

Tavern Dweller
posted September 15, 2009 10:04 AM
Edited by PvP at 21:05, 15 Sep 2009.

Quote:

Thanks for you advices. It is really helpful and works well.

However , in my simple example , the enemy hero will act twice at the same time ( one cast Battle Cry and then defend) ,which is not logical in the battle. though I can use it by return nil it actually increase the diffculty. Can I remove the enemy hero's defend action ?

By the way , where can I get this map? It looks like that what you mentioned is not the offical campaign -The day of fire.


The campaign i was talking about can be downloaded here:
http://www.maps4heroes.com/heroes5/campaigns/campaigns.php

Correct name is: 566 year - The Day of Fiery Tears. So it is probably what you thought it is.

Though, i'm not sure about a way to remove defend action. As i recall i've sent you a complete script function list so you may try to find something there, but i myself can't come up with anything that would look like all good solution to the problem. If this defend action irritates you, because it is always defend you can return not nil. If it's ATB shift that bothers you, you may try:

- to shift enemy hero ATB position to say 0.5 inside function (so he wouldn't be the first to act after you've left your function) (not sure this one would work though)

- catch the next person acting after hero with similar hook and shift
hero's ATB from there to make his turn come faster.
(if you are shifting ATB position the safe way is to do it from some kind of hook, because otherwise it may lead to ATB desync problems).


By the way,
another idea is to overload function Start() the same way you did with DefenderHeroMove. The functions that are put there are run at the start of the battle right after preparation phase is finished. (for instance something like Lethos spec can be emulated this way)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
magnomagus
magnomagus


Responsible
Legendary Hero
modding wizard
posted September 15, 2009 03:06 PM
Edited by magnomagus at 15:08, 15 Sep 2009.

@PvP: Are you by coincidence the creator of the PvP scripts from the russian tournament edition?, If so then i would like to ask you a few questions.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
PvP
PvP

Tavern Dweller
posted September 15, 2009 03:15 PM

Quote:
@PvP: Are you by coincidence the creator of the PvP scripts from the russian tournament edition?, If so then i would like to ask you a few questions.


Yes, it's me. Mirthless is also my account, but i lost a password for it so had to create a new one. So you already sent me a mail with some questions). But if you want i may answer some more.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
magnomagus
magnomagus


Responsible
Legendary Hero
modding wizard
posted September 15, 2009 05:59 PM

Now everything seems clear to me. I was thinking Pvp and mirthless were two different persons, and I didn't know you actually made the script (before changing your name to Pvp). The questions were indeed sent to your mail, but since I have not received a reply I feared mirthless was dissappeared. (Maybe something went wrong or you need more time?)
Of course don't feel obliged to do anything, I'm not in a hurry. You can also post the answers here if this suits you better, since they are all about map scripting.


____________
MMH5.5 Downloads | MMH5.5 Translations | MMH5.5 FAQ

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
PvP
PvP

Tavern Dweller
posted September 15, 2009 08:55 PM
Edited by PvP at 21:03, 15 Sep 2009.

Quote:
Now everything seems clear to me. I was thinking Pvp and mirthless were two different persons, and I didn't know you actually made the script (before changing your name to Pvp). The questions were indeed sent to your mail, but since I have not received a reply I feared mirthless was dissappeared. (Maybe something went wrong or you need more time?)
Of course don't feel obliged to do anything, I'm not in a hurry. You can also post the answers here if this suits you better, since they are all about map scripting.




I sent you reply, but probably it went missing. So i've copied it and resent from another email account. Have you recieved it?
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
magnomagus
magnomagus


Responsible
Legendary Hero
modding wizard
posted September 16, 2009 02:05 AM

I have received it now and sent you a reply, Thanks a lot!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
WindBell
WindBell


Hired Hero
posted September 16, 2009 03:16 AM

Quote:
Quote:

Thanks for you advices. It is really helpful and works well.

However , in my simple example , the enemy hero will act twice at the same time ( one cast Battle Cry and then defend) ,which is not logical in the battle. though I can use it by return nil it actually increase the diffculty. Can I remove the enemy hero's defend action ?

By the way , where can I get this map? It looks like that what you mentioned is not the offical campaign -The day of fire.


The campaign i was talking about can be downloaded here:
http://www.maps4heroes.com/heroes5/campaigns/campaigns.php

Correct name is: 566 year - The Day of Fiery Tears. So it is probably what you thought it is.

Though, i'm not sure about a way to remove defend action. As i recall i've sent you a complete script function list so you may try to find something there, but i myself can't come up with anything that would look like all good solution to the problem. If this defend action irritates you, because it is always defend you can return not nil. If it's ATB shift that bothers you, you may try:

- to shift enemy hero ATB position to say 0.5 inside function (so he wouldn't be the first to act after you've left your function) (not sure this one would work though)

- catch the next person acting after hero with similar hook and shift
hero's ATB from there to make his turn come faster.
(if you are shifting ATB position the safe way is to do it from some kind of hook, because otherwise it may lead to ATB desync problems).


By the way,
another idea is to overload function Start() the same way you did with DefenderHeroMove. The functions that are put there are run at the start of the battle right after preparation phase is finished. (for instance something like Lethos spec can be emulated this way)



Another question, why random(top) function cannot be called in combat ( Generate a NO GLOBAL VARIABLE error)? i find it is presented in work-everywhere function list.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
pei
pei


Famous Hero
Fresh Air.
posted November 02, 2009 06:17 PM
Edited by pei at 00:43, 04 Nov 2009.

Is it possible to control a neutral troop on the map?Like making it go directly to X point, whenever userīs turn ends the creature would move one square of the map.Any hints as how to script this?

EDIT:
so the following is all my code in map properties/scripts-->

function SpawnAssassins()
montype = 72;
moncnt = 50;
CreateMonster("a1",montype, moncnt, 50,106,1,0,0,0);
end;


Trigger(NEW_DAY_TRIGGER, "RunDaily");


function RunDaily()  

if(GetDate(DAY_OF_WEEK) == 1) then
SpawnAssassins();
end;
if(GetDate(DAY_OF_WEEK) == 2) then
SetObjectPosition("a1", 28, 241, floor = 0);
end;
      if(GetDate(DAY_OF_WEEK) == 3) then
SetObjectPosition("a1", 28, 240, floor = 0);
end;
end;

I get the error that "RunDaily" function is not defined. What does this mean?Should i organize my code in a different way?
RunDaily is also the name of a location where i want the craetures to spawn.

I play the map and no creature is spawned...what im i doing wrong?

Thanx in advance people.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bis2fioute
Bis2fioute

Tavern Dweller
posted November 12, 2010 01:38 PM

Map Editor - How to change town's race when captured ?

Hi guys,

I am creating a map and I would like one of the town to take the race of the player that captures it.
I've tried a couple of things : script which I don't master at all.
I've also noticed this Capture trigger line in the town's properties tree and it doesn't do anything.

First of all is it possible ? Can you help me ?

Thanks

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
WindBell
WindBell


Hired Hero
posted November 12, 2010 05:41 PM

Quote:
Hi guys,

I am creating a map and I would like one of the town to take the race of the player that captures it.
I've tried a couple of things : script which I don't master at all.
I've also noticed this Capture trigger line in the town's properties tree and it doesn't do anything.

First of all is it possible ? Can you help me ?

Thanks


You can add a trigger of this town in script ( when the owner change, etc.)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
FrostyMuadDib
FrostyMuadDib


Supreme Hero
By the power of Vivendi!
posted December 23, 2010 05:49 PM

I have a question about GetAllNAmes() function. It returns a string of hero names separated with space character, and I need to extract those names. Is there a way to manipulate strings in H5? There are plenty of functions in LUA but I was unable to use them. Thanks in advance.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Warmonger
Warmonger


Promising
Legendary Hero
fallen artist
posted December 23, 2010 05:55 PM

Quote:
I get the error that "RunDaily" function is not defined.

Bacase Lua is run-time execution script and you need to define functions before calling them. Just put the trigger below definition.
____________

The future of Heroes 3 is here!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
PvP
PvP

Tavern Dweller
posted December 24, 2010 09:31 AM
Edited by PvP at 09:36, 24 Dec 2010.

Quote:
I have a question about GetAllNAmes() function. It returns a string of hero names separated with space character, and I need to extract those names. Is there a way to manipulate strings in H5? There are plenty of functions in LUA but I was unable to use them. Thanks in advance.


Well, i'm not sure if it's possible with this function.
I've always used these instead (they return results as an array already):

GetPlayerHeroes(player)
GetObjectNamesByType(object_type)
(not 100% sure, but as i recall object_type = AdvMapHero needed type, you can check exact object type in \data\data.pak\types.xml file )

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
FrostyMuadDib
FrostyMuadDib


Supreme Hero
By the power of Vivendi!
posted December 24, 2010 06:19 PM

Thanks GetObjectNamesByType() solved my problem with heroes. But now I have another. I am trying to make monsters on map just disappear when encountered by certain heroes. I had to use SetObjectEnabled(monster,nil) beecause otherwise the there is a battle before my script starts. But, when I use this function, AI heroes just ignore those monsters, they are treating them like obstacles. Is there a way to make AI heroes encounter them? I tried with SetAIPlayerAttractor() but it's not working. And another question, is there a way to check which of the players on map is AI controlled?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
markkur
markkur


Responsible
Legendary Hero
Once upon a time
posted December 24, 2010 06:20 PM

Quote:
Is it possible to control a neutral troop on the map?


Don't take this as accurate ftm but I think I read somewhere on the CH thread that it is NOT possible. I think someone was trying to do the same sort of thing? I'll try to find it. In the mean time maybe someone can help and prove my memory wrong. It would be a great option to have.

I wish all the Q & A's from all sites were organized in the Wikia.
____________
"Poetry is a felt change of consciousness"

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
PvP
PvP

Tavern Dweller
posted December 24, 2010 07:11 PM

Quote:
Thanks GetObjectNamesByType() solved my problem with heroes. But now I have another. I am trying to make monsters on map just disappear when encountered by certain heroes. I had to use SetObjectEnabled(monster,nil) beecause otherwise the there is a battle before my script starts. But, when I use this function, AI heroes just ignore those monsters, they are treating them like obstacles. Is there a way to make AI heroes encounter them? I tried with SetAIPlayerAttractor() but it's not working. And another question, is there a way to check which of the players on map is AI controlled?


Can't give you a good solution for the monster dissapearance problem right away without knowing more details. Maybe you should use a region enter trigger on the area around monster to remove it instead of object touch trigger on the mosnster. In this case you won't have to disable monster and AI will probably atack it, thus entering region, setting trigger and launching monster disapearance.

Answering the second quesion there is a function IsAIPlayer(player) that returns 1 if player is AI and 0 otherwise.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
FrostyMuadDib
FrostyMuadDib


Supreme Hero
By the power of Vivendi!
posted December 27, 2010 11:06 AM

Thank you again About those disappearing monster, I thought I could avoid regions, but it seems to be the only way because of AI ignoring disabled monsters.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 4 pages long: 1 2 3 4 · «PREV / NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.1376 seconds