Current Unity Build Base: 10.21
4/8/20, 10:29AM Pacific
(Began work on dodge mechanic: I created and named the script file that will handle this. Now, to begin the actual coding work. Check below for more information on my idea for this.)
- ItemTemplate baseRange Variable (Finished) - I have added a baseRange variable to the itemTemplate file to store an items potential range. Think of this as a value you can use to define the range an item will affect. I'm using this for melee combat, to dynamically assign the reach of each weapon, so weapons have different attack ranges. However, you could use this for anything you need a range value attached to, say a magical affect area or a cast rang or any other possibility you can think of for range; you could assign it to spherecasts to create area affect stuff. You can access this value through the itemHelper.cs script and the getRange() method. You can also access and read it out in UI's using the %ft variable within strings.
- Dynamic Weapon Range (Finished) - Each weapon has a unique float point value assigned to it to simulate a unique attack range. Currently is pulled from itemtemplate through the itemHelper.cs and assigned in the weaponManager.cs anytime you attack. Fists are defaulted to the classic range of 2.25f. Any weapon with 0 range does not show and is broken/bugged. Ensure weapons have a range value of some sort for them to show in fps mode. There is a built in if - then error catcher, but please do not rely on it. Set your base range in your itemtemplate file.
- Debug Raycasting Added: (Finished) - I added a simple unity debug raycasting line into the Weaponmanager script. You will now be able to see the raycast of a weapon attack in the unity engine within the scene window. This is not built into the DF engine, so it will not show up dynamically in game. I do not plan on adding it into the df engine either.
- Dynamic Weapon Stamina Cost (Finished) - Stamina cost for swings is now based on the items weight and range to give weapons more variety and feel. Current formula is simple; ((range+weight)*2). This gives a range of 5 to 17 cost depending on the size and weight of the weapon. Will probably refine formula further later on.
- Dynamic Raycasts/Spherecasts(Finished) - Traditional raycasts in most classic games used single raycasts to save on cpu demand, so raycasts would draw one long line instantly for the raycast check. This was effective, but did not simulate real life well, as everything has to move in physical space over time to simulate physics. I have added raycasts that can grow overtime to simulate an attack moving through space. Stabs hitdetect now moves outward overtime from the player increasing in length until it reaches the weapons attack length,
- Dynamic Weapon Speed (Finished) - I have inserted in a public variable into the fpsWeapon script to allow easy manipulation of attack speeds/animations. It can be accessed and set through the fpsWeapon.cs object via .AttackSpeed method. Large weapons feel heavier and slower, small weapons feel lighter and faster.
- Movement Based Attack Types (Finished) - Currently finished a simple movement based attack system. Each strafe key initiates the attack based on that direction. As an example, left strafe = MouseDirection.left. If you're standing still and not moving at all, attacks go back to classic random choice.
- Slower Attack Movement(Finished) - Finished a simple attack movement modifier. You know have your movement reduced by 60% while attacking. I may try to tie it to the current animation frame to create a more realistic feel to movement while swinging.
- Combat/Unsheathed Stance Slowdown(Finished) - When you go into combat stance/sheathed state, you will move 15% slower, as your more focused on your senses and muscle memory. Sprinting/crouching bonus/debuff will still be applied, but then debuffed by the 15% penalty when in combat/unsheathed mode. So trying to be in a combat stance and sneak at the same time is going to go even slower, as it should. Have you ever tried to sneak while staying in a combat ready, muscle memory, heightened senses state? Yeah, not so easy to do and maintain.
- Weapon Collision Simulation/Feedback(Finished) - DF engine begins sending out raycasts on every frame. Once it hits an object, the raycasts stop. A bool trigger then tells the animation system to replay the animation backwards at an accelerated rate. This simulates a hit and collision. Marking it as finished, but plan on smoothing animations at some point.
- Multiple Raycast Code(Finished) - I have inserted in a coding loop so hit detect raycasts will continually shoot out from the players camera, using the weapons range, to simulate actual weapon swings from beginning to end. Currently raycast stops on first object hit detection. Uses weapons animation time to sync raycast and time their shots (shoots about 30 within a normal animation). As each raycast is shot, a lerp vector transform moves it along a defined axis based on the animation time. Once an object is hit, raycast stop, fps collision animation begins, and player sets back to idle. Marked as finished, even though I have to refine the vector offsets for the stab and down animations.
- High/Smooth FPS Attack Animations(Finished) - Hijacked animation coroutine, added a for loop that uses mathf.lerp calculator to scale smooth animation simulation no matter the attack speed. *All weapons have been finished.* I've finished all weapon attack animations covering the four base attacks I'm using (left, right, stab, and down). I do need to wrap up fists attacks, redo stab, and do more refinement to minimize a few weapons with noticeable frame skipping, but I'm still marking it as finished. It is in a playable, immersive state.
- Weapon Movement Bob(Finished) -This is supposed to simulate the natural bob running with a weapon would cause. It is tied directly into the frame animation offset variable, which creates nice little side effects, like slower bobbing on stride/run and faster bobs on small movements, like side or back stepping. It works with all weapons, including magical ones and the fists. I'm marking it as finished.
- Range & Inertia UI Readouts(Finished) - If an item has a range, the players inventory will display it after the normal ui readout. Upon opening the item info panel, the player will see the normal information, item range, and item inertia..
- Realistic Dodge Mechanic(Started) - the dodge system is traditionally based on random roles to calculate if a hit is dodged by the player/enemy. This leads to confusing combat and engagement at times, as a series of bad rolls can make enemies hard to plan for and ruin a well thought out battle/fight. I've started work on a dodge script that will hopefully allow the player/enemy to mimic a real dodge. For the player, random roll dodging will be removed and the dodge will be completely player controlled; The players tied stats will affect its usefulness/effectiveness; the more the player has in the stat, the less stamina the dodge will cost, the quicker you can do it, and your immune to damage window will increase. For enemies, I will for now keep the random roll system, so you can still randomly have your attacks dodged; however, the enemy will actually move a direction and stop any attack momentarily to mimic the look of an actual dodge and make them reset momentarily their attack on you.
- Unique Item ID Ranges(Started) - I mimicked the weight float point system, as it allows for tons of customization of the value and easy access for ui read outs on the fly. However, to get the system in and tested. I shortcutted the weaponManager.cs script right to the template to retrieve the weapon range instead of creating a unique instance of the weapon and assigning a value to that. This will limit all weapons to their item template value no matter what you do currently. I do plan on implementing the uniqie item range values into weaponcombat.cs later on. This will allow for each item to have custom range values in case any modder ever wants to do interesting things with this value, like create enchantments that increase range.
- Toggle Block(Not Started) - Shields in traditional df had very little benefit. According to thr unofficial wiki and code I have found, shields did very little past adding 1 to 4 armor to you. df unity team added code so it now at least takes armor damage for your arms and hands. However, I wish to add a toggle block similar to modern systems, like skyrim.
- Blade Variations(Not Started) - All differing blade types use the same sprite for their animations. This leads to tantos looking the same as dia-katanas on screen. We can modify their size by changing the render size through brute force code to setup differing sized blades for the differing weapons.
- Movement Modifiers Tied to Weapons(Not Started) - I want movement modifiers for the unsheathed and attack reductions to vary some based on the weapons range and weight to simulate weight and physics of running with said weapon.
- Recoil Specific Animations(Not Started) - Recoil animations are pretty sad right now; it is a rewind of the base animations backwards from object hit. We can improve this, and possibly make recoil animations for hitting an enemy versus a solid object, like a wall, prop, or asset.
- FPS Console Command Script: I created a script file to enable some basic console commands for controlling and manipulating the FPSWeapon script. I do not recommend changes these. Doing say risks animation and raycast bugs appearing as these are finally tuned to the engine limits and animations system.
- OffsetDistance: This is a float value that changes animation offset distance. Default value varies between .2 and .28 depending on the weapon being used. Higher values faster offset moves.
- DisableSmoothAnimations: This enables and disables the default or improved animation system.
- ChangeAttackSpeed: This subtracts or adds a certain float value from the default animation attack speed; Use .01 increments.
-ChangeHorPos: Changes start and end position of hit arc detection; starts at 45 degree and does 90 degree arc to end at 45 degrees on opposite side. (-start float -end float).
-ChangeRaycastLerp; Changes how slow or fast the hit arc is drawn. Default is .188f. Recommend .01f increments.
-ChangeMovementMods; Multiplies base movement speed for sheathed and attack animations. Default is -sheathed .85f -attack .4f. Set values to 1 to disable any movement reduction. (-sheathed float -attack float).
- All Weapon Stats Calculate Once/Before All Attack Code: I moved all weapon states and debug message code to run once, right after the weaponManager.cs detects a player attempting an attack. I believe this should stop any bugs having to do with weapon numbers being assigned after the swing and animation code executes.
Weapon Range Code Improvement: Weapon range was original being calculated every frame. This seemed off for multiple reasons. The first being that range was originally set as a unchangeable constant float variable of 2.25f; so, why does the engine need the number continually updated, if it never will change by design. Two, the raycasting code only shoots out one spherical ray on every attack, which pulls the range value to figure out the rays distance; So, why does it need to continually know the range every processed frame? I think this was done originally to allow for dynamic range affects and other mechanics, but they never got to any of it and rammed this constant value in. This ultimately seems like a waste of cpu cycles/frames. I have moved the range value pull from a constant method into the attack boolean trigger. Now, it only grabs this value on every successful attack trigger. This should free up some cpu cycles/frames.
- Added Debug Messages: Needed to know exactly what was happening with the back-end combat system while playing a game for better coding and number tweaking. I have programmed in three different debug messages. One reads out the current weapons range, the next is the current weapons fatigue cost, and the last one will appear when you make contact with an enemy hitbox and verify if you successfully rolled a hit or did not. The last one is critical, as it was hard to know if my code was broken or if I had just missed a hit chance roll in the back-end engine. The first two debug readouts can be found in the weaponManager.cs, right by where it assigns the range and staminafatigue value. The last one is embedded in the formulahelper.cs, way down by the melee hit chance detection code.
- In-depth project and discussion on combat and animation system and related code: viewtopic.php?f=14&t=2533
- A very in-depth breakdown of the combat system and animation system and how they work together to create what happens on the screen: viewtopic.php?f=22&t=2508
- In-depth discussion, with visual flow chart, of the fps animation system and all related script files the control and run it: viewtopic.php?f=22&t=2554