Page 2 of 8

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 5:27 pm
by GottaLove88s
What sounds are you using when the engineer removes the trees, hedgerow or tank traps?
Could you add an explosion sound and animation? To show demolition at work...
Also, it shouldn't come as a total surprise to the enemy...
What do you think?

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 5:29 pm
by Amaris
GottaLove88s wrote:YAY!! You make awesome icons... I'm sure you can knock up a Tank Trap icon in your sleep! (remember, I've seen your aircraft icons from NAM! )
Sorry to destroy a legend but I DON'T DRAW THIS AIRCRAFT ICONS! I stole them into the game War In The Pacific. :oops:
GottaLove88s wrote:Removing hedge immediately in front of the unit would toootally solve my problem...
I try it. Without warranty. :mrgreen:

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:03 pm
by GottaLove88s
Ahem, let me rephrase then... You recreate awesome icons... Replication being one of the highest compliments, naturally! ;-)

Guarantee not required. Believe me, if your code permits our Tourney guys to successfully remove hedge even 50% of the time, some of 'em would willingly mow your lawn, clean your car, heck, from the gripes I'm hearing, maybe even have your children... They're desperate, lol...

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:04 pm
by GottaLove88s
But, no, recalling your previous requests... I don't believe that any are millionaires with a free iPad to give to you, lol (I will check tho! 8) )

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:10 pm
by GottaLove88s
No pressure, monsieur, but I've advertised your exciting activities... viewtopic.php?f=115&t=39693&p=389136#p389136
We await with baited breath (hand grenades at the ready)

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:22 pm
by Amaris
Cut a hedge:

Image
Image
Image
Image

It does not work in the corners: The unit should be in front of the hedge to destroy.

It should also improve the script.
The GetUnitFacing() return the unit facing angle but returned values ​​are not always the same for the same unit's orientation (0 or 16 for example) :shock:

That's all for today. :P

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:37 pm
by GottaLove88s
May I have the code... SVP, SVP...??? :shock:

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:51 pm
by Amaris
Alrights but this is the primitive test!

TERRAFORM.BSF:

Code: Select all

FUNCTION ALL_TERRAFORM(me, tilex, tiley)
{
int tuilex;
int tuiley;
int id;
int count;
int object;

	tuilex = GetUnitX(me);
	tuiley = GetUnitY(me);
	
	id = GetTileID("MoreTiles", "Tile1") ;

	AddVizText(tuilex, tuiley, "IDS_TT_TERRAFORM", "ffffff");
	
	PlaceTile(tuilex, tuiley, id, 0);
	
	for (count = 100 ; count >= 0; count--)
	{
		object = GetTileObject(tuilex, tuiley, count);
		
		//Log("Object:", object);
		
		if (object != -1)
		{	
			if (IsObjectName(object, "tree") == 1)
			{			
				DeleteObject(object);
			}
			if (IsObjectName(object, "tree1") == 1)
			{			
				DeleteObject(object);
			}
			if (IsObjectName(object, "tree2") == 1)
			{			
				DeleteObject(object);
			}
			if (IsObjectName(object, "tree3") == 1)
			{			
				DeleteObject(object);
			}	
			if (IsObjectName(object, "tree4") == 1)
			{			
				DeleteObject(object);
			}
			if (IsObjectName(object, "TREE_BLOCKING") == 1)
			{			
				DeleteObject(object);
			}			
		}

	}
	
	SetAttrib(me, "AP", 0);
}

FUNCTION CHECK_ALL_TERRAFORM(me, tilex, tiley) 
{
int ret ;
int id;
int id2;
int id3;
int tuilex;
int tuiley;

	ret = -2 ;
	
	tuilex = GetUnitX(me);
	tuiley = GetUnitY(me);
	
	if ((tuilex == tilex) && (tuiley == tiley))
	{	
		if ((IsUnitType(me, "us_engineer") == 1) && (IsUnitValid(me) == 1))
		{
			id = GetTileOnTile(0, tuilex, tuiley);
			
			id2 = GetTileID("MoreTiles", "Tile8") ;
			id3 = GetTileID("MoreTiles", "Tile9") ;
			
			if ((id == id2) || (id == id3))
			{
				if (GetAttrib(me, "AP") == GetBaseAttrib(me, "AP"))
				{
					ret = 1;
				}
			}
		}
	}
	
	return ret ;
}

