Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Tot one suggestion for improvement

A topic by AleDerXan created Oct 26, 2024 Views: 742 Replies: 10
Viewing posts 1 to 7
(14 edits) (+1)

Now, in menu, names of persons, who was first for Lona, is dinal strings.

IMHO…


Now there in game:

["#{$game_text["menu:sex_stats/record_butt_virginity_taken"]} : ", $story_stats["sex_record_butt_virginity_taken"]],

I think, that it isn't good. Because changing language in the middle of the game, won't change names there.


Next code will be better:

Before:
    
textV = ""
    
textV +=      $game_text[$story_stats["sex_record_butt_virginity_taken"][0],true]
    
textV +=     " " + $game_text[$story_stats["sex_record_butt_virginity_taken"][1],true] if !["",0,nil].include?($story_stats["sex_record_virginity_taken"][0]) && !["",0,nil].include?($story_stats["sex_record_virginity_taken"][1])
    
textV +=     " " + $game_text[$story_stats["sex_record_butt_virginity_taken"][2],true] if !["",0,nil].include?($story_stats["sex_record_virginity_taken"][1]) && !["",0,nil].include?($story_stats["sex_record_virginity_taken"][2])
    
In the middle
["#{$game_text["menu:sex_stats/record_butt_virginity_taken"]} : ", textV],


And if we wants normal menu without strange strings, we need change all code in game as this:

$story_stats["sex_record_virginity_taken"] = "#{$game_text["DataNpcName:race/#{occupied_holes[i][1]}",true]}#{$game_text["DataNpcName:name/#{occupied_holes[i][2]}",true]}#{$game_text["DataNpcName:part/penis",true]}" if ["",0,nil].include?($story_stats["sex_record_virginity_taken"])

To something like this:

if ["",0,nil].include?($story_stats["sex_record_virginity_taken"][0])
    $story_stats["sex_record_virginity_taken"][0] = "DataNpcName:race/#{occupied_holes[i][1]}"    
    $story_stats["sex_record_virginity_taken"][1] = "DataNpcName:name/#{occupied_holes[i][2]}"
    $story_stats["sex_record_virginity_taken"][2] = "DataNpcName:part/penis"
end

Or do something like:

$story_stats["sex_record_virginity_taken"] = "DataNpcName:race/#{occupied_holes[i][1]}" + "|||" + "DataNpcName:name/#{occupied_holes[i][2]}" + "|||" + "DataNpcName:part/penis" if ["",0,nil].include?($story_stats["sex_record_virginity_taken"])

And then use this method:

$story_stats["sex_record_virginity_taken"].split("|||").each{|part|; textV = textV.to_s + $game_text[part,true] + " "} if !["",0,nil].include?($story_stats["sex_record_virginity_taken"])
["#{$game_text["menu:sex_stats/record_butt_virginity_taken"]} : ", textV.to_s],
(77 edits) (+1)

And the second one suggestion for improvement:

Every barter list of items in trade, to be changed by modder, need from modder to overwrite the whole dialog . It makes huge conflicts between mods.

May be it's possible to use something like this in json of items:

"barters": [{
        "barter": {
            "name": "CommonOrc",
            "type": 0,
            "set": null,
            "price": 1000,
            "min": 10,
            "max": 20
        }
}],

