Community Scripts
** Please credit community members who’s scripts you have used in your game projects.
Grenade Script
Do 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.
Light Follow Player
player check position playerX playerY playerZ if $playerLight == 0 { playerLight=1 light create $playerX $playerY $playerZ 256 255 0 0 //save light spawn position, for future movement lightSpawnX=$playerX lightSpawnY=$playerY lightSpawnZ=$playerZ } //Calculate new offset lightOffsetX=$playerX lightOffsetX-=$lightSpawnX lightOffsetY=$playerY lightOffsetY-=$lightSpawnY lightOffsetZ=$playerZ lightOffsetZ-=$lightSpawnZ light offset $lightSpawnX $lightSpawnY $lightSpawnZ $lightOffsetX $lightOffsetY $lightOffsetZ