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 > MapHaven Guild > Thread: Heroes 5 Map Editor Help and Tips...
Thread: Heroes 5 Map Editor Help and Tips... This thread is 43 pages long: 1 ... 6 7 8 9 10 ... 20 30 40 43 · «PREV / NEXT»
rdeford
rdeford


Known Hero
Wyld Mapper
posted July 28, 2008 09:29 PM
Edited by rdeford at 21:38, 28 Jul 2008.

Quote:
Quite simply, do I put the triggers in the map script or object script?


Put them in the map script.

I like to put the trigger directly under the function it triggers, but it can go anywhere in the script, even inside another function.

The two object oriented triggers require the name of the object as one parameter, plus other parameters. Providing the object's script name as a parameter value is how the trigger associates the function doing the work with the object that the player interacts with.  As mentioned in the official doc, these are the parameters for the two object oriented triggers:

OBJECT_CAPTURE_TRIGGER – requires the old owner of the object, the new owner of the object, the name of the hero who captured it (if any), and the name of the object itself

OBJECT_TOUCH_TRIGGER – requires the hero’s name and the object’s name
____________
-------------
Mage of Soquim

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


Known Hero
Wyld Mapper
posted July 29, 2008 07:15 PM

Quote:
More info, it looks like the teams setting is not sticking.  After setting it correctly as a 2v6, then clicking ok, I double checked it at teams 1 - 8 are set to team 1.  

Number of teams is set to 2, but there are not any players on team 2.  I think I remember something like this posted earlier in this thread, but I thought it was a different issue.  I am going to see if there was a fix for that...


I think it is the same issue. Try doing a Save while in the Editor, then check the teams settings. If they have reverted to the default, go back into the teams and set them to 2 teams, 2 players on teams one, and 6 players on team 2. Then move some object on the map one square and back again. Do another save. Recheck the team setting. It should stay as you set it. If it doesn't check and re-do the settings for each player. Repeat the teams settings and the Save cycle.

I just tested this technique on a random map I created from the game menu. I ended up with a 2V6V1V1V1 game, but the flags were set up correctly for a 2V6 map, so I think all is OK.
____________
-------------
Mage of Soquim

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


Honorable
Undefeatable Hero
proud father of a princess
posted July 30, 2008 08:30 AM

+QP applied to rdeford for constantly helping out other members refering to the H5 script editor.

Good job!
____________
Better judged by 12 than carried by 6.

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


Promising
Legendary Hero
fallen artist
posted July 31, 2008 09:23 AM
Edited by Warmonger at 09:38, 31 Jul 2008.

I'm working on a new map (yeah, again) where the objective is to kill 10.000 Cyclops scattered all over the area. How to count the stacks slayed? I was trying to figure out how it was done in Mercenaries map, but it looks terribly:

Quote:
function combatresults(bid)
 local n_stacks, tc,i,cr,num,dead,minc,maxc;

 if GetSavedCombatArmyHero(bid,1)==hero then
   --print("Brand wins!");
   earnrenown(0.1);
   --slavery
   if (slavery==5) then
     n_stacks = GetSavedCombatArmyCreaturesCount(bid,0);
     tc=0;
     for i=0,n_stacks-1 do
       cr, num, dead = GetSavedCombatArmyCreatureInfo(bid,0,i);
       minc = (dead-mod(dead,10))/10;
       maxc = (dead-mod(dead,2))/2;
       tc = tc + 3*(minc+random(maxc-minc+1))*slavecost[cr];
     end;
     if tc>0 then
       ShowFlyingSign({path.."slavescaptured.txt";totalcost=tc},hero,PLAYER_1,5);
       currentslaves=currentslaves+tc;
     end;
   end;
 end;

end;

