Unit Switching Sides --- Capture

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Unit Switching Sides --- Capture

Post by Merr »

Moved over from JAPAN thread ....
pipfromslitherine wrote:Assuming you are using the standard Functions.BSF code, then a unit sitting on the tile should switch the side to that unit's side. It will then stay that way until the other side should capture it.

CHeers

Pip
I'm not using the standard Functions.BSF code .... Which function does this? I've looked :cry:

To capture a unit (switch sides) .... I'm using a modified BullDoze :

Code: Select all

FUNCTION ALL_CAPTURE(me, unit, tilex, tiley)
{
int ap ;
int effectX ;
int effectY ;
//int p ;

	effectX = tilex * 100 ;
	effectY = tiley * 100 ;
	effectX += 50 ;
	effectY += 50 ;

//	AddVizSpotAnim(effectX, effectY, "wreck_clearing", 0, 0) ;
	AddVizUnitText(unit, "IDS_UNIT_CAPTURE", "ffffff", 1) ;
	DestroyUnit(unit, 255) ;
	RemoveUnit(unit, 2) ;
	AddUnit(tilex,tiley,0,"Surrender_brit") ;
//	p = GetUnitOnTile(tilex,tiley) ;
//	SetAttrib(unit,"AP",8) ;
	
	// stop me firing and bulldozing
	//SetAttrib (me, "Shots", 0) ;
	
	// reduce AP 
	ap = GetAttrib (me, "AP") ;
	ap -= CHECK_ALL_CAPTURE (me, unit, tilex, tiley) ;
	SetAttrib (me, "AP", ap) ;
}
The DestroyUnit causes the extra casualty... as you know :wink:
pipfromslitherine
Site Admin
Site Admin
Posts: 9898
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

I think there is some miscommunication happening here. My comment is regarding Victory Points and how they change hands.

Switching unit sides is not really something that is supported - your approach of killing off the first unit and rebuilding is probably the only way to do it. But the casualty issue is a fair one. I will see if there is a simple way to avoid it.

Cheers

Pip
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr »

pipfromslitherine wrote:I think there is some miscommunication happening here. My comment is regarding Victory Points and how they change hands.

Switching unit sides is not really something that is supported - your approach of killing off the first unit and rebuilding is probably the only way to do it. But the casualty issue is a fair one. I will see if there is a simple way to avoid it.

Cheers

Pip
:oops: my bad .... No worries on casualty issue ... War isn't pretty, neither should the casualty report!
pipfromslitherine
Site Admin
Site Admin
Posts: 9898
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

Having a flag for a unit to tell the code not to count it as a casualty shouldn't be too tricky. I just need to make sure it doesn't impact anything that I rely on for other things :)

Cheers

Pip
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr »

pipfromslitherine wrote:Having a flag for a unit to tell the code not to count it as a casualty shouldn't be too tricky. I just need to make sure it doesn't impact anything that I rely on for other things :)
Hmmm, an interesting brain fart on your end 8)

It might be an ugly smell if I can't carry the prisoner back ... however, the prisoner can be given AP's and he'll have to fend for himself.
This won't be a problem with normal units that are "trapped" and then "released".

Good thinking .... Holler at us if you got something to try out, or you can point in that general direction and I'll try to follow.

As always ... please don't let this distract you from other priorities ... I'm more than happy to be at the end of the cue.
pipfromslitherine
Site Admin
Site Admin
Posts: 9898
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

It was pointed out to me that strictly you don't need to destroy a unit to make it vanish - using just RemoveUnit will remove it from play without affecting the results score.

Cheers

Pip
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr »

pipfromslitherine wrote:It was pointed out to me that strictly you don't need to destroy a unit to make it vanish - using just RemoveUnit will remove it from play without affecting the results score.

Cheers

Pip
Ok ... cool ... I'll try that ...

On another note .... I had an idea using globals ... like VP's but it randomly selects a "gVPX and vVPY" ...
In the TICKS .... I use the same code for VP (end battle), but instead of being ON the tile, it checks for tiles ADJACENT to vpX and vpY. This will call a PlaceUnit and plop the prisoner on the x,y. However, additional code has to be written to check for the prisoner on the map, otherwise being next to the X,Y will open a flood gate of Prisoners ... not bad if you release more than one prisoner from his shackles!

Anyway, it's an idea for later use ... perhaps something completely different ... Monty Python style :wink:
Post Reply

Return to “Battle Academy : Modders Corner ”