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 ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 5 - Modders Workshop > Thread: [H5] Combat Script to Summon Creatures before Battle
Thread: [H5] Combat Script to Summon Creatures before Battle
cyanight
cyanight


Hired Hero
posted September 08, 2009 01:37 AM
Edited by angelito at 09:20, 08 Sep 2009.

[H5] Combat Script to Summon Creatures before Battle

Im trying to make a script to summon a group of creatures for a hero when he is defending.  This is the script I came up with and its not working.  I put this script in the Adventure Map Properties script tab. Please help of you can.

SetHeroCombatScript("Freyda", "AddMegaCreature");

function AddMegaCreature()
 AddCreature(DEFENDER, 52, 10, x = 5, y = 5);
end;


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


Promising
Legendary Hero
fallen artist
posted September 08, 2009 06:53 AM
Edited by Warmonger at 06:53, 08 Sep 2009.

Actually you should put first command in main map script and the second as additional script file (as you did). See official campaigns to see how combat scripts are called, they should be named by file path and name.

What does console read?
____________
The future of Heroes 3 is here!

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


Hired Hero
posted September 08, 2009 02:02 PM

Console?  Im not sure what you mean.

I looked up a scenerio where Godric summons creatues after the first wave of creatures is destroyed and that script is tied to the castle.  All the script was inside the tab on the castle.  I rewrote the script but I still cannot get it to work.  They are using the same function Add Creatures and for some reason this function will not work or execute.  

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


Hired Hero
posted September 09, 2009 01:48 AM

Here is the code that I have been using on the script tab of a town.

function Reinforcements()
       repeat
sleep(10);
len = length(GetDefenderCreatures());
until len == 0;
AddCreature(DEFENDER,CREATURE_CAVALIER,10,15,10);
repeat
sleep(10);
  DefCreatures = GetDefenderCreatures();
until length(DefCreatures) == 0;
Finish(ATTACKER);
end;


function PlayerLoose()
repeat
sleep(10);
until length(GetAttackerCreatures()) == 0;
Finish(DEFENDER);
end;

if GetAttackerHero() ~= nil and GetDefenderHero() ~= nil then
 EnableAutoFinish(nil);
 SetControlMode(ATTACKER,MODE_MANUAL);
while combatStarted() == nil do
sleep(1)
end;
 startThread(PlayerLoose);
 startThread(Reinforcements);
end;


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


Hired Hero
posted September 10, 2009 05:53 PM

I found a solution to my problem and I thought I would post it.  It seems the problems I was having with scripting always result on one of two things.  Either I have the code in the wrong place or I have it attached to the wrong trigger.  In this case it was the code was in the wrong place. From my experience I have found that placing the combat script on the Hero solved the problem.  The way I attached this code was as follows.

1) First click on the hero.  
2) Then press CTRL-SPACE. This opens a panel on the right side of the screen.
3) Click on Combat Script and enter a new type like "COMBATSCRIPT" This will then open a screen that has two items on the left side. The second one is called ScriptText.  This is the one you want to click on.  
4) Then just put your script lines in that window.  For Example: AddCreature(DEFENDER,CREATURE_CAVALIER,10,15,3);  
This will add 10 Cavaliers to the defender.  You can add conditions to the code to make it work when the hero is attacking as well.  

Anyways I thought I would post my solution Im not sure if this is the correct way but its working flawlessly.



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


Promising
Legendary Hero
fallen artist
posted September 10, 2009 06:06 PM
Edited by Warmonger at 18:07, 10 Sep 2009.

He's a man
You can also create new, separate .lua files with combat code, but I found their triggering troublesome.
____________
The future of Heroes 3 is here!

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


Hired Hero
posted September 10, 2009 09:58 PM

Thanks.. Now whats this console your talking about?  

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


Hired Hero
posted March 01, 2010 12:55 AM

