help with ranged bombardment

I removed the

Code:
	if (!pPlot->canSeePlot(pTargetPlot, getTeam(), airRange(), getFacingDirection(true)))
	{
		return false;
	}

And it fixes it in a good way (It can bombard at its range, but not when its hidden in fog of war). I.E. it cant fire in non visible areas, but it can fire if f.ex. a plane does recon mission or a friendly unit is close to target so it can "spot" it.

There is one thing though. The yellow borders are still there, and not showing as with planes, but with features/hills blocking.

The reason why I want to let sieges be able to shoot over forest and hills is that Arty, Mobile Arty and especially Rocket Arty shouldnt be blocked at range 1 coz of a small forest or similar.
 
Shouldn't the long range ones like Rocket Arty have a minimum range if possible to implement :D
Sounds weird to have someone launching a rocket at you when you are standing beside it.
 
the problem is that for the AI to use ranged bombard, it still need some <iCombatLimit> which means sieges can still attack directly, which I guess is even shorter than range 1 attacks.
Besides even a range 1 attack is several kilometers, so I think its ok as is (Im scared the AI wouldn't understand it anyway ;))
 
the problem is that for the AI to use ranged bombard, it still need some <iCombatLimit> which means sieges can still attack directly, which I guess is even shorter than range 1 attacks.
Besides even a range 1 attack is several kilometers, so I think its ok as is (Im scared the AI wouldn't understand it anyway ;))

well the quick fix to this issue is simpe but ugly. I simply made it so that the siege weapon's basic attack sucks miserably. To solve the AI attacking issue, if you take out all AI tags that cause the AI to attack directly, they won't do so. generally the tag called counter will make them bombard a lot.
 
you can try to test which unitai's make the units attack and which don't. not all of them are used for attacking. you can also set the defaultai to counter. this way the unit will use bombardment mostly but also use the units for other purposes as well. it doesn't work quite so well for certain combinations though.

you should be able to set unitai's in the worldbuilder through the unit editing option.
 
I edited the gamecore.dll so instead of the fixed constant damage/bombard damage, it will be a randomized 0 to Max value.
(I also randomized airstrike damage, collateral damage, number of units getting collateral and a few others) :
http://forums.civfanatics.com/showpost.php?p=12415323&postcount=76

and while the edit in itself is rather small and simple, it is the best change (including everything in my mod) that I have made to civ4 so far (imho)
 
I edited the gamecore.dll so instead of the fixed constant damage/bombard damage, it will be a randomized 0 to Max value.
(I also randomized airstrike damage, collateral damage, number of units getting collateral and a few others) :
http://forums.civfanatics.com/showpost.php?p=12415323&postcount=76

and while the edit in itself is rather small and simple, it is the best change (including everything in my mod) that I have made to civ4 so far (imho)

my feedback is I like it. can I ask for the changed code so that I can play around with it?
 
Its in CvUnit.cpp
example is for collateraldamage (red is the original), but as another one suggested maybe the range is too big (could be a total miss or a total max) so I came up with another (B) (that also doesnt require XML editing

Code:
int CvUnit::collateralDamage() const
{
	[COLOR="Red"]return[/COLOR] (GC.getGameINLINE().getSorenRandNum(([COLOR="Red"]std::max(0, (m_pUnitInfo->getCollateralDamage()))[/COLOR]), "Some Log Message"));
}

(B) (havent tested this one though)

Code:
	return ((GC.getGameINLINE().getSorenRandNum((std::max(0, (m_pUnitInfo->getCollateralDamage()))), "Some Log Message")) + ((std::max(0, (m_pUnitInfo->getCollateralDamage()))) / 2));
 
Its in CvUnit.cpp
example is for collateraldamage (red is the original), but as another one suggested maybe the range is too big (could be a total miss or a total max) so I came up with another (B) (that also doesnt require XML editing

Code:
int CvUnit::collateralDamage() const
{
	[COLOR="Red"]return[/COLOR] (GC.getGameINLINE().getSorenRandNum(([COLOR="Red"]std::max(0, (m_pUnitInfo->getCollateralDamage()))[/COLOR]), "Some Log Message"));
}

(B) (havent tested this one though)

Code:
	return ((GC.getGameINLINE().getSorenRandNum((std::max(0, (m_pUnitInfo->getCollateralDamage()))), "Some Log Message")) + ((std::max(0, (m_pUnitInfo->getCollateralDamage()))) / 2));

intereesting. from the way your code looks, it should work, but it doesn't seem to work for me =(
 
could I ask someone to test something for me? Just another crude test for ranged bombardment and AI's

so I'm thinking instead of having to remove unitai's that allow for the unit to attack people, it might be better just to set the bonlydefensive tag to 1 (aka machine guns can only defend). and of course you still have to use the counter unitai to cause it to use its bombardment attack.

edit: nevermind on this, it turns out I'll have to do this anyway.
 
could I ask someone to test something for me? Just another crude test for ranged bombardment and AI's

so I'm thinking instead of having to remove unitai's that allow for the unit to attack people, it might be better just to set the bonlydefensive tag to 1 (aka machine guns can only defend). and of course you still have to use the counter unitai to cause it to use its bombardment attack.

edit: nevermind on this, it turns out I'll have to do this anyway.

ok so here's the conclusion:

the ai script for the siege units to bomb cities will also cause them to attack units in a city for collateral damage. to avoid this, you'll need to use bonlydefensive. that way they don't get their offensive attack.
 
so, they will still use range bombardments even though they are defensive only?
In reality that just makes the unit better imho. I really wanted to get rid of the suicide sieges.

Im working on getting them to recieve XP for bombarding/Range Attacks (have already implemented it for Airstrikes and Airbombing, so hopefully it shouldnt be a big problem). Also working to make the yellow range indicator to show correctly (its currently being blocked by features having <iSeeThrough>1</iSeeThrough>)
 
so, they will still use range bombardments even though they are defensive only?
In reality that just makes the unit better imho. I really wanted to get rid of the suicide sieges.

Im working on getting them to recieve XP for bombarding/Range Attacks (have already implemented it for Airstrikes and Airbombing, so hopefully it shouldnt be a big problem). Also working to make the yellow range indicator to show correctly (its currently being blocked by features having <iSeeThrough>1</iSeeThrough>)

as far as i can tell, that's how they've been acting. I haven't thoroughly tested it, just a simple scenario test with wb.
 
Strange. I dont get any AI range attacks when setting it to defensive only. But if I remove it, the AI will attack Ranged and not directly.

Btw, I made a new button for range attacks :



Also, I need to apply the randomization directly at the attack, not at the definition, so the earlier code might work as inteded, but when mouseover the catapult it will show the randomized result, not the max possible result.
 
Strange. I dont get any AI range attacks when setting it to defensive only. But if I remove it, the AI will attack Ranged and not directly.

Btw, I made a new button for range attacks :



Also, I need to apply the randomization directly at the attack, not at the definition, so the earlier code might work as inteded, but when mouseover the catapult it will show the randomized result, not the max possible result.

oh, i put the earlier code in and i got the same % damage message every attack
 
the code was just for collateral damage, which isnt being shown. It have to be put in a couple of places.
I fixed the variable mouseover problem by putting the bombard code (it was only a problem with bombard, but i changed airbomb code to) into the attack, instead of the int.

I'm gonna clean the code (together with Air Combat XP mod, and a modified Bombard/Range Attack XP) and upload it as soon as I tested it thoroughly.
 
I changed the code and added a random XP between Min XP and Max XP given.
this is usually between 0 and 1, which I guess is ok, since giving too much tends to be overpowered.

I wanted it to be given by the effectiveness of the attack so
if
damage given < than 50% of max damage possible then 0 XP
and
damage given > than 90% of max damage possible then XP * 2

and might implement that later, but being so new to the SDK and C++, I think I wait a bit ;)
Anyone wants to give a go at the above is more than welcome. I marked all my changes with // Vincentz Random Damage.
 

Attachments

  • CvUnit.zip
    55.5 KB · Views: 51
I changed the code and added a random XP between Min XP and Max XP given.
this is usually between 0 and 1, which I guess is ok, since giving too much tends to be overpowered.

I wanted it to be given by the effectiveness of the attack so
if
damage given < than 50% of max damage possible then 0 XP
and
damage given > than 90% of max damage possible then XP * 2

and might implement that later, but being so new to the SDK and C++, I think I wait a bit ;)
Anyone wants to give a go at the above is more than welcome. I marked all my changes with // Vincentz Random Damage.

nice. I did a bit more testing, and it does seem that the attacking with the defensive only doesn't work. It must have been a bug when it did. I can't figure out a good way to stop these units from suicide attacking through xml. maybe give them a withdraw of 100%?
 
edit:nevermind other bugs found

edit:bugs fixed

Ok so here's the conclusion:

I set the unitai's to attack_city and counter, and I set the icombatlimit to 1. This made the catapults bombard units without charging in. There was one bug however. I'm assuming that this is because of the low number I set the combat limit to. the ai's siege units refused to attack any units in forests and/or on hills. Perhaps trying to set the icombat limit a bit higher would have a better effect, but that still needs to be tested.
 
Top Bottom