Refactor Immovable Rod

I'm going to fall asleep now but I've remade immovable rod. It's pretty neat now if you throw one at the station.

Things I want to fix before this gets merged.
- It needs a better method for choosing targets and the target should terminate at the end of the zlevel approximately
- Still has some stupid issue where the appearance is all fucked up when it's tearing through the station instead of being like a normal projectile
This commit is contained in:
clusterfack
2016-01-26 04:36:03 -06:00
parent 13ff607beb
commit c1a0461d4f
12 changed files with 146 additions and 99 deletions

View File

@@ -33,7 +33,7 @@
var/list/locked_atoms
var/atom/movable/locked_to
var/locked_should_lie = 0 //Whether locked mobs should lie down, used by beds.
var/dense_when_locking = 1
var/lockflags = DENSE_WHEN_LOCKING | DENSE_WHEN_LOCKED
// Can we send relaymove() if gravity is disabled or we are in space? (Should be handled by relaymove, but shitcode abounds)
var/internal_gravity = 0
@@ -216,7 +216,7 @@
AM.anchored = 1
if(dense_when_locking)
if((lockflags & DENSE_WHEN_LOCKING) && (AM.lockflags && DENSE_WHEN_LOCKED))
density = 1
return 1
@@ -234,7 +234,7 @@
AM.anchored = initial(AM.anchored)
if(dense_when_locking)
if((lockflags & DENSE_WHEN_LOCKING) && (AM.lockflags && DENSE_WHEN_LOCKED))
density = initial(density)
return 1

View File

@@ -1,91 +0,0 @@
/*
Immovable rod random event.
The rod will spawn at some location outside the station, and travel in a straight line to the opposite side of the station
Everything solid in the way will be ex_act()'d
In my current plan for it, 'solid' will be defined as anything with density == 1
--NEOFite
*/
/obj/effect/immovablerod
name = "Immovable Rod"
desc = "What the fuck is that?"
icon = 'icons/obj/objects.dmi'
icon_state = "immrod"
throwforce = 100
density = 1
anchored = 1
Bump(atom/clong)
if(istype(clong, /turf/simulated/shuttle)) //Skip shuttles without actually deleting the rod
return
else if (istype(clong, /turf) && !istype(clong, /turf/unsimulated))
if(clong.density)
clong.ex_act(2)
for (var/mob/O in hearers(src, null))
O.show_message("CLANG", 2)
else if (istype(clong, /obj))
if(clong.density)
clong.ex_act(2)
for (var/mob/O in hearers(src, null))
O.show_message("CLANG", 2)
else if (istype(clong, /mob))
if(clong.density || prob(10))
clong.ex_act(2)
else
qdel(src)
return
if(clong && prob(25))
src.loc = clong.loc
/proc/immovablerod()
var/startx = 0
var/starty = 0
var/endy = 0
var/endx = 0
var/startside = pick(cardinal)
switch(startside)
if(NORTH)
starty = 187
startx = rand(41, 199)
endy = 38
endx = rand(41, 199)
if(EAST)
starty = rand(38, 187)
startx = 199
endy = rand(38, 187)
endx = 41
if(SOUTH)
starty = 38
startx = rand(41, 199)
endy = 187
endx = rand(41, 199)
if(WEST)
starty = rand(38, 187)
startx = 41
endy = rand(38, 187)
endx = 199
//rod time!
var/obj/effect/immovablerod/immrod = new /obj/effect/immovablerod(locate(startx, starty, 1))
// to_chat(world, "Rod in play, starting at [start.loc.x],[start.loc.y] and going to [end.loc.x],[end.loc.y]")
var/end = locate(endx, endy, 1)
spawn(0)
walk_towards(immrod, end,1)
sleep(1)
while (immrod)
if (immrod.z != 1)
immrod.z = 1
if(immrod.loc == end)
qdel(immrod)
immrod = null
sleep(10)
for(var/obj/effect/immovablerod/imm in world)
return
sleep(50)
command_alert("What the fuck was that?!", "General Alert")

View File

