Changing the Magic system

Ok, I am now finally sitting down to play with this. But before I go and ruin my installation, (yes, I made a copy of FF BEFORE I started to mess with this), I would like to run my ideas past you.

What I am planning on doing is basically copying the worker function. The current worker function is like this
PHP:
int /*BuildTypes*/ CyUnit::getBuildType()
{
	return (int) m_pUnit ? m_pUnit->getBuildType() : (int) NO_BUILD;
}

int CyUnit::workRate(bool bMax, int eBuild, int eFeature)
{
	return m_pUnit ? m_pUnit->workRate(bMax, (BuildTypes)eBuild, (FeatureTypes)eFeature) : -1;
}

What I think this means is getBuildType() determines what is being built. This would be modified to become getSpellCast(). This would then get what spell is being cast, and how much mana is required to cast it. workRate(bMax, (BuildTypes)eBuild, (FeatureTypes)eFeature) I don't know what this does however. I think it places the workers work rate into the feature, adding that to the construction of what is being built. Then from appearances, the feature itself is what stores how much work has been done on it to get a particular construction completed on it.

So to convert this to spellcasting, I would need to create a "spell" unit (or promotion, or something) that then gets the units "mana" added to it, and once complete, turns into the spell. That at least is what I think would end up needing to be done to make it work. Please correct me if I am wrong.

-Colin
 
Personally, I dislike the coloring done by [php][/php] tags, and much prefer simple [code][/code] tags. Completely personal preference though.

First problem is you are looking in a Cy_____ file. These files are a bridge between python and DLL, so just point you at functions which actually do things and tell you stuff. Head to the Cv____ files instead.

getBuildType tells you what action the unit is already involved in. There are other functions which actually start the building process (CvUnit::build(BuildTypes eBuild) being chief among them). You'd be more interested in shadowing those functions.

workRate tells you how many points the unit can contribute toward the iCost requirement of the Build order. So basically it is your Mana value. Since yours isn't highly variable, you can just use it directly, no need for the extra complications which builds need.


For spellcasting, it depends on how you want to work the ability to cast over multiple urns and share casting between units for how to store the mana up.If the caster will be immobile while casting with no option to break out of the cast, you can store on either Unit (caster) or Plot. If the caster may move while casting without interrupting his spell, it needs to store on the unit. If caster can move midcast, but loses all progress, again it doesn't matter which you store on. If caster can return to the same plot to resume the casting, it must be stored on the plot. If other casters can join in on the casting from across the map, you need to store on the player, if your allies can assist in the casting, it must be stored on the team...


Wherever you store it though, once enough is saved, you launch the spell from that place/person/item and you are done.
 
ahh... that was my problem. I was wondering why all the files seemed to be straight oneliners...

From what you've said, it looks like it doesn't matter if I store it on the tile or on the caster. If the spell takes more mana than the caster has, the caster will be immobilized, whereas if it takes less, the caster will cast the spell and be able to still move around etc.

As for the "mana", I plan on there being mana added solely from promotions - no unit will start out with mana. Channeling 1-3 each grant 10 mana, potency will grant 10 mana, and I'm planning on adding another line of mana granting promotions. Similarly for willpower, channeling 1-3 will each grant 10 willpower, and summoning 1-5 will grant 10 willpower, and combat 1-5 to summoned units - mages won't be able to take combat 1-5 themselves though.

-Colin
 
Yes, if you intend on immobility you can choose tile or unit. If you choose unit, then the caster who started the spell will be the one to finish it (bonus promotions or extra strength/resistance). If you choose unit, then you can decide on the most ideal caster present, or all of them, for bonuses (though you could still do that from the unit honestly).

All code for spells currently is in CvUnit, so that is probably ideal. With them being immobile, having the spell on the tile just makes it easier to let the spell keep going if the initial caster dies, and harder to cheat and move midcast by unexpected devices (immortal rebirth, event, portal, cargo...)
 
