Disable spell cast message?

Poke

Warlord
Joined
Oct 30, 2010
Messages
168
Been trying to set up a promotion which affects a unit in relation to the capital. I have this working (though I can't get square roots to work) but I've had to do it the same way Crown of Brilliance works, a spell autocast every turn. Because its a spell though, there's always a message stating it has been cast at the top of the screen, and considering this promotion effects all the civ's units, it's just going to get annoying. Is there a way to disable the message, and it's 'ding' noise?

Ideally I want this promotion to work with pyperturn, but I can't get it to work with that at all
 
Could you give any more specifics? Maybe post the code? What is the code supposed to do.


It should be possible to have the promotion work only with the PyPerTurn effect, but you may need to use more complex and slower python to do effects that would have been handled in xml/C++.


It is generally considered bad form, but you could also have the effect of the spell handled by its python prereq instead of its python result. The spell would never be cast so the message would not show, but it could still do stuff before returning that the prerequisite is never met. This effect would not happen once per turn, but rather whenever a unit is selected (and has not cast yet, unless you make the spell IgnoreHasCasted). It would fire whenever the unit moves to a new tile, or if you just deselect and reselect the unit. I fairly recently realized that the AI does not check for casting as often though, so it does not seem to benefit from such passive spells most of the time.
 
The code is based off the Teleport-to-Capital spell. Units with the promotion lose benefits according to the distance from capital. The code works, but requires the caster and loc arguments, and I'm guessing pyperturn only supports one? (I don't know much about python, I'm just picking away learning from current scripts)

I'll try it the way you suggested. The spell only needs to fire if there's a change in position, so that should be sufficient for now - AI code for this civ is going to be a nightmare anyway.

Thanks :)
 
The only parameter passed to PyPerTurn is pCaster, but you can get the location with pCaster.getPlot() pretty easily. Actually, I don't think CIV4SpellInfos.xml has any other real parameters either. You can hardcode things (I use this in a much more general sense than Kael would) it in either place though, as integers or strings.


I'm curious as to why your code would require the loc argument when the code it is based on actually does not. The Escape spell in CIV4SpellInfos.xml passes 'Capital' as a second argument to def spellTeleport(caster, loc) in CvSpellInterface.py, but this second argument is never actually called by the code below and so is actually irrelevant. (I think loc may have meant something in an old version of FfH, but has been superfluous at least since the move to BtS.)



PyPerTurn effects happen once per turn, which could be before or after moving. The player has no real way of controlling exactly when it will happen. If you want it to be called whenever the unit moves then you either need to make SDK changes to re-enable the onMove calls, or use the python prereq as a spell.


If this effects all of the civ's units, then you probably don't really need the promotion at all. You just use a civilization prereq for the spell instead.

If distance from the capital is important, be sure to consider what happens when the civ had no capital, like at the start of a game before their first settler settles.
 
I tried it with pCaster the other day, but it didn't initiate the script - nothing happened. I could only get it to work using the modified teleport spell. I'll try it again though, I suspect I missed a tab or used a capital letter in the wrong place or something (just realised today how pedantic python is!)

I thought it was odd that it didn't use 'loc' either, but I'm clutching at straws in wondering why pyperturn wasn't working

No worries about the capital not existing, have a conditional set for that

The nature of the promotion/spell should be passive. If I can get pyperturn to work that might be ideal, and I can compensate whether the effect happens before the unit moves or not either way. I don't know which method is the least expensive to use though, the bad-form prereq spell, or pyperturn


Don't suppose you know how to import math functions into the script? I tried adding "import math", hoping the module was there already but it didn't work. It's not vital, but I'd love to get math.sqrt(x) or x**.5 working

Cheers again
 
might be a stupid proposition but why not make it layered :
-basic promotion given by race/civilisation.
-acitvated promotion : attained when requirements are met (close enough to capital eg 15-10tiles), needs basic promotion.
-activated promotion 2 : attained when requirements are met (closer from capital, eg 10-5 tiles)...etc
...etc

have the "attained when requirements are met" be evaluated at each movement of the unit.

for distance evaluation, you can use either
-"higher of vertical distance and horizontal distance" as the biggest of the two is exactly the distance the unit will travel to go from one point to the other, movement cost/roads not being taken into account.
-number of movement points/turns as if calculated for a displacement of the unit (the counter should be somewhere) : takes roads into account and the fact that logistics is easier with roads and through plain than on wild forestedhills: Issue: haste and mobility might affect the count if turns are used.
 
might be a stupid proposition but why not make it layered :
-basic promotion given by race/civilisation.
-acitvated promotion : attained when requirements are met (close enough to capital eg 15-10tiles), needs basic promotion.
-activated promotion 2 : attained when requirements are met (closer from capital, eg 10-5 tiles)...etc
...etc

have the "attained when requirements are met" be evaluated at each movement of the unit.

for distance evaluation, you can use either
-"higher of vertical distance and horizontal distance" as the biggest of the two is exactly the distance the unit will travel to go from one point to the other, movement cost/roads not being taken into account.
-number of movement points/turns as if calculated for a displacement of the unit (the counter should be somewhere) : takes roads into account and the fact that logistics is easier with roads and through plain than on wild forestedhills: Issue: haste and mobility might affect the count if turns are used.

Thanks for the info :)

The benefits are currently planned like that, with perhaps 10 promotions to make the effect seem more continuous, rather than discrete jumps once a conditional is crossed. For now I'm just using caster.setbaseCombatStr to see if its working correctly. It still has to be calculated each turn/move though

For distance eval I'm using pythagoras (though I can't use square roots) - it's only the physical distance I need, not the time/turns. I'll explain why once I've shifted the barebones over from FfH
 
MagisterCultuum, that pyrequirement setting works perfectly. Thank you
 
poke :
for distance : don't use pythagoras.
as in civ, a unit can go 2 left, 2up or 2 diagonal..
and 2left + 2 up costs two times more movement than 2diagonals but reaches the same place.

Thus, in cIV, for distance, you can really use the max of horizontal dist versus vertical distance.

else there should be 2 "distance from palace" counter somewhere ... but I don't know where :
-to calculate the "distance from palace" in a city maintenance.
-distance to palace is somehow taken into account when you do a trade mission with a GM (it takes into account : same continent, other civ, target city size/commerce/culture, capital size size/commerce/culture, and distance from palace (different results on the same continent if you go farther from your palace).
 
I couldn't find the distance-from-palace code - I assumed it was in the dlls. Movement isn't an issue for this mod - I'm really after the radial distance in the purest sense, similar to how cultural borders look when they extend. Pythag works great considering the map is a cartesian plane

I can't get the square root (neither math.sqrt(x) nor x**.5 work) I can set the conditions based on the (x1-x2)²+(y1-y2)² result. It wasn't vital, but being able to root would have been nice
 
Top Bottom