@@ -117,7 +117,8 @@
return 1
else
if(istype(mover, /obj/item/projectile))
return prob(66) //Fairly hit chance
var/obj/item/projectile/projectile = mover
return prob(projectile.grillepasschance) //Fairly hit chance
else
return !density

View File

@@ -14,7 +14,7 @@
icon = 'icons/obj/stools-chairs-beds.dmi'
locked_should_lie = 1
dense_when_locking = 0
lockflags = 0
anchored = 1
var/sheet_type = /obj/item/stack/sheet/metal
var/sheet_amt = 1
@@ -113,7 +113,7 @@
icon = 'icons/obj/rollerbed.dmi'
icon_state = "down"
anchored = 0
dense_when_locking = 1
lockflags = DENSE_WHEN_LOCKING | DENSE_WHEN_LOCKED
/obj/item/roller
name = "roller bed"

View File

@@ -3,7 +3,7 @@
desc = "You sit in this. Either by will or force."
icon_state = "chair"
locked_should_lie = 0
dense_when_locking = 0
lockflags = 0
sheet_amt = 1

View File

@@ -57,6 +57,7 @@ var/list/event_last_fired = list()
possibleEvents[/datum/event/meteor_wave] = 15
possibleEvents[/datum/event/meteor_shower] = 40
possibleEvents[/datum/event/blob] = 10
possibleEvents[/datum/event/immovable_rod] = 15
possibleEvents[/datum/event/radiation_storm] = 50
if(active_with_role["Medical"] > 1)

View File

@@ -0,0 +1,131 @@
//Immovable rod
//Passes through the station destroyed all dense objects and damage all dense turfs
//As well as hurting all dense mobs
//Recoded as a projectile for better movement/appearance
/datum/event/immovable_rod
announceWhen = 100
/datum/event/immovable_rod/announce()
command_alert("What the fuck was that?!", "General Alert")
/datum/event/immovable_rod/start()
immovablerod()
/proc/immovablerod()
var/startx = 0
var/starty = 0
var/endy = 0
var/endx = 0
var/startside = pick(cardinal)
//Starts near the transition edge of the zlevel at a random point on one of the four cardinal dirs
switch(startside)
if(NORTH)
starty = world.maxy-TRANSITIONEDGE-5
startx = rand(TRANSITIONEDGE+5,world.maxx-TRANSITIONEDGE-5)
if(EAST)
starty = rand(TRANSITIONEDGE+5,world.maxy-TRANSITIONEDGE-5)
startx = world.maxx-TRANSITIONEDGE-5
if(SOUTH)
starty = TRANSITIONEDGE+5
startx = rand(TRANSITIONEDGE+5,world.maxx-TRANSITIONEDGE-5)
if(WEST)
starty = rand(TRANSITIONEDGE+5,world.maxy-TRANSITIONEDGE-5)
startx = TRANSITIONEDGE+5
//One of the turfs in the 60x60 square in the center of the zlevel
endx = rand((world.maxx/2)-30,(world.maxx/2)+30)
endy = rand((world.maxy/2)-30,(world.maxy/2)+30)
new /obj/item/projectile/immovablerod(locate(startx, starty, 1), locate(endx, endy, 1))
/obj/item/projectile/immovablerod
name = "Immovable Rod"
desc = "What the fuck is that?"
icon = 'icons/obj/objects.dmi'
icon_state = "immrod"
throwforce = 100
density = 1
anchored = 1
locked_atoms = list()
grillepasschance = 0
mouse_opacity = 1
/obj/item/projectile/immovablerod/New(atom/start, atom/end)
..()
step_delay = round(0.5, world.tick_lag)
if(end)
throw_at(end)
/obj/item/projectile/immovablerod/throw_at(atom/end)
for(var/mob/dead/observer/people in observers)
to_chat(people, "<span class = 'notice'>Immovable rod has been thrown at the station, <a href='?src=\ref[people];follow=\ref[src]'>Follow it</a></span>")
original = end
starting = loc
current = loc
OnFired()
yo = target.y - y
xo = target.x - x
process()
/obj/item/projectile/immovablerod/ex_act()
return
/obj/item/projectile/immovablerod/singularity_act(size,var/obj/machinery/singularity/singularity)
singularity.expand(STAGE_FIVE) //An unstoppable object must have crazy mass, also seriously what are the chances of this
qdel(src)
/obj/item/projectile/immovablerod/bresenham_step(var/distA, var/distB, var/dA, var/dB)
if(step_delay)
sleep(step_delay)
if(error < 0)
var/atom/newloc = get_step(src, dB)
if(!newloc)
bullet_die()
forceMove(newloc)
error += distA
return 0//so that bullets going in diagonals don't move twice slower
else
var/atom/newloc = get_step(src, dA)
if(!newloc)
bullet_die()
forceMove(newloc)
error -= distB
return 1
/obj/item/projectile/immovablerod/forceMove(atom/destination,var/no_tp=0)
..()
if(z != starting.z)
qdel(src)
return
if(loc.density)
loc.ex_act(2)
if(prob(25))
clong()
for(var/atom/clong in loc)
if(!clong.density)
continue
if(istype(clong, /obj))
if(clong.density)
clong.ex_act(1)
else if(istype(clong, /mob))
if(istype(clong, /mob/living/carbon/human))
var/mob/living/carbon/human/H = clong
H.visible_message("<span class='danger'>[H.name] is penetrated by an immovable rod!</span>" , "<span class='userdanger'>The rod penetrates you!</span>" , "<span class ='danger'>You hear a CLANG!</span>")
H.gib()
else if(clong.density || (istype(clong,/mob/living) && prob(10))) //Only 1 Ian was harmed in the coding of this object, RIP
clong.visible_message("<span class='danger'>[clong] is scraped by an immovable rod!</span>" , "<span class='userdanger'>The rod scrapes part of you off!</span>" , "<span class ='danger'>You hear a CLANG!</span>")
clong.ex_act(2)
if(prob(25) && (!clong || !clong.density || clong.gcDestroyed)) //did we just clear some shit?
clong()
/obj/item/projectile/immovablerod/proc/clong()
playsound(src, 'sound/effects/bang.ogg', 50, 1)
visible_message("CLANG")