FUNCTION UISETUP_ALL_TERRAFORM()
{
	StartString() ;
	PrintString("IDS_TT_TERRAFORM") ;
	
	SetUITooltip(); 
	
	SetUITexture("action_terraform", "ffffffff") ;
}


FUNCTION UIBUTTON_ALL_TERRAFORM(me, x,y,width, height, tilex, tiley)
{
	


	//RenderVCenteredString(x,y,width,height,10,1,"ff000000") ;
}
TANKTRAP.BSF:

Code: Select all

FUNCTION ALL_TANKTRAP(me, tilex, tiley)
{
int count;
int object;

	
	AddVizText(tilex, tiley, "IDS_TT_TANKTRAP", "ffffff");
	
	for (count = 0 ; count < 100; count++)
	{
		object = GetTileObject(tilex, tiley, count);	
		
		if (IsObjectName(object, "TANKTRAPS") == 1)
		{
			DeleteObject(object);
			count = 101;
		}
	}
	
	SetAttrib(me, "AP", 0);
}

FUNCTION CHECK_ALL_TANKTRAP(me, tilex, tiley) 
{
int ret ;
int tuilex;
int tuiley;
int object;
int count;

	ret = -2 ;
	
	tuilex = GetUnitX(me);
	tuiley = GetUnitY(me);
	
	if (GetDistanceBetweenTiles(tilex, tiley, tuilex, tuiley) > 1)
	{
		return ret;
	}
	
	if ((IsUnitType(me, "us_engineer") == 1) && (IsUnitValid(me) == 1))
	{
		for (count = 0 ; count < 100; count++)
		{
			object = GetTileObject(tilex, tiley, count);	
			
			if (object != -1)
			{
				if (IsObjectName(object, "TANKTRAPS") == 1)
				{
					if (GetAttrib(me, "AP") == GetBaseAttrib(me, "AP"))
					{
						ret = 1;
					}
				}
			}
		}
	}
	
	return ret ;
}

FUNCTION UISETUP_ALL_TANKTRAP()
{
	StartString() ;
	PrintString("IDS_TT_TANKTRAP") ;
	
	SetUITooltip(); 
	
	SetUITexture("action_tanktrap", "ffffffff") ;
}


FUNCTION UIBUTTON_ALL_TANKTRAP(me, x,y,width, height, tilex, tiley)
{
	


	//RenderVCenteredString(x,y,width,height,10,1,"ff000000") ;
}
ADDTRAP.BSF

Code: Select all

FUNCTION ALL_ADDTRAP(me, tilex, tiley)
{
int object;
int orientation;
int tuilex;
int tuiley;

	
	tuilex = tilex * 100 ;
	tuiley = tiley * 100 ;
	
	tuilex = tuilex + 50;
	tuiley = tuiley + 50;
	
	AddVizText(tuilex, tuiley, "IDS_TT_ADDTANKTRAP", "ffffff");
	
	object = PlaceObject(tuilex, tuiley, "Test", "TankTraps");
	
	Log("Object:", object);
	
	// orientation = GetObjectRotation(me);
	
	// SetObjectRotation(object, 0) ;
	
	SetAttrib(me, "AP", 0);
}

FUNCTION CHECK_ALL_ADDTRAP(me, tilex, tiley) 
{
int ret ;
int tuilex;
int tuiley;
int object;
int count;

	ret = -2 ;
	
	tuilex = GetUnitX(me);
	tuiley = GetUnitY(me);
	
	if (GetDistanceBetweenTiles(tilex, tiley, tuilex, tuiley) > 1)
	{
		return ret;
	}
	
	
	
	if ((IsUnitType(me, "us_engineer") == 1) && (IsUnitValid(me) == 1))
	{
		ret = 1;
	
		for (count = 0 ; count < 100; count++)
		{
			object = GetTileObject(tilex, tiley, count);	
			
			if (object != -1)
			{
				if (IsObjectName(object, "TANKTRAPS") == 1)
				{
					ret = -2;
				}
			}
		}
	}
	
	return ret ;
}

