3UC/4UC for VP: Project Coordination Thread

Status
Not open for further replies.
One before latest. 1-26.
 
So I can't debug it, different DLL.
I've got a CTD on the 1st turn. Could be the same reason.
Basically the problem is with IsWithinDistanceOfUnit(). It is called somewhere within UnitSetXY event and the plot where this unit is supposed to be is non-existent (NULL). It crashes the game then.

There are many calls to IsWithinDistanceOfUnit(), I can't say which one is problematic. The correct syntax for this function is:
Code:
IsWithinDistanceOfUnit(UnitTypes eOtherUnit, int iDistance, bool bIsFriendly, bool bIsEnemy)
I've noticed 1 call that uses promotion type instead of unit type (Goedendag).
Also 0 as distance (Shophet, Ballista, Sofa, Goedengad)? What's the point? Nothing is within 0 distance.

The whole set is as follows:
Code:
bool IsWithinDistanceOfUnit(UnitTypes eOtherUnit, int iDistance, bool bIsFriendly, bool bIsEnemy) ;
bool IsWithinDistanceOfUnitClass(UnitClassTypes eUnitClass, int iDistance, bool bIsFriendly, bool bIsEnemy) ;
bool IsWithinDistanceOfUnitCombatType(UnitCombatTypes eUnitCombat, int iDistance, bool bIsFriendly, bool bIsEnemy) ;
bool IsWithinDistanceOfUnitPromotion(PromotionTypes eUnitPromotion, int iDistance, bool bIsFriendly, bool bIsEnemy) ;
bool IsAdjacentToUnit(UnitTypes eOtherUnit, bool bIsFriendly, bool bIsEnemy) ;
bool IsAdjacentToUnitClass(UnitClassTypes eUnitClass, bool bIsFriendly, bool bIsEnemy) ;
bool IsAdjacentToUnitCombatType(UnitCombatTypes eUnitCombat, bool bIsFriendly, bool bIsEnemy) ;
bool IsAdjacentToUnitPromotion(PromotionTypes eUnitPromotion, bool bIsFriendly, bool bIsEnemy) ;
 
0 distance is unit on the same tile. Like GG or other unit (with mods allowing use of more than 1 unit per tile).

I fixed (Beta Branch) Goedendag file. It was looking for dead unit and checking it with WithinDistance fuction.

Now it is something else. After few turns it crashed me. Now I started another game and everything works fine.
 
Ok, I can explain that one more time. Unit set XY is needed. Without a doubt. It reacts on building or creating unit BUT it is triggered before unit gets its PROMOTIONS. We track promotions in lua to check if unit is one we are looking for so we need UnitBuild and UnitCreate to track promotions. Those are triggered in different situations. UnitTrained is not triggered when CS gifts unit, when you get worker from policy etc. So we will have 3 possible outcomes:
  • unit moves - UnitSetXY
  • unit is trained - UnitSetXY, UnitTrained
  • units is given from somewhere - UnitSetXY, UnitCreated.
I cannot do that using only setXY. I tried, but those are needed. You said tht changing in dll is not possible so I left that as it was before our github conversation about that. I closed issue because no one posted message there for long time. I thought it was explained.
 
Last edited:
It is: unit is trained - UnitSetXY, UnitCreated, UnitTrained for trained units.

The outcome is ONE and depends on what you want to track - movement, creation or city traning. You don't need multiple calls to those functions, only ONE depending on situation.

Btw, you check for promotion PROMOTION_UNIT_AMERICA_MONITOR and I think the idea is the unique unit itself grants benefits, right? It should be checked against the unit type then.
 
But promotions stay after upgrade so tracking unit type won't work.
 