I thought I had a solution to my problem but it seems my combat script only works outside of towns.  When the hero enters a town the above combat script does not trigger when the town is attacked.  As above I tried placing the code on the CombatScript for the town but had no success.  But as soon as the hero left the town the script would continue working.  

Please help if you can.

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


Hired Hero
posted March 01, 2010 02:40 PM

Anyone have an idea why this script wont work when the hero is in town?

Please help

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

Tavern Dweller
posted March 05, 2010 10:26 AM
Edited by PvP at 10:35, 05 Mar 2010.

Quote:
Anyone have an idea why this script wont work when the hero is in town?

Please help


Well i think the thing is that when hero is in town and you attack town you actually interact with the town object not the hero. (i had simmilar problem when tried to set touch trigger to the hero) But as far as i know combat script can only be attached to the hero.

Maybe you should try attaching script to the attacking hero ?

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


Hired Hero
posted March 08, 2010 01:59 PM

Thank you.. That worked perfectly.  I never thought of attaching it to the player hero.

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


Hired Hero
posted March 08, 2010 03:21 PM

Does anyone know how to play visual effects in a combat script?

I have been using this function to create visual effects on the adventure map but I wanted to know if I could play a visual effect during combat on the arena map.  Whenever I try to play a visual effect inside a combat script the visual effect does not play.  Please help if you can.


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

Tavern Dweller
posted March 09, 2010 05:19 PM

Quote:
Does anyone know how to play visual effects in a combat script?

I have been using this function to create visual effects on the adventure map but I wanted to know if I could play a visual effect during combat on the arena map.  Whenever I try to play a visual effect inside a combat script the visual effect does not play.  Please help if you can.




As far as i know there is no way to directly add some eye candies to combat except the following way:
- play victory\lose animation by combatPlayEmotion(side, victory)

- play some animation on the unit by playAnimation(unitName, animName, action)

- cast spell by your hero. There are some spells that as far as i know do nothing except playing some visual effect for example: SPELL_EFFECT_SUMMON_ELEMENTALS_AIR, SPELL_EFFECT_DIMENSION_DOOR_END, SPELL_DEMON_SOVEREIGN_FX and etc.

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


Hired Hero
posted March 10, 2010 07:49 PM

I am trying to play a spell visual effect. The script works fine until it encounters my playvisualeffect function

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

Tavern Dweller
posted March 10, 2010 09:06 PM
Edited by PvP at 12:25, 11 Mar 2010.

Quote:
I am trying to play a spell visual effect. The script works fine until it encounters my playvisualeffect function



What i meant in my previous post is that there is no function in combat that will allow you to just play visual effect(ie PlayVisualEffect function only works on adventure map and not in combat). But i think you can cast certain spells by your hero using functions like UnitCastGlobalSpell or UnitCastAreaSpell that won't do anything except visual effect. (not sure if it would work exactly as i think though, never tried this myself)

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


Hired Hero
posted March 11, 2010 10:30 PM

Quote:
Quote:
I am trying to play a spell visual effect. The script works fine until it encounters my playvisualeffect function



What i meant in my previous post is that there is no function in combat that will allow you to just play visual effect(ie PlayVisualEffect function only works on adventure map and not in combat). But i think you can cast certain spells by your hero using functions like UnitCastGlobalSpell or UnitCastAreaSpell that won't do anything except visual effect. (not sure if it would work exactly as i think though, never tried this myself)


I dont see any refereces to a function like that in the script pdf.  what are the params for the function UnitCastGlobalSpell or UnitCastAreaSpell

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

Tavern Dweller
posted March 12, 2010 08:02 AM

Quote:

I dont see any refereces to a function like that in the script pdf.  what are the params for the function UnitCastGlobalSpell or UnitCastAreaSpell


Something like this i think:
UnitCastAimedSpell(unitName, spell, targetUnit)
UnitCastAreaSpell(unitName,spell,x,y)
UnitCastGlobalSpell(unitName,spell)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0310 seconds