Grenade
@everyoneDo you want to make some kind of grenades in your game? I've got you here pal!
Put these lines of code into your loop_script:
//BOMB THROWING LOGIC player check rotation rotx roty degtorad=$roty degtorad-=45 degtorad*=0.034906585 global.bombthrowy=SIN($degtorad) global.bombthrowx=COS($degtorad) global.bombthrowx*=-15 global.bombthrowy*=-15 degtorad=$roty degtorad*=0.0174532925 fixbty=SIN($degtorad) global.bombthrowy+=$fixbty degtorad=$rotx degtorad*=0.0174532925 global.bombthrowf=SIN($degtorad) global.bombthrowf*=350 global.bombthrowv=COS($degtorad) global.bombthrowv*=-350 global.bombthrowv+=80 global.bombthrowz=COS($degtorad) global.bombthrowz*=-21 global.bombthrowz+=21
21 = player height divided by 2. 15 = player radius minus one plus grenade radius (works best when it's zero). 350 = throw force.
Use this frame into FSM:
frame 0 0.01 0 0 0 SPAWN fbombprj $global.bombthrowx,$global.bombthrowz,$global.bombthrowy $global.bombthrowf,$global.bombthrowv
"fbombprj" - is an enemy with zero radius that does nothing and act as a throwable object, since decorations don't have any physics.
Pros: Now you have a means of throwing stuff. It even takes into account if you look up or down.
Cons: To prevent spawning things through walls when you stand next to them, we have to spawn things one unit inside player's radius. It pushes back a little, barely noticeable while in movement. But if you make your projectile radius bigger that zero - pushback is much more noticable. By tweaking the 15 number - you can increase the pushback even more without changing the projectile radius.