[English] Hardcoded functions

  • In this thread we can collect hardcoded functions and how they work.


    Today Iearned:


    SpendMoney(Alias, Amount, Reason)


    does work differently for AI dynasties. Instead of losing the full amount of money, they indeed only lose Amount*(0.8-DifficultyLevel*0.1)


    To avoid that you would need to make it so:


    If DynastyIsAI(Alias) then
    SpendMoney(Alias, (Amount*(10/(8-DifficultyLevel))), Reason)
    else
    SpendMoney(Alias, Amount, Reason)
    end

    This was probably done to boost the rather weak AI, but you should really know that to balance things correctly. As it is, this hardcoded change in behavior might actualy lead to money inflation, because on highest difficulty it spawns 60 percent (!) additional money everytime the AI buys something.


    Thus I consider it bad design and a bug

  • Interesting side fact for SpendMoney. The function actually has an undocumented fourth parameter of type Boolean. The 4th parameter defaults to "false".

    Code
    SpendMoney(Target, 1000, "misc", true)

    If set to "true", the money will be spent even if the SIM does not have enough money. Otherwise the money is not spent and the function returns "false".

  • AddEvidence has undocumented parameters.


    Script Docu says:



    But you can add additional aliases (variable, at least 10) to the function to share the evidence


    So you can use it like this:


    AddEvidence("", "Destination", "EvidenceVictim", Evidence, "Destination", "Sim0", "Sim1", "Sim2", "Sim3", "Sim4", "Sim5", "Sim6", "Sim7", "Sim8", "Sim9")


    Remember: it creates one new memory event; all sims will have the same memoryevent. So if that gets to court, it will cleared from all memories


    Note also: it will add with 100% credibility for all Sims

  • Lua
    CityPrepareOfficesToVote("city","OfficeList",false)

    Get a List of offices for a given city and Call it OfficeList.
    With ListSize("OfficeList") we can get the size in a number, so we can use for i=0, ListSize-1 do to go through all of them, check the elements with ListGetElement("OfficeList", i,"Office") (Office is Output-Parameter)

  • Code
    CityGetDynastyCharList("settlement", "assessor_candidates")

    I found this in Trial.lua


    Probably very useful for a lot of AI functions and town statistics, but I am not sure if this gets all family members (at a certain age) or only party members. Need to test this further.

    Edit: Only party members, age 16+ (when they are adults)



    Code
    CityGetDynastyCharList("Settlement", "Dyn_List")
        local lsize = ListSize("Dyn_List")
        LogMessage("City Dyn List is "..lsize)
        for i=0, lsize-1 do
            ListGetElement("Dyn_List", i, "Check_Sim")
            if AliasExists("Check_Sim") then
                LogMessage("DynChar Name "..GetName("Check_Sim"))
            end
        end

    This gets you a full list in the log. Interesting observation: Players are always index 0, and other coloured dynasty follow directly after him, before Shadows are shown.