[MODCOMP] Sniper Mod

TheLopez

Deity
Joined
Jan 16, 2006
Messages
2,525
Location
Oregon
Sniper Mod
By: TheLopez

Last Updated 05/03/06

Version: v0.6.1
Patch Compatibility: v1.61
MP Compatible: ?
Download Mod v0.6.1

Description:

This mod adds sniper functionality generically to the game. To enable a unit to
have the sniper features their combat type must be set to UNITCOMBAT_SNIPER.
Two new units have been included with this mod component to demonstrate this
functionality: sniper and modern sniper. The sniper represents the sniper from
the ~1750s to the end of the 1800s or from the American revolution through the
American civil war. The modern sniper represents roughly what modern combat
snipers are today.


Installation Instructions:

1) Unzip this into the "civ4_install_folder\Mods\" folder.
2) Open the CivilizationIV.ini configuration file
3) Change the Mod line to read: Mod = Mods\Sniper Mod
4) Load the game.
5) Then play as normal.

-----Game Play-----
Spoiler :

- Added sniper unit combat type to differentiate snipers from regular military
units

- 25+ INI options allowing players to configure:
- Valid sniper targets
- How terrain affects snipers
and much, much more.


-----Units-----
Spoiler :

- Sniper:
[TAB]- Requires: Rifling Technology
[TAB]- Cost: 165
[TAB]- Combat: 9
[TAB]- Movement: 2
[TAB]- Invisible to most units
[TAB]- Can explore rival territory
[TAB]- 0-1 first strikes
[TAB]- -50% attack vs. mechanized infantry
[TAB]- -50% attack vs. armored units
[TAB]- Starts with sentry
[TAB]
Modern Sniper:
[TAB]- Requires: Assembly Line Technology and Sniper School
[TAB]- Cost: 210
[TAB]- Combat: 12
[TAB]- Movement: 2
[TAB]- Invisible to most units
[TAB]- Can explore rival territory
[TAB]- 1-2 first strikes
[TAB]- -25% attack vs. mechanized infantry
[TAB]- -25% attack vs. armored units
[TAB]- Starts with sentry and advanced sniper training


-----Buildings/Improvements-----
Spoiler :

Added:
- Sniper School:
[TAB]- Costs 140 hammers
[TAB]- Required to build Modern Snipers
[TAB]- Requires some barracks per Sniper School (changes for each difficulty
[TAB] level) and a barracks in the city
[TAB]- Sniper school will be lost if the city is conquered
[TAB]


-----Promotions/Traits-----
Spoiler :

Added:
- Line of Sight:
[TAB]- +1 Visibility Range
[TAB]- +1 Sniper Range
[TAB]- Given to sniper units on hills

- Advanced Sniper Training:
[TAB]- Can attack multiple times
[TAB]- Can use enemy roads
[TAB]- +1 Movement range
[TAB]- +25% Withdrawal chance
[TAB]- Available to sniper units

- Aim I:
[TAB]- +8% Shooting accuracy for sniper units
[TAB]- Available to sniper units

- Aim II:
[TAB]- +15% Shooting accuracy for sniper units
[TAB]- Available to sniper units

- Aim III:
[TAB]- +13% Shooting accuracy for sniper units
[TAB]- Available to sniper units

- Aim IV:
[TAB]- +10% Shooting accuracy for sniper units
[TAB]- Available to sniper units

- Aim V:
[TAB]- +8% Shooting accuracy for sniper units
[TAB]- Available to sniper units

- Fatal Shot I:
[TAB]- +12% Chance shot will be fatal
[TAB]- Available to sniper units

- Fatal Shot II:
[TAB]- +15% Chance shot will be fatal
[TAB]- Available to sniper units

- Fatal Shot III:
[TAB]- +7% Chance shot will be fatal
[TAB]- Available to sniper units

- Obfuscation I:
[TAB]- +12% Chance sniper won't be detected by enemy units
[TAB]- Available to sniper units

- Obfuscation II:
[TAB]- +15% Chance sniper won't be detected by enemy units
[TAB]- Available to sniper units

- Obfuscation III:
[TAB]- +9% Chance sniper won't be detected by enemy units
[TAB]- Available to sniper units



-----Notes to Modmakers-----

