RIGHT, here's me hacking the SDK.
in CvUnit.cpp, took out all the work in the function at 10501-> so it looks like:
Every unit in the plot, friend or foe, will be booted out.
This works as I expected.
So, there must be something wrong in the rest of it. Can I see if I have the logic right?
Check each unit in the plot our newunit is being moved to (loopunit).
If the loopunit is hostile* to newunit:
- If both units can co-exist@, no action.
- If newunit can capture+ loopunit, capture it.
- If loopunit can capture newunit, capture it. (I don't think this is in at present?)
- Anything else, boot it out of the plot (which may kill it).
If loopunit is not hostile to newunit:
- no action.
* units will be hostile if :
owners are at war; or
unit is always hostile; or
unit is HN and not owned by same player (not sure if this is in at present?)
@ units can co-exist if:
either is invisible to the other; or
either unit has special flag to allow it to coexists with enemy units (?)
+ unit can capture if:
target is a capturable type and potential capturer has the ability to capture; or
target is a piece of equipment, regardless of what potential capturer is.
Is that the whole of the logic? If I can understand that I can try to figure out why what I am trying to do does not work right.
EDIT:
doing more testing. Looks like the
if (!isInvisible(pLoopUnit->getTeam(), false))
line may be the one causing the problem. I'll test some more...
EDIT 2:
yep, tested with the invisibility check in, I get an unidentifable C++ error every time I create a hostile unit in the plot.
EDIT 3:
commented out the works for CvUnit::isInvisible and just made it return False, no error. I think the fault is in this function.
EDIT 4:
int iTemp;
iTemp = (plot()->isInvisibleVisible(eTeam, getInvisibleType()));
when I put these lines into isInvisible I get the error.
anyone got any idea why?
in CvUnit.cpp, took out all the work in the function at 10501-> so it looks like:
Code:
if (pLoopUnit != NULL)
{
// MARNOK
// TEST
pLoopUnit->jumpToNearestValidPlot(); // can kill unit
}
This works as I expected.
So, there must be something wrong in the rest of it. Can I see if I have the logic right?
Check each unit in the plot our newunit is being moved to (loopunit).
If the loopunit is hostile* to newunit:
- If both units can co-exist@, no action.
- If newunit can capture+ loopunit, capture it.
- If loopunit can capture newunit, capture it. (I don't think this is in at present?)
- Anything else, boot it out of the plot (which may kill it).
If loopunit is not hostile to newunit:
- no action.
* units will be hostile if :
owners are at war; or
unit is always hostile; or
unit is HN and not owned by same player (not sure if this is in at present?)
@ units can co-exist if:
either is invisible to the other; or
either unit has special flag to allow it to coexists with enemy units (?)
+ unit can capture if:
target is a capturable type and potential capturer has the ability to capture; or
target is a piece of equipment, regardless of what potential capturer is.
Is that the whole of the logic? If I can understand that I can try to figure out why what I am trying to do does not work right.
EDIT:
doing more testing. Looks like the
if (!isInvisible(pLoopUnit->getTeam(), false))
line may be the one causing the problem. I'll test some more...
EDIT 2:
yep, tested with the invisibility check in, I get an unidentifable C++ error every time I create a hostile unit in the plot.
EDIT 3:
commented out the works for CvUnit::isInvisible and just made it return False, no error. I think the fault is in this function.
EDIT 4:
int iTemp;
iTemp = (plot()->isInvisibleVisible(eTeam, getInvisibleType()));
when I put these lines into isInvisible I get the error.
anyone got any idea why?