Ok, I have been looking at the code in my free time (which is amazingly sparse by the way), and have come to a few conclusions.

First, I need to create a new variable called mana or something like that. Once I have that, everything else seems to be rather easy.

From what it looks like, I will modify getCastingLimit() to return how much mana the caster has. As long as this is above 0 it will allow CvUnit::cast to run. Then, I will need to change cast so that way when a spell is cast, it reduces that much mana from the caster, and if the mana needed is greater than what the caster has, it puts it on a delayed cast. Then each turn the caster gains back his max mana amount, but is held until he has used all the mana needed to cast any spell that requires more mana than he has.

So then the question is - how do I add mana as a variable that can be used in XML and such? And do you think that I'm on the right track?

-Colin
 
Hi Colin --

I like some of the magic changes you are proposing. I am looking into making some other changes to magic in my "Dynamic Dural" thread. My changes are complimentary to yours but might be of interest to you.

Basically, I have created an alternate Great Commander unit called the "Arcane Analyst." This great commander is intended to provide a special chain of commander promotions that enhance magic users, although they are not a real magic-user on their own (although I might add few oddball buff spells for flavor.) Right now the unit is locked to be Dural-only and has to be promoted to from the Professor although it might be interesting to expand it to the Amurites and perhaps the Sheaim (yeah, extra promotions for Sheaim to bring about Armageddon earlier!)

The flavor of this unit is that they are not a mage themselves, but are a sort of "mage consultant" that comes at or after Sorcery. They're like a moving magical library that mages can consult for help. It's hard to get them, though -- and even harder to keep training, promotions and XP should be expensive for them. The Dural model that I am building is of a training-oriented society that requires lots of special and expensive buildings to train them.

Right now the only arcane-related commander promotions that are in "stock" FF (heh that is kind of an oxymoron) are "Arcane Mentor I" and "Arcane Mentor II". Each of these add an XP rate gain bonus to the units commanded. I have also created two new GC promotions -- "Arcane Detachment I" and "Arcane Detachment II" -- which give Spell Extension I and Spell Extension II to the units commanded. I am going to add more promotions to be available for this unit so there are many possible promotions paths and the player can choose to be a generalist Arcane Analyst or go crazy on some particular summoning path.

I wonder if the promotions for Willpower you might be interested in would be useful to associate with this Arcane Analyst, and if this unit might also provide some more of the magical flavor that you want. Sort of an elder magical sage to provide guidance to up-and-coming wizardous whippersnappers :).

Thanks --

jrandrew
 
What I want willpower to be is something that every caster has, and it would determine that casters ability to control his summons. This would make willpower be something solely associated with that unit.

However, because I'm trying to relate willpower to units through promotions, you would be able to create a promotion for a commander that grants additional willpower (or mana) to all his underlings.

So for an example right now - a sheim adept. As an adept, he gets channeling 1, which gives him 10 mana and 10 willpower. The summoner trait grants summoning 1 to all arcane units, and the arcane trait grants potency, which will in additiong to granting faster levelling up, will also grant 10 mana. Summoning 1 grants +10 willpower, and combat 1 to all summoned units. If this adept wants to focus on being a summoner, and the civ has 2 death mana, he can take his first 4 promotions (free one, the ones at 2xp, 5xp, and 10xp), on getting summoning 2-5. This would mean that he would have 20 mana, and 60 willpower. If a skeleton costs 10 willpower to maintain, and 20 mana to summon, that would mean that he would be able to control 6 combat 5 skeletons. If there was anything else that granted willpower (tower of necromancy, staff of summoning, etc), he would be able to control even more.

If you wanted to make a commander who could buff arcane units, you could add a promotion "Master Summoner" or something like that, that grants +x willpower to all units under his command, or reduces the costs of all summons by x willpower, or whatever you would like. Similarly, you could do the same for mana. If you wanted to make this "Arcane Analyst" only able to help mages, you could make him be an "upgrade" of the great commander. For example, using your dural, instead of getting a tactician upon recieving a great commander, they could recieve a commander. This commander could then upgrade to a tactician if you wanted him to focus more on helping regular units. Or you could allow him to upgrade to the Arcane Analyst, who is blocked from many of the regular promotions, but recieves additional possible promotions that are limited to just him.

