Call to H-IV mapmakers - AI enchancing scripts

The old Heroes games developed by New World Computing. Please specify which game you are referring to in your post.

Moderator: Moderators

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 23 2015, 17:38

It depends on wheter we Can put variables on artifacts if there is 2 or more. Then we Can give back all but still ensure AI doesnt equip 3 Stunning Arrow.


The first artifact that we give back is put in an empty equip slot.

There is an easy way to solve this (equip 3 Arrow), but the script will be bigger.

First take all artifact and set each variable = number of item. (but the number of predefine "take script" must be decide)

Then, when we give back artifact (for misc and ring because there is more than 1 slot), we need to decide how many artifact of each we want to give back.

For exemple, this is a list of how many item of the same type we want to give back with priority (let's call this list the "Number list"):
1 Flamming Arrow
4 Maranthea's Mug
1 Arrow of Stunning
4 Gambler's deck

Exemple#1
If the hero has 2 Flaming Arrow, 0 Maranthea's Mug, 2 Arrow of Stunning and 2 Gambler's deck, the script will do:

Give 1 Flaming Arrow (only 1 in the "Number list"), give 0 Maranthea's Mug (because variable vMaranthea = 0, the hero don't have this artifact), give 1 Arrow of Stunning (only 1 in the "Number list"), and give 2 Gambler's deck (variable vGamblerDeck = 2). At the end (when all misc artifact are giving back according to the "Number list"), we give back the remaining misc artifact (so 1 flaming Arrow and 1 Arrow of Stunning)

This is not difficult to script, but the script for misc artifact will be almost twice bigger.


Exemple #2:
If the hero has 0 Flaming Arrow, 2 Maranthea's Mug, 2 Arrow of Stunning and 2 Gambler's deck, the script will do:

Give 2 Maranthea's Mug, give 1 Arrow of Stunning and give 2 Gambler's deck (but the second Gambler's deck will be put in the Backpack because all 4 slot are already use). Then give back the remaining Arrow.


Exemple#3
If the hero has 0 Flaming Arrow, 4 Maranthea's Mug, 1 Arrow of Stunning and 1 Gambler's deck, the script will do:

Give 4 Maranthea's Mug, give 1 Arrow of Stunning (put in the backpack because all 4 slot are equip with Maranthea's Mug) and give 1 Gambler's deck (put in the Backpack because all 4 slot are already use).


Like I said, it's easy to do, but we will need to remove some artifact at some point. Why: because if we always keep all* artifact and the script take/give let's say 4 artifact of each type, but the computer has now 5 Arrow of Stunning (with 1 equip), the script will take 4 Arrow of Stunning (but not the one equip because the script always take artifact in the backpack first), then when we will give back artifact, 1 slot will be already equip (with the fifth Arrow of Stunning), so only 3 slot are empty.

My point is that we should decide how many of each item we want to keep.
Let's say we want to keep 3 Arrow of Stunning but equip only 1, we should take 4 Arrow of Stunning from the hero (I mean up to 4) but give back only 3 (give 1, and at the end give back up to 2). So that way, if the computer has 4 Arrow, at the end of the script, he will have only 3. This prevent the AI to accumulated multiple item of one type (prevent to AI to get more than the "take" script)

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1110
Joined: 12 Nov 2011

Postby Karmakeld » Jun 23 2015, 21:42

For simplicity sake I would say 2 artifacts should be enough. How often has any of us encountered an AI hero with 3 or more of the same valuable artifact?
Of course we could risk losing 1 or more artifact from the game, but if 1 AI hero is carrying 3 Maranthea's Mug, there's a chance there might be more in the map.
Only other issue I can think of is maps with quests that might require x numbers of the same artifact. But an info about how the Artifact table script works, could warn players about this possible issue..
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

User avatar
GreatEmerald
CH Staff
CH Staff
Posts: 3329
Joined: 24 Jul 2009
Location: Netherlands

Postby GreatEmerald » Jun 23 2015, 22:14

Karmakeld wrote:Only other issue I can think of is maps with quests that might require x numbers of the same artifact. But an info about how the Artifact table script works, could warn players about this possible issue..


Yeap, but I'd rather keep compatibility. Even with regular shop artifacts. A larger script doesn't sound too bad in my opinion.

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1110
Joined: 12 Nov 2011

