mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
possibly fix infinite bananball works
This commit is contained in:
@@ -492,6 +492,7 @@
|
|||||||
adjSpeed = 1
|
adjSpeed = 1
|
||||||
adjForce = 0
|
adjForce = 0
|
||||||
var/isBouncing = FALSE //Prevents it bouncing infinitely due to some dark curse of throw_at()
|
var/isBouncing = FALSE //Prevents it bouncing infinitely due to some dark curse of throw_at()
|
||||||
|
var/lastBounceCount = 0
|
||||||
|
|
||||||
/obj/item/cannonball/bananium/throw_at(atom/target, range, speed, override = 1)
|
/obj/item/cannonball/bananium/throw_at(atom/target, range, speed, override = 1)
|
||||||
if(!cannonFired)
|
if(!cannonFired)
|
||||||
@@ -508,21 +509,27 @@
|
|||||||
/obj/item/cannonball/bananium/throw_impact(atom/hit_atom, var/speed, mob/user)
|
/obj/item/cannonball/bananium/throw_impact(atom/hit_atom, var/speed, mob/user)
|
||||||
..()
|
..()
|
||||||
if(!cannonFired)
|
if(!cannonFired)
|
||||||
|
lastBounceCount = 0
|
||||||
return
|
return
|
||||||
|
lastBounceCount++
|
||||||
if(isliving(hit_atom))
|
if(isliving(hit_atom))
|
||||||
honkMob(hit_atom)
|
honkMob(hit_atom)
|
||||||
else if(isitem(hit_atom) && hit_atom.density)
|
else if(isitem(hit_atom) && hit_atom.density)
|
||||||
spawn(3) //Give throwing time to stop bullying me
|
spawn(3) //Give throwing time to stop bullying me
|
||||||
if(!throwing && cannonFired)
|
if(!throwing && cannonFired)
|
||||||
honkBounce(hit_atom)
|
|
||||||
|
honkBounce(hit_atom,lastBounceCount)
|
||||||
|
|
||||||
|
|
||||||
/obj/item/cannonball/bananium/proc/honkMob(var/mob/living/L)
|
/obj/item/cannonball/bananium/proc/honkMob(var/mob/living/L)
|
||||||
L.Knockdown(rand(2,10))
|
L.Knockdown(rand(2,10))
|
||||||
playsound(src, 'sound/items/bikehorn.ogg', 75, 1)
|
playsound(src, 'sound/items/bikehorn.ogg', 75, 1)
|
||||||
honkBounce(L)
|
honkBounce(L,lastBounceCount)
|
||||||
|
|
||||||
/obj/item/cannonball/bananium/proc/honkBounce(var/atom/cTarg)
|
/obj/item/cannonball/bananium/proc/honkBounce(var/atom/cTarg, var/tot_bounces = 0)
|
||||||
|
if(tot_bounces > 10)
|
||||||
|
stopBouncing()
|
||||||
|
return 0
|
||||||
var/list/honkStep = alldirs.Copy()
|
var/list/honkStep = alldirs.Copy()
|
||||||
var/honkDir = get_dir(src, cTarg)
|
var/honkDir = get_dir(src, cTarg)
|
||||||
honkStep -= list(honkDir, turn(honkDir, 45), turn(honkDir, -45)) //Every direction possible except directly, or diagonally, toward what we hit
|
honkStep -= list(honkDir, turn(honkDir, 45), turn(honkDir, -45)) //Every direction possible except directly, or diagonally, toward what we hit
|
||||||
@@ -531,6 +538,8 @@
|
|||||||
bounceStep(honkDir)
|
bounceStep(honkDir)
|
||||||
|
|
||||||
/obj/item/cannonball/bananium/proc/bounceStep(var/honkDir)
|
/obj/item/cannonball/bananium/proc/bounceStep(var/honkDir)
|
||||||
|
if(lastBounceCount > 25)
|
||||||
|
stopBouncing()
|
||||||
if(cannonFired)
|
if(cannonFired)
|
||||||
if(prob(10) && istype(get_turf(src), /turf/simulated))
|
if(prob(10) && istype(get_turf(src), /turf/simulated))
|
||||||
var/turf/simulated/T = get_turf(src)
|
var/turf/simulated/T = get_turf(src)
|
||||||
@@ -543,6 +552,7 @@
|
|||||||
throwing = 0
|
throwing = 0
|
||||||
kinetic_acceleration = 0
|
kinetic_acceleration = 0
|
||||||
isBouncing = FALSE
|
isBouncing = FALSE
|
||||||
|
lastBounceCount = 0
|
||||||
if(cannonFired)
|
if(cannonFired)
|
||||||
cannonAdjust()
|
cannonAdjust()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user