As for myself, First I am planning on getting mana and willpower working in the DLL. Then I'm going to go and change the current spell system. Once I have all that, then I'm going to look at other nerfs/buffs opened up by this new system. If you would like to use what I make in your own however, you are more than welcome to use what I make once I finally get it working.

-Colin
 
I actually really like the idea of this and got to thinking about a couple of things. This is mostly just ideas I thought would go well with this and you might like enoguh to actually consider, though.

(Worth noting I have NO idea about modding Civ4, so some things may or may not be impossible. Most will likely be stupid.)

I like heroes because they're unique. Love Grigori for adventurers, though the backstory for them helps. So one of the first ideas I got from this was ways of making generic units more unique.

Someone mentioned storing the Willpower/mana totals for each unit in the unit itself, instead of just tallying the promotions and unit type. This may be completely impractical, but what about making the values for each mage a little random? Stock adept has 10/10 mana and willpower. Would it be possible to make them random between five and fifteen, for example? It may be better to make them have to add up to 20, but even so it would make specific adept/mages naturally better at certain things - summoning or 'normal' magic. This would probably require changing mage and archmage upgrades to multiply the totals by 2 and 1.5 respectively instead of +10 to each, but yeah.
Could be annoying when trying to build a stack of summoners/fireball lobbers, but thats kinda the point - you wouldnt realistically get an entire group of people exactly as good at everything as each other, and it would make it more fun (IMO at least).

Tying into that is two abilities every mage unit would have - concentrate and uhh...focus mana. Crappy names but they work for this at least. One would permanently sacrifice three mana and one strength to add one to willpower, while the other would do the reverse (Still -1 strength). Almost always a bad idea, but it would be incredibly useful for certain situations. 'oh crap I'm gonna lose my capital. If only that mage had one more mana so I could cast X' sorta things. You mess up the unit you spent so long getting xp for, but it might just save your city/army/give you that little boost needed to wipe somebody out.

Last thing because I write too much: You already mentioned mages being able to work together when summoning, but what about expanding it? I dont know how much you want to change the spell system (Or add any spells at all, no idea), but what about spells/summons that cant be used with just one guy? Really strong summons that need massive willpower totals to not go barb the next turn every time, spells that require so much mana that a fully upgraded archmage with 15 starting mana couldnt come close to and take several turns to cast, but drastically weaken an entire army etc. I've had it happen a few times where me and the AI/other guy have a huge stack each, but one is in a city with fortify bonus and it ends up with both armies sitting there since the attacking stack cant beat the defenders, but dont want to leave them to start their own invasion. Making the defender decide between rushing out to kill the group of mages casting X spell or taking the hit and hoping they can still take the other stack is one example. It would make marksman and guardsman better too :D


...Bugger, I DID have something constructive to say that wasnt mindless wishing, but I seem to have forgotten it.
 
I don't like the idea of getting random mana/willpower, simply because right now as a kind of general idea I want level 1 spells to cost 10 mana, level 2 20 mana, and level 3 30 mana. Similarly for willpower. With that being said, it would really suck to have 1 adept who has to take 2 turns to cast a level 1 spell, and another who can cast 2 every turn. On top of that, I'm not sure how to put a random number into the XML.

Another point about that though is that an adept/mage/archmage isn't just one person. It is a unit, just like everything else. The difference is instead of everyone in the unit being great spellcasters or somesuch, the unit consists of the spellcaster and his followers who do things like help him with his rituals/etc.

To change the ability of the various adepts and such, I plan on having sets of promotions that they can take. These promotions would allow you to choose between having more spells to cast, having your direct damage spells do more, being able to control more summons, or being able to cast more often.

As for group casting, I haven't made any decisions here yet. I have considered what would be needed to make it work, but for now it has been set aside until I get it working.