Trigger(COMBAT_RESULTS_TRIGGER,"combatresults");
--cost of slaves      
slavecost = {30,30, 40,40, 40,40, 0,0, 40,40, 50,50, 0,0, --human
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, --devil
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, --undead
            0,0, 35,35, 35,35, 35,35, 0,0, 0,0, 0,0, --elven
            10,10, 0,0, 0,0, 40,40, 0,0, 0, 0, 0,0,  -- wizard
            30,30, 30,30, 50,50, 40,40, 0,0, 50,50, 0,0, --dark elves
            0, 0, 0, 0, 0, 0, 0, --elems, dark knight, phoenix
            40,40, 40,40, 40,40, 40,40, 40,40, 70,70, 0,0, --dwarves
            30, 40, 40, 0, 40, 50, 0,  -- rebels
            0, 0, 0, 0,      -- wolf, yeti, manticore, mummy  
            25,25, 0,0, 50, 50, 50,50, 70,70, 0,0, 0,0, --orcs
            0, 0,0,0,0, 0,0, -- devil
            30, 30, 50, 40, 0, 50, 0, -- d elves
            0, 35, 35, 35, 0, 0, 0, -- elves
            0, 0,0, 0, 0, 0, 0, -- undead
            10, 0, 0, 40,0,0,0, --wizard
            40,40,40,40,40,70,0, -- dwarves
            25,0,50,50,70,0,0 --orcs
      };  


I guess it reads gold values from the array to give some gold on quest hut later, however what I need for now is much more simple.

Also, how to trigger functions on day 1? I'd like to put some stacks on the map immediately when it starts, depending on player's faction.

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


Known Hero
Wyld Mapper
posted July 31, 2008 04:55 PM
Edited by rdeford at 19:38, 31 Jul 2008.

Quote:
I'm working on a new map (yeah, again) where the objective is to kill 10.000 Cyclops scattered all over the area. How to count the stacks slayed? I was trying to figure out how it was done in Mercenaries map, but it looks terribly:
--text removed--

Also, how to trigger functions on day 1? I'd like to put some stacks on the map immediately when it starts, depending on player's faction.


It is complicated. Franzy, the author of Mercenaries, is the most advanced H5 script writer I know of. You can learn a lot about scripting from studying his scripts, in fact reading his scripts is what inspired me to learn H5 scripting. But his scripts are at the Master level and can be a bit of a puzzle for the student.

As for counting monsters killed, I think one of the standard objectives named OBJECTIVE_KIND_DEFEAT_NEUTRALS will work just fine for you. According to the manual, the Defeat Neutrals objective requires the scripting name of a stack of on-map creatures. Since it can have several parameters, all you have to do is give each stack a unique name and use those names in the parameter list of the objective. That way the objective will count the monsters killed for you.

If the standard objective won't work in your script, then you can use the approach to counting I used in my Mining Tycoon map. You can study my approach by reading the script. Since I am not the scripting Master Franzy is, you will find it much simpler.

Briefly, here is what I did. If the unique names you use for the stacks are done with incremental numbers as the last characters in the names, such as cyclops1, cyclops2, -- cyclops999 and so forth, you can concatenate the index of the for loop onto a fixed string to generate the names of the stacks. Then you can use the IsObjectExists(objectName) function to see if it is still present on the map.

Off the top of my head, without testing it, here is an example to give you the basic idea:

function countCyclops()
local count = 0;
for i=1, 999 do
if IsObjectExists("cyclops"..i) then
count = count + 1;
end;
end;
return count;
end;


EDIT-- You cannot trigger a function on day 1. But, all commands in the script that are outside a function are executed on day 1 before the player gets his or her turn to move. So, just make a list of commands up at the top of your script and let the game begin. See the scripts for just about any of my maps to see examples.

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


Promising
Legendary Hero
fallen artist
posted August 01, 2008 11:45 AM
Edited by Warmonger at 11:47, 01 Aug 2008.

Oh Godd, it looks like a long way before me. I can't make even simplest script working.

Quote:
function urgashwillquest (heroName)
if HasArtefact(heroName, "ARTIFACT_NIGHTMARISH_RING") and HasArtefact(heroName, "ARTIFACT_HELM_OF_CHAOS") then
ShowFlyingSign ("objective complete", "UrgashWillHut",1,1); --Ignore
end;
ShowFlyingSign ("Maps\SingleMissions\Cyclophobia\Hi.txt", "UrgashWillHut",1,1);
end;
Trigger(OBJECT_TOUCH_TRIGGER, heroName,"UrgashWillHut","urgashwillquest");



It should day Hi!, but instead says the hut is empty.
No console errors here.

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


Known Hero
Wyld Mapper
posted August 01, 2008 04:22 PM
Edited by rdeford at 16:26, 01 Aug 2008.

Quote:
Oh Godd, it looks like a long way before me. I can't make even simplest script working.

