3UC/4UC for VP: Project Coordination Thread

Status
Not open for further replies.
Two more hints:
1. I would reconsider using names like 1.xxx.lua or 2.yyy.lua. Lua is a bit weird, and uses internal flat file system (do dir tree). Then all calls to that file system are actually pattern based. It means that if somebody somewhere will try to be smart and look for extension using dot "." it will get stupid results from that files. You don't have this issue now and it's very rare that it would happen - it's just a precaution for the future.
2. Those calls for unit:IsWithinDistanceXXX check all tiles within specified distance. No need to repeat them for each ring.
 
This will stack. It will check at the bignning of the turn if unit is on it own ground and has promotion, then do simple heal. If unit is fortified there will be second heal at the end of turn.
Why not do something like the yellow brow and have a permanent dummy promotion, then the healing promotion which lua takes on and off, if the Chasqui is in friendly territory? That is what I originally tried to do, and it would prevent odd healing interactions

Code:
include("FLuaVector.lua")

local ePromotionChasqui = GameInfoTypes.PROMOTION_CHASQUI_HEAL_DUMMY

function Chasquiwasi(iPlayer, iUnit)
    local pPlayer = Players[iPlayer]

    if not( pPlayer and pPlayer:IsAlive()) then return end
    for unit in pPlayer:Units() do

        if unit:GetUnitType() == ePromotionChasqui then
            local pPlot = Map.GetPlot(unit:GetX(), unit:GetY())

            if pPlot then
                unit:SetHasPromotion(GameInfoTypes.PROMOTION_CHASQUI_HEAL, (pPlot:GetOwner() == iPlayer))
            end
        end
    end
end

Events.UnitActionChanged.Add(Chasquiwasi)
PROMOTION_CHASQUI_HEAL_DUMMY - placeholder promotion just for lua check, does nothing
PROMOTION_CHASQUI_HEAL - AlwaysHeal = true, HealInFriendlyTerritory = 5 (15 total)
 
so this then?
Code:
include("FLuaVector.lua")

function Chasquiwasi(iPlayer, iUnit)
    local pPlayer = Players[iPlayer]

    if not( pPlayer and pPlayer:IsAlive()) then return end
    for unit in pPlayer:Units() do

        if unit:IsHasPromotion(GameInfoTypes.PROMOTION_CHASQUI_HEAL_DUMMY) then
            local pPlot = Map.GetPlot(unit:GetX(), unit:GetY())

            if pPlot then
                unit:SetHasPromotion(GameInfoTypes.PROMOTION_CHASQUI_HEAL, (pPlot:GetOwner() == iPlayer))
            end
        end
    end
end

Events.UnitActionChanged.Add(Chasquiwasi)

As a quick aside, why did someone add "the" to, like, half the civs' folder names? It makes it so we essentially have 2 mutually exclusive alphabetical lists and it makes it harder to find things
 
Last edited:
As a quick aside, why did someone add "the" to, like, half the civs' folder names? It makes it so we essentially have 2 mutually exclusive alphabetical lists and it makes it harder to find things
Probably because their full English name contains "The". But I would also like to have folder names without "The", easier to look for files.
 
For now I did smth like this:
Code:
include("FLuaVector.lua")

function Chasquiwasi(iPlayer)
    local pPlayer = Players[iPlayer]

    for pUnit in pPlayer:Units() do
        if pUnit:IsHasPromotion(GameInfoTypes.PROMOTION_CHASQUI_HEAL) then
            local pPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY())

            if pPlot:GetOwner() == iPlayer then
                pUnit:ChangeDamage(-5)

                if pPlayer:IsHuman() and pPlayer:IsTurnActive() then
                    local vUnitPosition = PositionCalculator(pUnit:GetX(), pUnit:GetY())

                    Events.AddPopupTextEvent(vUnitPosition, "[COLOR_POSITIVE_TEXT]Chasquiwasi[ENDCOLOR]", 1)
                end
            end
        end
    end
end

function PositionCalculator(i1, i2)
    return HexToWorld(ToHexFromGrid(Vector2(i1, i2)))
end

GameEvents.PlayerDoTurn.Add(Chasquiwasi)
I will push to Github later on. It works well with fortification.

No "the" then. I will revert that.
 
The directory thing isn't a big deal. I just didn't really understand why it was happening. And yeah it makes things take slightly longer to find.

I still think it would be best to tie the chasquiwasi promotion to the promotion itself, instead of having the heal function as a lua event. I think it works better as a sort of modified March promotion, which always gives a heal as if you had fortified that turn, but doesn't stack with fortifying. This keeps Chasqui moving, and makes it so they don't heal faster if they stop moving, so there is no reason to stop moving.

I also don't think it needs a floating text. The green numbers for how much they healed that turn is enough notification
 
@Infixo no errors. It crashes when I go to main menu then when I start game, alt+tab to check what's going on it is frozen.
@pineappledan Renewal Cycle on Holkan had the same floating text so I added it. It is only info where did you get second heal from.

I can add part excluding fortified units.
 
I still think it would be best to tie the chasquiwasi promotion to the promotion itself, instead of having the heal function as a lua event.
I think that healing in general happens at the end of the turn? If so, then it is better to use the promotion for that and leave the rest for the game.
If healing happens at begining of the turn (so, actually before the player is activated) then it is easier and faster to simply run it in PlayerDoTurn.
 
@Infixo no errors. It crashes when I go to main menu then when I start game, alt+tab to check what's going on it is frozen.
Hm... I've noticed along the way that you are using / were using 43civs config? I am running standard config. Anyone else running 43civs here?
 
I found a tiny problem with UnitSetXY event. It is called as a part of unit's death process (delayed death). Problem is that when it is called, the unit's plot is set to NULL, so some functions may cause CTD when called.
This happens with IsWithinDistanceOfUnit() set of functions. I will fix it for Sofa and check if there are more cases like this.
 
No need, I change all such functions into PlayerEndTurnComplete event. I also fix sofa because there's no IsMounted lua function. I lamost finished. Wait please on my push to github before you change something. Now it is your turn. :P
 
@Infixo Ok. I finished my work for today. Ohh, I did almost immediately after you said you want those folders names changed. Sorry. I suppose only you were working on such files.

I finished move/build/create rework, fixed sofa, reworked chasqui and changed those bloody folder names. That was major changes. Some text fixes also.
 
No, India was untouched. I ran lua and IsMounted was not reacting. It is also not visible in wikia. I used db.
 
@Infixo Ok. I finished my work for today. Ohh, I did almost immediately after you said you want those folders names changed. Sorry. I suppose only you were working on such files.
I finished move/build/create rework, fixed sofa, reworked chasqui and changed those bloody folder names. That was major changes. Some text fixes also.
It's ok. I synced everything with no issues. I will check if CTD is gone.
 
I'm surprised :eek2:.
Check Chasqui and change it if it is not good. I think it works well now.
 
Status
Not open for further replies.
Back
Top Bottom