From f3902cb80e9fd83f27804462016f0bdf0abfb285 Mon Sep 17 00:00:00 2001 From: uporotiy Date: Sun, 16 Jan 2011 20:52:39 +0000 Subject: [PATCH] Started work on traps. Added a "rocks fall" trap. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@877 316c924e-a436-60f5-8080-3fe189b3f50e --- code/game/objects/traps.dm | 75 ++++++++++++++++++++++++++++++++++++++ tgstation.dme | 1 + 2 files changed, 76 insertions(+) create mode 100644 code/game/objects/traps.dm diff --git a/code/game/objects/traps.dm b/code/game/objects/traps.dm new file mode 100644 index 00000000000..5583e0376bf --- /dev/null +++ b/code/game/objects/traps.dm @@ -0,0 +1,75 @@ +/obj/trap + name = "trap" + desc = "It's a trap!" + density = 0 + var/uses = 1 //how many times it can be triggered + +/obj/trap/New() + ..() + src:visibility = 0 //seriously, it keeps saying "undefined var" when I try to do it in the define + +/obj/trap/HasEntered(victim as mob|obj) + trigger(victim) + +/obj/trap/Bumped(victim as mob|obj) + trigger(victim) + +/obj/trap/proc/trigger(victim) + if(!uses) + return + uses-- + +/obj/trap/rocksfall + name = "rocks fall trap" + desc = "Your DM must really hate you." + var/aoe_radius = 3 //radius of rocks falling + var/aoe_include_dense = 0 //if it includes dense tiles in the aoe + var/aoe_range_or_view = "view" //if it includes all tiles in [radius] range or view + var/rocks_amt = 10 //amount of rocks falling + var/rocks_seeking = 0 //if 1, rocks fall only on mobs, otherwise it picks the turfs in the area at random + var/rocks_min_dmg = 50 //min damage per rock + var/rocks_max_dmg = 100 //max damage per rock + var/rocks_hit_chance = 100 //the chance for a rock to hit you + +/obj/trap/rocksfall/trigger() + + ..() + + var/list/targets = list() + + if(!rocks_seeking) + switch(aoe_range_or_view) + if("view") + for(var/turf/T in view(src,aoe_radius)) + if(!T.density || aoe_include_dense) + targets += T + if("range") + for(var/turf/T in range(src,aoe_radius)) + if(!T.density || aoe_include_dense) + targets += T + + for(var/i=0,i