First draft of zombies and walk sequence:
Will probably change a lot but this if fine for now because I don't even know what I'm planning on doing since the zombie and grass are the same colors of green. Which one I'm going to change or if I will have dirt paths for them to walk on. Will figure it out as I go.
I also added formula for damage to zombies, which here is simplified version:
100%-1%-(35% x Distance*)+(25% x (AimSkill/10) x Distance*)
- Start at 100% success rate
- -1% No matter what condition always has 1% chance of missing
- Ignore the right half after the + because AimSkill starts at zero. Will add leveling up later. (zero times anything is zero)
- *Distance: will be between 0 and 1. 1 being edge of screen and 0 being right at player. Same formula used in the aiming function which was explained in previous post
- Let's say distance is zero, you would be dead, but for example's sake, zero times 35% is zero so 99% success rate
- Zombie is at edge of screen/at spawning location -> distance would equal 1. Therefore 100%-1%-35% = 64%. So 64% is the lowest success rate possible with current formula (will probably tweak for balancing later)
- I actually flip it around and pass the miss percentage by taking 1 minus above formula
playerShoot formula passes two parameters
- Random number between 0 and 1
- The percentage chance of missing
:
After the animations, state variable, and such are changed the success rate will be compared to the random number. Four possible outcomes:
- Headshot: 5% chance all the time. For now, I want there always to be a chance of a headshot at any range. Above a 0.95 random number will cause instant death
- 1.5 Damage: Not always possible but this is when you would make a "good shot" or "critical hit". Determined by if your random number is twice the fail chance. So if you have only 30% fail rate, above 0.3 will hit but above 0.6 will do 1.5 times damage. If fail chance is above 50% then this wouldn't be possible.
- Regular damage: Obviously, if random number is higher than fail chance then it hits.
Damage number is stored in player instance variable so I can tweak easily and make it easy to add weapons with different damage. The zombie UID and amount of damage are passed to a function to deduct the health.
Next to do: blood particles and animating zombie death so shooting is more fulfilling!