| 1711 | } |
| 1712 | |
| 1713 | void doLaunchContents() |
| 1714 | { |
| 1715 | // Translate cartoon flight speed to parabolic |
| 1716 | float speed = 100000.0f / (fall_delay + 1); |
| 1717 | int min_zspeed = (fall_delay+1)*4900; |
| 1718 | |
| 1719 | float bonus = 1.0f + 0.1f*(origin_pos.z -cur_pos.z); |
| 1720 | bonus *= 1.0f + (distance_flown - 60) / 200.0f; |
| 1721 | speed *= bonus; |
| 1722 | |
| 1723 | // Flight direction vector |
| 1724 | df::coord dist = target_pos - origin_pos; |
| 1725 | float vx = dist.x, vy = dist.y, vz = fabs((float)dist.z); |
| 1726 | normalize(vx, vy, vz); |
| 1727 | |
| 1728 | int start_z = 0; |
| 1729 | |
| 1730 | // Start at tile top, if hit a wall |
| 1731 | ProjectilePath path(origin_pos, target_pos); |
| 1732 | auto next_pos = path[distance_flown+1]; |
| 1733 | if (next_pos.z == cur_pos.z && !isPassableTile(next_pos)) |
| 1734 | start_z = 49000; |
| 1735 | |
| 1736 | bool forbid_ammo = DF_GLOBAL_VALUE(standing_orders_forbid_used_ammo, false); |
| 1737 | |
| 1738 | MapExtras::MapCache mc; |
| 1739 | std::vector<df::item*> contents; |
| 1740 | Items::getContainedItems(item, &contents); |
| 1741 | |
| 1742 | for (size_t i = 0; i < contents.size(); i++) |
| 1743 | { |
| 1744 | auto child = contents[i]; |
| 1745 | |
| 1746 | if (forbid_ammo) |
| 1747 | child->flags.bits.forbid = true; |
| 1748 | |
| 1749 | // Liquids are vaporized so that they cover nearby units |
| 1750 | if (child->isLiquid()) |
| 1751 | { |
| 1752 | auto flow = Maps::spawnFlow( |
| 1753 | cur_pos, |
| 1754 | flow_type::MaterialVapor, |
| 1755 | child->getMaterial(), child->getMaterialIndex(), |
| 1756 | 100 |
| 1757 | ); |
| 1758 | |
| 1759 | // should it leave a puddle too?.. |
| 1760 | if (flow && Items::remove(mc, child)) |
| 1761 | continue; |
| 1762 | } |
| 1763 | |
| 1764 | auto proj = Items::makeProjectile(mc, child); |
| 1765 | if (!proj) continue; |
| 1766 | |
| 1767 | bool keep = apply_impact_damage(child, 50000, int(250000*bonus)); |
| 1768 | |
| 1769 | proj->flags.bits.no_impact_destroy = keep; |
| 1770 | //proj->flags.bits.bouncing = true; |
nothing calls this directly
no test coverage detected