With data of price multiplier, and with data of number of items, with two numbers, and use  Random.new.rand(num1..num2)   in any barter dialog. With anything else if need. (I know a little in trading code , so it's only idea.)

And add items to trade, by something like this (it's only example of idea)

NPCName Ivent: (.rb)
    ####A lot of code####
good = []
$data_ItemName.each{|item|
    next if item[1] == nil
    next if item[1].barters == nil 
    item[1].barters.each{|barter|
        next if barter == nil
        next if barter.name != NPCname #Or group of NPC
        it = barter
        good += [[it.type, item.id, it.set, it.price, Random.new.rand(it.min..it.max)]]
    }
}
    ###A lot of code###

This method will allow every modder to simply add his own armors, weapons, and items to any trader. And it won't stop others modders from doing the same things with the same  traders.

Or we can use (in some cases) group/type of trader instead of name. Or do it in one time. Use for NPC in their event not only their uniq "barters" in json. We can  do the same "each each good+=" for groups after uniq items adding to the "good" array.

This method can be used not only for traders. Drop, or chests to. Simply use codename of chest as name of barter and then use the same code to create a list of items.

Or we can think of any other way to ensure that modders don't have to change the event code.

May we can create $data_BarterName… And use data from item's json (or create special folder for barters with special json files and collect them by the same way as $data_arpgskills) and put it in $data_BarterName, not in $data_ItemName, to decrease computer strain of working with $data_ItemName.

$data_BarterName  - hash of barters

 $data_BarterName["NPCName"]  - array (of barter's items)  

  $data_BarterName["NPCName"][n] - array or hash for each item

  $data_BarterName["NPCName"]  += [modders array/hash for modder item]

And then modders can do something like this (not exactly this) $data_BarterName["NPCName"] += hash_data_from_their_json["NPCName"]    (Or do it manually in code instead of using json)

good = []
$data_BarterName["NPCName"].each{|it|
     good += [[it["type"], $data_ItemName[it["item_name"]].id, it["set"], it["price"], Random.new.rand(it["min"]..it["max"])]]
}


Or, may be i don't know something and this is already exist.

(8 edits) (+1)

Yes. There is a way to emulate that.

—————

test json, made for Noer Tavern Waifu. But we can add another barters to this file. And add more than one item to barters. Or we can do it in more than one file.

{
    "barters": [{
        "npc_name": "59_69",
        "items":  [{
            "item_name": "ItemSurBot", 
            "custom_price": null, 
            "price_mult": 1, 
            "rndMin": 1,
            "rndMax": 5
        }]
    }],
}


Test code:

module DataManager
    class << self
        alias_method :load_mod_database_TEST, :load_mod_database
    end
    
    def self.load_mod_database
        load_mod_database_TEST
        $TEST_mod_name = "Mod TEST"
        $TEST_modFolder = "ModScripts/_Mods/#{$TEST_mod_name}"
        $data_NameBarters_TEST = {}
        FileGetter.getFileList("#{$TEST_modFolder}/Data/Barters/*.json").each{|file|
            add_new_goods(file)
        }
    end
    
    def self.add_new_goods(path)
        temp_hash = nil
        
        begin
            temp_hash = JSON.decode(open(path).read)
        rescue 
            msgbox("Error in Json == [[ #{path} ]] :: def self.add_new_goods")
        end
        return if temp_hash == nil
        
        temp_hash["barters"].each{|barter|
            goods = []
            barter["items"].each{|item|
                item_name = item["item_name"]
                custom_price = item["custom_price"]
                price = (item["price_mult"])*($data_ItemName[item_name].price.to_i)
                minNum = item["rndMin"]
                maxNum = item["rndMax"]
                goods += [[*$data_ItemName[item_name].get_type_and_id, custom_price, price.round, Random.new.rand(minNum..maxNum) ]]
            }
            if $data_NameBarters_TEST[barter["npc_name"]] == nil
                $data_NameBarters_TEST[barter["npc_name"]] = goods
            else
                $data_NameBarters_TEST[barter["npc_name"]] += goods
            end
        }
    end
end
        
module GIM_ADDON
    
    alias_method :alias_manual_trade_TEST, :manual_trade unless method_defined?(:alias_manual_trade_TEST)
        
    def manual_trade(good,charStoreHashName=nil, charStoreTP=0, charStoreExpireDate=nil, noSell=false, noBuy=false)
        goods = $data_NameBarters_TEST["#{charStoreHashName}"]
        good += goods if goods != nil
        alias_manual_trade_TEST(good, charStoreHashName, charStoreTP, charStoreExpireDate, noSell, noBuy)
    end
        
end
(+1)

man you are on a roll eccma has noted this post as well

(91 edits)

I think, that it will be better if 

$data_NameBarters

Will be created officially in the game. May as {}. But with unique name.

And then create adding mod-goods from it to barters in oficcial scripts.

Then modder will need only to modify this hash.

Because while all modders need to create new hash, then they create new alias_method for "def manual_trade". And if there will be a lot of mods, there will be a "multi-story pagoda".

If $data_NameBarters (or another name) will be one for all of mods, and adding mod-goods to trade will be one in offficial code of game, it will be better for optimization.

And, may be, sometimes it will be easier for Eccma in some cases to use $data_NameBarters and json files, for adding goods,  instead of adding  manually.

——

And i see that it's possible to add shopNerf to this method.

But it's will really increase code complexity.

——

BigMama.json  (Update comm. It's more useful to make one file for one npc)

{
    "npc_name": "59_69",
    "items":  [
        {
            "item_name": "ItemSurBot", 
            "custom_price": null, 
            "price_add": 0,
            "price_mult": 1, 
            "rndMin": 1,
            "rndMax": 5,
            "shop_nerf": [
                {
                    "base": 0, 
                    "base_mult": 1,
                    "attr_name": "weak", 
                    "attr_mult": 1, 
                    "attr_type": 0
                },
                { 
                    "base": -100,
                    "base_mult": 0,
                    "attr_name": "sexy",
                    "attr_mult": -1,
                    "attr_type": 0
                }
            ]
        },
        {
            "item_name": "ItemAdvBot",
            "custom_price": null,
            "price_add": 0,
            "price_mult": 1,
            "rndMin": 1,
            "rndMax": 5,
            "shop_nerf": [
                {
                    "base": 0,
                    "base_mult": 1,
                    "attr_name": "weak",
                    "attr_mult": 0.5,
                    "attr_type": 0
                }
            ]
        }
    ]
}


WorldDifficulty - increase price

weak - increase price

sexy - decrease price

simply use 

"shop_nerf": [
                {
                    "base": 0, 
                    "base_mult": 0,
                    "attr_name": 0,
                    "attr_mult": 0, 
                    "attr_type": 0
                }
            ]

to set it's effect to zero.

Code for modders:

module DataManager
    class << self
        alias_method :load_mod_database_TEST, :load_mod_database
    end
    
    def self.load_mod_database
        load_mod_database_TEST
        $TEST_mod_name = "Mod TEST"
        $TEST_modFolder = "ModScripts/_Mods/#{$TEST_mod_name}"
        $data_NameBarters_TEST = {} if $data_NameBarters_TEST == nil
        FileGetter.getFileList("#{$TEST_modFolder}/Data/Barters/*.json").each{|file|
            add_new_goods(file)
        }
    end
    
    def self.add_new_goods(path)
        temp_hash = nil
        
        begin
            temp_hash = JSON.decode(open(path).read)
        rescue 
            msgbox("Error in Json == [[ #{path} ]] :: def self.add_new_goods")
        end
        return if temp_hash == nil
            
        goods = []
        temp_hash["items"].each{|item|
            item_name = item["item_name"]
            custom_price = item["custom_price"]
            price = (item["price_mult"])*($data_ItemName[item_name].price.to_i) + item["price_add"]
            minNum = item["rndMin"]
            maxNum = item["rndMax"]
            nerf = item["shop_nerf"]
            goods += [[*$data_ItemName[item_name].get_type_and_id, custom_price, price.round, Random.new.rand(minNum..maxNum), nerf ]]
        }
        if $data_NameBarters_TEST[temp_hash["npc_name"]] == nil
            $data_NameBarters_TEST[temp_hash["npc_name"]] = goods
        else
            $data_NameBarters_TEST[temp_hash["npc_name"]] += goods
        end
    end
end
#######   This part of code can be official. #######
#######  Without using alias_method, of course.  ###
####################################################
    
module GIM_ADDON
    
    alias_method :alias_manual_trade_TEST, :manual_trade unless method_defined?(:alias_manual_trade_TEST)
        
    def manual_trade(good,charStoreHashName=nil, charStoreTP=0, charStoreExpireDate=nil, noSell=false, noBuy=false)
        goods = add_mod_goods(charStoreHashName)
        good += goods if goods != nil
        alias_manual_trade_TEST(good, charStoreHashName, charStoreTP, charStoreExpireDate, noSell, noBuy)
    end
        
    def add_mod_goods(charStoreHashName=nil)
        goods_base = $data_NameBarters_TEST["#{charStoreHashName}"]   
        return if goods_base == nil
        goods = []
        goods_base.each{|good_one|
            begin
                shop_nerf = 0
                good_one[5].each{|nerf|
                    attr_mult = nerf["attr_mult"]
                    attr_name = nerf["attr_name"]
                    if attr_name.class == String
                        attr_type = nerf["attr_type"]
                        nerf_attr = $game_player.actor.battle_stat.get_stat(attr_name, attr_type)
                    else
                        nerf_attr = attr_name.to_i
                        #You can use number instead of name and then it will be simple value. And then you can use your mathematical skills to do whatever you want. It can be useful to make base "shop_nerf" - negative (to turn price to zero). For example. Start price from zero: price*(1(base formula) - 1(this iteration) + weak*0.001(next iteration)).
                    end
                    nerf_attr_mod = attr_mult*nerf_attr
                    nerf_base = nerf["base"]
                    nerf_base_mult = nerf["base_mult"]
                    shop_nerf1 = ([([$story_stats["WorldDifficulty"].round, 100].min)*nerf_base_mult + nerf_base, 0].max*0.001)
                    shop_nerf2 = nerf_attr_mod*0.001  #A lot of sexy can alow Lona to get item and earn money by getting item (only for example).
                    shop_nerf += shop_nerf1 + shop_nerf2
                }
                price = (good_one[3]*(1+shop_nerf)).round
            rescue
                price = good_one[3]
            end
            goods +=[[good_one[0], good_one[1], good_one[2], price, good_one[4]]]
        }
        return goods if goods != []
    end
end
(6 edits) (+1)

I updated method. Eccma can looks at it if want. Its more useful now. 

91 edits of post.

(+1)

Some text relayed from eccma.


Eccma417:https://itch.io/t/4233858/tot-one-suggestion-for-improvement his text flag fix confirmed better. but i m gonna do it with my style 😕

Eccma417:point is allow it load text flag. not SAVE TEXT

Eccma417:in this case. some new def will be more reasonaable

Eccma417:also. reset her hole record

Eccma417:for trade.... now sure if i can do it... there are alot trade rely by custom codes and logic... make it a json need a stable strature.

Eccma417: ex... i would add more item if a quest done

Eccma417:or even lona is too weak

Eccma417:or fskadfglsdflgkjsdlfgkjaoewirjf

(24 edits)

Ok. It's fine.

My own quest is done.

Eccma's quest has started.

At the very least, I've already figured out a way for modders to add items to traders without overwriting  dialogs.

While Eccma's quest is not yet done all of this will not happen centrally. But it will still work.


Eccma can use json method for simple cases (may be it's possible to add some tags into items in jsons of traders, for story_stats[""] or actor.stat[""] check? ShopNerf is already added by me in code above), and use old method when it's something really unique, and slowly extend the json method. Let's say, Eccma can use a hybrid way, for short. And even that is enough for modders to connect to the existing structure and use it then.

(34 edits)

Next. I made it's simplier to mind of modders.

Not:  (in "def manual_trade")

goods = add_mod_goods(charStoreHashName)
good += goods if goods != nil


Then:

begin; name = $game_map.interpreter.get_character(0).npc_name; rescue; name = nil; end
goods = add_mod_goods(name) if name != nil
good += goods if goods != nil

And then use in json normal names instead of numbers. 

{
    "npc_name": "UniqueTavernWaifu",
    "items":  [
        {
            "item_name": "ItemSurBot", 
            "custom_price": null, 
            "price_add": 0,
            "price_mult": 1, 
            "rndMin": 1,
            "rndMax": 5,
            "shop_nerf": [
                {
                    "base": 0, 
                    "base_mult": 1,
                    "attr_name": "weak", 
                    "attr_mult": 1, 
                    "attr_type": 0
                },
                { 
                    "base": -100,
                    "base_mult": 0,
                    "attr_name": "sexy",
                    "attr_mult": -1,
                    "attr_type": 0
                }
            ]
        },
        {
            "item_name": "ItemAdvBot",
            "custom_price": null,
            "price_add": 0,
            "price_mult": 1,
            "rndMin": 1,
            "rndMax": 5,
            "shop_nerf": [
                {
                    "base": 0,
                    "base_mult": 1,
                    "attr_name": "weak",
                    "attr_mult": 0.5,
                    "attr_type": 0
                }
            ]
        }
    ]
}


And we can add  story_stats check and stats check after shopnerf. And work with it in "def add_mod_goods", and when collect data from jsons to $barter_hash. Of course we should allow code to ignore if some of the hash-keys don't exist in some of jsons. If not need then allow human to don't write keys in json.. 

We can add something like this to allow adding item to good :


"req_lower_than": [{"stat_name": "name (as weak)", "value": num}, {.......}] ,

for example. If Lona have high weak then she can't buy something



"req_higher_than": [{"stat_name": "name (as sexy or morality)", "value": num}, {.......}] ,

for example. Lona need to have high sexy to buy something strange

Or may be:

"req_between": [{"stat_name": "name (as weak)", "valueMin": num, "valueMax": num }, {...}] ,



"req_story_stats": [{"story_stats_name": "name of story stat", "value": num (or other)}, {.......}] ,

for example. Lona need to done certain quest to buy something uniq


"req_game_player_stat": [{"player_stat_name": "name of stat", "value": num (or other)}, {.......}] ,

For example Elisa won't sell aids of stats while Lona don't need it. 

Or Lona can't buy something if her stat["SlaveBrand"] != 0 :

req_game_player_stat": [{"player_stat_name": "SlaveBrand", "value": 0}],
(8 edits)

As offtop. (It's a reason of my first post in this topic)

I'm working on one mine mod.


And I've made it so that under certain specific conditions, this will happen:

if ["",0,nil].include?($story_stats["sex_record_virginity_taken"])
    $story_stats["sex_record_virginity_taken"] = $game_text["menu:main_stats/name",true]
end


And if the conditions are met again with little changes:

if ["",0,nil].include?($story_stats["sex_record_first_kiss"])
    $story_stats["sex_record_first_kiss"] = $game_text["menu:main_stats/name",true]
end


And if the conditions are met again with another little changes:

if ["",0,nil].include?($story_stats["sex_record_butt_virginity_taken"])
    $story_stats["sex_record_butt_virginity_taken"] = $game_text["menu:main_stats/name",true]
end

(And now I'm thinking of adding not only the name, but also Lona's title as well. Or race.)

(3 edits)

Next one. It's simply. Not about modding. Only question about game code.

Why this:

?

When it's possible to do this: