Ranged attacks - possible?

Discussion in 'Civ4 - Creation & Customization' started by Exel, Jan 16, 2006.

  1. Déja

    Déja Beyond the Mod

    Joined:
    Dec 19, 2005
    Messages:
    353
    That's one reason I'm doing the bomber air strike style of ranged combat, though with my mod, you can shoot blindly into fogged and undiscovered territory, but you won't know if you hit anything if you can't see it. (units that are there WILL be damaged, though)
     
  2. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    Expanding air strike to other units (when the SDK is available) seems like the best way to impliment ranged combat, as the code base for mechanics and the AI is already there. Different projectile types could be exposed to the XML (Aircraft, shell, missile, etc), and units could then have interception chances against different types, firing back at the attacker.
     
  3. Exel

    Exel Prince

    Joined:
    Nov 25, 2001
    Messages:
    440
    Location:
    Finland
    Could you care to elaborate the system you are using?

    I agree, this seems like the best way to go.
     
  4. Déja

    Déja Beyond the Mod

    Joined:
    Dec 19, 2005
    Messages:
    353
    I think I've already mentioned it earlier in this thread, but basically you click bombard (or attack or whatever it turns out being for that unit) and then you get the bomber targeting system. You click on the square you want to bombard, and it damages that square and the squares around it (if the unit can do collateral damage)
     
  5. RED DIAMOND

    RED DIAMOND Prince

    Joined:
    Dec 24, 2005
    Messages:
    380
    Forgive me for sounding daft but I just don't get it. Correct me if I am wrong , but it seems like Kael and Deja seemed to have the ranged art thing resolved to some degree, right?

    If that is correct, then why do we not have at the an Alpha of something that could provide this system to the Art in the game? Clearly this thing is over the heads of 90% of us and that includes people that now how to mod like me, its the coding part where I and about 90% of us loose out.

    Since that is the case refferals to other threads about spells etc. is really not helpful to those of us that don't know python(90%). What would be helpful is an Alpha release with instructions on how to implement the system for wider testing(this might actually help perfect the system). Just a thought.;)
     
  6. Exel

    Exel Prince

    Joined:
    Nov 25, 2001
    Messages:
    440
    Location:
    Finland
    Could you give me the code you are using so I can inspect it and possibly do further development on it? I'd be most appreciative.

    At least describe the exact mechanics involved. I'm a little lost here trying to figure out who did what exactly, so bare with me. If I understood correctly it is based on Kael's summoning code, right? Does it work by summoning a new "bomber" unit that is then able to carry out the bombing mission, or how?
     
  7. Déja

    Déja Beyond the Mod

    Joined:
    Dec 19, 2005
    Messages:
    353
    No, I don't use Kael's summoning trick. Mine actually plots a circle of targets and highlights the one under the mouse... then after the user clicks, it performs the strike.
     
  8. Exel

    Exel Prince

    Joined:
    Nov 25, 2001
    Messages:
    440
    Location:
    Finland
    Could you share your invention with us?
     
  9. Déja

    Déja Beyond the Mod

    Joined:
    Dec 19, 2005
    Messages:
    353
    I have... I use the spell targeting selection demo I've linked a few times on these boards. Look under the Completed Mods section.
     
  10. RED DIAMOND

    RED DIAMOND Prince

    Joined:
    Dec 24, 2005
    Messages:
    380
    Finally got the spell demo to work. There is no visual attached to it though?
     
  11. talchas

    talchas Prince

    Joined:
    Jan 3, 2006
    Messages:
    428
    No, although it may be possible, I am no good with visuals. There is a CyEngine.triggerEffect that might work though. It uses Assets/XML//Misc/CIV4EffectInfos.xml and you would use CvEffectInfo to figure out which was which and call the function. (all speculation, no testing done)
     
  12. elite_dannux

    elite_dannux Chieftain

    Joined:
    Aug 11, 2005
    Messages:
    26
    Location:
    Sweden
    are there any more news with this problem or a mod that is out in public?
     
  13. RED DIAMOND

    RED DIAMOND Prince

    Joined:
    Dec 24, 2005
    Messages:
    380
    Looked at the spell demo and got it to work. Still awaiting the offered write up on your method:D
     
  14. RED DIAMOND

    RED DIAMOND Prince

    Joined:
    Dec 24, 2005
    Messages:
    380
    Thx, but do you or does anyone else know exactly how to use this CyEngine thing in the spell demo files? Clearly, my python skills are limited so I really would not know how to invoke this command without crashing the .py file:lol:
     
  15. talchas

    talchas Prince

    Joined:
    Jan 3, 2006
    Messages:
    428
    Ooh, this is nice.
    Add this to a copy of your CIV4EffectInfos.xml:
    Code:
    		<EffectInfo>
    			<Type>EFFECT_SPELL</Type>
    			<Description>Boom</Description>
    			<fScale>0.2</fScale>
    			<fUpdateRate>1.2</fUpdateRate>
    			<Path>Art/Interface/Effects/EmpBlast.nif</Path>
    			<bIsProjectile>0</bIsProjectile>
    		</EffectInfo>
    
    Then add this to the same file as whereever your spells are defined:
    Code:
    def getEffectInfo(name):
    	for i in range(gc.getNumEffectInfos()):
    		item=gc.getEffectInfo(i)
    		if(item.getType()==name):
    			return i
    
    and add this at the bottom of your spell function:
    Code:
    CyEngine().triggerEffect(getEffectInfo("EFFECT_SPELL"),targetPlot.getPoint())
    where targetPlot is the name of the second parameter. This causes the ping effect (which looks like a pseudo-explosion, probably why its called empburst) to be displayed at whatever tile you clicked, running at 20% size and 20% more speed.

    Art/Interface/Effects/LaserHit.nif looks cool too - green ball giving off sparks.
    Art/Interface/Effects/ResourceBOMB.nif at 1/3 size or so would be ok for an earthquake - bit short though
    Art/Interface/Effects/Stasis.nif is nice - red ball and swirly stuff, but it would need to be moved down a bit, cause it is currently above the unit
    Art/Effects/fireworks/fx_fireworks_red.nif and of course fireworks!
     
  16. RED DIAMOND

    RED DIAMOND Prince

    Joined:
    Dec 24, 2005
    Messages:
    380
    When I get home tonite I will try it. Talchas you da man:goodjob: :king:

    Edit: Well I tried this and I am obviously inept when it comes to python.:blush:

    I tried putting the info into the spelldemo files in the places where it appeared/seemed like you said it should go(frankly I don't know exactly where in the 9 different spelldemo .py files the info really should go:confused: ) I got it working past the python hit and miss errors:D , but never got any visual effect:crazyeye:

    It would be ultra cool if some kind person that does know python would just add this one tiny little effect to the spelldemo:scan:

    If not, I will just have to be satisfied with no graphics or sound upon attack. Heck at least I was able to get it working and place it in some ranged units for my game. That was the bottom line anyway.:D
     
  17. talchas

    talchas Prince

    Joined:
    Jan 3, 2006
    Messages:
    428
    Well, there is now an updated version with the graphics in the spelldemo thread. No sound currently, although that is doable.

    On another note, it is possible to have the AI do stuff without the SDK (limited stuff). In CvGameUtils override AI_unitUpdate and place your AI code there. To make a unit move call pUnit.getGroup().pushMoveToMission(x,y), where pUnit = argsList[0]. It may be that if you return true from this method, the AI won't do anything, I'm not sure. If you want to do something afterward, I think you need to override CvEventManager's onUnitMove. You might want to just make a method doAI(unit) in something like MyMod.py and call MyMod.doAI in each of these methods to ensure you do what you want. Use the scriptData to make your code remember long term stuff. If you want to do something like trigger a ranged attack, do whatever you do in the ui code that lets the player do so in this location. So if you call MyMod.fireAt(tile) there, call it in the AI method too
     
  18. mystikmind2005

    mystikmind2005 Prince

    Joined:
    Jan 31, 2006
    Messages:
    510
    I have to say that nothing comes close to being as much of a disaster as the missing ability to attack units with the bombard ability from ships and artillery in civ4!! It is in civ3 so i have no idea why it vanished, I must assume people must have requested it at some point although I cannot imagine why?? Has everyone forgotten how annoying it is to throw away five frigates just to take out one cheating AI frigate?? Or am I the only unlucky player here? I need to be able to use the first 4 frigates to bombard the enemy ship instead of sacrificing them all for nothing.
    Is it possible to modify ships and artillery to work the same as they do in civilisation3?
     
  19. Kael

    Kael Deity

    Joined:
    May 6, 2002
    Messages:
    17,401
    Location:
    Ohio
    This system worked beautifully! :D Brilliant work coming up with it and thanks for sharing it with us. Im going to use it to spice up some of the spells in FfH.
     
  20. RED DIAMOND

    RED DIAMOND Prince

    Joined:
    Dec 24, 2005
    Messages:
    380
    Kael. If we might ask which files did you edit?
     

Share This Page