NP300
Prince
Random Invisibility Mod
I have been working on a mod to incorporate randomness into the invisibility system. For a long time I have thought that it is boring for destroyers to be able to see submarines 100% of the time. I thought it would be more fun if they only had a certain probability of spotting the sub, such as 25%.
Originally I based my mod on Primem0ver's Graded Invisibility Mod. However, primem0ver has not updated his mod for Beyond the Sword.
Recently, Thomas SG discovered that the newer versions of Beyond the Sword incorporate a graded invisibility system. Thus, I have been able to use this to build my Random Invisibility Mod.
I owe a debt to Primem0ver, since examining his code allowed me to figure out where I needed to make my changes.
In addition, I have incorporated Lethal Sea Bombard into my mod. Now any air units with an iAirCombatLimit above 50 can sink ships. For this, I am in debt to Gedemon and his Air Forces Mod, since examining his code allowed me to see where I needed to make the changes. I used Gedemon's code, and modified it to make it work with Beyond the Sword 3.13.
How does the Mod work? I have added three tags to GlobalDefines:
EXTRA_MAX_AIR_DAMAGE_TO_SEA is from Gedemon's mod, and works in the same way. It controls how much the iAirCombat Limit is increased for attacks on sea units.
RANDOM_INVISIBILITY_NUMERATOR and RANDOM_INVISIBILITY_DENOMINATOR control the base probability of seeing an invisible unit. For example, if you want your units to have a 50% chance of seeing invisible units, you set the numerator=1 and the denominator=2.
The values should be greater than zero and not greater than 32,000.
If you use the SeeInvisible tags in Civ4UnitInfos carefully, you can give different units different probabilities of seeing different units. For example, in the sample Civ4UnitInfos that I have provided, the SeeInvisible for the Attack Sub reads as follows:
Notice that INVISIBLE_SUBMARINE appears twice. This makes the code give the Attack Sub two chances to spot Subs (instead of the default of one). Therefore, the Attack Sub has a greater chance of seeing Subs, than of seeing Attack Subs.
How can we calculate the odds of spotting an invisible unit? By default the numerator=1, and the denominator=8. This means that the base odds are 1/8. So you would think that the Attack Sub has 1/8 chance of spotting an Attack Sub, and about a 23% chance of spotting Subs.
Math:
1 - [(1 - 1/8)*(1-1/8)] = 0.234375
However, it is not so simple, because the invisibility code is recalculated each time a unit moves. Therefore, the odds of seeing an invisible unit are higher than stated above in practice. By how much depends on how many moves a unit has, and how far away said unit can see.
With the default 1/8 base odds, the sample SeeInvisible tags, and a visibility range of 2, I have found that Attack Subs can see other Attack Subs about 23% of the time, and can see Subs about 40% of the time.
To increase the chances of a unit seeing an invisible unit, simply repeat the relevant SeeInvisible tag more times as in:
The above provides 4 passes, instead of 1. The more times you repeat the same tag, the greater the odds of seeing the invisible unit. As you add the same tag, the probability of spotting the unit will approach 100%, but will never actually get to 100%.
To reduce the chances of a unit seeing an invisible unit, you can reduce the base odds to be lower than 1/8.
Setting numerator=1 and denominator=1 reduces the Mod to the normal state, where units with SeeInvisible have 100% odds of seeing invisible.
I have not tested this sample mod very extensively. Thus, I expect that it may have some unexpected bugs. This is particularly true of the Lethal Sea Bombard, which I have barely tested.
Notes:
1) Versions 0.2 and B 0.30 are for Beyond the Sword 3.17. Version C 0.60 is for BTS 3.19 and Better BTS AI 1.01.
2) Version B 0.30 is available here.
3) Version C 0.60 is available here.
4) If you use this mod in another mod, just give me credit. I would also appreciate it if you would let me know if you use this mod in your mod. I would like to know how people use this.
5) The SDK code is commented with "Random Invisibility" and "Lethal Sea Bombard" to let you know about the relevant alterations.
I have been working on a mod to incorporate randomness into the invisibility system. For a long time I have thought that it is boring for destroyers to be able to see submarines 100% of the time. I thought it would be more fun if they only had a certain probability of spotting the sub, such as 25%.
Originally I based my mod on Primem0ver's Graded Invisibility Mod. However, primem0ver has not updated his mod for Beyond the Sword.
Recently, Thomas SG discovered that the newer versions of Beyond the Sword incorporate a graded invisibility system. Thus, I have been able to use this to build my Random Invisibility Mod.
I owe a debt to Primem0ver, since examining his code allowed me to figure out where I needed to make my changes.
In addition, I have incorporated Lethal Sea Bombard into my mod. Now any air units with an iAirCombatLimit above 50 can sink ships. For this, I am in debt to Gedemon and his Air Forces Mod, since examining his code allowed me to see where I needed to make the changes. I used Gedemon's code, and modified it to make it work with Beyond the Sword 3.13.
How does the Mod work? I have added three tags to GlobalDefines:
EXTRA_MAX_AIR_DAMAGE_TO_SEA
RANDOM_INVISIBILITY_NUMERATOR
RANDOM_INVISIBILITY_DENOMINATOR
EXTRA_MAX_AIR_DAMAGE_TO_SEA is from Gedemon's mod, and works in the same way. It controls how much the iAirCombat Limit is increased for attacks on sea units.
RANDOM_INVISIBILITY_NUMERATOR and RANDOM_INVISIBILITY_DENOMINATOR control the base probability of seeing an invisible unit. For example, if you want your units to have a 50% chance of seeing invisible units, you set the numerator=1 and the denominator=2.
The values should be greater than zero and not greater than 32,000.
If you use the SeeInvisible tags in Civ4UnitInfos carefully, you can give different units different probabilities of seeing different units. For example, in the sample Civ4UnitInfos that I have provided, the SeeInvisible for the Attack Sub reads as follows:
INVISIBLE_SUBMARINE,INVISIBLE_SUBMARINE,INVISIBLE_NUCLEAR_SUB
Notice that INVISIBLE_SUBMARINE appears twice. This makes the code give the Attack Sub two chances to spot Subs (instead of the default of one). Therefore, the Attack Sub has a greater chance of seeing Subs, than of seeing Attack Subs.
How can we calculate the odds of spotting an invisible unit? By default the numerator=1, and the denominator=8. This means that the base odds are 1/8. So you would think that the Attack Sub has 1/8 chance of spotting an Attack Sub, and about a 23% chance of spotting Subs.
Math:
Spoiler :
1 - [(1 - 1/8)*(1-1/8)] = 0.234375
However, it is not so simple, because the invisibility code is recalculated each time a unit moves. Therefore, the odds of seeing an invisible unit are higher than stated above in practice. By how much depends on how many moves a unit has, and how far away said unit can see.
With the default 1/8 base odds, the sample SeeInvisible tags, and a visibility range of 2, I have found that Attack Subs can see other Attack Subs about 23% of the time, and can see Subs about 40% of the time.
To increase the chances of a unit seeing an invisible unit, simply repeat the relevant SeeInvisible tag more times as in:
INVISIBLE_SUBMARINE,INVISIBLE_SUBMARINE,INVISIBLE_SUBMARINE,INVISIBLE_SUBMARINE
The above provides 4 passes, instead of 1. The more times you repeat the same tag, the greater the odds of seeing the invisible unit. As you add the same tag, the probability of spotting the unit will approach 100%, but will never actually get to 100%.
To reduce the chances of a unit seeing an invisible unit, you can reduce the base odds to be lower than 1/8.
Setting numerator=1 and denominator=1 reduces the Mod to the normal state, where units with SeeInvisible have 100% odds of seeing invisible.
I have not tested this sample mod very extensively. Thus, I expect that it may have some unexpected bugs. This is particularly true of the Lethal Sea Bombard, which I have barely tested.
Notes:
1) Versions 0.2 and B 0.30 are for Beyond the Sword 3.17. Version C 0.60 is for BTS 3.19 and Better BTS AI 1.01.
2) Version B 0.30 is available here.
3) Version C 0.60 is available here.
4) If you use this mod in another mod, just give me credit. I would also appreciate it if you would let me know if you use this mod in your mod. I would like to know how people use this.
5) The SDK code is commented with "Random Invisibility" and "Lethal Sea Bombard" to let you know about the relevant alterations.