Skip to content

Commit

Permalink
Mine spawning improvements (adresses review)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bokkiewokkie committed Sep 13, 2024
1 parent 6ff7de4 commit 17408b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
18 changes: 10 additions & 8 deletions nsv13/code/controllers/subsystem/starsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ Returns a faction datum by its name (case insensitive!)
if(backupx && backupy)
target.contents_positions[OM] = list("x" = backupx, "y" = backupy) //Cache the ship's position so we can regenerate it later.
else
target.contents_positions[OM] = list("x" = rand(15, 240), "y" = rand(15, 240))
target.contents_positions[OM] = list("x" = rand(15, world.maxx - 15), "y" = rand(15, world.maxy - 15))
else
if(!OM.z)
START_PROCESSING(SSphysics_processing, OM)
Expand Down Expand Up @@ -894,6 +894,8 @@ Returns a faction datum by its name (case insensitive!)
/datum/star_system/proc/spawn_enemies(enemy_type, amount)
if(!amount)
amount = difficulty_budget
if(amount <= 0)
amount = 1 //Why else are you calling this?
for(var/i = 0, i < amount, i++) //number of enemies is set via the star_system vars
if(!enemy_type)
enemy_type = pick(SSstar_system.enemy_types) //Spawn a random set of enemies.
Expand All @@ -902,16 +904,16 @@ Returns a faction datum by its name (case insensitive!)
/datum/star_system/proc/spawn_mines(faction, amount)
if(!amount)
amount = difficulty_budget*2
if(amount <= 0)
amount = 1 //Why else are you calling this?
if(!faction) //Someone forgot to set their IFF
faction = alignment
var/z_level = 1
if(occupying_z)
z_level = occupying_z
if(!occupying_z) //We didn't get one
for(var/i = 0, i < amount, i++)
var/obj/structure/space_mine/M = new /obj/structure/space_mine(null, faction, src) //You are in nullspace now
contents_positions[M] = list("x" = rand(5, world.maxx - 5),"y" = rand(5, world.maxy - 5))
for(var/i = 0, i < amount, i++)
var/obj/structure/space_mine/M = new /obj/structure/space_mine(get_turf(locate(rand(5, world.maxx - 5), rand(5, world.maxy - 5), z_level)), faction, src) //random location in the system
if(z_level == 1) //We didn't get one
contents_positions[M] = list("x" = M.x,"y" = M.y)
M.moveToNullspace()
new /obj/structure/space_mine(get_turf(locate(rand(5, world.maxx - 5), rand(5, world.maxy - 5), occupying_z)), faction, src) //random location in the system

/datum/star_system/proc/lerp_x(datum/star_system/other, t)
return x + (t * (other.x - x))
Expand Down
16 changes: 13 additions & 3 deletions nsv13/code/modules/overmap/weapons/mines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@
. = ..()
if(system)
current_system = system
else if(!current_system) //Someone is probably spawning us on the overmap, so we assume it's next to the main ship
current_system = SSstar_system.find_main_overmap().current_system
else if(!current_system)
for(var/obj/structure/overmap/OM in range(2, src)) //It probably spawned next to a ship
if(OM.current_system)
current_system = OM.current_system
break
if(!current_system) //If an admin spawned you in, it's their job to clean you up. This should never happen normally.
log_runtime("Space mine spawned at x=[x],y=[y],z=[z] with no system or ship nearby!")
if(new_faction)
faction = new_faction
update_icon()
var/static/list/loc_connections = list(COMSIG_ATOM_ENTERED = PROC_REF(on_entered))
AddElement(/datum/element/connect_loc, loc_connections)
return
current_system.system_contents |= src
if(new_faction)
faction = new_faction
Expand Down Expand Up @@ -61,7 +72,6 @@
icon_state = "mine_[faction]"
else
icon_state = "mine_unaligned"
faction = "unaligned"

/obj/structure/space_mine/obj_break(damage_flag)
if(prob(80))
Expand Down

0 comments on commit 17408b0

Please sign in to comment.