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: Script question
Thread: Script question
nhs12008
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?
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
lotihoti
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

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
nhs12008
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.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
lotihoti
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 )

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
nhs12008
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:

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


Responsible
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.  

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
nhs12008
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:

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


Supreme Hero
By the power of Vivendi!
posted April 17, 2015 03:42 PM
Edited by frostymuaddib at 15:47, 17 Apr 2015.

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).

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
nhs12008
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 here(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

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


Supreme Hero
By the power of Vivendi!
posted April 17, 2015 05:26 PM

Ah, ok

Just keep in mind that there can be only one callback function per specific trigger

 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.0384 seconds