1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

The Modding Q&A Thread

Discussion in 'Rhye's and Fall Modmods' started by Leoreth, Apr 2, 2011.

  1. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    Code:
    	getDefenderCombatValues(*pDefender, pPlot, iAttackerStrength, iAttackerFirepower, iDefenderOdds, iDefenderStrength, iAttackerDamage, iDefenderDamage, &cdDefenderDetails);
    
    [COLOR="Red"]	iAttackerStrength = iAttackerStrength * std::max(10, (GET_PLAYER(getOwnerINLINE()).getStability() + 100)) / 100; //LuKo
    	iDefenderStrength = iDefenderStrength * std::max(10, (GET_PLAYER(pDefender->getOwnerINLINE()).getStability() + 100)) / 100; //LuKo[/COLOR]
    	
    	int iAttackerKillOdds = iDefenderOdds * (100 - withdrawalProbability()) / 100;
    I've created above changes but nothing has changed (except maybe sometimes unit dying in combat respawns and is ready to attack again).

    [EDIT]:
    Woohoo! I've made it! I've changed damage instead of strength and everything is OK :) Confusing that AttackerDamage means damage dealt TO attacker but... :)
     
  2. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,090
    Gender:
    Male
    Location:
    Leblanc
    I doubt it. C doesn't know booleans as a primitive data type, all conditions result in 0 or 1 respectively, that's why you can go on manipulating them with integer operations.

    Python on the other hand knows booleans. Maybe someone was smart enough to define multiplication on booleans, but if not, it'll result in an error.
     
  3. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    civ-addicted, yeah thats correct. The value True can be used instead of the integer value 1 in mathematical calculations. Likewise the value False is equals zero.

    But you can lose the parenthesis. Most of the time you can.

    Also, you can use the value None instead of -1. Python is very handy that way.
     
  4. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    J. pride, my script is kinda clumsy and if you wanna be able to add culture to more spawning cities I could upgrade the Barbs module for you, so that this would be easily achieved. Extremely easily, even.

    edit: This is how to augment the foundCity() method:
    Spoiler :
    Code:
            def foundCity(self, iCiv, lCity, name, iTurn, iPopulation, iUnitType, iNumUnits[COLOR="Red"], iCulture=-1[/COLOR]):
                    if ((iTurn == getTurnForYear(lCity[2]) + lCity[3]) and (lCity[3]<10)): # conversion from years - edead
                            #print self.checkRegion(tUr)
                            bResult, lCity[3] = self.checkRegion(lCity)
                            if (bResult == True):
                                    pCiv = gc.getPlayer(iCiv)
                                    pCiv.found(lCity[0], lCity[1])
                                    self.getCity((lCity[0], lCity[1])).setName(name, False)
                                    if (iPopulation != 1):
                                            self.getCity((lCity[0], lCity[1])).setPopulation(iPopulation)
                                    if (iNumUnits > 0):
                                            self.makeUnit(iUnitType, iCiv, (lCity[0], lCity[1]), iNumUnits, 0)
    [COLOR="Red"]                                if iCulture:
                                            self.getCity((lCity[0], lCity[1])).changeCulture(iCiv, iCulture, True)[/COLOR]
                                    return True
                            if (bResult == False) and (lCity[3] == -1):
                                    return False
    With these edits in place, you can (optionally) add a culture value to any city spawn line:
    Code:
    		self.foundCity(iIndependent2, lWarsaw, "Warszawa", iGameTurn, 3, con.iCrossbowman, 3[COLOR="Red"], 100[/COLOR])
    Note that the previously posted code is not needed with this setup.
     
  5. J. pride

    J. pride King

    Joined:
    Feb 23, 2011
    Messages:
    788
    Thanks again Baldyr :salute:, I have successfully added the module; this makes it even easier to edit the culture
     
  6. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    You only added the code marked with red, right? You didn't add the whole thing I posted, I hope. (Also, there are two edits, don't miss the first line!)
     
  7. J. pride

    J. pride King

    Joined:
    Feb 23, 2011
    Messages:
    788
    I just highlighted the previous code and pasted this one in its place
     
  8. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Good, now you get to test my work. :D No warranty included.
     
  9. civ-addicted

    civ-addicted King

    Joined:
    Aug 8, 2009
    Messages:
    852
    Location:
    The City of the Lion
    Spoiler :
    Python is handy in every way:lol:
     
  10. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Not to be overly critical or anything, but the current foundCity() method is fairly cluttered. You should be able to get away with something along these lines:
    Code:
            def foundCity(self, iCiv, lCity, name, iTurn, iPopulation, iUnitType, iNumUnits, iCulture=-1):
    		iX, iY, iYear, dummy = lCity
                    if iTurn == getTurnForYear(iYear):
                            if self.checkRegion(lCity)[0]:
                                    pCity = gc.getPlayer(iCiv).found(iX, iY)
                                    pCity.setName(name, False)
                                    if iPopulation:
                                            pCity.setPopulation(iPopulation)
                                    if iNumUnits:
                                            self.makeUnit(iUnitType, iCiv, (iX, iY), iNumUnits, 0)
                                    if iCulture:
                                            pCity.changeCulture(iCiv, iCulture, True)
    This should be easier on the eyes and could also be good for learning how to mod with Python scripting.
     
  11. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,090
    Gender:
    Male
    Location:
    Leblanc
    Say about Python what you will, it really is programmer-friendly.
     
  12. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    How can I get rid of Nationalism-required-for-respawn feature? Simply changing 2 checks in RiseAndFall.py to CivsWithNationalism>=0?
     
  13. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,090
    Gender:
    Male
    Location:
    Leblanc
    That would be a way to do it, yes.
     
  14. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    Thanks :) Do anyone have any idea what could cause some tribal villages to not disappear when visited (but not working anymore so it's rather graphic glitch)? I assume it can be connected with merging my mod with Next War scenario because I think once there was a village in Portugal but now my warriors see there just a city ruins looking like an arcology shielding.
     
  15. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,090
    Gender:
    Male
    Location:
    Leblanc
    No idea. Goody huts count as a tile improvement graphic-wise iirc, so maybe you messed with their order in the XML files?
     
  16. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    I've changed the order to match Next War's. I assume the order could be stored somewhere in RFC files?

    How to make the last unit in city (nearly) immune to plague? And make damage (more) unhealthiness-dependant? And make cities with +8 health immune to plague? And that's it... for now :p
     
  17. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    The order of the XML entries need to match the mod.

    How? You learn some practical Python, you evaluate the Plague module and edit it accordingly. What's the problem? :D
     
  18. LuKo

    LuKo The Royal Guard

    Joined:
    Aug 28, 2006
    Messages:
    1,501
    Location:
    Poland
    Hmmm... I can see a few. Probably one day I will fix the problem by "hard way"- trying, failing and trying again. That's why every hint is welcome.

    [EDIT]: Where is stored data allowing creating bigger cities by later civs?
     
  19. The Turk

    The Turk Deity

    Joined:
    Jun 25, 2008
    Messages:
    2,189
    Gender:
    Male
    Location:
    Canada
    Hi Everyone!

    Boy oh boy do I have an issue with coding events! ;)

    Basically in my mod I've added in a unit called the "True Cross", which is a unit which only spawns ONE TIME, when then Crusaders capture Jerusalem, and instead of giving a relic like in the past, this time it should give the iTrue_Cross unit. But every time I start up a game, I get my new event pop-up, but I don't receive the True Cross unit, I just receive a relic, like in the past! This has led me to believe that I have not altered all the files I need to, to have a new event. So I've attached all the files I've altered in my pursuit to get this new event.

    Oh and the event is called, "TRUE_CROSS_RECOVERED"

    Thank You for anybodies help! :)
     

    Attached Files:

  20. civ_king

    civ_king Deus Caritas Est

    Joined:
    Mar 9, 2006
    Messages:
    16,368
    Okay, n00b question: How do I make it so I can mouse over a tile and get the coords?
     

Share This Page