Postby Karmakeld » Jun 24 2015, 7:23

How many artifacts do you think it is required to check for in the script?
I'm more concerned about complexity, as there is already a good amount of artifacts, and each additional check is multiplied with all artifacts. The script could get quite long. I just don't think we should make it longer than necessary.
Another solution could be to decrease amount of checks by e.g 1 as artifact ranks increases - as higher ranks are more rare. Is that acceptable?
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

User avatar
GreatEmerald
CH Staff
CH Staff
Posts: 3329
Joined: 24 Jul 2009
Location: Netherlands

Postby GreatEmerald » Jun 24 2015, 12:03

I'm more thinking that to limit complexity, all artifacts would be equipped only once first. So the script would be, take all artifacts, set the variables to counts, then give back one of each artifact in sequence, then give back all the remaining artifacts in sequence. It wouldn't make the script too complex, no multiplications here. If an artifact is useful more than once, then even on the first cycle all of the artifacts can be returned (and then no check for it on the second cycle).

And this only applies to artifacts that have multiple slots to begin with: misc and rings.

I think that's about what PatFX was thinking of. In which case we just need a list of misc/ring artifacts that stack.

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 25 2015, 1:44

How many artifacts do you think it is required to check for in the script?
I'm more concerned about complexity, as there is already a good amount of artifacts, and each additional check is multiplied with all artifacts.


I'm more thinking that to limit complexity, all artifacts would be equipped only once first. So the script would be, take all artifacts, set the variables to counts, then give back one of each artifact in sequence, then give back all the remaining artifacts in sequence. It wouldn't make the script too complex, no multiplications here.


There is two way of doing this script.

#1- First way is by doing this (for exemple, let's do it with Longsword and let say we want to keep 2 artifact of each) :

Encounter script:
conditional action:
if hero has artifact (longword), then take 1 longsword, set variable vLonsword to vLongsword +1
if hero has artifact (longword), then take 1 longsword, set variable vLonsword to vLongsword +1

We do this for all artifact, then, we give back artifact:

conditional action:
if vLongsword > 0, then give 1 Longsword and set vLonsword to vLongsword - 1
if vLongsword > 0, then give 1 Longsword and set vLonsword to vLongsword - 1

OR

if vLongsword = 2, then give 2 longsword and set vLongsword to 0
if vLongsword = 1, then give 1 Longsword and set vLongsword to 0

2 conditionnal with both scenario. We do this for all artifact (there will be a little difference for ring and misc artifact because they have multiple slot, but forget it for now.)


Now, if we want to keep 4 artifact of each:

Encounter script:
conditional action:
if hero has artifact (longword), then take 1 longsword, set variable vLonsword to vLongsword +1
if hero has artifact (longword), then take 1 longsword, set variable vLonsword to vLongsword +1
if hero has artifact (longword), then take 1 longsword, set variable vLonsword to vLongsword +1
if hero has artifact (longword), then take 1 longsword, set variable vLonsword to vLongsword +1

and

conditional action:
if vLongsword > 0, then give 1 Longsword and set vLonsword to vLongsword - 1
if vLongsword > 0, then give 1 Longsword and set vLonsword to vLongsword - 1
if vLongsword > 0, then give 1 Longsword and set vLonsword to vLongsword - 1
if vLongsword > 0, then give 1 Longsword and set vLonsword to vLongsword - 1

So Karmakeld is right: each additional check is multiplied with all artifacts


Now let's look at the other way of doing this script:
#2- Second way is by using triggerable events. With this method, we can easily keep any number of item because we can use iterative script. The problem is that each hero must have a different script (not very different, but different). If the eqilibris team will use a program to modified the map file, the program can do it, but the programmer will have more work to do. I will explain:

Let's use the same artifact (Longsword) with some triggered script:

Hero#1
Triggerable events#1:
Name "LongswordTakeCount1":
conditional action:
if hero has Longsword, then take 1 longsword, set vLongsword to vLongsword +1, trigger custom event named "LongswordTakeCount1"

