Magic/Square Selection demo mod

The Great Apple said:
Righty. I've been poking away all day trying to get teleportation to work... but I'm hitting one small snag. It would seem that self.chooserActive is never true, even when I've just set it to be true... which... is really quite frustrating.
Thats odd, can you post an example?

Also, about the right click thing, one solution is to just change it so right-click brings up the popup menu (thats what I have normally). However, returning 1 from onMouseEvent supposedly consumes the click, but maybe it doesn't work for the main map.
 
Well, finally got around to incoporating this ranged art into the game. Only problem, well not really a problem, but it would be nice to have some kind of explosion graphic to go along with the damage. Is there an easy way to release a version that incoporates an explosion upon use?:cool:
 
RED DIAMOND said:
Well, finally got around to incoporating this ranged art into the game. Only problem, well not really a problem, but it would be nice to have some kind of explosion graphic to go along with the damage. Is there an easy way to release a version that incoporates an explosion upon use?:cool:
Well, if you can make an explosion graphic appear at all from the python, it would be easy to make it appear when you use this. I posted an idea about this over here http://forums.civfanatics.com/showthread.php?t=154225 but I haven't tried it to see if it would work.
 
Well, it works, see the other thread for details or download the new version yourself (once the attachments are no longer "In Progress").
 
Yeah, they are part of the "In progress" attachments. I'll add links manually to the first post.
 
There we go. Try it now.
 
talchas said:
There we go. Try it now.

Yippie:lol: Got it working bro! Now to test more effects. I think the bombing/bombardment effects might look better:D

Sound has been resolved by the man TALCHAS!
 
Hrmm do you think it would be psosible using this, to have targeted promotions?

So you select a particular person, and that person gets the selected promotion?
 
Taranthor said:
Hrmm do you think it would be psosible using this, to have targeted promotions?

So you select a particular person, and that person gets the selected promotion?
Yes, you could do that. Instead of casting a spell, you could use unit.setHasPromotion("PROMOTION_ABC",True) to give it the promotion. The only problem is that if you clicked on a square with multiple units in it you would need a way to select only one of them.
 
Instead of casting the spell, can't you create a pop-up with a pulldown list of the units on that square, and a button called "Promote" or something?

You select the unit from the pulldown list, and then clicking the promote button returns the unit ID which then is affected by the setHasPromotion code.

The worldbuilder uses a pull-down menu when editing units... you select the unit you want to edit from the pulldown menu and then you edit that unit's stats. I'm sure it wouldn't be too difficult to look at that code and use it to choose who gets a promotion...
 
Yeah, you could do it - it would just take a bit more work.
 
Shqype said:
Instead of casting the spell, can't you create a pop-up with a pulldown list of the units on that square, and a button called "Promote" or something?

You select the unit from the pulldown list, and then clicking the promote button returns the unit ID which then is affected by the setHasPromotion code.

The worldbuilder uses a pull-down menu when editing units... you select the unit you want to edit from the pulldown menu and then you edit that unit's stats. I'm sure it wouldn't be too difficult to look at that code and use it to choose who gets a promotion...

I need a pulldown like that when my units with "Marksmen" ability attack a stack. "Marksman" allows the attacker to pick the defender instead of the goign against the best defender.

So let me know if you work out a good way to do this.
 
1st of all, very nice job talchas. Kudos to you. Anyways

talchas said:
[*](bug)Currently if you pick a spell + then switch units, it still lets you try to cast and is generally bugged. It should just cancel casting when you switch. You could probably get around the preresquisites for a spell like this.
Couldn't you use the onUnitSelected to cancel the casting after the player selects a unit, that is if casting is enabled?

talchas said:
[*]Changing the tooltips to add ones for the spell buttons and to display the mana for units would be nice too, but I have no idea if this is doable. Maybe if you used really large action numbers for appendMultiListButton that aren't used by Civ4 but are positive so you could somehow give them a tooltip? I haven't looked at that stuff.
Unfortunately, I have tried changing the tooltips for some of the new custom features in my new unnamed mod and it is hardcoded. I guess we will have to wait until the SDK comes out. :cry:
 
TheLopez said:
Couldn't you use the onUnitSelected to cancel the casting after the player selects a unit, that is if casting is enabled?

Probably, I didn't really look to find a way around that problem.
 
TheLopez said:
Couldn't you use the onUnitSelected to cancel the casting after the player selects a unit, that is if casting is enabled?
That's what I'm using and it seems to work fine, althought I don't do a check to see if it's enabled - surely it's quicker just to make it disabled no matter what?
 
I'm getting an error with this mod. It works fine until I save the game and exit. Then when I reload I get:

Traceback (most recent call last):

File "CvScreensInterface", line 601, in forceScreenRedraw

File "CvMainInterface", line 826, in redraw

File "CvMainInterface", line 1518, in updateSelectionButtons

RuntimeError: unidentifiable C++ exception
ERR: Python function forceScreenRedraw failed, module CvScreensInterface

CvMainInterface (I thinik you called it SpellDemoInterface) at line 1518 is where you add the buttons for the spells:

Code:
for spell in spells:
							#CyInterface().addImmediateMessage("spell %s number %d art %s" % (spell.getName(),spell.getActionNumber(),spell.getButton()),"")
							art = spell.getButton()
							actionnum =spell.getActionNumber() ##for some reason if I put this all on 1 line it gives me a MemoryError or an "unidentifiable c++ exception"
							screen.appendMultiListButton( "BottomButtonContainer",art, 0, WidgetTypes.WIDGET_ACTION, actionnum, -1, False ) #adds the spell button

It also looks like you had the same problem and thought you fixed it by seperating some code on to two lines.
Anyone know what could be causing this? Like I said, it works fine until you save, exit civ, and then try to load and continue the game.

Roger Bacon
 
I believe that the reason my thing works at all is that C++ is lazy and accessing a negative array (or something) index works - it just points to some random bit of memory. You can see this if you do "print CyGlobalContext().getPromotionInfo(-1).getSomeProperty()" in the python console - sometimes it will work and give gibberish, sometimes it will error out. Theres a semi-workaround in the ActionButtons mod which essentially goes through and sees which ones crash out and which ones work, and only uses the ones that work, but I haven't backported the changes here because not as many people seemed to be using it. When Firaxis can release the new patch and the SDK, I'll release a new version of ActionButtons that doesn't rely on this hack.
 
talchas said:
I believe that the reason my thing works at all is that C++ is lazy and accessing a negative array (or something) index works - it just points to some random bit of memory. You can see this if you do "print CyGlobalContext().getPromotionInfo(-1).getSomeProperty()" in the python console - sometimes it will work and give gibberish, sometimes it will error out. Theres a semi-workaround in the ActionButtons mod which essentially goes through and sees which ones crash out and which ones work, and only uses the ones that work, but I haven't backported the changes here because not as many people seemed to be using it. When Firaxis can release the new patch and the SDK, I'll release a new version of ActionButtons that doesn't rely on this hack.

So does this workaround allow you to continue a saved game? Right now I probably will not use this code because it makes it impossible to continue a saved game. Why are you using negative numbers for ACTION_NUMBER at all?

Roger Bacon
 
Back
Top Bottom