If you want to use the Sniper Mod in your mod I have tried to make things as
easy as possible for you. In the XML files modified sections are enclosed by:
<!-- -->
<!-- Sniper Mod Start -->
<!-- -->
and
<!-- -->
<!-- Sniper Mod End -->
<!-- -->

In the Python files I have added #<Sniper Mod Start> and #<Sniper Mod End> in
all of the places that I have made changes to the original files.

All I ask is that you give me credit.

-----Known Issues-----

- When selecting a unit that isn't the stack leader as a snipers target their
animation is not displayed when they are shot.

- When two snipers from the same civilization are in the same plot and one is
discovered then both snipers will be visible.


-----Version Information-----

-----v0.6.x-----

- Changed the name of the "Sniper" promotion to "Advanced Sniper Training" per
Jeckels suggestion.

- Fixed the bug reported by Jeckel in the SniperUtils.py file in the
getSniperTargets method, sniperUtils was used instead of self.

- Added the missing TXT_KEY_BUILDING_SNIPER_SCHOOL_STRATEGY tag. Reported by
Shqype.

- Fixed the issue causing the selection cursor to act "funny" when the world
builder screen was used, reported by Shqype.

- Added Kael's sample code to change the "or" promotion prerequisites to "and".

- Integrated Talchas Action Buttons v2.0 Mod

- Updated the SDK code to include in the promotion: aim, fatal shot chance and
obfuscation. These changes include showing the information correctly in the
civilopedia and in the game.

- Added the configurable option allowing for players to specify that a war is
initiated between the owner of the sniper and the snipers target when the
sniper shoots a the target.

Spoiler :

-----v0.5.x------

- Updated all of the python code and XML to be compatible with the v1.61 patch

- Consolidated all of the game text XML into one file.

- Fixed the bug reported by Aranor that prevented the firing of sniper shots at
selected targets.

- Added the code to reset the visibility of a plot for a sniper if they were
found the previous turn but were not killed and they did not move.

- Added the code to reset a snipers harass shots at the begining of their
owners turn.

- Started reorganizing code preparing for release

- Readded code to enable snipers to waste shots if the mod is configured to
allow them to waste shots.

- added the option allowing players to specify how many shots snipers can take
when their harassment action has been set.

- Finished adding comments to all appropriate code

- Prepared code for release by removing commented out code


-----v0.4------

- Added the code enabling the AI players in the game to use snipers. Beware
they do use the snipers and when they do score successful kills and can get
promotions they will select the best ones for their snipers. YOU HAVE BEEN
WARNED.

- Added obfuscation code. Sniper units can now be found by different units
depending on their experience level, and yes sniper units will tend to find
other sniper units a lot easier then regular units.

- Added code that will make it so terrain affects sniper obfuscation. I.e.
Sniper in a plot with trees = harder to find sniper.

- Fixed the issue addressed by talchas in his action buttons mod comp where
sometimes an exception is thrown when a action button ID number is used.


-----v0.3------

- Added the option allowing players to configure how many experience points
snipers get for each successful shot.

- Fixed bug reported by Aranor allowing players to continue shooting at targets
even if the sniper had run out of moves.

- Fixed bug reported by Aranor that would give sniper units extra promotions
even if they didn't deserve it.

- Removed the ability to kill off regular citizen specialists.

- Modified the terrorize citizens feature. When a sniper terrorizes a city all
of the citizens working plots will flee the plots they are working and go
into the city.

- Added code to correctly give sniper units their line of sight promotions when
they are created or built.


-----v0.2------

- Broke-up the event management code from the core sniper code.

- Created and added one more action image, the disabled take shot image. This
image will be displayed when snipers cannot use the take shot action.

- Added the option allowing players to specify if the sniper shooting and
visibility range should always be displayed or only when the take shot action
is turned on.

- Added death sounds when a sniper successfully kills a target in a city.

- Added the option allowing players to specify if all successful shots (fatal
and non-fatal) should give sniper units experience or if only fatal shots
should give units experience.

- Implemented fatal shot code that makes use of the fatal shot promotions. What
this means is that not every single shot sniper units fire are going to kill
the intended target.

- Added the option allowing players to include or exclude city targets as valid
targets for sniper units. Also added the options allowing players to
individually include or exclude the different types of citizens as valid
targets for sniper units. The different possible targets for sniper units in
cities are: units, specialists, super specialists (great people who joined
the city) and citizens. The last target "citizens" does not directly target
and kill off the population. Instead, it will allow your sniper units to
terrorize the citizen population and cause unrest.