with this script, the take and count is automatic (I don't know how to say it in english...) I mean, the hero can have 78 Longsword, and they will all be remove and count.


Then a second Triggerable events:
Hero#1
Triggerable events#2:
Name "LongswordGive1":
conditional action:
if vLongsword > 0, then give 1 Longsword, set vLongsword to vLongsword -1, trigger custom event named "LongswordGive1"

With this script, all the Longsword (any number) will be giving back.

Now the encounter script:
trigger custom event named "LongswordTakeCount1"
..... (the same for each artifact), then....
trigger custom event named "LongswordGive1"
.....(the same for each artifact)

This method look more simple, but for hero#2, we will need to do this:
Triggerable events#1:
Name "LongswordTakeCount2":
conditional action:
if hero has Longsword, then take 1 longsword, set vLongsword to vLongsword +1, trigger custom event named "LongswordTakeCount2"

...and...

Triggerable events#2:
Name "LongswordGive2":
conditional action:
if vLongsword > 0, then give 1 Longsword, set vLongsword to vLongsword -1, trigger custom event named "LongswordGive2"

Then...

encounter script:
trigger custom event named "LongswordTakeCount2"
..... (the same for each artifact), then....
trigger custom event named "LongswordGive2"
.....(the same for each artifact)

Hero#3 = "LongswordTakeCount3"....
Hero#4 = "LongswordTakeCount4"....


With this script, GreatEmerald is right: It wouldn't make the script too complex, no multiplications here.

The difference is for the programmer that will include this script into a tool. The first method, you can easily copy/paste script on each hero, but this is more complex for the guy that will do the script (probably me) because we need to decide how many artifact of each we want to keep and more we keep, more job to do the script. The second method is more easy for the guy doing the script, but for the programmer, he will need to change the name of each script according to the hero(hero#1 = LonwsordTakeCount1, LongswordGive1, modified each triggerable event to call itself and then modified the encouter script. Hero#2 LongswordTakeCount2....)

This can be done easily* (I mean, it's not difficult, but need a lot more job) by programing (change the number at the end of the name of each triggerable events for each hero and modified triggerable events and encounter script on each hero too), but it's not as easy as copy/paste the script of method #1.

Now I really would like to know what method equilibris would like to choose.

.....sorry for the big wall of text....

What do you think about it?

User avatar
GreatEmerald
CH Staff
CH Staff
Posts: 3329
Joined: 24 Jul 2009
Location: Netherlands

Postby GreatEmerald » Jun 25 2015, 5:47

The term for the second method is "recursion". It's a recursive script.

Yea, I've been thinking about the latter, but why can't you add, for hero 2, a script called "redirect1" that simply calls LongswordTakeCount1?

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1110
Joined: 12 Nov 2011

Postby Karmakeld » Jun 25 2015, 8:20

The first issue is that we have 1 variable e.g Longsword, which will check the amount on ALL AI heroes. If triggered they all go off at the same time, and we must assume the heroes carries different numbers of a given artifact, so will the game be able to tell the difference between hero 1 carrying 2 swords and hero 2 carrying 0 swords?
Second issue is can we automatically increase variable names for each AI hero on the map? (I recall Dalai said early on, that this is unlikely to be possible).
About script names, can't we place all artifact checks in just one script? And just run the script again for rechecks?
Or did you plan to run a script; trigger LongswordTakeCount, trigger SwordofSwiftnessTakeCount, trigger AngelsBladeTakeCount etc. in the same script and then also make each of those scripts recursive? 8|
I fear what might happen if we run recursive scripts at the same time as that many triggered scripts.
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 25 2015, 9:18

Yea, I've been thinking about the latter, but why can't you add, for hero 2, a script called "redirect1" that simply calls LongswordTakeCount1?


I can't because the script LongswordTakeCount1 will be executed for each hero on the map. I mean, we can if we do this:

Hero#1:
Encounter:
set variable vEncounter to 1

Hero#2:
Encounter:
set variable vEncounter to 2

Then, you can use the same name for the triggerable event ("LongswordTakeCount")on each hero, but the script must be different:

Hero#1
triggerable event "LongswordTakeCount"
if vEncounter = 1, then...

Hero#2
triggerable event "LongswordTakeCount"
if vEncounter = 2, then...

With this method, I was using an other triggerable event ("ArtifactScript") that use a conditionnal action if vEncounter = 1 for hero #1, then call "LongswordTakeCount" and "LongswordGive" and then set vEncounter to 0

It works.... but this method is similar* (but worst) to method#2 in my previous message because you need to set a number for each hero and modified the conditionnal action for each triggerable event on each hero (A lot of work for the programmer too). I don't like this method because the script will be partially executed on each hero on the map (I mean, the first conditionnal action will be verified, but will be false, so not executed). If there is 100 hero on the map and the current troop has 3 heroes (3 encounter script in a sequence), each script will be partially executed 300 times..... each artifact has at least 2 script (TakeCount and Give), so if there is 100 artifact, that means 300*200 = 60000 script partially executed for a troop of 3 heroes....... Method#2 is a lot better in my opinion (or method #1 is even more simple for programming a tool)


I will try few more things, but I don't think we can do the exact same script (with the same name) on all hero (using triggerable events) without some problem.

Anyone have a good idea???

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 25 2015, 9:46

The first issue is that we have 1 variable e.g Longsword, which will check the amount on ALL AI heroes. If triggered they all go off at the same time, and we must assume the heroes carries different numbers of a given artifact, so will the game be able to tell the difference between hero 1 carrying 2 swords and hero 2 carrying 0 swords?
Second issue is can we automatically increase variable names for each AI hero on the map? (I recall Dalai said early on, that this is unlikely to be possible).
About script names, can't we place all artifact checks in just one script? And just run the script again for rechecks?
Or did you plan to run a script; trigger LongswordTakeCount, trigger SwordofSwiftnessTakeCount, trigger AngelsBladeTakeCount etc. in the same script and then also make each of those scripts recursive? eyes wide open
I fear what might happen if we run recursive scripts at the same time as that many triggered scripts.


We can solve your issue#1 (script go off at the same time, but are executed (run) in a sequence, but a lot of script running....), issue#2 I don't know (this is possible, but not easy and for equilibris team), Regarding same script name with all artifact check (I don't think so. You mean take 1 artifact of each then recall this script until there is no more artifact on the hero, maybe it's possible, but not easy for sure) ....not all script in the same script, all different recursive script. I fear the same thing.

....anyway, personnaly, I don't think we should use triggerable event for this kind of script (except if this is simple for equilibris to increase script name and modified script for each hero, I don't know, maybe they have a good programmer in the team). To many problems.....


So the question reamains (method#1): How many artifact of each do we want to keep??

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1110
Joined: 12 Nov 2011

Postby Karmakeld » Jun 25 2015, 12:44

Encountered event only allows us to place conditional actions not create a string of events named LongswordTakeCount, that can only be done with triggered script. But PatFx you already showed this in one of your examples.

I have a map where AI heroes will have their troops exchanged for other troops during Players turn. The same triggerable event (same name) runs a check on each hero and sets variables to determine which and how many creatures to change. Now the funny thing is, the script is copied thus using same name and variable name and it works fine. I tried to do a similar thing with artifacts, but using PatFx's suggested variables (set to +1), but all artifacts would end up on the first hero. So I don't have any simple solution..
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

User avatar
GreatEmerald
CH Staff
CH Staff
Posts: 3329
Joined: 24 Jul 2009
Location: Netherlands

Postby GreatEmerald » Jun 25 2015, 13:01

Oh, right, it's not object-oriented... Ugh. Well, in that case, is there a way to determine whether the artifact was equipped or not? So that a hero could be cleared of equipped artifacts, and then removing only two of each type of artifact would do.

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 25 2015, 14:48

I tried to do a similar thing with artifacts, but using PatFx's suggested variables (set to +1), but all artifacts would end up on the first hero. So I don't have any simple solution..


I had the exact same problem.

The way triggerable event works:

Let's say there is 4 hero on the map with all the same triggerable event "message" name (Simple scriple with only display message, but the message show the hero number #1,#2,#3 and #4). On encounter on each hero, trig this custom trigerrable event.

How it works:

If you merge hero#2 and hero#3 and hero#4 and put hero #4 first position, hero#3 second and hero#2 third position, and then fight (encounter). The first hero in the troop (Hero #4) will trig the encounter script (trigger custom event named message) first:
Hero#1 dispaly message, then hero#4 then hero#3 then hero#2.

After, the second hero in the troop (hero#3) trig his encounter script:
Hero#1 display message, then hero#4 then hero#3 then hero#2.

After, the third hero in the troop (hero#2) will trig his encounter script:
Hero#1 display message, then hero#4 then hero#3 then hero#2.

The way it work is: The triggerable event is trig on the first hero that was create on the map first, then the second...... except if you merge few heroes, the position of the hero has a higher priority over when it was create.

If you merge hero#1,#2 and #3 and put hero#3 first, hero#2 second and hero#1 third position in the troop, the message will be:

message hero#3, message hero #2, message hero #1 and then message hero#4 (first hero (hero#3) trig his encounter script), then message hero#3, message hero #2, message hero #1 and then message hero#4 (second hero (hero#2) trig his encounter script), then message hero#3, message hero #2, message hero #1 and then message hero#4 (third hero (hero#1) trig his encounter script)


That's why all artifact goes on the first hero and that's why I need an other variable to prevent the script to run on each hero (Hero#1 set vEncounter to 1, Hero#2 set vEncounter to 2..... and then at the beginning of the triggerable event, put a conditionnal action: if vEncounter =1 for hero#1, vEncounter = 2 for hero#2. This was the only way that I did found to make it work (with the same trigerrable name), but the script partially run on every hero on the map, so it's not a good idea. Method #2 was better because each triggerable event on each hero had his own name (so not execute for each hero on the map).... but I prefer the old school method without any recursive script (method#1)


is there a way to determine whether the artifact was equipped or not?


No

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 25 2015, 15:18

I have not finish the left hand list yet, but one thing I want you to know is that we will not look for Scroll and Parchment with this script, I think you can understand why. 8|

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1110
Joined: 12 Nov 2011

Postby Karmakeld » Jun 25 2015, 15:21

I think you're right about method#1 being the best solution.
Then it also shouldn't be necessary to add hero 1, 2, 3..
I'm not sure if we can differ between 2 or more heroes in the same army, though. But if you're up for the amount of scripting, and GE can accept a general check of 2 (misc excepted), I think we're good.
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 25 2015, 15:55

Then it also shouldn't be necessary to add hero 1, 2, 3..
I'm not sure if we can differ between 2 or more heroes in the same army, though.


What do you mean??

I will do the script on 1 hero and the same script can then be copy (I hope) on all hero on the map. I already use a similar script for artifact in one of my map (but not for all artifact...) and it works fine for any number of hero in the troop (but I did not copy, I did the script on each hero...= lots of script)

But if you're up for the amount of scripting, and GE can accept a general check of 2 (misc excepted), I think we're good.


No problem for scripting and 2 of each (misc excepted) looks good to me.

User avatar
GreatEmerald
CH Staff
CH Staff
Posts: 3329
Joined: 24 Jul 2009
Location: Netherlands

Postby GreatEmerald » Jun 25 2015, 16:53

Well, that's the thing... If the hero has, say, four Dwarven Shields. If you only remove two, you might remove only the ones in the backpack (unless removing always takes the equipped artifact, but I doubt that's how it works). So the hero will still have the Dwarven Shield equipped and will not equip the Adamantine Shield. Meanwhile if you remove all, but return only two Dwarven shields, a quest gate asking for four Dwarven shields will no longer be passable. Both cases aren't very good.

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1110
Joined: 12 Nov 2011

Postby Karmakeld » Jun 25 2015, 17:26

Quote:

Then it also shouldn't be necessary to add hero 1, 2, 3..
I'm not sure if we can differ between 2 or more heroes in the same army, though.

What do you mean??


I meant variables 1, 2 etc shouldn't be nessecary with encountered scripts. But if 2 heroes join army, will the artifact script run like the messages from your example, so it doesn't end up on just the one of them?

Question is if it's still not overall an improvement, even if we should miss an occasional artifact or two? Or as I suggested earlier, reduce amount according to artifact rank?
But I agree we should give back every taken artifact.

but one thing I want you to know is that we will not look for Scroll and Parchment with this script, I think you can understand why. eyes wide open


Oh yeah, this script project has a tight budget, and there isn't the time or the money to do it all. But did I miss something? I mean, was there a vote between Parchments/Scroll vs. ?? :-D
Oh well, seriously, what if a hero carries a scroll? Wouldn't it be our aim to replace it with a shield? (not sure how/if they equip parchments they can't read). Or do we just keep the scroll equipped?
I read somewhere the game can't tell the difference between scrolls and parchments but just checks scrolls as true, not the specific spell. This would mean that just one line is needed, unless we let them to just carry the scroll/parchment..?
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 580
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Jun 26 2015, 0:02

I think the recursive solution would work best for what you guys have been discussing today. You could save exactly the number of each artifact on encounter and replace exactly the same number on victory/defeat.

It wouldn't have to trigger on every hero on the map for every encounter, that's where the automated tool comes into play :D Once you create the necessary scripts on a single hero, extract the scripts with H4Util (I don't know how to do this part, but I believe you can do that). Then, you can add a tag to the end of the script name and variables (#heroName for example).

This is what you can give to Dalai.

Then, the nifty tool that's going to insert the scripts can have a block that checks for tags in the script, gets the necessary info (ie. the hero's name for the #heroName tag), and replaces the tag with the info. So the script named Remove and Count Artifacts#heroName will be named Remove and Count Artifacts Mudgeon, and this script will be the one inserted for Mudgeon's encounter script.

I'm assuming, of course, that the nifty tool is being written in a nice programming language where string operations are available ;)

Did I miss anything?

User avatar
PatFX
Peasant
Peasant
Posts: 68
Joined: 05 Mar 2015
Location: Montreal, Canada

Postby PatFX » Jun 26 2015, 4:46

But if 2 heroes join army, will the artifact script run like the messages from your example, so it doesn't end up on just the one of them?


If method #1 is use (without recursive script), there is no problem. Each hero can have the exact same script and all variable for artifact can have the same name too. The script must be place on Encounter script on each hero. When a troop of 3 hero encounter an ennemy, the first hero trig the encouter script:

Remove/count Robe of the Guardian (vRobeGuardian = number of Robe of the gardian on this hero)
Remove/count Longsword (vLongsword = number of longsword on this hero)
Remove/count Gambler's Deck (vGamblerDeck = number of Gamber's deck on this hero)
......

Then give back artifact with the highest priority:

Give X Robe of the Guardian (X = vRobeGuardian), then set vRobeGuardian to 0)
Give X Tiger Armor (X = vTigerArmor), then set vTigerArmor to 0)
......

At the end of the encouter script of the first hero, all variable are back to 0.

Then, the second hero trig his encounter script...... and then the third one.

If any number of hero join this troop, each hero will trig his encounter script in a sequence, starting with the first one, then the second one, then third......


Or as I suggested earlier, reduce amount according to artifact rank?


Not a bad idea, but personnaly, I would prefer a predifined number (same number for most artifact).


Oh well, seriously, what if a hero carries a scroll? Wouldn't it be our aim to replace it with a shield? (not sure how/if they equip parchments they can't read). Or do we just keep the scroll equipped?
I read somewhere the game can't tell the difference between scrolls and parchments but just checks scrolls as true, not the specific spell. This would mean that just one line is needed, unless we let them to just carry the scroll/parchment..?


There is a lot of bug with the scroll/parchment script:
You can put this in a script:

if hero has artifact scroll of Bless, take scroll of bless from this hero

......but the script will look only if there is a scroll on the hero (like you said, no difference between each different scroll or parchment), no matter if it's Bless or anything else (Aura Fear, Giant Strenght...), and remove a scroll. Same with parchment. So there is no way to know what scroll you did remove, so you can't give it back. Anyway, there is too many spell, even if it was working, I can't do this script within 5 years of scripting full time..... lol

The other thing is if the hero has multiple scroll/parchment. If you remove 1 scroll and the hero has 2 scroll, the scroll that will be remove will be the one in the backpack (same has other artifact)

So I think we should pray that the hero has not a scroll/parchment equip, because we will not be able to equip a shield witout taking a scroll/parchment. If the scroll is equip, we will need to keep the scroll equip. If we remove multiple scroll/parchment, we will be able to equip a shield, but we will lose those scroll/parchment forever. If they have the scroll and parchment in the back pack, we can equip a shield and there will be no problem.

So, like you said, we will let them just carry the scroll/parchment. At least, if the hero have any other left hand artifact before the hero find a scroll/parchment, there will be no problem because the script will equip the left hand artifact, so when the hero find the scroll, he will go in the backpack and stay there for the rest of the game.


Well, that's the thing... If the hero has, say, four Dwarven Shields. If you only remove two, you might remove only the ones in the backpack (unless removing always takes the equipped artifact, but I doubt that's how it works). So the hero will still have the Dwarven Shield equipped and will not equip the Adamantine Shield. Meanwhile if you remove all, but return only two Dwarven shields, a quest gate asking for four Dwarven shields will no longer be passable. Both cases aren't very good.