-Colin
 
Ive been meaning to learn xml (And to a lesser extent, Python - Mount&Blade made me shy away from it a little though) for awhile, so if nothing else you gave me an excuse to take a look at a couple of the files :D

Heres a slightly relevant question: Will adepts/mages/priests be limited in the spells they can cast (Like now), or will the channelling requirements be removed and the higher level spells just take way longer for the lower tier units? If the second, is it just a straight 'better unit types have more mana' thing, or would the higher level channellings grant multipliers? (Channelling 2: +10 mana/willpower, 0.8x mana/willpower cost for level 2 spells (Example again)) Then again, that last part would screw with the set mana costs so probably a bad idea.

Final thing before I shut up spouting random ideas properly: have you considered toggleable metamagics (Not the mana type) ala MP Turbo from FF games? Probably stuff like summons taking 30% less willpower but having a -20% strength promotion, AoE range+1 for 100% mana cost etc. I see 'em functioning like the assassin's mask (Minus religion requirement - or maybe not?) While mages and archmages would still be way better than their lower counterparts, being able to use higher tier magic before leveling that far (Even if it does take more turns) would devalue them somewhat. This was the most interesting thing I could think of to fix it ;)

...And yeah, finding combinations of metamagics to fit situations would be silly amounts of fun. Especially figuring out what combinations other players use.

Actually, I need to start writing these down before I forget. I think I finally found an excuse to dig out python for an actual reason :O
 
Spells will still be limited by channeling. The primary purpose of mana/willpower stuff is to make it possible for higher level mages to have some point to casting lower level spells. In addition, I am also planning on having mulisphere spells. Ex. Fire 3 + Air 3 will allow you to cast 3 spells instead of just 2. However, because I'm also adding promo's that buff up a mages mana/willpower/spelldamage, etc. It won't be a simple case of "Hey, let me take a few more spell spheres, cause I have nothing else to use my promotions on". You will have to decide - "do I want more options and mix spells, or do I want to be able to cast more often".

At the moment the general idea is to change the current spells to be 10x mana for regular spells, 20x mana and 10x willpower for the summons, with x being the spell level. Then the mix spells might change things - some mix spells will cost more/less mana than other spells of their level, etc.

To prevent WAY to many combinations, I am limiting mix spells to be within the same sphere. So Elementalism sphere's will only mix with other elementalism spheres, etc.

-Colin
 
Sounds like a good way of doing it. As for multisphere spells, what about metamagic? Would that have none, or a couple of random ones, or what? Multisphere spells with more than two spheres? Granted, the last one is only because I see a fire+air+water+earth spell being the magical equivalent of a nuke, but still.



Also, completely out of place here, but where would I ask about how to do basic stuff to figure out how to mod stuff e.g. add a promotion or spell sorta thing. The mod modder thread seems to be for people who already know the basics of it.
 
The problem with multsphere spells with more than 2 spells is that the spell schema only allows 2 prerequisite promotions per spell. You could use a pythoprereq to check to make you it has any number of promotions, but that would be slower and would not automatically show up in the pedia or mouseovers. You could also change the schema, but to make it would you would have to compile a new DLL.



Eventually you'll probably want to try python and maybe even C++, but it is probably best to start to learn to mod by toying around with the XML files. You can copy existing spells, promotions, units, etc., and then change a few things. Most of the tags are fairly self explanatory.
 
The problem with multsphere spells with more than 2 spells is that the spell schema only allows 2 prerequisite promotions per spell. You could use a pythoprereq to check to make you it has any number of promotions, but that would be slower and would not automatically show up in the pedia or mouseovers. You could also change the schema, but to make it would you would have to compile a new DLL.



Eventually you'll probably want to try python and maybe even C++, but it is probably best to start to learn to mod by toying around with the XML files. You can copy existing spells, promotions, units, etc., and then change a few things. Most of the tags are fairly self explanatory.

