|
|
nhs12008
Tavern Dweller
|
posted April 16, 2015 05:54 PM |
|
Edited by nhs12008 at 00:36, 17 Apr 2015.
|
Script question
Hi there, I'm trying to solve a problem to make my combat script.
I tried to make script for casting spell at start of combat,
but first I need to know My Hero's in-combat name to use function.
The problem is when I used func @print() in game, it doesn't work properly.
Here are what I tried :
@print(GetAttackerHero()) : nil
@print(GetUnits(0, 0)) : attacker-hero
It only displays Heroes to attacker-hero.
And I tried UnitCastAimedSpell("CREATURE_SPRITE", 26, "CREATURE_BLADE_JUGGLER")
but it doesn't work too - it says ' "CREATURE_SPRITE" doesn't exist. '
Are there other ways to make the script or I missed somthing?
Thanks in advance !
EDIT : I also tried @print(unitNames()), It said :
attacker-hero , attacker-2-CREATURE_SPRITE, etc.
Hero's name was not displayed, and creature's name doesn't work with above functions, too.
Is there anyone who has or had the same problem with me?
____________
|
|
lotihoti
Famous Hero
|
posted April 16, 2015 06:54 PM |
|
|
Try to use the id number:
Spriteid = 44, blade juggler = 45
Btw: for scripting and other minor questions use the question topic
|
|
nhs12008
Tavern Dweller
|
posted April 16, 2015 07:46 PM |
|
|
lotihoti said: Try to use the id number:
Spriteid = 44, blade juggler = 45
Btw: for scripting and other minor questions use the question topic
Thanks for the reply, but id number doesn't work too.
Yeah, I missed it, Sorry
And for the your previous answer, Sure, I enabled cosole and I did attack.
____________
|
|
lotihoti
Famous Hero
|
posted April 17, 2015 08:07 AM |
|
|
So let me repeat it:
You start a combat using
StartCombat(Parameter,...);
After that you call your script (does it run? Does it get the call?).
Then you try
Print(GetAttackerHero()) and you get nil.
I cant test it right now - will do it after work (12hours to go xD )
|
|
nhs12008
Tavern Dweller
|
posted April 17, 2015 02:42 PM |
|
Edited by nhs12008 at 14:55, 17 Apr 2015.
|
lotihoti said: So let me repeat it:
You start a combat using
StartCombat(Parameter,...);
After that you call your script (does it run? Does it get the call?).
Then you try
Print(GetAttackerHero()) and you get nil.
I cant test it right now - will do it after work (12hours to go xD )
I started game and selected Haven, Irina and attacked Imps in front of Sawmill.
My script run, but says no hero name every time.
But I tried other's combat script worked properly in his game.
http://heroescommunity.com/viewthread.php3?TID=31037
Here is what i tried.
I changed the unit name to 11, and it worked !
but I want to know why my combat script doesn't work...
Another question :
Is it possible to use same trigger with the different function? for instance,
Using both Trigger(NEW_DAY_TRIGGER, "addCreatures1");
and Trigger(NEW_DAY_TRIGGER, "addCreatures2"); .
In my games, the latter trigger worked only P:
|
|
markkur
Honorable
Legendary Hero
Once upon a time
|
posted April 17, 2015 02:55 PM |
|
|
nhs12008 said: Using both Trigger(NEW_DAY_TRIGGER, "addCreatures1");
and Trigger(NEW_DAY_TRIGGER, "addCreatures2"); .
In my games, the latter trigger worked only P:
Since I don't see you are calling for "two different days" to add both creatures I would investigate giving both creatures in the same line. Seems to me, the last line is just over-riding the first?; sort of like the game does with updated files.
|
|
nhs12008
Tavern Dweller
|
posted April 17, 2015 03:01 PM |
|
Edited by nhs12008 at 15:15, 17 Apr 2015.
|
markkur said:
nhs12008 said: Using both Trigger(NEW_DAY_TRIGGER, "addCreatures1");
and Trigger(NEW_DAY_TRIGGER, "addCreatures2"); .
In my games, the latter trigger worked only P:
Since I don't see you are calling for "two different days" to add both creatures I would investigate giving both creatures in the same line. Seems to me, the last line is just over-riding the first?; sort of like the game does with updated files.
Here's what i tried actually.
function addspells1()
Mast = GetHeroSkillMastery("Faiz", 10);
if Mast == 2 then
TeachHeroSpell("Faiz", 15-random(5));
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", nil);
end;
end;
function addspells2()
Mast = GetHeroSkillMastery("Faiz", 10);
if Mast == 3 then
TeachHeroSpell("Faiz", 21-random(5));
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", nil);
end;
end;
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", "addspells1");
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", "addspells2");
Yup, I thought the same. maybe it was just override.
Are There no other ways to run both trigger? P:
|
|
frostymuaddib
Promising
Supreme Hero
育碧是白痴
|
posted April 17, 2015 03:42 PM |
|
|
Quote: Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", "addspells1");
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", "addspells2");
This just overrides your first callback function, so everytime Faiz levels up, ony addspells2 will be called.
Try combining your two callback functions in one:
function addspells()
Mast = GetHeroSkillMastery("Faiz", 10);
if Mast == 2 then
TeachHeroSpell("Faiz", 15-random(5));
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", nil);
elseif Mast == 3 then
TeachHeroSpell("Faiz", 21-random(5));
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", nil);
end;
end;
and then just add callback with:
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", "addspells");
As for this
Quote: UnitCastAimedSpell("CREATURE_SPRITE", 26, "CREATURE_BLADE_JUGGLER")
I'm not sure that I understood your problem correctly, but instead of "CREATURE_SPRITE" string, you must use 'stack name' in combat. The only way you can get those names (as far as I know) is by using this functions: unitNames() and GetUnits(side, type). You can find their descriptions here(there are plenty of functions here that are useful, but were not documented by NIVAL).
|
|
nhs12008
Tavern Dweller
|
posted April 17, 2015 04:10 PM |
|
Edited by nhs12008 at 16:15, 17 Apr 2015.
|
frostymuaddib said:
Quote:
As for this
Quote: UnitCastAimedSpell("CREATURE_SPRITE", 26, "CREATURE_BLADE_JUGGLER")
I'm not sure that I understood your problem correctly, but instead of "CREATURE_SPRITE" string, you must use 'stack name' in combat. The only way you can get those names (as far as I know) is by using this functions: unitNames() and GetUnits(side, type). You can find their descriptions [url=http://heroescommunity.com/viewthread.php3?TID=23668&PID=1185685#focus]here[/url](there are plenty of functions here that are useful, but were not documented by NIVAL).
Thanks ! when I inserted its 'stack name' exactly, it worked !!
And what I wanna make was that
When he gets advanced and expert Dark Magic, give him a random dark spell, not once, but twice.
Making script so he will get a spell only once, so I decide to make the script as this
function addspells1()
Mast = GetHeroSkillMastery("Faiz", 10);
if Mast == 3 then
TeachHeroSpell("Faiz", 21-random(10));
TeachHeroSpell("Faiz", 21-random(10));
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", nil);
end;
end;
Trigger(HERO_ADD_SKILL_TRIGGER, "Faiz", "addspells1");
Which will give him spells once but two
|
|
frostymuaddib
Promising
Supreme Hero
育碧是白痴
|
posted April 17, 2015 05:26 PM |
|
|
Ah, ok
Just keep in mind that there can be only one callback function per specific trigger
|
|
Panicwarlord
Tavern Dweller
|
posted January 21, 2024 12:22 PM |
|
|
Week of Dragon
Hi, I'm Panicwarlord and I need your help for Heroes of Might and Magic 5, I wanted to ask how to have the "week of dragon" as a week which doubles the growth of shadow dragons and black dragons with the ID script, I have to call the game console and then how do I do it? please help me what is the code of this cheat, an answer and thanks!
____________
|
|
|
|