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

An Idiots Guide to Editing the DLL

Discussion in 'Civ4 - Modding Tutorials & Reference' started by xienwolf, Mar 16, 2009.

  1. renegadechicken

    renegadechicken Warlord

    Joined:
    Aug 12, 2007
    Messages:
    227
    Location:
    Civ II Verne Scenario
    Thank you so much for doing this! This tutorial is desperately needed, because C++ is used in such a different way for Civ IV (as you yourself noted!). I look forward to your next lesson! :)
     
  2. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    By the way, I will write all of these on-the-fly. So if anybody has some specific requests for what I should write the tutorials on which are still upcoming, feel free to request them. Most likely what you request will lead to far more interesting "Oh yeah! I have to do this too..." moments than the things which I grab, and potentially be useful somewhere in a mod (not sure how many people were just DYING for a promotion to get better results from goody huts with...)

    EDIT: Added a new section to post #1 about commenting your code. I realized that while I advised the prospective modder to do so, I didn't exactly tell them HOW to do so, except for once in passing when I said that "//" starts a line comment.
     
  3. renegadechicken

    renegadechicken Warlord

    Joined:
    Aug 12, 2007
    Messages:
    227
    Location:
    Civ II Verne Scenario
    Well, here's a request, but I don't know how hard this would be to code, so I'll understand if this doesn't get mentioned in your tutorial... :)

    I'm working on a mod for Final Frontier, and I need a Promotion that is basically an "Ion Pulse." The promotion is a once-per-turn "spell" (like in FFH2) that disables a single unit for one (or two) turn(s). The tricky part is where stacks come into play; I don't want it to hit the whole stack! :) My preference would be for the player who fired the pulse to be able to choose which unit to hit. If that's truly impossible, I'd settle for the strongest unit.

    Would this be a useful example of how to use SDK/C++? I really don't know-- I'll leave that up to you. :)
     
  4. Jean Elcard

    Jean Elcard The Flavournator

    Joined:
    Feb 26, 2006
    Messages:
    1,008
    Location:
    Leipzig, Germany
    I think you should use a darker green than "lime" for comments and stuff. It's incredibly hard to read on my screen (using standard forum colors).
     
  5. Iceciro

    Iceciro Special Ability: Decimate

    Joined:
    Jul 12, 2006
    Messages:
    1,944
    Location:
    in ur empire, takin ur cities
    You could show us where BTS' Great General creation is hid. I'm sure a lot of people would like to tweak those numbers, if nothing else. There's also a lot of stuff about the specialists in general that's not a part of xml/python.

    And I want to re-enable generals through combat. :p
     
  6. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    I'll move over to a more base-line color and check out the default scheme for readability too in the future. Don't understand why people stick with the default layout here :p

    Not sure if I completely understand how you want the Ion Pulse to function, but it would most likely not be something you would implement as a new XML Field. To allow the ability to be targetted you would want to utilize python, so it might be a good example for the "Creating a Python Callback" function. Though honestly if this is the only promotion which will ever do such a thing you are better off sticking to pure python for it. Not too easy of a function to generalize, and you don't want to hard-code in the DLL since it is a mild PITA to adjust things.


    From what I see in the FfH base code, you can re-enable Great Generals from combat by just creating a unit (any unit) which offers a LeaderPromotion or LeaderExperience. In Fall Further I actually stopped this function from running at all, so THERE you would have to remove a block in the DLL (void CvPlayer::setCombatExperience(int iExperience)).
     
  7. zenspiderz

    zenspiderz Just some bloke..

    Joined:
    Apr 10, 2006
    Messages:
    1,496
    Wow this great. I have been praying for this info for ages. At the moment tho' i am busy making unit graphics but soon as i get tired of that i will be back to editing my mod and it is fast getting to the point where i will need to monkey about with the sdk to achieve my vision. Nice work!
     
  8. renegadechicken

    renegadechicken Warlord

    Joined:
    Aug 12, 2007
    Messages:
    227
    Location:
    Civ II Verne Scenario
    Well, what I'm going for is almost exactly like the spell "Blinding Light" from FFH2 with some important changes: the "spell" wouldn't hit all units in all adjacent plots, but would be targeted at one plot (similar to bombarding), and could only hit a single unit (chosen by the "casting" player). Man, now that I describe, it really sounds complex...

    But does that make it a bit clearer what I'm after? If it's all in Python, then that's cool, but it would not be my only Promotion (I plan on adding quite a few others that might be similar to other FFH2 spells). Once again, though, I understand if you don't include this in your tutorial...but I can hope! :)
     
  9. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    I think I mostly follow what you are seeking with it. And due to being targetted/triggered type of effects, the spells are almost all best as spells.

    If you want them to act on each turn, then they gain some validity as candidates for an XML field in PromotionInfos, but even then you really want it to be something that you use on a lot of different promotions (can't think of many good examples), something INCREDIBLY simple/passive (like bBlitz), or something which will have numerical differences between different promotion (like iCombatBonus). Something which is a "do this thing each turn" hits a bit of a grey area (it could be a fairly simple thing, like March promotions "always heal"). However, the moment you talk about targetting and strategic choices, then it starts to sound more appropriate for python to handle.
     
  10. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    This thread wants to be stickied. Please, moderator, sticky it.
     
  11. renegadechicken

    renegadechicken Warlord

    Joined:
    Aug 12, 2007
    Messages:
    227
    Location:
    Civ II Verne Scenario
    Yes, definitely! :)
     
  12. Agent327

    Agent327 Observer

    Joined:
    Oct 28, 2006
    Messages:
    16,103
    Location:
    In orbit
    Better actually PM a Mod or they might not see (to) it.;)
     
  13. Ajidica

    Ajidica High Quality Person

    Joined:
    Nov 29, 2006
    Messages:
    20,314
    Very nice job. I only read the fist post and basics of the dll, but very well writted and useful once I get into the dll after learning python. We needed an idiots guide.
     
  14. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    OMG ! Can I really ask for moderator status when I'll be blind ? (sthg that will happen eventually :cool:)

    More seriously, I prefer to be confident and think moderators are reading the threads by themselves from time to time and not only upon user's report. I think that sticky thread doesn't have to be requested, petitioned or lobbyied. IMO polite suggestion is all about it.
     
  15. Agent327

    Agent327 Observer

    Joined:
    Oct 28, 2006
    Messages:
    16,103
    Location:
    In orbit
    Well, if you think lobbying will do no good... (I merely mentioned it, because there's countless threads out there, which can't possibly all be read by moderators - they'd have a full-time job doing that.)
     
  16. LoneTraveller

    LoneTraveller Warlord

    Joined:
    Apr 30, 2008
    Messages:
    283
    Location:
    Montreal, Quebec
    I need basic info about python and SDK. I'm learning the xml part of modding and getting to a point of working the files okay by myself (through the help of many ppl in these forums).

    I'm wondering when would I need python or SDK ? What is the modding point when someone has to migrate to python or SDK ? An example for each would be nice.

    Thank you
     
  17. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
  18. LoneTraveller

    LoneTraveller Warlord

    Joined:
    Apr 30, 2008
    Messages:
    283
    Location:
    Montreal, Quebec
    Its helpful indeed.

    Thank you.
     
  19. Kalimakhus

    Kalimakhus Emperor

    Joined:
    May 8, 2007
    Messages:
    1,249
    @xienwolf

    I just wanted to say that this is really a wonderful and most needed guide. I've read the intro and skimmed through some of the other posts and I really like the way you explain things so as to make it really easy for beginners who possibly have never wrote C++ code before. On the other hand the guide is so helpful even for those who know C++ very well. There is a difference between knowing the language and knowing how to get things done with a specific API.

    I hope a moderator would notice the thread and sticky it but I doubt it will happen unless someone (maybe you) PMs one of them. I can judge from the fact that the thread for setting up the SDK with Visual Studio has been around for years without becoming a sticky up till now. Moderators have limited time and they would spend it in the most trafficked sub-forums (this is not really one of them of course).
     
  20. Thunder_Gr

    Thunder_Gr Emperor

    Joined:
    Dec 8, 2008
    Messages:
    1,362
    Location:
    Universe
    Amazing guide Xienwolf! Thank you! :goodjob:
     

Share This Page