In a reversed imitation of DeletObject(id) in Vaslui,I'm trying to add a bridge during the battle,sth got wrong

Moderator: rbodleyscott

Post Reply
locustmustdie
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 117
Joined: Fri Mar 05, 2021 11:33 am

In a reversed imitation of DeletObject(id) in Vaslui,I'm trying to add a bridge during the battle,sth got wrong

Post by locustmustdie »

Battlescript.txt:

Code: Select all

//add the object at x,y (in 100ths) to the map.  Returns an id for use with other object functions - not constant across game runs. Returns -1 if not valid object
PlaceObject(x, y, objectSet, objectName)
I tried to do this in FUNCTION StartTurn(side)

Code: Select all

            if (GetTurn() == 2)      // ((GetGlobal("vp6") == 0) && (GetUniversalVar("bridgerepaired") == 0))  (GetTurn() == 2) is for testing convenience
                     {
                                    AddVizCam(37,28,0);
                                    PlaceObject(37, 28, "Bridge", "BridgeRiver");
 			            ShowUIScreen("BattlePop0", "Anim1", "IDS_SCN_ORLEANS_BRIDGEREPAIRED");
			            AddVizDelay(30);
                                    SetUniversalVar("bridgerepaired",1);                                 
                     }

Or did I misunderstand that this Function just return a value to test if it is possible to place such a object? Not actualy do it.
then I tried to use this

Code: Select all

PlaceObjectByStyle(37, 28, "NorthernEurope", "BridgeRiver",  "SouthernEurope");
the explainations:

Code: Select all

//place an object from the specified style with the specified name. x and y are in 100ths. If an alternateStyle is specified, it will be used if the primary style does not contain an appropriate object
PlaceObjectByStyle(x, y, style, name, [alternateStyle])
seems correct,but neither does it work.
Does the program permit such order in-battle?
Perhaps I should look into this

Code: Select all

FUNCTION ALL_PLACE_FF(me, tilex, tiley)
{
  int facing;
  int rotation;
  int object;
  int unitX;
  int unitY;
  int x;
  int y;
  int side;
  int type;
  int edge;
  
  side = GetUnitSide(me);
  
  type = gFFStats[side].type;
  edge = 0;
  if (type == 0)
  	{
  		edge = 1;
  	}
  
  SetVisibleUnitCount(me); // Set pre-move visible unit count for Undo purposes.
  ResetMovedLastFlags(side);
  
  unitX = GetUnitX(me);
  unitY = GetUnitY(me);
  
  facing = GetFacing(unitX,unitY,tileX,tileY);
  rotation = GetFFRotation(facing, edge);
  
  if (type == 0) // Ditch (Edge object)
  	{
  		if (facing == 0)
  			{
  				x = (unitX * 100) + 50;
  				y = (unitY * 100) + 100;
  			}

  		if (facing == 90)
  			{
  				x = (unitX * 100) + 100;
  				y = (unitY * 100) + 50;
  			}
 			
  		if (facing == 180)
  			{
  				x = (unitX * 100) + 50;
  				y = unitY * 100;
  			}  			

  		if (facing == 270)
  			{
  				x = unitX * 100;
  				y = (unitY * 100) + 50;
  			}
  	}
  else // Centred object
  	{
		  x = (unitX * 100) + 50;
		  y = (unitY * 100) + 50;
		}
  
  GetFFObjectName(type, 0);

//  object = PlaceObject(x, y, gAdjustableObjectStyle, GetWorkString(0)); 
  object = PlaceObjectByStyle(x, y, gAdjustableObjectStyle, GetWorkString(0), "NorthernEurope"); // vM1.3.2 change
  SetObjectRotation(object, rotation);
  
  SetLocalTileData(tilex, tiley);
  
  gFFStats[side].number -= 1;

	// If stakes replaced by FF, don't keep stakes as well.
	if (GetAttrib(me, "Stakes") == 1)
		{
			SetAttrib(me, "Stakes", 2);
		}  
}
alter the coordination by this way? 3700+50,2800+100 ?
locustmustdie
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 117
Joined: Fri Mar 05, 2021 11:33 am

Re: In a reversed imitation of DeletObject(id) in Vaslui,I'm trying to add a bridge during the battle,sth got wrong

Post by locustmustdie »

Fixed after testings.Its the coordination should be transformed by times 100,+50,+50 to the middle of the tile
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28337
Joined: Sun Dec 04, 2005 6:25 pm

Re: In a reversed imitation of DeletObject(id) in Vaslui,I'm trying to add a bridge during the battle,sth got wrong

Post by rbodleyscott »

locustmustdie wrote: Sat Feb 04, 2023 8:20 am Fixed after testings.Its the coordination should be transformed by times 100,+50,+50 to the middle of the tile
Correct
Richard Bodley Scott

Image
locustmustdie
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 117
Joined: Fri Mar 05, 2021 11:33 am

Re: In a reversed imitation of DeletObject(id) in Vaslui,I'm trying to add a bridge during the battle,sth got wrong

Post by locustmustdie »

As tested,a twisted 90degree object is be like

Code: Select all

       
                                    object=GetTileObject(37, 28, 0);
                                    SetObjectRotation(object, 157); //in radians*100
The animation is one action,not two,or can't be perceived as two,Good!
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28337
Joined: Sun Dec 04, 2005 6:25 pm

Re: In a reversed imitation of DeletObject(id) in Vaslui,I'm trying to add a bridge during the battle,sth got wrong

Post by rbodleyscott »

locustmustdie wrote: Sat Feb 04, 2023 10:50 am As tested,a twisted 90degree object is be like

Code: Select all

       
                                    object=GetTileObject(37, 28, 0);
                                    SetObjectRotation(object, 157); //in radians*100
The animation is one action,not two,or can't be perceived as two,Good!
Or

Code: Select all

object = PlaceObject(...
SetObjectRotation(object, 157); //in radians*100
or

Code: Select all

object = PlaceObjectByStyle(...
SetObjectRotation(object, 157); //in radians*100
That way you don't need to use GetTileObject(...
Richard Bodley Scott

Image
Post Reply

Return to “Field of Glory II: Medieval - Scenario Design”