View File

@@ -10,6 +10,7 @@
layer = 4
stat = DEAD
density = 0
lockflags = 0 //Neither dense when locking or dense when locked to something
canmove = 0
blinded = 0
anchored = 1 // don't get pushed around

View File

@@ -36,6 +36,7 @@ var/list/impact_master = list()
var/p_x = 16
var/p_y = 16 // the pixel location of the tile that the player clicked. Default is the center
var/grillepasschance = 66
var/damage = 10
var/damage_type = BRUTE //BRUTE, BURN, TOX, OXY, CLONE are the only things that should be in here
var/nodamage = 0 //Determines if the projectile will skip any damage inflictions

View File

@@ -1364,3 +1364,6 @@ var/proccalls = 1
#define STARVATION_BRAIN_DAMAGE 2.5
#define STARVATION_OXY_HEAL_RATE 1 //While starving, THIS much oxygen damage is restored per life tick (instead of the default 5)
#define DENSE_WHEN_LOCKING 1
#define DENSE_WHEN_LOCKED 2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 96 KiB

View File

@@ -314,7 +314,6 @@
#include "code\game\gamemodes\endgame\xmas\xmas.dm"
#include "code\game\gamemodes\events\biomass.dm"
#include "code\game\gamemodes\events\black_hole.dm"
#include "code\game\gamemodes\events\clang.dm"
#include "code\game\gamemodes\events\dust.dm"
#include "code\game\gamemodes\events\miniblob.dm"
#include "code\game\gamemodes\events\power_failure.dm"
@@ -1056,6 +1055,7 @@
#include "code\modules\events\event_manager.dm"
#include "code\modules\events\grid_check.dm"
#include "code\modules\events\heist.dm"
#include "code\modules\events\immovablerod.dm"
#include "code\modules\events\infestation.dm"
#include "code\modules\events\ion_storm.dm"
#include "code\modules\events\masshallucination.dm"