# Smashing windows with thrown rocks

**URL:** <https://discourse.cataclysmdda.org/t/smashing-windows-with-thrown-rocks/796>\
**Category:** The Garage\
**Created:** [April 13, 2013, 4:37pm UTC](https://discourse.cataclysmdda.org/t/smashing-windows-with-thrown-rocks/796 "2013-04-13T16:37:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pingpong](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@pingpong](https://discourse.cataclysmdda.org/u/pingpong)\
**Post date:** [April 13, 2013, 4:37pm UTC](https://discourse.cataclysmdda.org/t/smashing-windows-with-thrown-rocks/796/1 "2013-04-13T16:37:21Z")

</div>

I don’t think it makes sounds and it doesn’t make sticks or sheets come out.

---

<div class="post-metadata">

**Author:** ![Sirian](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@Sirian](https://discourse.cataclysmdda.org/u/Sirian)\
**Post date:** [April 13, 2013, 8:41pm UTC](https://discourse.cataclysmdda.org/t/smashing-windows-with-thrown-rocks/796/2 "2013-04-13T20:41:17Z")

</div>

I just checked and you were right, so I decided to look into it and here’s what I found :

Throwing stuff, as far as terrain goes, uses the function “shoot”, whereas smashing uses “bash”.

These functions are created in “map.cpp”, starting as follows :  
Shoot

`void map::shoot(game *g, const int x, const int y, int &dam,
                const bool hit_items, const unsigned effects)`  
Bash

```auto

```

There are probably other discrepancies between Shoot and Bash than just with breaking windows, but I focused on windows and indeed the Shoot function lacks sound and item generation when destroying windows, as well as not handling some types of windows, whereas Bash does everything properly, so I did some creative copypasta, and here’s the result :

Right now, Shoot does this :

[code] case t\_window:  
case t\_window\_domestic:  
case t\_window\_alarm:  
dam -= rng(0, 5);  
ter\_set(x, y, t\_window\_frame);  
break;

case t\_window\_boarded:  
dam -= rng(10, 30);  
if (dam \> 0)  
ter\_set(x, y, t\_window\_frame);  
break;

case t\_wall\_glass\_h:  
case t\_wall\_glass\_v:  
case t\_wall\_glass\_h\_alarm:  
case t\_wall\_glass\_v\_alarm:  
dam -= rng(0, 8);  
ter\_set(x, y, t\_floor);  
break;[/code]

where it should do that :

```auto
 case t_window_domestic:
 case t_curtains:
 case t_window_domestic_taped:
  dam -= rng(0, 5);
  g->sound(g->u.posx, g->u.posy, 18, "glass breaking!");
   ter_set(x, y, t_window_frame);
  spawn_item(x, y, (*itypes)["sheet"], 0, 1);
  spawn_item(x, y, (*itypes)["stick"], 0);
  break;

 case t_window_boarded:
  dam -= rng(10, 30);
  if (dam > 0)
  g->sound(g->u.posx, g->u.posy, 18, "crash!");
   ter_set(x, y, t_window_frame);
   const int num_boards = rng(0, 2) * rng(0, 1);
   for (int i = 0; i < num_boards; i++)
    spawn_item(x, y, (*itypes)["splinter"], 0);
  break;

 case t_window:
 case t_window_alarm:
 case t_window_alarm_taped:
 case t_window_taped:
  dam -= rng(0, 5);
  g->sound(g->u.posx, g->u.posy, 18, "glass breaking!");
   ter_set(x, y, t_window_frame);
  break;

 case t_wall_glass_h:
 case t_wall_glass_v:
 case t_wall_glass_h_alarm:
 case t_wall_glass_v_alarm:
  dam -= rng(0, 8);
  g->sound(g->u.posx, g->u.posy, 18, "glass breaking!");
  ter_set(x, y, t_floor);
  break;
```

For the sound volume I used 18, the same as smashing, and I used the same way to generate sound as when shooting triggers an alarm, but I used the bashing sounds text. Hopefully I did this right.

If someone with a github account could check this and do the change/report here if it doesn’t work, I’d be most grateful (crossing my fingers here, since I’m not exactly used to write code).

---

<div class="post-metadata">

**Author:** ![pingpong](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@pingpong](https://discourse.cataclysmdda.org/u/pingpong)\
**Post date:** [April 14, 2013, 3:23pm UTC](https://discourse.cataclysmdda.org/t/smashing-windows-with-thrown-rocks/796/3 "2013-04-14T15:23:16Z")

</div>

but but it’s completely helpful things are buggy in this case, except for the lack of sheets, but it’s not like there isn’t 100 windows per house