FUNCTION UISETUP_ALL_ADDTRAP()
{
	StartString() ;
	PrintString("IDS_TT_ADDTANKTRAP") ;
	
	SetUITooltip(); 
	
	SetUITexture("action_tanktrap", "ffffffff") ;
}


FUNCTION UIBUTTON_ALL_ADDTRAP(me, x,y,width, height, tilex, tiley)
{
	


	//RenderVCenteredString(x,y,width,height,10,1,"ff000000") ;
}
CUTHEDGEDROW.BSF:

Code: Select all

FUNCTION ALL_CUTHEDGEDROW(me, tilex, tiley)
{
int object;
	
	AddVizText(tilex, tiley, "IDS_TT_CUTHEDGEDROW", "ffffff");

	object = GetGlobal("Del_Hedge");
	
	Log("Object:", object);
	
	DeleteObject(object);
	
	SetAttrib(me, "AP", 0);
}

FUNCTION CHECK_ALL_CUTHEDGEDROW(me, tilex, tiley) 
{
int ret ;
int id;
int id2;
int id3;
int tuilex;
int tuiley;
int count;
int object;
int UnitFace;
int xd;
int yd;
int ux;
int uy;
int flag;

	ret = -2 ;
	flag = 0;
	
	tuilex = GetUnitX(me);
	tuiley = GetUnitY(me);
	
	UnitFace = GetUnitFacing(me);
	
	Log("UnitFace:", UnitFace);
	
	if (GetDistanceBetweenTiles(tilex, tiley, tuilex, tuiley) > 1)
	{
		return ret;
	}
	
	if ((IsUnitType(me, "us_engineer") == 1) && (IsUnitValid(me) == 1))
	{
		for (count = 0 ; count < 100; count++)
		{
			object = GetTileObject(tilex, tiley, count);	
			
			if (object != -1)
			{
				if (IsObjectName(object, "hedgrow2") == 1)
				{
					if (UnitFace == 0)
					{
						xd = GetObjectPositionX(object);
						yd = GetObjectPositionY(object);
						
						// Log("Hedge:", xd, yd);						
						
						ux = tilex * 100;
						uy = tiley * 100;
						
						ux = ux + 50;
						
						// uy = uy + 50;
						
						Log("Need:", ux, uy);
						
						if ((xd == ux) && (yd == uy))
						{
							flag = 1;
							SetGlobal("Del_Hedge", object);
							
							// Log("Object:", object);
							count = 101;
						}						
					}
				
					if (UnitFace == 90)
					{
						xd = GetObjectPositionX(object);
						yd = GetObjectPositionY(object);
						
						// Log("Hedge:", xd, yd);						
						
						ux = tilex * 100;
						uy = tiley * 100;
						
						uy = uy + 50;
						
						// uy = uy + 50;
						
						Log("Need:", ux, uy);
						
						if ((xd == ux) && (yd == uy))
						{
							flag = 1;
							SetGlobal("Del_Hedge", object);
							
							// Log("Object:", object);
							count = 101;
						}						
					}

					if (UnitFace == 180)
					{
						xd = GetObjectPositionX(object);
						yd = GetObjectPositionY(object);
						
						// Log("Hedge:", xd, yd);						
						
						ux = tilex * 100;
						uy = tiley * 100;
						
						ux = ux - 50;
						
						// uy = uy + 50;
						
						Log("Need:", ux, uy);
						
						if ((xd == ux) && (yd == uy))
						{
							flag = 1;
							SetGlobal("Del_Hedge", object);
							
							Log("Object:", object);
							count = 101;
						}						
					}

					if (UnitFace == 270)
					{
						xd = GetObjectPositionX(object);
						yd = GetObjectPositionY(object);
						
						// Log("Hedge:", xd, yd);						
						
						ux = tilex * 100;
						uy = tiley * 100;
						
						uy = uy - 50;
						
						// uy = uy + 50;
						
						Log("Need:", ux, uy);
						
						if ((xd == ux) && (yd == uy))
						{
							flag = 1;
							SetGlobal("Del_Hedge", object);
							
							// Log("Object:", object);
							count = 101;
						}						
					}					
				
				

				}
			}
		}
	}
	
	if (flag == 1)
	{
		if (GetAttrib(me, "AP") == GetBaseAttrib(me, "AP"))
		{
			ret = 1;
		}	
	}
	
	return ret ;
}

