How to fix minefield issues?

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
Schweinewitz
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 255
Joined: Wed Feb 23, 2011 6:51 pm
Location: Münster, Germany

How to fix minefield issues?

Post by Schweinewitz » Mon Sep 05, 2016 9:52 am

I'm working on an Axis-side defensive senario in which I use mines. Problem is that they are not working correctly - see screenshot below. First, infantry avoids them and tries to find a way around the minefields. As turn follows turn, they don't care anymore and enter the minefields without further ado. Vehicles too. They suffer no casualities.

This issue was reported first when the Kursk campaign was released:

http://www.slitherine.com/forum/viewtop ... es#p541487

I haven't played the Soviet Kursk campaign yet; is it fixed?

Which script is necessary for full-functional minefields?

Thanks in advance!

Image[/quote]

pipfromslitherine
Site Admin
Site Admin
Posts: 9248
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to fix minefield issues?

Post by pipfromslitherine » Tue Sep 06, 2016 3:24 pm

I am not sure of the specific logic for minefields, but it can be changed (IIRC) by overriding the DATA/OBJECTS/SYSTEM/OBJECTS.BSF script for the minefield function, which determines what should happen when a unit moves onto a minefield.

Cheers

Pip
follow me on Twitter here

Schweinewitz
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 255
Joined: Wed Feb 23, 2011 6:51 pm
Location: Münster, Germany

Re: How to fix minefield issues?

Post by Schweinewitz » Tue Sep 06, 2016 6:32 pm

Hello Pip!

Here's the code:

Code: Select all

FUNCTION minefield(objectid, tilex, tiley, objectx, objecty, check, user, unit)
{
	int id;
	int i;
	int exp;
	int suppressionDamage;
	int morale;
	
	if( check != 0 )
	{
		if( GetUnitSide(unit) == 0 )
		{
			if (tilex == objectx && tiley == objecty)
			{
				return 2 ;
			}
			else
			{
				// the next step in the unit's path will run them over a mine, reacting will give player a chance to pick a new route
				if (GetRouteNextX(unit) == objectx && GetRouteNextY(unit) == objecty)
				{
					return 1 ;
				}
			}
		}
		return -1 ;
	}
	else
	{
		// is the unit on our tile?
		if( (tilex == objectx && tiley == objecty ) && (GetUnitSide(unit) == 0) )
		{
		
			//is the unit an engineer unit?
			if ( CanUnitDisarmMines(unit) == 1 )
			{
				if (IsUnitSquadType(unit, "INFANTRY") == 1)
				{
					SetAttrib(unit, "AP", 0);
				}
				else
				{
					AddVizFunctionCall("PlaySFX", tilex, tiley, 57) ;
					PlayUISFX(75);
					AddVizUnitSpotAnim(unit, 255, "bang", 4, 0) ;
				}
				DeleteObject(objectid);
				
				AddVizDelay(10) ;
				if ( GetShowSide() == GetCurrentSide() )
				{
					AddVizFunctionCall("GetHeadImage", GetCurrentSide(), "BP0Image:", 13) ; 
					AddVizFunctionCall("ShowUIScreen", "BattlePop0", "Anim1", "IDS_MINECLEAR", GetWorkString(13)) ;
				}
			}
			//the unit is not an engineer, there is chance it gets destroyed
			else
			{
				if (Rand(0,100)>=25);
				{
				
					if(GetAttrib(unit, "Blocking")==0)
					{
						
						SetAttrib(unit, "AP", 0);
						suppressionDamage = HE_Attack ( -1, unit, 74, tilex, tiley, 74, 4, 57, 1 );
						MoraleUpdate (unit, -1, suppressionDamage);
						//morale = GetAttrib(unit, "morale");
						//morale = morale - suppressionDamage;
						//SetAttrib(unit, "morale",morale);
					}
					else
					{
						
						AddVizFunctionCall("PlaySFX", tilex, tiley, 57) ;
						PlayUISFX(75);
						AddVizUnitSpotAnim(unit, 255, "bang", 4, 0) ;
						KillUnit(unit, 255) ;
						DamageTile(tilex, tiley, 50);
					}
					
					AddVizDelay(10) ;
					if (GetShowSide() == GetCurrentSide() ) 
					{
						AddVizFunctionCall("GetHeadImage", GetCurrentSide(), "BP0Image:", 13) ; 
						AddVizFunctionCall("ShowUIScreen", "BattlePop0", "Anim1", "IDS_MINE", GetWorkString(13)) ;
					}
				}
			}
		}
		return 0 ;
	}
}
The fundamental question is: "What is to be done?" (Lenin) :mrgreen:

The line that attracs my attention is:

Code: Select all