Yes, you will remove only the shield in the backpack first and the hero will still have a Dwarven Shield equip (and 1 more in his backpack). If the same hero has all the 4 dwarven shield on him (equip+backpack) and we remove all but give back 2, you are right, this can create some problem with quest. But don't forget that if 3 hero are in the troop and 1 hero has 2 Dwarven and the other 2 hero has 1 Dwarven each, this will create no problem at all. So to get problem, you need a quest with multiple artifact of the same type, and all artifact on the same hero. Anyway, we can keep 4 artifact of the same type if we want, it's just a lot more work for the guys doing the script....

If we decide to keep 4 artifact of each, I will take up to 5 and give back up to 4. It's important to take more then what we give because if the hero has 5 Dwarven (1 equip) and I take only 4, this hero will always have a Dwarven shield equip. If the hero has 7 Dwarven (1 equip), after 3 encounter script, the hero will have only 4 Dwarven and I can be sure that all Dwarven will be remove (Take the 1 equip) before I start giving back artifact (to equip the Adamatin shield for exemple)

For misc artifact, that's exacly what I tought I will do (take up to 5, give back 4), so I can do it for all artifact too. In my opinion, it's a little bit too much, because it's only to prevent 1 scenario: All artifact for a quest are on the same hero.

For quest, people can ask for 10 ring of Strenght (and all guard by the same hero), we don't know....

