Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits)

Wow good luck man... Feels like you'll need it.

EDIT: Thanks to your info I managed to do things. I cannot clean the data except manually (there's also data for non animals that is useless!) but I can aboid creating extra useless data.

I found a workaround by limiting the calls to createrelativesdata, first modifying getrelativename:

func getrelativename(person, person2):
    var result = null
    var data1 
    var data2
    if !globals.state.relativesdata.has(person.id) || !globals.state.relativesdata.has(person2.id):
        return null
    else:
        data1 = globals.state.relativesdata[person.id]
        data2 = globals.state.relativesdata[person2.id]
    #if globals.state.relativesdata.has(person.id):
    #    data1 = globals.state.relativesdata[person.id]
    #else:
    #    createrelativesdata(person)
    #    data1 = globals.state.relativesdata[person.id]
    #if globals.state.relativesdata.has(person2.id):
    #    data2 = globals.state.relativesdata[person2.id]
    #else:
    #    createrelativesdata(person2)
    #    data2 = globals.state.relativesdata[person2.id]
    
    #print(data1, data2)
    for i in ['mother','father']:
        if str(data1[i]) == str(data2.id):
            result = '$parent'
        elif str(data2[i]) == str(data1.id):
            result = '$son'
    for i in [data1, data2]:
        if i.siblings.has(data1.id) || i.siblings.has(data2.id):
            result = '$sibling'
    if result != null:
        result = person2.dictionary(result)
    return result

But createrelativesdata is also called in some places of globals.gd: it makes sense for impregnation. But in some other places, it doesn't.

This function tends to create data for a false return. I just return false without creating data instead.

func checkifrelatives(person, person2):
    var result = false
    var data1 
    var data2
    if !globals.state.relativesdata.has(person.id) || !globals.state.relativesdata.has(person2.id):
        return false
    else:
        data1 = globals.state.relativesdata[person.id]
        data2 = globals.state.relativesdata[person2.id]
    #if globals.state.relativesdata.has(person.id):
    #    data1 = globals.state.relativesdata[person.id]
    #else:
    #    createrelativesdata(person)
    #    data1 = globals.state.relativesdata[person.id]
    #if globals.state.relativesdata.has(person2.id):
    #    data2 = globals.state.relativesdata[person2.id]
    #else:
    #    createrelativesdata(person2)
    #    data2 = globals.state.relativesdata[person2.id]
    for i in ['mother','father']:
        if str(data1[i]) == str(data2.id) || str(data2[i]) == str(data1.id):
            result = true
    for i in [data1, data2]:
        if i.siblings.has(data1.id) || i.siblings.has(data2.id):
            result = true
    
    
    return result

After testing, it seems to work! There is just some issue I noticed: sibilings and step siblings are bugged, and sometimes get errors (comparisons of string names with -1). Unsure if this is prior to modifications or after, but I found some fix to it.

First modify the function connectrelatives, which seems to be the culprit:

func connectrelatives(person1, person2, way):
    if person1 == null || person2 == null || person1.id == person2.id:
        return
    if !globals.state.relativesdata.has(person1.id):
        createrelativesdata(person1)
    if !globals.state.relativesdata.has(person2.id):
        createrelativesdata(person2)
    if way in ['mother','father']:
        var entry = globals.state.relativesdata[person1.id]
        for child in entry.children:
            connectrelatives(person2, globals.state.relativesdata[child], 'sibling')
        entry.children.append(person2.id)
        entry = globals.state.relativesdata[person2.id]
        entry[way] = person1.id
        if typeof(person1) != TYPE_DICTIONARY && typeof(person2) != TYPE_DICTIONARY:
            addrelations(person1, person2, 200)
    elif way == 'sibling':
        var entry = globals.state.relativesdata[person1.id]
        var entry2 = globals.state.relativesdata[person2.id]
        # if one parent is -1 and the other a string_id, it will throw an error! Need to ensure strings
        var good_type_mom = (typeof(entry.mother) == typeof(entry2.mother)) && (typeof(entry.mother) == typeof(person1.id))
        var good_type_dad = (typeof(entry.father) == typeof(entry2.father)) && (typeof(entry.father) == typeof(person1.id))
        var good_types = good_type_mom && good_type_dad
        if good_types and ((entry.mother == entry2.mother) && (entry.father == entry2.father)):
            if !entry.siblings.has(entry2.id):
                entry.siblings.append(entry2.id)
            if !entry2.siblings.has(entry.id):
                entry2.siblings.append(entry.id)
        elif (good_type_mom && (entry.mother == entry2.mother)) || (good_type_dad && (entry.father == entry2.father)):
            if !entry.halfsiblings.has(entry2.id):
                entry.halfsiblings.append(entry2.id)
            if !entry2.halfsiblings.has(entry.id):
                entry2.halfsiblings.append(entry.id)

And then the problem in its calls, when using impregnation. Change the end of the function impregnation (still in globals.gd):

    #calls to connectrelatives is bugged for siblings
    #problem seems to be at the identification of mother AND father simultaneously
    #as connectrelatives do not assign both parents simultaneously
    createrelativesdata(baby)
    globals.state.relativesdata[baby.id]['mother'] = mother.id
    if realfather != -1:
        globals.state.relativesdata[baby.id]['father'] = father.id
        connectrelatives(father, baby, 'father')
    connectrelatives(mother, baby, 'mother')
    mother.preg.baby = baby.id
    mother.preg.duration = 1
    
    mother.metrics.preg += 1
    globals.state.babylist.append(baby)

And this seemed to resolve my issues. Hope it helps other people.