|
Thread: [H5] Combat Script to Summon Creatures before Battle | |
|
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;
|
|
Warmonger
Promising
Legendary Hero
fallen artist
|
posted September 08, 2009 06:53 AM |
|
|
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!
|
|
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.
|
|
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;
|
|
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.
|
|
Warmonger
Promising
Legendary Hero
fallen artist
|
posted September 10, 2009 06:06 PM |
|
|
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!
|
|
cyanight
Hired Hero
|
posted September 10, 2009 09:58 PM |
|
|
Thanks.. Now whats this console your talking about?
|
|
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.
|
|
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
|
|
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 ?
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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)
|
|
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
|
|
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)
|
|
|