FUNCTION UISETUP_ALL_CUTHEDGEDROW()
{
	StartString() ;
	PrintString("IDS_TT_CUTHEDGEDROW") ;
	
	SetUITooltip(); 
	
	SetUITexture("action_terraform", "ffffffff") ;
}


FUNCTION UIBUTTON_ALL_CUTHEDGEDROW(me, x,y,width, height, tilex, tiley)
{
	


	//RenderVCenteredString(x,y,width,height,10,1,"ff000000") ;
}

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:55 pm
by GottaLove88s
WOW!! Un grand merci

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 6:56 pm
by GottaLove88s
Quickly looking at the terraform code, will it still work if the square contains, say a British sealion tree 2 and a French blocking tree? I often mix multiple tree types to achieve different colours and patterns... :-)

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 7:09 pm
by GottaLove88s
Forgive the coding fool's question, but how do I modify this so it will work for british_engineer OR german_engineer

if ((IsUnitType(me, "us_engineer") == 1) && (IsUnitValid(me) == 1))

Pls may I sneak a look at the full scenario folder for this mod to see all of the moving parts?

Re: Adding new functionality to engineers...?

Posted: Fri Mar 15, 2013 7:11 pm
by GottaLove88s
Does Terraform also change the Tile type from Forest to Grass, as well as remove the trees?

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 8:53 am
by Amaris
GottaLove88s wrote:Quickly looking at the terraform code, will it still work if the square contains, say a British sealion tree 2 and a French blocking tree? I often mix multiple tree types to achieve different colours and patterns... :-)
No, the script is very simple! It only removes the trees of French tileset for now. But it can do if we change accordingly.
Make me a list of ALL items to be deleted and I will.
And I also have found the source of those nasty warnings!

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 9:02 am
by GottaLove88s
Theoretically, trees to be removed could include 2-3 per square of...

French trees 1 to 4
French blocking tree
British trees 1 to 4
British blocking tree
Palm trees (so we can use it on the big pacific islands, I'm sure you're working on! ;-)
Desert blocking tree

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 9:04 am
by GottaLove88s
Hedgerows to be removed could be from French or British object sets (does BA differentiate?)

They're often accompanied to stone wall or desert stone wall... For nice visuals for fortresses

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 9:04 am
by Amaris
GottaLove88s wrote:Forgive the coding fool's question, but how do I modify this so it will work for british_engineer OR german_engineer

if ((IsUnitType(me, "us_engineer") == 1) && (IsUnitValid(me) == 1))
I'm lazy coder. :oops:
I just do this to test to see if this is possible.
Then it's possible.
So I have a new 'project'!

If you want this for german, british and other engineer, the script must be completed.
Must be replaced:

Code: Select all

if ((IsUnitType(me, "us_engineer") == 1) && (IsUnitValid(me) == 1))
{
    ....
}
by:

Code: Select all

if (IsUnitValid(me) == 1)
{
    if ((IsUnitType(me, "us_engineer") == 1) || (IsUnitType(me, "uk_engineer") == 1) || (IsUnitType(me, "german_engineer") == 1))
    {
        ...
    }
}
GottaLove88s wrote:Pls may I sneak a look at the full scenario folder for this mod to see all of the moving parts?
Alrights. I'll put it on my site.

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 9:05 am
by GottaLove88s
What was causing the warnings?

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 9:08 am
by GottaLove88s
Can we add an explosion sound when the demolition executes? (A mortar type animation in the target square, before removing the tree/tank trap/hedgerow, would be über nice too, but you've created A LOT already :-))

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 9:08 am
by Amaris
GottaLove88s wrote:Does Terraform also change the Tile type from Forest to Grass, as well as remove the trees?
Of course! :roll:

US engineer is on Forest tile (without tree):
Image

After the are on an open ground tile:
Image

Re: Adding new functionality to engineers...?

Posted: Sat Mar 16, 2013 9:09 am
by GottaLove88s
Ps. Bonjour Monsieur! How's the Côte d'Azur?
There's a screaming cold wind and 2m waves frothing, here in Sussex...