- Added the option allowing players to specify if killing off specialists
reduces the population in a city or not.

- Added the options allowing players to specify the base sniper attributes:
aim, fatal shot and obfuscation.


-----v0.1------

- Setup Sniper Mod infrastructure leveraged some of it from Aranor's sniper mod

- Integrated Dr Elmer Jiggle's event manager and INI parsing code.

- Added "Line of Sight" promotion and option allowing players to enable or
disable the promotion. This change also includes the hiding or displaying of
the promotion in the civilopedia.

- Added Sniper promotion and unit combat type. The sniper unit combat type will
be used to distinguish snipers from regular units.

- Added the "Sniper School" building used to train modern snipers with custom
image for the button. Still need a custom model and skin for the actual in
game building.

- Added two sniper units, sniper and modern sniper. The modern sniper can only
be built in a city with a sniper school. Both are fully implemented including
their civilopedia entries.

- Finished adding the sniper promotions including civilopedia entries: Aim 1-5,
Obfuscation 1-3 and Fatal Shot 1-3.

- Added code to highlight the sniper shooting range and the sniper visibility
range. Also added five new player configurable INI options to support the
highlighting feature for snipers. These configurable options allow players to
set what sniper range highlighting should be displayed, what colors should be
used to display the highlighting and if snipers should be able to ignore
terrain features such as hills, peaks, forests, etc.

- Figured out how to programmatically trigger unit animations! Added test code
allowing the currently selected sniper to shot a unit. The damage done to
that "unit" depends on how many entities are in the unit. When the sniper
shoots its attack animation is triggered and the target unit entity death
animation is also triggered.


-----===Credits & Thanks===-----

- Exavier
[TAB]Composite Mod - readme.txt format

- TGA and 12monkeys
[TAB]For proving that plot highlighting isn't hard :)

- Bhruic, TGA, 12monkeys, Zuul and everyone else participating in the Revealing
Invisible Units thread - http://forums.civfanatics.com/showthread.php?p=3881063&posted=1#post3881063[TAB]

- Stone-D
[TAB]SD-Toolkit
[TAB]
- C.Roland
[TAB]For providing the wonderful sniper school model and skin
[TAB]
- korvgubben
[TAB]For providing a starting point for my sniper mod

- Aranor
[TAB]For providing a starting point for my sniper mod and extensively testing
[TAB]the mod from day one!!!
[TAB]
- Dr Elmer Jiggle
[TAB]For providing the INI file parser code allowing for players to
[TAB]customize this mod without having to touch the python code!!!

- Talchas
[TAB]For his Action Buttons v2.0 Mod

- Kael
[TAB]For providing the sample code needed to add new tags in the game schema
[TAB]and how to correctly read their values through the SDK.
[TAB][TAB]
- Testers
[TAB]Aranor, Kael, Jeckel, Killamike718, Shqype and Lord Olleus
 
Screenshots for the sniper mod:
 

Attachments

  • Sniper1.jpg
    Sniper1.jpg
    59.7 KB · Views: 895
  • Sniper2.jpg
    Sniper2.jpg
    154.1 KB · Views: 1,472
  • Sniper3.jpg
    Sniper3.jpg
    192.8 KB · Views: 1,234
So, this is the stelth atack ala civ3....
UNITCOMBAT_SNIPER, for submarine too :cooool:
You rocks, TheLopez.
 
TheLopez:

If you put the target in a new group (not the unit itself: CvSelectionGroup* == CvUnit->joinGroup(blah blah blah) ) it should bring it to the top of the pile and then the animation will run.

Dale
 
I explored that idea, but that means if the target is owned by another human player you will be breaking up their group. Then of course you could just restore the group after the animation if the target is still alive... It's still a hack though. There has to be a better way... I'll have to dig into the SDK again...
 
Maybe look into CvUnit::isGroupHead(). There might be a way to set it as group head. Being a list it should be as simple as redirecting the Node pointers.
 
Its finally out and looks cool :goodjob:
Seems to me, that it was a long way from the first idea to the this release, wasn't it?
 
12monkeys said:
Its finally out and looks cool :goodjob:
Seems to me, that it was a long way from the first idea to the this release, wasn't it?
What do you mean by "it was a long way from the first idea to the this release"? Its has already been a long day for me, need more coffee!!!


