• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Quick Modding Questions Thread

Sorry, I never meant to be disrespectful :(
I meant that I don't have the time, energy and patience to become skilled programmer as you guys.
Why I want to use AI generated stuff is that I don't want to ask "Hey, guys, can someone write me a code that..."
I know that I'll never become a real programmer but stay a merger. I like to look up codes already written and try to figure out how modify it to my needs; first on my own, than by asking for help from the community.
I don't want to discredit those who can do the real thing. Quite the other hand: I don't expect others to do things for me for free. That's why I was hoping that AI generated code may be a help for me, so I can try something, and when it doesn't work the experts can point out what's wrong or at least where to start.

And let me underline again: I am very thankful for all the help received here.
It boils down to the fact that reviewing a piece of code to see how and if its going to work without knowing anything about how it was written basically takes as much effort as just writing your own anyway.
 
I asked ChatGPT to write me a code:


Code:
import random
import time

# Function definitions
def play_and_wait(soundtrack, wait_time):
    print(f"Executing CyInterface().DoSoundtrack('{soundtrack}')...")
    # Replace the following line with actual code to execute CyInterface().DoSoundtrack()
    print(f"Playing {soundtrack}...")
    time.sleep(wait_time)
    print(f"Waited for {wait_time} seconds.")

# List of tasks
tasks = [
    ("AS2D_VICTORY1", 36),
    ("AS2D_VICTORY2", 28),
    ("AS2D_VICTORY3", 93),
    ("AS2D_VICTORY4", 45)
]

# Shuffle the tasks
random.shuffle(tasks)

# Execute the tasks in random order
for task in tasks:
    play_and_wait(task[0], task[1])

Is that doable? Is that a good start?
Testing shows time.sleep() simply hangs the game for the wait_time duration, and (since Civ 4 doesn't support multithreading) I don't see any way for this approach to be implemented.

Instead, I'd recommend that the playlist is preshuffled into a list of system times calculated accordingly and that the audio play function doesn't even consider time at all.

The play function can then be called from onGameUpdate in CvEventManager.py when a playlist item's scheduled time no longer exceeds the current time.
 
Testing shows time.sleep() simply hangs the game for the wait_time duration, and (since Civ 4 doesn't support multithreading) I don't see any way for this approach to be implemented.
Oh, okay. Thanks for testing it. I'd didn't have the time yet to test it myself.


Instead, I'd recommend that the playlist is preshuffled into a list of system times calculated accordingly and that the audio play function doesn't even consider time at all.

The play function can then be called from onGameUpdate in CvEventManager.py when a playlist item's scheduled time no longer exceeds the current time.
That's beyond my present understanding.
How can you schedule it?

EDIT:
I started doing some research and found this article:
So I will need to use something like described under the part "Scheduling Multiple Tasks", right?

(And FYI I didn't ask any AI this time :p )
 
Last edited:
That's beyond my present understanding.
How can you schedule it?
I didn't read the article, although there's no need for anything beyond the time library (or something similar like datetime).

In fact, all that's necessary are two method calls to get the current time (e.g. time.clock()): First save it in a variable where you figure out how soon you want the playlist to start (which you'll use in your playlist time calculations).
Then compare that variable to the current time on game update.
 
Code:
def onBuildingBuilt(self, argsList):
        'Building Completed'
        pCity, iBuildingType = argsList
        game = gc.getGame()
    
        if iBuildingType == gc.getInfoTypeForString("BUILDING_PETRA"):
            pPlayer = gc.getPlayer(pCity.getOwner())
            (loopCity, iter) = pPlayer.firstCity(false)
            while(loopCity):
                pPlot = loopCity.plot()
                if pPlot.isHills():
                    xPlot = pPlot.getX()
                    yPlot = pPlot.getY()
                    Game.setPlotExtraYield(xPlot, yPlot, YieldTypes.YIELD_PRODUCTION, 4)
                (loopCity, iter) = pPlayer.nextCity(iter, false)

Why doesn't this code work? The idea is that when the player has built Petra, tiles with cities on the hills will receive additional hammers.
 
How i can create dummy buildings? I mean bildings with hide description, pedia, city inteface, visibility etc.
I tried to use tag bGraphicalOnly but it doesn't work.
I want to use it for Wonder <freebuilding> tag to create different effects in All cities. For example, +2 hammers in every city when wonder is built.
 
I have two short questions:
1. Do I have to create a new dll file every time I change something in the SDK file?
2. Do I need all somethig.h files etc. to configure the dll?
 
I have two short questions:
1. Do I have to create a new dll file every time I change something in the SDK file?
2. Do I need all somethig.h files etc. to configure the dll?
#1. Yes every change to the DLL requires a recompilation.
#2. .h files are C++ header files. If you are going to be doing C++ programming you really should look them up because they are critical. But a TLDR is that these files tell the compiler what piece of code is where, So you can't create the DLL without them.
 
#1. Yes every change to the DLL requires a recompilation.
thank you for anser
#2. .h files are C++ header files. If you are going to be doing C++ programming you really should look them up because they are critical. But a TLDR is that these files tell the compiler what piece of code is where, So you can't create the DLL without them.
i mean, to editing sdk i must downland all from this github link
 
thank you for anser

i mean, to editing sdk i must downland all from this github link
Yes. It's all or nothing.

This said, if you really have not ever done any work with C++ at all before I would advise you to look into some basic tutorials first before you get into moding the DLL. You don't need anything fancy. Just like, hello world level of understanding. Just enough to get a feel for things at the very least.
 
Though you don't need to download the files manually one by one. (Just in case that that's the concern.) If you navigate up one level, you can download a ZIP archive: link
 
when i compile SDK and i get this problem
1714027988442.png
 
Last edited:
Did you follow the relevant tutorials, use the proper version of visual studio and compiler etc?
 
Back
Top Bottom