Skip to content

Commit

Permalink
ITS FULLY ACCURTE NOW THANK GOGDDA HAHA
Browse files Browse the repository at this point in the history
  • Loading branch information
MLGTASTICa committed Aug 9, 2024
1 parent 57935d6 commit 6692f96
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
46 changes: 43 additions & 3 deletions code/controllers/subsystems/bullets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ SUBSYSTEM_DEF(bullets)
var/canContinue
var/oldX
var/oldY
var/list/colored = list()
for(var/datum/bullet_data/dataReference in current_queue)
current_queue.Remove(dataReference)
projectile = dataReference.referencedBullet
Expand All @@ -309,9 +310,27 @@ SUBSYSTEM_DEF(bullets)
//message_admins("X: [movementTurf.x] Y:[movementTurf.y] Z:[movementTurf.z]")
if(movementTurf == currentTurf)
canContinue = projectile.scanTurf(currentTurf, bulletDir, currentX, currentY, currentZ, &stepX, &stepY, &stepZ)
dataReference.globalX += stepX
dataReference.globalY += stepY
dataReference.globalZ += stepZ
if(canContinue == PROJECTILE_CONTINUE)
dataReference.globalX += stepX
dataReference.globalY += stepY
dataReference.globalZ += stepZ
else
dataReference.globalX = stepX
dataReference.globalY = stepY
dataReference.globalZ = currentZ
currentTurf.color = COLOR_RED
message_admins(" 1 New turf, X:[round(dataReference.globalX/32)] | Y:[round(dataReference.globalY/32)] | Z:[round(dataReference.globalZ/32)]")
dataReference.lifetime = 0
if(movementTurf != currentTurf)
message_admins("Adjusted for Delta")
projectile.pixel_x -= (movementTurf.x - currentTurf.x) * PPT
projectile.pixel_y -= (movementTurf.y - currentTurf.y) * PPT
projectile.pixel_z -= (movementTurf.z - currentTurf.z) * PPT
projectile.forceMove(movementTurf)
movementTurf.color = COLOR_RED
colored += movementTurf
dataReference.lifetime = 0
break
else
canContinue = projectile.scanTurf(currentTurf, bulletDir, currentX, currentY, currentZ, &stepX, &stepY, &stepZ)
if(canContinue == PROJECTILE_CONTINUE)
Expand All @@ -324,18 +343,33 @@ SUBSYSTEM_DEF(bullets)
dataReference.globalY += stepY
dataReference.globalZ += stepZ
projectile.forceMove(movementTurf)
movementTurf.color = COLOR_GREEN
colored += movementTurf
else
dataReference.globalX = stepX
dataReference.globalY = stepY
dataReference.globalZ = currentZ
message_admins(" 2 New turf, X:[round(dataReference.globalX/32)] | Y:[round(dataReference.globalY/32)] | Z:[round(dataReference.globalZ/32)]")
movementTurf = locate(round(stepX/PPT), round(stepY/PPT), round(currentZ/PPT))
movementTurf.color = COLOR_RED
if(movementTurf != currentTurf)
message_admins("Adjusted for Delta")
projectile.pixel_x -= (movementTurf.x - currentTurf.x) * PPT
projectile.pixel_y -= (movementTurf.y - currentTurf.y) * PPT
projectile.pixel_z -= (movementTurf.z - currentTurf.z) * PPT
projectile.forceMove(movementTurf)
movementTurf.color = COLOR_RED
colored += movementTurf
dataReference.lifetime = 0
break
else
dataReference.globalX = stepX
dataReference.globalY = stepY
dataReference.globalZ = currentZ
currentTurf.color = COLOR_RED
message_admins(" 3 New turf, X:[round(dataReference.globalX/32)] | Y:[round(dataReference.globalY/32)] | Z:[round(dataReference.globalZ/32)]")
dataReference.lifetime = 0
break

//message_admins("stepX:[stepX] , stepY : [stepY]")

Expand Down Expand Up @@ -370,6 +404,12 @@ SUBSYSTEM_DEF(bullets)
projectile.finishDeletion()
bullet_queue.Remove(dataReference)

if(length(colored))
addtimer(CALLBACK(src, PROC_REF(deleteColors), colored.Copy()), SSbullets.wait * 15)

/datum/controller/subsystem/bullets/proc/deleteColors(list/specialList)
for(var/turf/tata in specialList)
tata.color = initial(tata.color)

/datum/controller/subsystem/bullets/fire(resumed)
return realFire()
Expand Down
3 changes: 0 additions & 3 deletions code/modules/projectiles/hitbox_datums.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ boolean lineLine(float x1, float y1, float x2, float y2, float x3, float y3, flo
firstRatio = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator
secondRatio = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denominator
if(firstRatio >= 0 && firstRatio <= 1 && secondRatio >= 0 && secondRatio <= 1)
/// Distance to intersection of point
message_admins("pstepX = [*pStepX] , pstepY = [*pStepY]")
*pStepX = x1 + firstRatio * (x2 - x1)
*pStepY = y1 + firstRatio * (y2 - y1)
message_admins("Collision put at X:[x1 + *pStepX] Y:[y1+ *pStepY]")
return TRUE
//return list(x1 + firstRatio * (x2 - x1), y1 + firstRatio * (y2 - y1))
//message_admins("X-collision : [x1 + firstRatio * (x2 - x1)] Y-collision : [y1 + firstRatio * (y2] - y1)]")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ GLOBAL_LIST(projectileDamageConstants)
on_impact(A)
atomFlags |= AF_VISUAL_MOVE
density = FALSE
dataRef.lifetime = 1
dataRef.lifetime = 0

/obj/effect/bullet_sparks
name = "bullet hit"
Expand Down

0 comments on commit 6692f96

Please sign in to comment.