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 > Heroes 4 - Lands of Axeoth > Thread: Distance between 2 moving objects.
Thread: Distance between 2 moving objects. This thread is 2 pages long: 1 2 · NEXT»
IamNotHelping
IamNotHelping


Hired Hero
posted July 09, 2021 04:09 AM
Edited by IamNotHelping at 05:02, 09 Jul 2021.

Distance between 2 moving objects/ see if an unit entered combat.

Hello, I wanted to ask if there existed a system to get the distance between 2 moving objects?

What I wanted to do was that an army gets boost in morale if a specific ship is nearby, or debuff in the contrary case.
Of course It could be any other triggerable events.
What I imagined was to separate the coast and the sea in different areas. And if the ship is present in an area, the army is present in the according land area, then it gets a boost.
(That's for my example of land/sea, if its just land/land or sea/sea it could be simplified to being in the same area.)


For example ship in sea1 and army in land1.

Problem1
what troubles me with this method is that the distance in this case might be wrong.
Lets say ship is on the west side of Sea1 while army is on the east side of Land1, it might be closer to the ship if it was on the west side of Sea2.

Limiting areas is eazy with 2 layers placed event.

In layer close to area1,
If area2 true then set area1 true, area2 false   else do nothing.
In layer close to area2
If area1 true then set area2 true, area1 false   else do nothing.

It could be manageable by reducing the size of the areas.
I was just curious if someone developped a tactic to get the distance between 2 moving objects.

Problem2:
If 2 ships enter area1, it will set the area1 to true. However after the first ship leave it, it will be set to false, while there still exists a ship in it.
I can only see a solution by identifying the armies by a hero inside them, however I don't really want to have too much playable plot related heroes in a campaign when only 2 of them will be carried over the next map.
Too limit impact, I can give them snowty stats, a lvl20 who only knows basic combat and whose attack/defense/speed are reduced to 0.
Problem is that this captain of a ship character would reduce by 1 the slot on the ship, I cannot stop the player to remove it from the ship. (Most of the coast in contact with the sea that ship is are landable, so putting gates everywhere to stop him landing would be too space-costly and ugly)

If possible I don't wanna cover the whole map of placed event to give a coordinate to each location.

Btw is there a way to see if an unit entered combat?
Otherwise if I applied a boost "until next combat", be it morale, luck or hero stats, then it disapears after the first fight, while what i wanted was a buff for the whole day.
I believe a continuous event is needed, that under some condition give the boost again. (If you dont put a condition you might get infinite buff/debuff that becomes a debuff/buff. I forgot to put it once, and it gave me -250 moral which became +25 morale.)
____________

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

Tavern Dweller
posted July 09, 2021 09:41 AM

My first thought on how to calculate the distance you would need placed events everywhere, which would make movement on the sea very cumbersome. The reason is that ships that pass placed events on the sea will always make a stop on a placed event even if your path was set to go through them and not stop. I know this happens because I had it on one of my own maps, but you should test this yourself first before working a lot on your script. It might have been specific to the script I was running on the placed event.

As for the giving a morale boost for one day, that should be easy with a continuous script as you said yourself. Just make the script that triggers the boost set a variable "boostday" to current day and have the continuous script trigger morale boost only if boostday equals current day.

This sounds like an interesting idea and hopefully there is a simpler way than having to cover the whole passable part of the map with placed events.

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


Hired Hero
posted July 09, 2021 11:57 AM

zense said:
My first thought on how to calculate the distance you would need placed events everywhere, which would make movement on the sea very cumbersome. The reason is that ships that pass placed events on the sea will always make a stop on a placed event even if your path was set to go through them and not stop. I know this happens because I had it on one of my own maps, but you should test this yourself first before working a lot on your script. It might have been specific to the script I was running on the placed event.



I believe that it is normal to stop on a placed event. At least it certainly does when you are displaying some messages. If it stops the player during each of his moves it would be unplayable on a map where there are placed event everywhere.
I would really prefer to use delimited areas rather than events everywhere, it is less precise but its less confusing. The problem of coordinates is that you would have to set false all the coordinates around it each time you move. So its a pain not only to place them, name them but also to implement them.


Edit: you dont automately stop at a placed event, at least a placed event that run on the background doesnt stop you. For example setting a numeric or boolean variable doesnt stop you. However if it displays a message, start a combat or something like that it would. And not only ships but heroes at well could be stopped by those kinds of placed events.


zense said:

As for the giving a morale boost for one day, that should be easy with a continuous script as you said yourself. Just make the script that triggers the boost set a variable "boostday" to current day and have the continuous script trigger morale boost only if boostday equals current day.



My issue isn't about giving a buff to an army, but how to keep it all day.
If you don't put a limiter boolean variable, the continuous event would keep giving buffs as long as the condition are satisfied. For example it would repetively give you a +2 moral boost, so you would have +255 moral while you only wanted +2.
To prevent this, I added a boolean so its something like

Cond: {if:[and: food>2; boolean is true] then [seq: +2 moral, set boolean to false] else: [do nothing]}

However that +2 moral only last 1 combat. After the combat, boolean is still false, so the requirements aren't fulfilled.
One of the thing that could keep track if a combat ocured or not is checking the total number of creatures if it decreased or not.
However 1 you dont always lose units in a fight,
2 you can decrease units without entering a fight by example splitting an unit and killing it.
Those 2 things makes this a method to check if a fight happened obsolete.

Edit: Nvm I was dumb, I forgot we had the victorious event, I never used it before. I only need to set the boolean true again after a victorious fight.
____________

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


Hired Hero
posted July 09, 2021 12:39 PM

I already know how to re-apply a buff or debuff after a combat, using the victorious event.
I wanted to ask if it was clear what was the order of events hapening.
For example a hero has
Timed event1
Timed event2
Continuous event 1
Continuous event 2
Map has
Timed event3
Continuous event 3
Continuous event 4
Is it gonna be T3, T1, T2, C3, c4, C1, C2
Or something like t3, c3 c4 t1 c1 c2
Or something else

Does there exist an order of priority for the source of events?
For example map>town>army>hero>mines>dwelings.
____________

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


Honorable
Famous Hero
posted July 09, 2021 05:56 PM

As far as applying a buff for each battle for a day, why not use the encountered event on the hero?

You can just put a conditional in there on a variable, and if true, give morale until next battle. The conditional is just used to enable / disable the buff.

As far as calculating the distance between objects in the game, not that I know of.

The placed events around boundaries is pretty much the way you have to do any proximity testing. I think you pretty much said this, but you want two layers on the area boundaries, one for entering, one for leaving, and a small buffer of space in between. When entering, set to true, and when both are true, your morale boost is enabled.

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


Hired Hero
posted July 09, 2021 06:45 PM
Edited by IamNotHelping at 19:16, 09 Jul 2021.

iliveinabox05 said:
As far as applying a buff for each battle for a day, why not use the encountered event on the hero?

You can just put a conditional in there on a variable, and if true, give morale until next battle. The conditional is just used to enable / disable the buff.



I see, The way I had found was buffs/debuffs in continuous and they are reactivated by a boolean turned true in victorious.
I think your method is better computation wise than continuous but I'm not sure if if those buffs would still be activated in a combat triggered by an event.
If two friendly units meet up, would the buff also be applied? If you encounter some wild armies and let them flee would the buff still be applied?
What I find problematic is the posibility to 'save' the buff for a future fight.
For example A has buff on day1, but not on day 2.
A save the buff from encountering an ally or letting an enemy flee, during the first fight of day2, A would still have the buff.

Ps: You don't need to answer on those questions, I just wrote them down before I forget coz I have to go to sleep. Those questions are easy to check by myself and I'll do it tomorow morning.

Edit: Nvm, I couldnt sleep without knowing the answer.
1 Fights that happen in Event-> Combat  doesnt count as encounter, so the army wouldnt be buffed even if the conditions to be buffed are satisfied.
2 Meeting up with allies doesnt activate encounter.
3 Letting enemies flee still activates encounter (so you can save the buff for latter)
And even worse news, letting enemy flee still counts as being victorious. So if the core condition to stop the buff from being activated multiple time is turned back to true after being victorious then it is possible to stack the buffs.

For example:
Army A
ENCOUNTER
If (current day is day 1 of week  AND Boolean) then ( +5 luck, set Boolean to false)
VICTORIOUS
set Boolean to true

A meets an enemy and fight, it has +5 luck during the fight and lose it after.
A meets another enemy and let it flee, A receives a +5 luck and doesnt use it.
A meets another enemy and fight/let it flee: A has a total of +10 luck during the fight/ after the enemy fled.
____________

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


Honorable
Famous Hero
posted July 09, 2021 06:58 PM
Edited by iliveinabox05 at 18:59, 09 Jul 2021.

IamNotHelping said:
I see, The way I had found was buffs/debuffs in continuous and they are reactivated by a boolean turned true in victorious.
I think your method is better computation wise than continuous but I'm not sure if if those buffs would still be activated in a combat triggered by an event.
If two friendly units meet up, would the buff also be applied? If you encounter some wild armies and let them flee would the buff still be applied?
Its easy to make sure that the buff/debuff is only activated once per combat, what I find problematic is the posibility to 'save' the buff for a future fight.
For example A has buff on day1, but not on day 2.
A save the buff from encountering an ally or letting an enemy flee, during the first fight of day2, A would still have the buff.

Ps: You don't need to answer on those questions, I just wrote them down before I forget coz I have to go to sleep. Those questions are easy to check by myself and I'll do it tomorow morning.


I'm pretty sure the encountered script only triggers before a battle, but it's simple enough to test: just add a display script to the encountered event and run through the scenarios you mentioned.

And yes, combats triggered by an event still cause the encountered event to run.

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


Hired Hero
posted July 09, 2021 07:29 PM
Edited by IamNotHelping at 19:34, 09 Jul 2021.

iliveinabox05 said:


I'm pretty sure the encountered script only triggers before a battle, but it's simple enough to test: just add a display script to the encountered event and run through the scenarios you mentioned.

And yes, combats triggered by an event still cause the encountered event to run.


I just tested it and it seems that combat event doesnt count as encounter.
It didnt apply on a timed combat on day 1 for both encounter and continuous method.
However on a timed combat on day 2, encounter didnt apply and continuous did.
I also tested a fight triggered by a placed event, it didnt count as an encounter.

I also tested the continuous method on enemy fleeing. It also stacks the buffs... since them fleeing counts as a victory. Seems like I will have to find new limitations.

Edit seems like fleeing is the issue, is it possible to forbid enemies from running away? Or to prevent a hero feom taking off its shackles of war?
____________

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


Honorable
Famous Hero
posted July 09, 2021 07:45 PM

IamNotHelping said:
I just tested it and it seems that combat event doesnt count as encounter.


Interesting, that's news to me. I'm going to have to test that out when I get home. Can't believe I never would have tested that, as I have extensive placed event scripting for random battles and would have tested out my custom skills there.

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


Hired Hero
posted July 10, 2021 01:13 AM

iliveinabox05 said:
as I have extensive placed event scripting for random battles and would have tested out my custom skills there.


Oh, is that a way to keep the map alive and still have fights against wild armies even at later stages of the game? Or does new monsters appears every month like in preexisting games?
____________

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


Responsible
Legendary Hero
Modding the Unmoddable
posted July 10, 2021 03:02 AM

Quote:
seems like fleeing is the issue, is it possible to forbid enemies from running away? Or to prevent a hero feom taking off its shackles of war?


This was a problem for me too as powereful neutral heroes would "flee" (the encountered dialog, not in combat) even if they have abilities and spells to win the encounter.

What I think to prevent this is some options, all untested:
* Make encountered army turn neutral army into a placeholder player by an event.
* Make hero not have many occupied artifact slots. Give Shackles of War in encountered event.
* Have a lot of extra creatures before attacked, then remove them.

About fleeing in combat:
* Make changed player not have any towns. (could be temporarily changed via triggered even if they absolutely must have them at other times)
* Of course used shackles prevent this.
____________
Never changing = never improving

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


Hired Hero
posted July 10, 2021 03:02 AM

IamNotHelping said:

I wanted to ask if it was clear what was the order of events hapening.

Does there exist an order of priority for the source of events?
For example map>town>army>hero>mines>dwelings.


Ok, so i tested it and it seems pretty messed up.

Map>>> rest
Trigger takes effect directly
Timed> Continuous.
Army where heroes is > hero


Between town armies mines dwellings and garnisons there are no priorities based on what type of object it is. But only on which object was last moved in the editor.

The older it was last moved, the higher its priority. (Adding new events doesnt change its priority)

I initially thought there was an order according to the type of object then decided by the location of object (for example north/west>south/east but nop)

____________

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


Responsible
Legendary Hero
Modding the Unmoddable
posted July 10, 2021 03:04 AM

Last placed is good news. It means mapmaker has control instead of it being hardcoded.
____________
Never changing = never improving

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


Hired Hero
posted July 10, 2021 03:42 AM

NimoStar said:
Quote:
seems like fleeing is the issue, is it possible to forbid enemies from running away? Or to prevent a hero feom taking off its shackles of war?


This was a problem for me too as powereful neutral heroes would "flee" (the encountered dialog, not in combat) even if they have abilities and spells to win the encounter.

What I think to prevent this is some options, all untested:
* Make encountered army turn neutral army into a placeholder player by an event.
* Make hero not have many occupied artifact slots. Give Shackles of War in encountered event.
* Have a lot of extra creatures before attacked, then remove them.

About fleeing in combat:
* Make changed player not have any towns. (could be temporarily changed via triggered even if they absolutely must have them at other times)
* Of course used shackles prevent this.


I see,
I just tested the method of turning a neutral army into a player one and it works. They are unable to escape the encounter.
Equiping the shackles of war cannot stop a neutral enemy to flee during encounter.

Thanks, it was very helpful.
For my case the best thing is if we could have a variable to indiquate if the enemy fleed or not.
Since weak enemies running away is part of the game, some players dont want to kill creatures they like in neutral fights that could be avoided if the exp they offer is really not relevant (for example only worth 1% of needed exp).

What I hate Isn't the fact that the enemies flee the encounter in itself, but that it bypass the system I made to receive buffs/debuffs for all the fights of a same day.
It allows them to stack the buffs/debuffs and it can become game breaking.
____________

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


Hired Hero
posted July 10, 2021 03:49 AM

NimoStar said:
Last placed is good news. It means mapmaker has control instead of it being hardcoded.


Ya, it gives us more control so thats cool.
I was just pissed that I looked like an idiot testing for an hour what was the algorithm to decide whose event goes first.

I was like maybe north has prio
Oh maybe west has prio
Nvm maybe it starts from the corners than go to center.
Hmm, then which corners goes first.
That doesnt seem to be the case, maybe the map is separated in different areas or what not.
Damn it the order between armies is so messy, at least i have the set order town1>mine1>dweling1>garnison1>mine2>dweling2>garnison2>town2>town3 that wont betray me.
Why are you betraying me as well!!!

Wait a sec, its just who I last moved.
____________

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


Honorable
Famous Hero
posted July 10, 2021 04:28 AM
Edited by iliveinabox05 at 04:41, 10 Jul 2021.

IamNotHelping said:
Oh, is that a way to keep the map alive and still have fights against wild armies even at later stages of the game? Or does new monsters appears every month like in preexisting games?


Think about the Final Fantasy games, specifically when you enter certain areas and a battle can trigger randomly at any time.

That was the idea for the random battle system I implemented, with a slight difference: I linked number of steps taken to when a battle is triggered, rather than have a flat percentage on each tile. That just gives a little more control over how often or how little the random battles trigger.

They are just placed events, which can trigger these combats.

Only annoying thing is needing to completely cover the area for the random battles with the placed events, but it does ensure that every single play through is different.

Edit. I just tested the encountered event with a battle triggered by a placed event, and it did indeed run (showed the display script I used).

So, it only works if you use the encountered event on the actual hero. You are correct that the encountered scripts don't seem to be called via triggered battles when the scripts are put in the encountered event on the army object. Sounds very much like a bug to me.

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


Hired Hero
posted July 10, 2021 05:40 AM

iliveinabox05 said:
IamNotHelping said:
Oh, is that a way to keep the map alive and still have fights against wild armies even at later stages of the game? Or does new monsters appears every month like in preexisting games?


Think about the Final Fantasy games, specifically when you enter certain areas and a battle can trigger randomly at any time.

That was the idea for the random battle system I implemented, with a slight difference: I linked number of steps taken to when a battle is triggered, rather than have a flat percentage on each tile. That just gives a little more control over how often or how little the random battles trigger.


How do you keep track of number if steps? +1 counter each time you walk on it and reset to 0 when encounter?


[quote iliveinabox05]
So, it only works if you use the encountered event on the actual hero. You are correct that the encountered scripts don't seem to be called via triggered battles when the scripts are put in the encountered event on the army object. Sounds very much like a bug to me.


Maybe its about the order of events?
A hero's event always come after its army's event of the same type.
If placed event happen after army's encounter and before hero's encounter then it could explain.

I think I got the solution for my problem, asking the player if he wanna be a dick and use the bug or be a good guy and tell me if the enemies fleed during encounter.
If he wanna use the bug to stack buffs, I at least get to insult him so I'm fine with it.
____________

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


Honorable
Famous Hero
posted July 10, 2021 06:18 AM

IamNotHelping said:
Maybe its about the order of events?
A hero's event always come after its army's event of the same type.
If placed event happen after army's encounter and before hero's encounter then it could explain.

I think I got the solution for my problem, asking the player if he wanna be a dick and use the bug or be a good guy and tell me if the enemies fleed during encounter.
If he wanna use the bug to stack buffs, I at least get to insult him so I'm fine with it.


I also tried an army without a hero and using the encountered event, and it did not activate even without a hero in the stack.

So yeah, if it's not something that you can put on a specific hero, then you'll have to use a workaround.

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


Responsible
Legendary Hero
Modding the Unmoddable
posted July 10, 2021 06:40 AM

Quote:
I see,
I just tested the method of turning a neutral army into a player one and it works. They are unable to escape the encounter.
Equiping the shackles of war cannot stop a neutral enemy to flee during encounter.

Thanks, it was very helpful.
For my case the best thing is if we could have a variable to indiquate if the enemy fleed or not.
Since weak enemies running away is part of the game, some players dont want to kill creatures they like in neutral fights that could be avoided if the exp they offer is really not relevant (for example only worth 1% of needed exp).

What I hate Isn't the fact that the enemies flee the encounter in itself, but that it bypass the system I made to receive buffs/debuffs for all the fights of a same day.
It allows them to stack the buffs/debuffs and it can become game breaking.


Glad I could be of use. Yes, the shackles apparently only work during the battle itself, not in the "enemy wants to flee" encounter dialog. Unfortunate but it does have its logic.

What doesnt' is the lack of an "enemy never flees" simple checkmark. This was present in h3 in all neutrals, I guess someone (really dumb ) just decided to not implement it at all in h4...
____________
Never changing = never improving

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


Responsible
Supreme Hero
posted July 12, 2021 06:46 PM

I'm thinking it would be possible to set up and encountered/vicotorious script where you check the amount of creatures your enemy has upon encounter and when you're victorious. If not the number on the victorious script is less than the encountered, this would suggest the number is equal and thus they've fleed.
It would take some time to script, but I have a similar 'check creature amount' script that could easily be adjusted and copy/pasted with the H4MG tool. That would be my suggestion, beyond the solutions already posted. Can't guarantee it'll work, but you shouls try it out with an easy test setup.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 2 pages long: 1 2 · NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0767 seconds