Hedge
Moderators: Slitherine Core, BA Moderators
Hedge
I found another "special behavior".
Solo player all works ok, (after a lot of effort, btw), but unfortunately it do not seems to work in MP.
A unit has an action capable of removing a hedgerow.
In MP:
Playing side 0 you see how your unit removes the hedgerow.
When the other side loads the game (side 1), and look at the replay, the hedgerow is not removed...
Then when you load again side 0, you see that the hedgerow is still here. you can remove it again and again but it come back each turn.
Is there any logical in this?
I've and example scenario that do just that, I may send you if you wish.
BTW, this not happens on others objects, as tank traps for example, that are removed correctly in solo or MP.
Solo player all works ok, (after a lot of effort, btw), but unfortunately it do not seems to work in MP.
A unit has an action capable of removing a hedgerow.
In MP:
Playing side 0 you see how your unit removes the hedgerow.
When the other side loads the game (side 1), and look at the replay, the hedgerow is not removed...
Then when you load again side 0, you see that the hedgerow is still here. you can remove it again and again but it come back each turn.
Is there any logical in this?
I've and example scenario that do just that, I may send you if you wish.
BTW, this not happens on others objects, as tank traps for example, that are removed correctly in solo or MP.
-
jcb989
- Colonel - Fallschirmjäger

