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

General Modmodding Questions

Discussion in 'Rise from Erebus Modmod' started by 25Hour, May 5, 2010.

  1. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    I wasn't sure where to post (the ordinary modmodders forum being for base FFH mods), so I figured I'd just put this in the general RiFE forum and hope for the best. Others are invited to do the same! :D

    First, I know that Xienwolf's XML changes included a way to make a given promotion stackable with itself. My question is, is there any way via python to change (or get) the number of stacked promotions a unit has? (Ex. setting a unit to have 4 "Combat Booster" promotions when it's built, or getting the number of "Combat Booster" promotions a given unit has.) It occurred to me that if possible, this would be a very simple way of implementing a "general" sort of affinity for certain mana or resources. (Like, you could give new units a +1 movement rate promotion for each Water mana you have. Or +10% strength for each Death mana, or +5% withdrawal rate per Air mana, or whatever.)

    Anyway, can this be done with the current python setup?

    My second question is about buildings. (Reposted from my Leadermod thread.) I notice that the function I use to set buildings looks like it has the potential to set more than one of a certain type-- for example, pNest.setNumRealBuilding(iBuilding3, 0) or pNest.getNumBuilding(gc.getInfoTypeForString('BUILDING_PHLEGMATIC')). Does this mean that I can set a city to have two markets? Would the effects stack, if so? This sounds like a neat way to get gradient effects, if it works like it sounds it does. (Like, giving a city a +1% science building for each point on the AC.)

    Thanks for the help! :goodjob:
     
  2. Valkrionn

    Valkrionn The Hamster King

    Joined:
    May 23, 2008
    Messages:
    14,450
    Location:
    Crestview FL
    Yeah, I'll be making a modmodder's thread for the next version (certain change in the python that makes it important); For now, this will work. ;)

    How exactly do you think the Mechanos Affinity is done? :p

    Yes, it is VERY possible to count how many promotions a unit has... The way I handled the Mechanos, there are two promotions, nearly identical. First is granted to units, second is autoacquired based on the first. First one is visible and has the python effect, second one is an effect promo and is the one that stacks; No clutter that way. Main reason for two promotions is so that even if you lose all of the necessary resource, you can still get the effect back later.

    Here's the python:

    Code:
    def effectMechanosAffinity(pCaster):
    	iMechanosAffinity = gc.getInfoTypeForString('PROMOTION_MECHANOS_AFFINITY')
    	pPlayer = gc.getPlayer(pCaster.getOwner())
    	iRefinedNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_REFINED_MANA')) - 1
    
    	for i in xrange(pCaster.countHasPromotion(iMechanosAffinity)):
    		pCaster.setHasPromotion(iMechanosAffinity, False)
    	
    	for i in xrange(iRefinedNum):
    		pCaster.setHasPromotion(iMechanosAffinity, True)
    Notice the "Mana - 1" part; That's because of the trigger promotion, the visible one. Basically just a small bit of python that removes all of the promotions and then readds the correct amount each turn; Easiest way to do it. Not very resource intensive, either, so it could be expanded.

    So yes, a more general affinity mechanic is quite possible this way, and it's my backup if I fail to do it in the xml. Would just modify the python for the effect so that I can pass the requisite resource and promotion in the python call, so I only need one block of python. Like with the Equipment spells. ;)

    Frankly, I have no idea. I'd repost that one in the FF or FfH modmodder's thread; It's a question that should apply to all mods.
     
  3. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    Yeah, I hadn't considered the Mechanos affinity when I wrote that. Thanks for the help! I do so love gradient effects. :D
     
  4. snarko

    snarko DLLer

    Joined:
    Dec 9, 2003
    Messages:
    1,512
    Location:
    Sweden
    The maximum number of a building type in a city is controlled by a GlobalDefine, CITY_MAX_NUM_BUILDINGS. It's set to 1 in RifE (inherited from BtS).

    While you can add more than one building to a city via python don't do it.

    Most buildings will have no effect if you add more than one. Only a few exceptions, such as the free tech from infernal grimoire, will apply multiple times. Still, the game is not made for this. It could cause issues as the city will have one of the building and several "real" versions of the building at the same time.
     
  5. Valkrionn

    Valkrionn The Hamster King

    Joined:
    May 23, 2008
    Messages:
    14,450
    Location:
    Crestview FL
    Ah, good to see you back. ;)
     
  6. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    Good to know! Thanks. :D

    Now, one other question: In CvGameUtils, there's a function called "canDeclareWar." What does this do? As a test, I tried out setting it to "false", but I can declare war as normal even then.
     
  7. Opera

    Opera Deity

    Joined:
    Sep 21, 2008
    Messages:
    4,643
    Gender:
    Female
    You'd have to make sure that specific callback is used. See, in the DLL, probably in a function called "canDeclareWar", there's some stuff about python being able to bypass all of that. If that's stuff isn't enabled, the python callback isn't active.

    I'd say check the XML/PythonCallbacks.xml file and see if it's set to 1, if it's even there.
     
  8. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    Okay, I found the XML file, and the function is there and is set to 0. Is there any downside to setting it to 1? (Making the game run slower or something?) I'm just trying to figure out why it might have been deactivated.

    Actually, now that I think of it, the function seems to always return "true". Wouldn't that make it so that you would always be able to declare war, regardless of diplomatic actions which would otherwise stop you from doing so?

    Anyway, thanks for the help! What I'm trying to do is make an "Honorable" disadvantage-trait which stops you from declaring war if your score is more than twice that of your target. Or 1.5 times more, I'm still working out the details.
     
  9. sylvain5477

    sylvain5477 Cerebrus father

    Joined:
    Dec 30, 2007
    Messages:
    752
    A good way may be to set to 1 the xml and add the code in the python function.
    You can also check with a seach in files (notepad++) in the cpp files of the project where ths python is called (easy) to be sure it is at the right place (but given the name should be okay).

    I did this kind of thing once (set to 1 a callback and use itt) and it was working perfectly.
     
  10. snarko

    snarko DLLer

    Joined:
    Dec 9, 2003
    Messages:
    1,512
    Location:
    Sweden
    The callback is set to 0 because python will slow things down (or more correctly, python<->c++ will) and it's not used. Why use something that's not used? Pointless. But if you're going to use it, then it's not pointless anymore.

    Returning anything other than false or 0 has no effect on if you can declare war. The python callback can only be used to prevent declarations, not allow them.
     
  11. Tholal

    Tholal Emperor

    Joined:
    May 19, 2009
    Messages:
    1,676
    Like most functions, war declarations are handled in the DLL. The python function is there so that you can tack on some extra functionality. The DLL functions generally do some initial setups, then check to see if there is any pthon code, then continue on with their regular code if there is not.

    So in this case, for example, if you wanted to make it so that the AI wouldn't ever declare war before the AC hits 20, you could set up python check that would return false if the AC was less than 20.
     
  12. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    Ahhh, I see. This all makes a lot more sense now that I've read your responses. Thanks, you guys!
     
  13. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    Okay, so one other thing. I'm finding that it's very difficult to turn water into land, and vice-versa; I've narrowed it down to this bit of code, which seems to either crash the game or just turn everything to flatlands. Is there a way to turn water into land via python, or am I out of luck?

    Here's the code (procured from The_J's simple python things.)
    Code:
    	for iXLoop in range(iX - 1, iX + 2, 1):
    		for iYLoop in range(iY - 1, iY + 2, 1):
    				pPlot = CyMap().plot(iXLoop, iYLoop)
    				if (( pPlot.isPeak()==true  ) or (pPlot.isHills()==true)):
    					pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
     				pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_COAST" ), 1, 1)
    
    You all are an awesome resource, by the way. :D
     
  14. lemonjelly

    lemonjelly Modding For Ethne

    Joined:
    Jan 5, 2008
    Messages:
    864
    Location:
    UK
    I can see that being incredibly useful, if it worked...

    ...unfortunately, I have no idea how to make it work, sorry.
     
  15. black_imperator

    black_imperator Emperor

    Joined:
    Dec 4, 2005
    Messages:
    1,787
    i know that .

    It's a line in the dll of the SetPlotType function which prevents this kind of change. Comment that line and it will work . ( but the game ins't able to update graphics from this kind of change at the moment ,so you'll have some weird tiles.)
     
  16. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    Pity, that-- looks like it's a bridge too far, then, since I don't want to make changes involving editing the dreaded DLL/causing weird graphical glitches. (I'm trying to raise a one-tile city in the middle of the ocean.) At any rate, thanks for the assistance! :goodjob:

    Edit: Oh, looks like I can simply cause the city to spawn in the water and it seems to act normally when constructing units and buildings. Does this present problems that I'm not aware of, or am I in the clear?
     
  17. snarko

    snarko DLLer

    Joined:
    Dec 9, 2003
    Messages:
    1,512
    Location:
    Sweden
    Last time I tried to make a city on water, before even warlords, the city was impossible to capture under certain circumstances. I think it was this: if there's a unit defending it, units can't capture it. If it's undefended ships can capture it but no land unit can ever do so*.


    *Water walking units should be exempt from this rule. They may even be able to capture it if there's a unit defending the city.
     
  18. 25Hour

    25Hour Some sort of lemur

    Joined:
    Mar 14, 2008
    Messages:
    181
    Eh, looks like I'll just have to ditch the idea, then. The advice is much appreciated. :D
     
  19. Valkrionn

    Valkrionn The Hamster King

    Joined:
    May 23, 2008
    Messages:
    14,450
    Location:
    Crestview FL
    Never saw your edit, sorry.

    For now it causes problems, but that will be possible eventually. Has to be fixed, for the Bezeri. ;)
     
  20. GIR

    GIR It'sNotStupidIt'sAdvanced

    Joined:
    Jul 12, 2005
    Messages:
    884
    Location:
    EU
    @25Hour:
    i dont know if this will work for your graphic update but it works for updating hell terrain in FF(and RifE) without updating the whole map:

    pPlot.rebuildGraphics()
     

Share This Page