Thrown items can be targeted, has miss chance...

...based on distance, similar to projectiles.
This commit is contained in:
mwerezak
2014-07-15 01:14:04 -04:00
parent 836d2e40a8
commit f2845dbe76
21 changed files with 52 additions and 27 deletions

View File

@@ -141,7 +141,7 @@ var/const/tk_maxrange = 15
else
apply_focus_overlay()
focus.throw_at(target, 10, 1)
focus.throw_at(target, 10, 1, user)
last_throw = world.time
return

View File

@@ -303,9 +303,10 @@ var/global/list/PDA_Manifest = list()
throw_speed = 1
throw_range = 20
flags = FPRINT | TABLEPASS | CONDUCT
afterattack(atom/target as mob|obj|turf|area, mob/user as mob)
user.drop_item()
src.throw_at(target, throw_range, throw_speed)
src.throw_at(target, throw_range, throw_speed, user)
/obj/effect/stop
var/victim = null

View File

@@ -7,6 +7,8 @@
var/l_move_time = 1
var/m_flag = 1
var/throwing = 0
var/thrower
var/turf/throw_source = null
var/throw_speed = 2
var/throw_range = 7
var/moved_recently = 0
@@ -77,11 +79,13 @@
if(A.density && !A.throwpass) // **TODO: Better behaviour for windows which are dense, but shouldn't always stop movement
src.throw_impact(A,speed)
/atom/movable/proc/throw_at(atom/target, range, speed)
/atom/movable/proc/throw_at(atom/target, range, speed, thrower)
if(!target || !src) return 0
//use a modified version of Bresenham's algorithm to get from the atom's current position to that of the target
src.throwing = 1
src.thrower = thrower
src.throw_source = get_turf(src) //store the origin turf
if(usr)
if(HULK in usr.mutations)
@@ -170,6 +174,8 @@
//done throwing, either because it hit something or it finished moving
if(isobj(src)) src.throw_impact(get_turf(src),speed)
src.throwing = 0
src.thrower = null
src.throw_source = null
//Overlays

View File

@@ -394,7 +394,7 @@
if ( emagged ) // Warning, hungry humans detected: throw fertilizer at them
spawn(0)
fert.loc = src.loc
fert.throw_at(target, 16, 3)
fert.throw_at(target, 16, 3, src)
src.visible_message("\red <b>[src] launches [fert.name] at [target.name]!</b>")
flick("farmbot_broke", src)
spawn (FARMBOT_EMAG_DELAY)

View File

@@ -217,7 +217,7 @@
var/obj/item/meatslab = allmeat[i]
var/turf/Tx = locate(src.x - i, src.y, src.z)
meatslab.loc = src.loc
meatslab.throw_at(Tx,i,3)
meatslab.throw_at(Tx,i,3,src)
if (!Tx.density)
new /obj/effect/decal/cleanable/blood/gibs(Tx,i)
src.operating = 0

View File

@@ -403,7 +403,7 @@
if(!throw_item)
return 0
spawn(0)
throw_item.throw_at(target,16,3)
throw_item.throw_at(target,16,3,src)
src.visible_message("\red <b>[src] launches [throw_item.name] at [target.name]!</b>")
return 1

View File

@@ -552,7 +552,7 @@
if (!throw_item)
return 0
spawn(0)
throw_item.throw_at(target, 16, 3)
throw_item.throw_at(target, 16, 3, src)
src.visible_message("\red <b>[src] launches [throw_item.name] at [target.name]!</b>")
return 1

View File

@@ -464,7 +464,7 @@
return
else if(target!=locked)
if(locked in view(chassis))
locked.throw_at(target, 14, 1.5)
locked.throw_at(target, 14, 1.5, chassis)
locked = null
send_byjax(chassis.occupant,"exosuit.browser","\ref[src]",src.get_equip_info())
set_ready_state(0)

View File

@@ -231,7 +231,7 @@
var/missile_range = 30
/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack/Fire(atom/movable/AM, atom/target, turf/aimloc)
AM.throw_at(target,missile_range, missile_speed)
AM.throw_at(target,missile_range, missile_speed, chassis)
/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack/explosive
name = "SRM-8 Missile Rack"

View File

@@ -82,16 +82,19 @@
C = usr.buckled
var/obj/B = usr.buckled
var/movementdirection = turn(direction,180)
if(C) C.propelled = 1
B.Move(get_step(usr,movementdirection), movementdirection)
sleep(1)
if(C) C.propelled = 4
B.Move(get_step(usr,movementdirection), movementdirection)
sleep(1)
B.Move(get_step(usr,movementdirection), movementdirection)
if(C) C.propelled = 3
sleep(1)
B.Move(get_step(usr,movementdirection), movementdirection)
sleep(1)
B.Move(get_step(usr,movementdirection), movementdirection)
if(C) C.propelled = 2
sleep(2)
B.Move(get_step(usr,movementdirection), movementdirection)
if(C) C.propelled = 1
sleep(2)
B.Move(get_step(usr,movementdirection), movementdirection)
if(C) C.propelled = 0

View File

@@ -138,7 +138,7 @@
if(propelled)
var/mob/living/occupant = buckled_mob
unbuckle()
occupant.throw_at(A, 3, 2)
occupant.throw_at(A, 3, propelled)
occupant.apply_effect(6, STUN, 0)
occupant.apply_effect(6, WEAKEN, 0)
occupant.apply_effect(6, STUTTER, 0)

View File