But analyze goedendag. It gives nd takes buffs from unit.
  • When goedendag moves to unit or unit moves to goedendag, then we need to track that (UnitSetXY).
  • When you train Goedendag in the city after researchng it then we need to check all units around it (UnitTrained)
  • When you train unit you need to check if Goedendag is around the city (UnitTrained - SetXY won't work)
  • You made militaristic CS ally. It gave you goendendag - its special unit. You need to track all units around new Goedendag (Unitcreated - SetXY won't work)
I cannot choose what event is triggered. So I need to put all 3 to be sure every situation is fullfiled.

Are you 100% sure that Unit created is triggered on unit training? I believe it's not, I checked that. But I can do that again to be sure. Then UnitTrained wouldn't be needed.
 
updated civ5project file with art, sql, xml, lua with proper attributions

I realize now that the sofa promotion that I have coded is lost on promotion because it is tied to the unitType, not the promotion. I'll have to fix that

I believe the teutonic order description I have written is accurate
  • the chapter promotion uses the same SQL as the statue of Zeus wonder; it should immediately give all valid units the promotion once the TO is built
  • the Morale promotion is given to trained units via a dummy building which is build in every city immediately on completion of a barracks, and given to all cities with an existing barracks on completion of the TO. This should give Morale to all future trained units in any city with a barracks, but not to existing units
I believe what I have described is consistent with the code, as it is currently implemented, and consistent with the text description I have witten
 
Morale is given to all units. When I build TO my current scout also got that one. It is inherited ability from SQL so description is wrong. TrainedFreePromotion means all units trained (before and after) in the city.
 
But analyze goedendag. It gives nd takes buffs from unit.
  • When goedendag moves to unit or unit moves to goedendag, then we need to track that (UnitSetXY).
  • When you train Goedendag in the city after researchng it then we need to check all units around it (UnitTrained)
  • When you train unit you need to check if Goedendag is around the city (UnitTrained - SetXY won't work)
  • You made militaristic CS ally. It gave you goendendag - its special unit. You need to track all units around new Goedendag (Unitcreated - SetXY won't work)
I cannot choose what event is triggered. So I need to put all 3 to be sure every situation is fullfiled.

Are you 100% sure that Unit created is triggered on unit training? I believe it's not, I checked that. But I can do that again to be sure. Then UnitTrained wouldn't be needed.

Same as with Monitor - check for unit type...

Anyway I would rather propose more drastic idea and try to rationalize those calls. This is a turn-based game. I am not sure that you have to track everything that happens within your turn because most of it doesn't affect other players. What matters are final decisions - last position, attack, etc. Maybe using PlayerDoTurn or PlayerEndTurnCompleted would solve all those problems.
 
It was done that way in VP too. We analyzed that and made all UU have some of their unque abilities stay after upgrade. Only very OP ones or promos which wouldn't fit to them (like spear ability to sword) are lost.
 
@Infixo it is more common in VP for unique traits and promotions to carry forward on units than not. There are not very many cases of promotions which are lost on upgrade; the only 2 that come to mind are legion and Atlatlist

I just tested out my merge.
Inca Chasqui doesn't appear. something wrong there
Rolling over the tambo's text causes the game to freeze (text error)
Turtle ship text was not overwritten as intended Fixed

It is possible that this is caused by my file merge of renamed directories not actually deleting the old directories, causing conflicts.

I'll see what we can do w.r.t. the moral promotion thing. I don't think we want it to be giving units promotions retroactively, right? if that is how it is working then something's no good
 
Last edited:
PlayerEndTurnCompleted is working only for HUMAN players I believe.
PlayerDoTurn is bad. You set your unit in right place, no bonus is added during AI turns, then you need to move your unit and bonus is wasted.
 
Are you 100% sure that Unit created is triggered on unit training? I believe it's not, I checked that. But I can do that again to be sure. Then UnitTrained wouldn't be needed.
This is custom event. You need to enable it:
Code:
UPDATE CustomModOptions SET Value = 1 WHERE Name = 'EVENTS_UNIT_CREATED';
 
This is custom event. You need to enable it:
Code:
UPDATE CustomModOptions SET Value = 1 WHERE Name = 'EVENTS_UNIT_CREATED';
I did. I will check that tomorrow again. Then simplify code if needed.

@pineappledan But do not change anything in Germany until I merge it. Otherwise there will be conflicts.
 
Status
Not open for further replies.
Back
Top Bottom