- Posts: 1423
- Joined: Fri Nov 05, 2010 12:02 am
- Location: Bradenton, Florida
Re: Hedge
Off-topic slightly but in Merr scenarios, he always has those "hedgehog" Shermans in the random force selections.
Maybe you're busy making a use for them! It would be cool to punch through hedges with specially equipped Shermans,
I congradulate you on attention to details if that is where you are going with it.
Maybe you're busy making a use for them! It would be cool to punch through hedges with specially equipped Shermans,
I congradulate you on attention to details if that is where you are going with it.
Re: Hedge
This interest me, are you saying that in Merr scenarios there are Sherman Rhino capable of remove hedgerows?jcb989 wrote:Off-topic slightly but in Merr scenarios, he always has those "hedgehog" Shermans in the random force selections.
Maybe you're busy making a use for them! It would be cool to punch through hedges with specially equipped Shermans,
I congradulate you on attention to details if that is where you are going with it.
This is just I'm trying to do, in fact I get it work ok on solo games, but in MP, for a reason I can not understand, it do not work.
Re: Hedge
Pip, I think I found what's happening.
Globals cannot be used in action scripts (DATA/BATTLE/SCRIPTS), it seems that when BA executes the turn in the other side (MP) these are lost (?). The Globals were used in "the same script document".
I changed now the Globals to UniversalVar and it seems to work.
Maybe some kind of documentation about it, to prevent future modders to spend many hours crashing their minds will add.
The big problem, in my opinion, is not to be allowed to debug in MP, above all when BA don't have the same behavior in single than in MP mode.
Globals cannot be used in action scripts (DATA/BATTLE/SCRIPTS), it seems that when BA executes the turn in the other side (MP) these are lost (?). The Globals were used in "the same script document".
I changed now the Globals to UniversalVar and it seems to work.
Maybe some kind of documentation about it, to prevent future modders to spend many hours crashing their minds will add.
The big problem, in my opinion, is not to be allowed to debug in MP, above all when BA don't have the same behavior in single than in MP mode.
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Hedge
BA should behave identially in MP - it relies on it in fact. If there are places where that isn't the case then let me know and I will attempt to fix them. Globals are definitely usable in all scripts - I'm not entirely clear from your comment where they were not working. Unit scripts specifically should save their globals - I will double check that it is still working as intended as I can't think of a specific set of unit behaviour that relies on that fact. Globals will NOT work across instances of a script (that is - every unit has their own instance of a script).
I will allow MP debugging in the next update, but that won't be until the new year I would imagine.
Cheers
Pip
I will allow MP debugging in the next update, but that won't be until the new year I would imagine.
Cheers
Pip
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Hedge
It's more informative to tell me what the script is doing, and how it is hooked into the campaign you are working on. E.g. is it a unit script, etc.
Cheers
Pip
Cheers
Pip
Re: Hedge
It's an action script to remove hedgerow.
CHECK_ALL_HEDGE
As this kind of objects are placed in a special way in the tiles, when checking two tiles to see if there is a hedgerow it's difficult to know in which tile they are, CHECK_ALL_HEDGE do the job and calls a Function CheckTheObject that do some task and keeps several values to identify the tile where the hedgerow is placed, and return a value to CHECK_ALL_HEDGE that return 2 when it's ok.
ALL_HEDGE
Will remove the hedgerow, to avoid to repeat the complex process it used the values kept by CheckTheObject.
Originally in CheckTheObject I used several SetGlobal ("name", value), so here, Getting the globals the job would be easy, but did not work in MP as I explained before.
Then I just changed every SetGlobal and GetGlobal for SetUniversalVar and GetUniversalVar and works. In solo or MP.
Remember an anterior post mine, where I'd a similar problem with de tile data that seems no be kept in MP, and I bypassed putting and object in the tile (so small that can no be seen) and use the data object that works in MP from turn to turn.
CHECK_ALL_HEDGE
As this kind of objects are placed in a special way in the tiles, when checking two tiles to see if there is a hedgerow it's difficult to know in which tile they are, CHECK_ALL_HEDGE do the job and calls a Function CheckTheObject that do some task and keeps several values to identify the tile where the hedgerow is placed, and return a value to CHECK_ALL_HEDGE that return 2 when it's ok.
ALL_HEDGE
Will remove the hedgerow, to avoid to repeat the complex process it used the values kept by CheckTheObject.
Originally in CheckTheObject I used several SetGlobal ("name", value), so here, Getting the globals the job would be easy, but did not work in MP as I explained before.
Then I just changed every SetGlobal and GetGlobal for SetUniversalVar and GetUniversalVar and works. In solo or MP.
Remember an anterior post mine, where I'd a similar problem with de tile data that seems no be kept in MP, and I bypassed putting and object in the tile (so small that can no be seen) and use the data object that works in MP from turn to turn.
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Hedge
Hmmm - that absolutely should work I think. I will check it out - it sounds like a bug.
Cheers
Pip
Cheers
Pip
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Hedge
I've looked into this more, and I think I know what is going on.
Script globals are working correctly - they are saved and reset as they should be. So in MP, they will be manipulated during the turn, then are reset back to their values at the beginning of the turn, ready for the turn replay on the opponent machine. This is how the game results stay in sync, and how they are supposed to work.
Universal vars, on the other hand, are broken
. They get saved with whatever is in them at the point of the turn save - so at the end of the turn, and this is wrong. If you have anything which alters their values in a turn then you will get different results during the replay.
I think that (in this case) what happens is this: on the replay, the CHECK_ functions simply aren't called, and so no globals are set. Hence the order to remove the hedge doesn't work. When you set a universal it stays set and is saved out, so the order works. But this is fraught with danger
E.g. this won't work if the player does >1 of these orders in a turn (only the last one will actually have the values set up correctly).
I hope that has explained everything! I'll have to take a look at whether fixing the universal vars will break anything.
In terms of fixing it, I would suggest just recalling the function which determines the values in the first place and not caching the results. Given that the order is only called once, while the CHECK_ function is called every tick it's not really a meaningful performance gain.
Cheers
Pip
Script globals are working correctly - they are saved and reset as they should be. So in MP, they will be manipulated during the turn, then are reset back to their values at the beginning of the turn, ready for the turn replay on the opponent machine. This is how the game results stay in sync, and how they are supposed to work.
Universal vars, on the other hand, are broken
I think that (in this case) what happens is this: on the replay, the CHECK_ functions simply aren't called, and so no globals are set. Hence the order to remove the hedge doesn't work. When you set a universal it stays set and is saved out, so the order works. But this is fraught with danger
I hope that has explained everything! I'll have to take a look at whether fixing the universal vars will break anything.
In terms of fixing it, I would suggest just recalling the function which determines the values in the first place and not caching the results. Given that the order is only called once, while the CHECK_ function is called every tick it's not really a meaningful performance gain.
Cheers
Pip
Re: Hedge
Thanks, I'll try it.
BA is full of surprises:
Globals are reset at the beginning of each MP turn, so many things that works on solo play could not work on MP.
These are the kind of things that will be appreciate if documented
.
BA is full of surprises:
If I understand, a turn in BA is a player turn ( no both sides actions) this was assumed already...Script globals: they are saved and reset as they should be. So in MP, they will be manipulated during the turn, then are reset back to their values at the beginning of the turn
Globals are reset at the beginning of each MP turn, so many things that works on solo play could not work on MP.
These are the kind of things that will be appreciate if documented
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Hedge
MP isn't documented at all now I think about it! Basically the thing to remember is this - what is saved is the state at the start of your turn, then all your orders. This then needs to replay in exactly the same way on the opponent machine. This can be tricky to ensure and is the bane of my life to some extent.
I'll see if I can find time to better document it.
Cheers
Pip
I'll see if I can find time to better document it.
Cheers
Pip
Re: Hedge
Now that I'm checking again this script, I remember that it was a very hard task for the way the hedgerow are placed by BA editor.
When an action unit click a tile, you know the tile where the unit "me" is placed, and the (tileX tileY) clicked, but the hedgerow that separates the two tiles, could be in any of the two tiles, and as two hedgerows could be on the same tile it makes difficult to deal with (maybe there is a easy way I do not see).
Do you plan to fix the Universal variables in 2.0.8?, I'm asking to know is I'll need to change Fortified Line immediately.
When an action unit click a tile, you know the tile where the unit "me" is placed, and the (tileX tileY) clicked, but the hedgerow that separates the two tiles, could be in any of the two tiles, and as two hedgerows could be on the same tile it makes difficult to deal with (maybe there is a easy way I do not see).
Do you plan to fix the Universal variables in 2.0.8?, I'm asking to know is I'll need to change Fortified Line immediately.
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Re: Hedge
I don't want to tinker with the universals for this update, so it probably won't be solved. It also, as I say, won't work for more than one unit and wouldn't actually work at all if you are setting anything from inside the CHECK_ function, as this function isn't called at all during the replay. As I say, that it works currently because of the universals is really just luck with regard to how the universals are bugged
.
Basically you need to be able to work out everything you need to from the information in the order itself, as this is the only thing which is stored to make the replay happen.
Cheers
Pip
Basically you need to be able to work out everything you need to from the information in the order itself, as this is the only thing which is stored to make the replay happen.
Cheers
Pip