@@ -136,7 +136,12 @@
if(propelled || (pulling && (pulling.a_intent == "hurt")))
var/mob/living/occupant = buckled_mob
unbuckle()
occupant.throw_at(A, 3, 2)
if (pulling && (pulling.a_intent == "hurt"))
occupant.throw_at(A, 3, 3, pulling)
else if (propelled)
occupant.throw_at(A, 3, propelled)
occupant.apply_effect(6, STUN, 0)
occupant.apply_effect(6, WEAKEN, 0)
occupant.apply_effect(6, STUTTER, 0)

View File

@@ -116,7 +116,7 @@
H.concealed = 1
H.update_icon()
usr.visible_message("\The [usr] deals a card to \the [M].")
H.throw_at(get_step(M,M.dir),10,1)
H.throw_at(get_step(M,M.dir),10,1,H)
/obj/item/weapon/hand/attackby(obj/O as obj, mob/user as mob)
if(istype(O,/obj/item/weapon/hand))

View File

@@ -330,7 +330,7 @@
*/
item.throw_at(target, item.throw_range, item.throw_speed)
item.throw_at(target, item.throw_range, item.throw_speed, src)
/mob/living/carbon/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
..()

View File

@@ -1383,7 +1383,7 @@
status_flags |= LEAPING
src.visible_message("<span class='warning'><b>\The [src]</b> leaps at [T]!</span>")
src.throw_at(get_step(get_turf(T),get_turf(src)), 5, 1)
src.throw_at(get_step(get_turf(T),get_turf(src)), 5, 1, src)
playsound(src.loc, 'sound/voice/shriek1.ogg', 50, 1)
sleep(5)

View File

@@ -69,21 +69,31 @@
/mob/living/hitby(atom/movable/AM as mob|obj,var/speed = 5)//Standardization and logging -Sieve
if(istype(AM,/obj/))
var/obj/O = AM
var/zone = ran_zone("chest",75)//Hits a random part of the body, geared towards the chest
var/dtype = BRUTE
if(istype(O,/obj/item/weapon))
var/obj/item/weapon/W = O
dtype = W.damtype
var/throw_damage = O.throwforce*(speed/5)
var/zone
if (istype(O.thrower, /mob/living))
var/mob/living/L = O.thrower
zone = check_zone(L.zone_sel.selecting)
else
zone = ran_zone("chest",75) //Hits a random part of the body, geared towards the chest
//def_zone = get_zone_with_miss_chance(zone, src, 15*AM.throwing_dist_travelled)
zone = get_zone_with_miss_chance(zone, src) //TODO: store the location of the thrower and adjust miss chance with distance
if (O.throw_source)
var/distance = get_dist(O.throw_source, loc)
zone = get_zone_with_miss_chance(zone, src, min(15*(distance-2), 0))
else
zone = get_zone_with_miss_chance(zone, src, 15)
if(!zone)
visible_message("\blue \The [AM] misses [src] narrowly!")
visible_message("\blue \The [O] misses [src] narrowly!")
return
AM.throwing = 0 //it hit, so stop moving
O.throwing = 0 //it hit, so stop moving
if (istype(src, /mob/living/carbon/human))
var/mob/living/carbon/human/H = src
@@ -136,7 +146,7 @@
//This is called when the mob is thrown into a dense turf
/mob/living/proc/turf_collision(var/turf/T, var/speed)
src.take_organ_damage(speed*4)
src.take_organ_damage(speed*5)
/mob/living/proc/near_wall(var/direction,var/distance=1)
var/turf/T = get_step(get_turf(src),direction)

View File

@@ -110,7 +110,7 @@
user.visible_message("\red [user] fires [src]!", "\red You fire [src]!")
spike.loc = get_turf(src)
spike.throw_at(target,10,fire_force)
spike.throw_at(target,10,fire_force,user)
spike = null
update_icon()

View File

@@ -191,7 +191,7 @@
var/obj/item/weapon/arrow/A = arrow
A.loc = get_turf(user)
A.throw_at(target,10,tension*release_speed)
A.throw_at(target,10,tension*release_speed,user)
arrow = null
tension = 0
icon_state = "crossbow"

View File

@@ -131,7 +131,7 @@
user.visible_message("<span class='danger'>[user] fires [src] and launches [object] at [target]!</span>","<span class='danger'>You fire [src] and launch [object] at [target]!</span>")
src.remove_from_storage(object,user.loc)
object.throw_at(target,10,speed)
object.throw_at(target,10,speed,user)
var/lost_gas_amount = tank.air_contents.total_moles*(pressure_setting/100)
var/datum/gas_mixture/removed = tank.air_contents.remove(lost_gas_amount)

View File

@@ -43,7 +43,7 @@
var/obj/item/missile/M = new projectile(user.loc)
playsound(user.loc, 'sound/effects/bang.ogg', 50, 1)
M.primed = 1
M.throw_at(target, missile_range, missile_speed)
M.throw_at(target, missile_range, missile_speed,user)
message_admins("[key_name_admin(user)] fired a rocket from a rocket launcher ([src.name]).")
log_game("[key_name_admin(user)] used a rocket launcher ([src.name]).")
rockets -= I

View File

@@ -56,7 +56,7 @@
var/obj/item/weapon/grenade/chem_grenade/F = grenades[1] //Now with less copypasta!
grenades -= F
F.loc = user.loc
F.throw_at(target, 30, 2)
F.throw_at(target, 30, 2, user)
message_admins("[key_name_admin(user)] fired a grenade ([F.name]) from a grenade launcher ([src.name]).")
log_game("[key_name_admin(user)] used a grenade ([src.name]).")
F.active = 1