GarretSidzaka said:
very nice and thorough. how does this integrate into a mod like mine?
Let me know if you need help integrating the two.
 
Wow I just downloaded this and checked inside the folder for it and was shocked to see it has a new gamecore.dll. :wow:

I would assume that file goes into the my mod's assets folder in order to add it to my mod. Right?

Other than that I can see it will likely take me an hour or so to go through each file and make sure I am getting all the code into my files. :p

Kudos to you TheLopez on another awesome mod. :goodjob:
 
Ok I figured it out. The new gamecore.dll does go into the assets folder for my mod. :)

Ok for those who are implementing this into their mod.

I came across one little problem which those who have 12Monkeys' Plot List Enhancement Mod.

For PLE, it does not use the CvMainInterface.py but instead uses the PLEMainInterface file.

Well basically I had to add the Sniper mod info from the CvMainInterface.py into that file instead for my mod cause I have the PLE in my mod as well.

Before I did that I was not able to fire on units at all.


Now, I am having one other problem that I hope you can address, TheLopez. After getting everything to work, I found that most of my attacks were misses. In fact the only ones that I was able to hit were the "Terrorize Citizens" option. And instead killed a musketman. :confused:

Secondly, after the sniper has finished his turn, it isn't ending automatically. I have to end it manually by clicking on "Activate next turn".

And thirdly, the two new options of yours "Take Shot" and "Harrass Units" are showing up more than once, however, they don't all have the same hint popup. It's odd, one says cancel shot and the other says selection. :confused:

Anyways, I am sure this has something to do with the python files and how they are merged with other python comps. The mods I have merged together that use python files are "Composite Mod", "PLE", "Random Events" and of course the "Sniper mod".

Of course the Composite mod itself is what I used as a base to make my mod and it includes a few mods itself. I'm uncertain what could be causing this problem as I am not too familiar with Python code. So I hope you can help me. :)

Thanks in advance. ;)
 
First Open the CvModName.py file and change the value of the modName from "Sniper Mod" to the name of your mod.

Second, you don't need to include any of the changes in the CvMainInterface.py.old file... that's why I changed its extension from CvMainInterface.py to CvMainInterface.py.old.
 
TheLopez said:
First Open the CvModName.py file and change the value of the modName from "Sniper Mod" to the name of your mod.

Second, you don't need to include any of the changes in the CvMainInterface.py.old file... that's why I changed its extension from CvMainInterface.py to CvMainInterface.py.old.

Ahh ok thanks, I'll try that out. :D
 
the sniper doesnt actually die when attacking right???
and if a unit moves into same tile will sniper die?
very intriguing sniper idea i will play tomorrow and try it out...
 
Spartan117 said:
the sniper doesnt actually die when attacking right???
and if a unit moves into same tile will sniper die?
very intriguing sniper idea i will play tomorrow and try it out...
Nope, the sniper will not die if you use their take shot action. Though, you can still attack like normal with them and they can still be attacked.
 
well in that case great mod:D :D :D one last question....what is the different colors is it just cause ur isabella
or is the accurate more accurate when the enemy unit is closer to it

maybe someone could add something like this to archer and longbowmen but of course they would be visible;) but only like 1 tile range or something
 
The different colors represent the snipers visibility range and their shooting range. You can customize the colors through the "Sniper Mod Config.ini" file. Yes, shooting at enemies from a closer distance does equal a more accurate shot.

Please understand that the two sniper units I added are just for reference so people know how to create them. Basically to create a new archer sniper unit you would have to change their unit combat from "UNITCOMBAT_ARCHER" to "UNITCOMBAT_SNIPER". This way you could create elf rangers in a fantasy mod... if you wanted to.
 
by the way i dont really know where to ask but what weree your specific ideas on the land mine thing?

wow u came up with all those mod components?!?
 
Spartan117 said:
by the way i dont really know where to ask but what weree your specific ideas on the land mine thing?
I don't know just yet...

Spartan117 said:
wow u came up with all those mod components?!?
Do you mean did I write all of them or come up with the ideas? If you meant "did I write them all" then yes, but I had help in testing most of them. If you meant "did I come up with all of them" then no, several people have sent me requests and I have tried to fulfill them as best as possible..
 
Top Bottom