Quote:
function urgashwillquest (heroName)
if HasArtefact(heroName, "ARTIFACT_NIGHTMARISH_RING") and HasArtefact(heroName, "ARTIFACT_HELM_OF_CHAOS") then
ShowFlyingSign ("objective complete", "UrgashWillHut",1,1); --Ignore
end;
ShowFlyingSign ("Maps\SingleMissions\Cyclophobia\Hi.txt", "UrgashWillHut",1,1);
end;
Trigger(OBJECT_TOUCH_TRIGGER, heroName,"UrgashWillHut","urgashwillquest");



It should day Hi!, but instead says the hut is empty.
No console errors here.


Greetings WarMonger!

Hey, I haven't tried your function in a test map yet, but I think it is OK. You are doing a lot better than you realize.

Based on the symptoms you describe, I think the solution is simple. To re-purpose an object such as a Quest Hut and give it custom actions, you must first disable its normal behavior. From the official functions PDF guide:

Quote:
SetObjectEnabled – turn on/off the interactive object’s standard interaction with heroes.


If you are using TotE, it gives you even more scripting power over the disabled object. You can give the disabled object a custom name, custom description, and give it the active cursor you desire, all without having to create a custom object. Here is an example taken from the script for my Mining Tycoon map:


-- customize Seer's Hut to make the info kiosk
SetObjectEnabled("infoKiosk", nil);
SetDisabledObjectMode("infoKiosk", DISABLED_INTERACT);
OverrideObjectTooltipNameAndDescription("infoKiosk", path.."infoKioskName.txt", path.."infoKioskDesc.txt");
---------------------


By the way WarMonger, my H5 Scripting Tutorial will be ready for beta testing in a couple of days. I think you already know most of what is in the lessons, but, if you wish, I can send you a beta copy. I would appreciate knowing what you think of it. If yes then send me an email address via private message, else remain silent.


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


Promising
Legendary Hero
fallen artist
posted August 03, 2008 07:03 PM

One simple question: how to place an outpost with four creature tiers that would be linked to a players race?
There's no such object in editor's list, via scripts I found no option which could recognize the race

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


Known Hero
Wyld Mapper
posted August 03, 2008 07:39 PM

Quote:
One simple question: how to place an outpost with four creature tiers that would be linked to a players race?
There's no such object in editor's list, via scripts I found no option which could recognize the race