{
		// is the unit on our tile?
		if( (tilex == objectx && tiley == objecty ) && (GetUnitSide(unit) == 0) )
Hm. Which side is "our"? AFAIK the basic setting is 0 = Soviet, 1 = Axis. Has it something to do with that?

Some other questions:

Can this code here be changed that mines are dangerous to both sides? And: Has the Kursk campaign been fixed? If yes, where can the relevant script be found?

Any help appreciated!


Regards,

S.

pipfromslitherine
Site Admin
Site Admin
Posts: 9248
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to fix minefield issues?

Post by pipfromslitherine » Tue Sep 06, 2016 7:14 pm

We have not made any changes since the last patch. You are correct that the logic means mines only effect the player side (side 0 in single player is always the player side).

Cheers

Pip
follow me on Twitter here

Schweinewitz
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 255
Joined: Wed Feb 23, 2011 6:51 pm
Location: Münster, Germany

Re: How to fix minefield issues?

Post by Schweinewitz » Tue Sep 06, 2016 7:31 pm

So there's no solution for the problem. That's unfortunate, it restricts the possibilities of scenario creation considerably.

pipfromslitherine
Site Admin
Site Admin
Posts: 9248
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to fix minefield issues?

Post by pipfromslitherine » Tue Sep 06, 2016 9:11 pm

Not sure what you mean - you can change the script (by creating your own object set for your campaign) to function in whatever way you like.

Cheers

Pip
follow me on Twitter here

Schweinewitz
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 255
Joined: Wed Feb 23, 2011 6:51 pm
Location: Münster, Germany

Re: How to fix minefield issues?

Post by Schweinewitz » Wed Sep 07, 2016 3:35 am

Sorry, now I'm really confused. You said that "the logic means mines only effect the player side" but not that it is possible to change that in a way that both sides (player and AI) are affected by mines.

If so, how can I change it?


EDIT:

For clarification: I'm working on a campaign in which both sides are using mines.

pipfromslitherine
Site Admin
Site Admin
Posts: 9248
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to fix minefield issues?

Post by pipfromslitherine » Wed Sep 07, 2016 2:39 pm

You would create your own objects set in your campaign (e.g. by copying the SYSTEM folder into a newly named folder). Then you can edit the script (specifically the minefield function) to execute whatever logic you wish (e.g. you could add a data value to the mine objects when you lay them down to determine which side they should affect, or both, etc).

Cheers

Pip
follow me on Twitter here

Schweinewitz
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 255
Joined: Wed Feb 23, 2011 6:51 pm
Location: Münster, Germany

Re: How to fix minefield issues?

Post by Schweinewitz » Wed Sep 07, 2016 3:04 pm

Ok, now I get it, that sounds like a good solution. I will first try to create a new set of mines by duplicating the System folder. I'll report the results here.

Thank you very much! :)

Schweinewitz
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 255
Joined: Wed Feb 23, 2011 6:51 pm
Location: Münster, Germany

Re: How to fix minefield issues?

Post by Schweinewitz » Thu Sep 08, 2016 9:19 am

Ok, so I duplicated the System folder, renamed it System_de_Selby (for some reason) and put it into my campaign's Objects folder.

I opened OBJECTS.BSF and went to:

Code: Select all

{
      // is the unit on our tile?
      if( (tilex == objectx && tiley == objecty ) && (GetUnitSide(unit) == 0) )
I changed the 0 into 1.

The new System folder actually appears in the editor. In the scenario I'd choosen for testing I placed a Soviet unit on the map and surrounded it with the new de Selby mines. Placed other minefileds as well to try my luck with Axis units too.

During the test scenario I moved one of my units into a minefields. Nothing happened. That's a good sign. At least I thought so.

During the Allied turn the Soviet unit moved upon a mine. No explosion, nothing. - So changing the single value is not enough to achieve a side 1 killing minefield.

I went back to the script in the .BSF file, changed several entries from 0 to 1, same result.

I certainly do not understand enough of scripting to find a solution soon but will continue experimenting. For now I will not use the new mines in the winter scenario and replace them with wires or else instead so that I can continue building further scenarios that I have in mind.

pipfromslitherine
Site Admin
Site Admin
Posts: 9248
Joined: Wed Mar 23, 2005 10:35 pm

Re: How to fix minefield issues?

Post by pipfromslitherine » Thu Sep 08, 2016 3:05 pm

You would need to change both the side check you show, and also the one at the top of the function (inside the if( check != 0 ) block). There is also a chance for mines to not go off (the if (Rand(0,100)>=25) check).

Hope that helps!

Cheers

Pip
follow me on Twitter here

Schweinewitz
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 255
Joined: Wed Feb 23, 2011 6:51 pm
Location: Münster, Germany

Re: How to fix minefield issues?

Post by Schweinewitz » Thu Sep 08, 2016 6:26 pm

Yes, now the new mines are working! :D

Thanks, Pip!

Post Reply

Return to “Battle Academy 2: Modders Corner”