mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 19:52:40 +00:00
Implements turret trajectory prediction
- Adds trajectory checking for turrets, so they don't burn holes through other objects (like walls and AI's) if they wouldn't hit them anyway.
This commit is contained in:
@@ -605,8 +605,12 @@ var/list/turret_icons
|
|||||||
if(!raised) //the turret has to be raised in order to fire - makes sense, right?
|
if(!raised) //the turret has to be raised in order to fire - makes sense, right?
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
update_icon()
|
update_icon()
|
||||||
|
|
||||||
|
//targeting check, can we hit them?
|
||||||
|
if(!check_trajectory(target, src))
|
||||||
|
return
|
||||||
|
|
||||||
var/obj/item/projectile/A
|
var/obj/item/projectile/A
|
||||||
if(emagged || lethal)
|
if(emagged || lethal)
|
||||||
A = new eprojectile(loc)
|
A = new eprojectile(loc)
|
||||||
|
|||||||
@@ -385,7 +385,7 @@
|
|||||||
return //cannot shoot yourself
|
return //cannot shoot yourself
|
||||||
if(istype(A, /obj/item/projectile))
|
if(istype(A, /obj/item/projectile))
|
||||||
return
|
return
|
||||||
if(istype(A, /mob/living))
|
if(istype(A, /mob/living) || istype(A, /obj/mecha) || istype(A, /obj/vehicle))
|
||||||
result = 2 //We hit someone, return 1!
|
result = 2 //We hit someone, return 1!
|
||||||
return
|
return
|
||||||
result = 1
|
result = 1
|
||||||
@@ -424,15 +424,14 @@
|
|||||||
if(istype(M))
|
if(istype(M))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/proc/check_trajectory(atom/target as mob, var/mob/living/user as mob, var/pass_flags=PASSTABLE|PASSGLASS|PASSGRILLE, flags=null) //Checks if you can hit them or not.
|
/proc/check_trajectory(atom/target as mob|obj, atom/firer as mob|obj, var/pass_flags=PASSTABLE|PASSGLASS|PASSGRILLE, flags=null) //Checks if you can hit them or not.
|
||||||
if(!istype(target) || !istype(user))
|
if(!istype(target) || !istype(firer))
|
||||||
return 0
|
return 0
|
||||||
var/obj/item/projectile/test/trace = new /obj/item/projectile/test(get_step_to(user,target)) //Making the test....
|
var/obj/item/projectile/test/trace = new /obj/item/projectile/test(get_step_to(firer,target)) //Making the test....
|
||||||
trace.target = target
|
trace.target = target
|
||||||
if(!isnull(flags))
|
if(!isnull(flags))
|
||||||
trace.flags = flags //Set the flags...
|
trace.flags = flags //Set the flags...
|
||||||
trace.pass_flags = pass_flags //And the pass flags to that of the real projectile...
|
trace.pass_flags = pass_flags //And the pass flags to that of the real projectile...
|
||||||
trace.firer = user
|
|
||||||
var/output = trace.process() //Test it!
|
var/output = trace.process() //Test it!
|
||||||
qdel(trace) //No need for it anymore
|
qdel(trace) //No need for it anymore
|
||||||
return output //Send it back to the gun!
|
return output //Send it back to the gun!
|
||||||
|
|||||||
Reference in New Issue
Block a user