Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

[Code] Splinter Cell Stealth Framework

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [Code] Splinter Cell Stealth Framework

    Hi everyone,

    I've been working on a splinter-cell style stealth game, using light and sound for AI detection. It was built with the July 2013 Beta version. The only UTGame code it uses is UTProjectile, which is used for the rifle bullets and thrown items, so it should be easy to divorce completely. It also uses the UT assets as placeholders. Here are the following features:

    AI

    - Has a suspicion meter which increases when it hears or sees the player. The amount it's increased depends on the type and loudness of the noise, and how visible the player was when they were spotted. When it is above 0.25, it will stop to look at where it last saw or heard the player, when above 0.5 it will go over to investigate the area and above 1.0 it has seen the player and will attack. It will slowly decrease over time as long as the player remains hidden and doesn't make any noise.
    - Will respond to the sight of an unconscious ally and will run over to revive them
    - If it is attacking the player but the player is in darkness, it will spray rounds into the last known location of the player
    - Mappers can set up patrol routes and tell the AI to follow it in either a back-and-forth manner or in a loop, and tell the AI how long to pause at each point in the path

    Sound

    - The amount of noise the player makes when moving depends on the type of surface (dirt, stone, metal etc) and how fast they're moving
    - There are objects the player can throw. These make a loud noise on impact which will distract the AI. If the AI's suspicion is above 1.0, it will even fire at that location

    Visibility

    - Based on how well lit the pawn is, how close they are to the observer and how fast they're moving
    - Currently only pointlights (and dynamic pointlights) are supported, I haven't had time to do spotlights
    - The calculation takes into account the brightness of the pointlight, the radius and the falloff exponent
    - The more visible the player is, the greater the increase to the AI's suspicion when they're spotted
    - Skylights and dominant directional lights not supported

    Other Features

    - Throwable objects complete with trajectory preview to aid with aiming
    - Able to knock out an AI guard by pressing Use while behind them
    - Able to drag a dead or unconscious guard by pressing Use on their body
    - Simple rifle weapon system
    - Debug commands:
    * NoHearing - Makes all AI deaf
    * NoSight - Makes all AI blind
    * ShowSuspicion - Puts a number above each AI's head, telling you how suspicious they currently are


    Here is a video of it in action:




    The download link for the latest version can be found here:

    https://dl.dropboxusercontent.com/u/...k_20131229.zip


    Installation Instructions

    - Unzip the StealthFramework folder in UDK-2013-07\Development\src. Keep the folder in tact.
    - Unzip the StealthFrameworkGameContent folder into UDK-2013-07\UDKGame\Content. Again, keep the folder in tact.
    - Modify your DefaultEngine.ini file by adding the following line in the [Engine.ScriptPackages] section: +NonNativePackages=StealthFramework (make sure it's at the bottom of the list)
    - You will also need to add this line in the [UnrealEd.EditorEngine] section: +EditPackages=StealthFramework (make sure it's at the bottom of the list)
    - You will need to set up keybindings for the exec functions PrimeThrow (which displays the throw arc), ThrowItem (which throws the item currently carried) and Grab (which picks up items and knocks out AI)


    Known Issues

    - Only pointlights (static and dynamic) are supported at this time, all other lights will either not affect your visibility at all or might have unpredictable results
    - Lightmass needs to be disabled for all lights that will affect the play area, otherwise you will end up with areas that look lit but the game thinks you're in darkness. Think Doom 3 style lighting.
    - Dragging is a little buggy sometimes with limbs getting stuck in static mesh actors (seems to be particularly bad on the stone floor tile mesh that comes with UDK)
    - AI is unfinished and will sometimes act a little oddly, not investigating an area properly etc. Unfortunately I don't have the time to polish this up, but if you want to make any improvements I will of course credit you
    - I've not commented any of my code (I know, naughty!) but unfortunately I've not had the time I'd like to dedicate to polishing this up. Hopefully it should be fairly easy to read. I'll see about getting a cleaned-up and commented version out soon


    Thanks to

    - EvernewJoy for his rainbow trail effect which I have modified to create the arc throw preview


    Updates

    29/12/2013:
    - When the AI is attacking, it will no longer run to its starting position. Instead, it will move around its current location from time to time
    - AI now sees and checks dead bodies as well. A check is in place to avoid the AI reacting to the same corpse more than once. Suspicion will be raised to max (10.0)
    - You will now release a dragged body if you move to far from it (e.g. if it gets stuck on something)
    - You can no longer knock out a corpse
    - ThrownItem objects are no longer managed in individual classes, instead they use the same static mesh component as the ThrowableObject the player grabbed.
    Simply place a ThrowableObject object in the map, assign a static mesh to it and the game will do the rest.

    Any problems then let me know! Feedback is welcome.

    #2
    Thank you for the code! Looks nice. Many people tried implementing such visibility systems, will be an answer for them

    Comment


      #3
      Awesome stuff. Thanks for sharing!

      Comment


        #4
        Beautiful eprk

        Comment


          #5
          Awesome share!. Although make sure to change InventoryManagerClass=class'SPG_InventoryManager' to InventoryManagerClass=class'StealthFramework_Inven toryManager' in StealthFrameworkPawn (line: 451) otherwise compiler will show a warning.

          Comment


            #6
            Originally posted by ryanjon2040 View Post
            Awesome share!. Although make sure to change InventoryManagerClass=class'SPG_InventoryManager' to InventoryManagerClass=class'StealthFramework_Inven toryManager' in StealthFrameworkPawn (line: 451) otherwise compiler will show a warning.
            Oops! This is what happens when you have multiple projects on the same UDK installation I'll fix that with an update later today.

            Comment


              #7
              Just a quick question. How can i have throwables? I dragged and dropped StealthframeworkThrowableObject and set it to Bottle. But nothing appears in game . My main interest in this Framework was the projectile trajectory display.

              Comment


                #8
                Originally posted by ryanjon2040 View Post
                Just a quick question. How can i have throwables? I dragged and dropped StealthframeworkThrowableObject and set it to Bottle. But nothing appears in game . My main interest in this Framework was the projectile trajectory display.
                Hi Ryanjon2040. At the moment the throwable object is represented by a kActor in the world. The ThrownItem variable only determines which StealthFramework_ThrownItem class is given to the player when they pick it up however, so you still need to set the static mesh component as you would a regular kActor for it to actually appear. It's not a great system at the moment, as you need to write a new custom class if you want to create a new thrown item. It would be better if the thrown item appearance and the noise it makes is determined by options the mapper sets in the Throwable Object, and didn't need to be configured separately. For example, if you place a Throwable Object with a brick static mesh, then the Thrown Item projectile will also look like a brick without you having to create a new projectile class. When I have time I'll sort that out.

                Thanks for the responses so far guys, and keep pointing out issues or areas that can be improved. I'm going to make some updates when I can, so I'll update this thread periodically.

                PS: If anyone knows a good way to prevent the ragdoll "catching" on static mesh actors then let I'd be grateful if you could suggest something!

                Comment


                  #9
                  I have updated the code with some fixes. See the bottom of the original thread for details. This improves the way thrown objects are handled and contains some AI enhancements.

                  Comment


                    #10
                    thanks for sharing it, i will try to look at it soon as i can.

                    Comment


                      #11
                      Just tried the updated one and its awesome!. The throwables now work properly.

                      Comment


                        #12
                        The visibility says 0 all off the time

                        Comment


                          #13
                          Originally posted by udkA View Post
                          The visibility says 0 all off the time
                          Hi udkA. At the moment only PointLight actors are supported (which I think includes PointLightMovable and PointLightToggleable since they extend it), so make sure you're not trying to use spotlights or dominant directional lights. I will add support for those sometime soon.

                          It will also ignore any lightmass calculations since it would be insane trying to approximate those calculations in Unrealscript. Make sure when you make your map that Lightmass is either disabled entirely, or that you build your map in such a way that the actual play area is not impacted (by disabling lightmass on certain lights for example), otherwise you will find situations where an area looks well lit (because of light bounce from nearby sources) but the game thinks it's pitch dark. At the moment, if a player is further from a light than its radius then it is ignored, even though lightmass might extend the light's influence outside its radius.

                          If you're still having problems then let me know.

                          Comment


                            #14
                            wow Awesome work

                            it's very usefull for me Thanks for sharing
                            i will try it
                            i hope you keep updating this and still develop this project

                            Comment


                              #15
                              Cool ! Good work Neoptolemus !
                              You can add tutorial about AI Patrol ? Or add example map to package ? Because i don't understand it and i really want use your code in my project.
                              Please...

                              Comment

                              Working...
                              X