I saw that note in your script comments. At that time, I took a quick look through the functions and could not see any that would yield a direct solution. (There just isn't any function that will return the town type.) Sorry, I forgot to tell you.

Of course, the "random dwelling" map object does have a link to a particular castle, so you might think about placing that object on the map instead of creating the dwelling with the script. That way the game will automatically match the dwelling to the castle it is linked to no matter which type of castle the player chooses for that castle.


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


Promising
Legendary Hero
fallen artist
posted August 04, 2008 12:58 PM
Edited by Warmonger at 16:09, 04 Aug 2008.

Quote:
so you might think about placing that object on the map

Yep, but how to do that? There's no "random outpost" item to choose

EDIT: I solved this problem by force.
Quote:
Trigger (REGION_ENTER_AND_STOP_TRIGGER, "Recognize", "recognize");
function recognize (heroName)
  if GetHeroCreatures (heroName, CREATURE_PEASANT) >=0 or
     GetHeroCreatures (heroName, CREATURE_ARCHER) >=0 or
     GetHeroCreatures (heroName, CREATURE_FOOTMAN) >=0
  then

     tier1 = CREATURE_PEASANT;
     tier2 = CREATURE_LONGBOWMAN;
     tier3 = CREATURE_VINDICATOR;
     tier4 = CREATURE_ROYAL_GRIFFIN;
     tier5 = CREATURE_ZEALOT;
     tier6 = CREATURE_PALADIN;
     tier7 = CREATURE_ARCHANGEL;

     town = 0;
  end;

--and so forth
CreateDwelling("megadwelling",town,8,PLAYER_NONE,25,7,0,90);--finally works!
CreateMonster("megaguard", CREATURE_CYCLOP_UNTAMED, 250,26,7,0, MONSTER_MOOD_WILD, MONSTER_COURAGE_CAN_FLEE_JOIN,90);
end;
function joiner (tier,number,x,y,rot)
CreateMonster ("",tier,number,x,y,0,MONSTER_MOOD_FRIENDLY, MONSTER_COURAGE_ALWAYS_JOIN,rot);
end;
joiner (tier1,50,35,30,135);



It triggers exactly at the point where starting hero is placed.
When I write down all the creatures, it will return different town types thus different dwellings.

However, the function "joiner" doesn't work so cool, returns the error  with second argument - tier and I can't find out why is that.

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


Known Hero
Wyld Mapper
posted August 04, 2008 05:46 PM

Quote:
Quote:
so you might think about placing that object on the map

Yep, but how to do that? There's no "random outpost" item to choose

EDIT: I solved this problem by force.
Quote:
Trigger (REGION_ENTER_AND_STOP_TRIGGER, "Recognize", "recognize");
function recognize (heroName)
  if GetHeroCreatures (heroName, CREATURE_PEASANT) >=0 or
     GetHeroCreatures (heroName, CREATURE_ARCHER) >=0 or
     GetHeroCreatures (heroName, CREATURE_FOOTMAN) >=0
  then

     tier1 = CREATURE_PEASANT;
     tier2 = CREATURE_LONGBOWMAN;
     tier3 = CREATURE_VINDICATOR;
     tier4 = CREATURE_ROYAL_GRIFFIN;
     tier5 = CREATURE_ZEALOT;
     tier6 = CREATURE_PALADIN;
     tier7 = CREATURE_ARCHANGEL;

     town = 0;
  end;

--and so forth
CreateDwelling("megadwelling",town,8,PLAYER_NONE,25,7,0,90);--finally works!
CreateMonster("megaguard", CREATURE_CYCLOP_UNTAMED, 250,26,7,0, MONSTER_MOOD_WILD, MONSTER_COURAGE_CAN_FLEE_JOIN,90);
end;
function joiner (tier,number,x,y,rot)
CreateMonster ("",tier,number,x,y,0,MONSTER_MOOD_FRIENDLY, MONSTER_COURAGE_ALWAYS_JOIN,rot);
end;
joiner (tier1,50,35,30,135);



It triggers exactly at the point where starting hero is placed.
When I write down all the creatures, it will return different town types thus different dwellings.

However, the function "joiner" doesn't work so cool, returns the error  with second argument - tier and I can't find out why is that.


Try leaving out the word tier in the arguments you are passing to joiner() when you pass the numeric value. In other words, try:

joiner (1,50,35,30,135);

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


Promising
Legendary Hero
fallen artist
posted August 04, 2008 06:15 PM
Edited by Warmonger at 18:59, 04 Aug 2008.

It worked. Maybe because CRAETURE_PEASANT has number 1 on the list anyway? For Value=2 it spawned Conscript , as I expected. I just want in to read type from what I assigned to the same the same way it reads town variable.

Also tried to change creature IDs to numbers, but returns same error. I don't want to be forced to make mega-if clause for each creature type.

EDIT: With mega-if ladder at least it works

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


Known Hero
Wyld Mapper
posted August 04, 2008 07:40 PM

Quote:
It worked. Maybe because CRAETURE_PEASANT has number 1 on the list anyway? For Value=2 it spawned Conscript , as I expected. I just want in to read type from what I assigned to the same the same way it reads town variable.

Also tried to change creature IDs to numbers, but returns same error. I don't want to be forced to make mega-if clause for each creature type.

EDIT: With mega-if ladder at least it works


Off the top of my head, without trying it in a test script, I think the game thinks your tier1 -- tier7 are local variables so they are not valid outside the recognize() function. You should try declaring tier1 -- tier7 as global variables (i.e., outside any function). Then you should be able to use assign any of them a value then use it as a parameter when you call joiner() as in: joiner(tier1,50,35,30,135);

The all capital game constants such as CREATURE_PEASANT, CREATURE_LONGBOWMAN, etc. evaluate down to numbers. Try print(CREATURE_LONGBOWMAN); to check the truth of this. Anyway, you should be able to use either the all caps constant or the number in the code. Again, use embedded print() statements down in joiner() to see what you are really passing. The local variable problem may have been what was goofing you up.

By the way, the recognize() function is a very clever workaround to the the town ID problem. Good work!

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


Promising
Legendary Hero
fallen artist
posted August 04, 2008 08:36 PM
Edited by Warmonger at 20:36, 04 Aug 2008.

Maybe I should try it on the next map.

Ok, but where can I find ID script for ToH? I got only H5 and HoF IDs and when I used them, ID=1 suprisingly turned out to stand for stronghold town

Always wanted to be a programmer, now once I started I can't stop

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


Known Hero
Wyld Mapper
posted August 04, 2008 09:56 PM

Quote:
Maybe I should try it on the next map.

Ok, but where can I find ID script for ToH? I got only H5 and HoF IDs and when I used them, ID=1 suprisingly turned out to stand for stronghold town

Always wanted to be a programmer, now once I started I can't stop


The scripting guide The Basics of Heroes V Scripting ver. 2.0 for H5, HOF, & ToTE has ALL the ID's for TotE. And, yes, the H5 developers in their infinite foolishness did change the town ID's for each of the three H5 games. If ever you get into a developer position, do NOT do do this silliness. Add new ID's to the bottom of the list, leaving all the old ID's intact at the top of the list. That way, older user scripts will still work and be downward compatible.

I understand about not being able to stop doing scripting. I am a retired technical writer. I worked with software engineers for decades and always sort of envied them. Fortunately, along the way, I learned enough about software developement to teach myself H5 scripting with the help of the original scripting guide, and by looking at the scipts from other people's maps. When I wrote the script for my first map, The Virgin Of Ponce I, it was the most fun I'd had in years, more fun than playing the game in fact. I love it. But it eats up your free time like nothing else can. I think you know what I am talking about, eh?




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


Known hero
posted August 05, 2008 12:36 PM

Hi here. im new in heroes 5,  just played h3. i want to make object: in the kings mausoleum ( or what it is)  will be avaibile to train dead knights. if you make a script write it by hc message. please
____________
Sorry for my English. I am young and i am not from country where i need to speak english

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


Known Hero
Wyld Mapper
posted August 05, 2008 08:16 PM

Quote:
Hi here. im new in heroes 5,  just played h3. i want to make object: in the kings mausoleum ( or what it is)  will be avaibile to train dead knights. if you make a script write it by hc message. please


It is difficult to write a script that you can simply paste into your map. You will have to learn quite a bit about H5 scripting yourself to understand how to use anything we could send you. The basic steps that have to be done are:

1. Give the KM a script name, for example, KingsMausoleum.

2. Write a function that will train death knights, for example, transform the heroes squires into death knights.

3. Write a trigger for the function, for example, Trigger(OBJECT_TOUCH_TRIGGER,"KingsMausoleum", "trainDeathKnights");

So, if I were to make a function to do the training, I would need to know what you mean by "training," what kind of cost to associate with the training, how often to do it, who to do it for, and so on, and on. Making the function, a test map, and testing and debugging the function would require one to two hours of my time.

Then, you would have to do the map work required to use the function once I sent it to you, and you would have to know enough of H5 scripting to adapt the function to your use.

Download The Basics of Heroes V Scripting ver. 2.0 for H5, HOF, & ToTE from here: http://www.celestialheavens.com/viewpage.php?id=567
Read this guide, then see if you wish to continue with this project. I will help you write the script, but it is too hard for me to do it all for you.


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


Known hero
posted August 05, 2008 08:41 PM

i like h4 scripting system, there is everything writen in english, not scriptinig language.
____________
Sorry for my English. I am young and i am not from country where i need to speak english

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


Promising
Legendary Hero
fallen artist
posted August 05, 2008 09:10 PM
Edited by Warmonger at 21:13, 05 Aug 2008.

Luckily all the scripts are in English take a look at WoG ERM scripts to see the difference.
Quote:

I want to have a customized battlefield. I used this:
!?BF:76/24/1/1;
!!BF21/32 O21/48 O21/14 O21/66 O21/82 O21/99 O21/116 O21/134 O21/150 O21/168 O21/184;


And still there are fr34ks who develop RPGs in it.

In fact in H4 there were no scripts but easy-to-use listboxes. Worked great until you wanted to copy some of these functions

And yes, you should first come up with some project of this sctructure, not just demand "do what I want as I'm lazy". Show some interest and patience.

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


Known hero
posted August 05, 2008 09:15 PM

damn, ok ill try to make my own scripts (but im still lazy ) and i dont want to read that manual. and can someone make that script for me?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 43 pages long: 1 ... 6 7 8 9 10 ... 20 30 40 43 · «PREV / NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.1831 seconds