OR you could use autoacquire effect promos that require two spell spheres, that grant access to the cross sphere spells. ;)
 
Inventive as always Valk.
 
OR you could use autoacquire effect promos that require two spell spheres, that grant access to the cross sphere spells. ;)

I had not noticed that this was in the FF subforum, or I would have mentioned that.


I'd suggest that new modmoders start with FfH instead of FF. There is just too much to go though here, and it is easier to become familiar with the XML without all the trimming.
 
Well, for multisphere stuff, I refuse to have combinations involving more than 2 spheres. So you might mix fire and earth and get 1 spell, or air and ice and get another, but you will never mix fire, earth, and air - you will end up with three spells fire-air, fire-earth, and earth-air, more than enough to make it worth it to make some mages just elemental mages, and other mages just necromancy mages, etc. This, combined with only allowing combination's within one tech grouping allows me the latitude of having more spells than what is currently available (and being able to go wild with some combinations) without making my head explode trying to think of combinations for everything. As for metamagic, well, I'm going to try to get dispell magic to actually work how it is supposed to, as well as giving it a chance to dispell all summons within 1-2 squares, and change floating eye to apply a spell damage resistance promo. This would basically make it the anti-magic, giving protection against both direct damage mages and against summoning mages. However, I'm not planning any combinations with metamagic.

The only exception to the outside of sphere combination that I'm considering doing (after I get the base system working), is with enchantment. I may ressurect my enchantment overhaul, and change the enchantment spells from what they currently are to requiring an enchanter to have enchantment and another sphere to allow him to create items. This would be something like Enchantment 1 + Fire 1 allows firey blade, an item that gives +1 fire combat and allows the unit to do collateral damage (increases collateral cap by 10%). Of course, this would also mean buffing current ingame items, like orthus's ax, so the enchantment overhaul would be a fairly big project. As such, it is on hold until I overhaul the entire magic system.

As for learning to mod - its simple and easy. Just make a copy of whatever mod you are trying to make a modmod of (ex. FF), just in case you accidentally screw something up. Then go in, look at what is already there in the XML, and modify it however you want. For example, if you wanted to add a spell, then you can look at a spell that is already there (ex. enchant blade). If its something that requires python, look at something that already uses it (ex. scorch). If it requires DLL - find some other way to do it, ask for help from someone, or put it aside until you really want to learn C++ and working in pre-existing code.

-Colin
 
Ok, had a chance to sit down and go through the DLL again (this is going rather slowly... damn trying to get an engineering degree). Changes I've made so far

Added m_paiManaAmount and m_paiManaCost to CvUnit::CvUnit()
Added SAFE_DELETE_ARRAY for both under CvUnit::uninit()
Added changeManaAmount(kPromotion.getManaAmount()*ichange) in CvUnit::setHasPromotion()

Changes that I'm going to be doing, but haven't gotten to yet
add getManaCost() (a function that gets the mana cost from the spell, and returns an integer with that number)
add changeManaAmount() (a function that changes the mana amount that a unit has)
modify CvUnit::cast(), where it says
Code:
if(getCastingLimit()>0){changeCastingLimit(-1)}
to
Code:
if(getCastingLimit()>0) { changeCastingLimit(-getManaCost())}
and also add in somewhere what to do if the mana cost is greater than the amount the caster has.
modify getCastingLimit() to track how much mana the unit has, and how much has been used. Therefore, changeManaAmount will keep track of the units total mana, but casting limit will keep track of how much it has left.

I will also need to add a few lines to the header file.

My first question then is - what do I need to do to make it usable from the XML? I looked in Xienwolf's guide to the DLL, and maybe I'm just blind, but I didn't see anything in there that tells me what I need to do about that. I was trying to copy what I saw for affinity, but after browsing down half the CvUnit.cpp file, i kinda gave up on keeping track of that.

And my last question is - do you guys think I'm going the right direction for this? Or am I about to commit a colossal error that will leave me starting back from scratch?

-Colin
 
Top Bottom