That's why, if we can't use recursive script (if method#2 can be copy/modified for each hero, then there is no problem to keep any number), we will need to decide the number of each artifact that we think is OK in most scenario. Maybe 2 is not enought....

Personnaly (not because I'm lazy), I think 2 is enought because in all map that I did create, I did never put many artifact of the same type for a quest on 1 hero. Usually, I put them at different place on the map and on different hero (for quest with multiple artifact of the same type).... I don't know, I did not try a lot of map made by others mapmakers.....

I Like the idea of Karmakeld: an info about how the Artifact table script works, could warn players about this possible issue.. (if method#2 is not possible)


I think the recursive solution would work best for what you guys have been discussing today. You could save exactly the number of each artifact on encounter and replace exactly the same number on victory/defeat.

It wouldn't have to trigger on every hero on the map for every encounter, that's where the automated tool comes into play smile_teeth Once you create the necessary scripts on a single hero, extract the scripts with H4Util (I don't know how to do this part, but I believe you can do that). Then, you can add a tag to the end of the script name and variables (#heroName for example).

This is what you can give to Dalai.

Then, the nifty tool that's going to insert the scripts can have a block that checks for tags in the script, gets the necessary info (ie. the hero's name for the #heroName tag), and replaces the tag with the info. So the script named Remove and Count Artifacts#heroName will be named Remove and Count Artifacts Mudgeon, and this script will be the one inserted for Mudgeon's encounter script.

I'm assuming, of course, that the nifty tool is being written in a nice programming language where string operations are available wink


That's why I said that method #2 (recursive script explain in one of my previous post) is a good way to do it (but only if the tool use to insert scripts is in a nice programming language like you said, and it's more job for the equilibris guys, less job for the guys doing the script on 1 hero), but I don't know what tool they are using. With the complete script on a single hero, it could be easy to just modified the the script/variable name with a tag (in my post, I was using simple numbers at the end of the names as tag)

If the tool that will be use to insert the script on each hero can easily find every computer hero of a map in the file, than it should be easy to add a script for each hero and modified the names of Script/variables with tag (by incrementing a variable for each hero find)


Return to “Heroes I-IV”

Who is online

Users browsing this forum: No registered users and 7 guests