Skip to content

Commit

Permalink
bug: ascii laser was in the wrong position / fixing up staff damage
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jul 6, 2023
1 parent 1152b26 commit e04e4a0
Show file tree
Hide file tree
Showing 22 changed files with 371 additions and 181 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Bugs -->
<!-- ------ -->
<!-- Spell cost -->
<!-- Sword of duck summoning -->
<!-- ------ -->
<!-- -->
<!-- Performance -->
Expand Down
3 changes: 1 addition & 2 deletions python/things/mobs/ghost_mob.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def tp_init(name, text_long_name):
my.chance_d1000_shove(self, 200)
my.collision_check(self, True)
my.collision_hit_priority(self, 10)
my.dmg_received_doubled_from_fire(self, True)
my.environ_dislikes_acid(self, 100)
my.environ_dislikes_fire(self, 10)
my.gfx_ascii_fade_with_dist(self, True)
my.gfx_ascii_shown(self, True)
my.gfx_glows(self, True)
Expand All @@ -45,6 +43,7 @@ def tp_init(name, text_long_name):
my.is_attackable_by_player(self, True)
my.is_biome_chasms(self, True)
my.is_biome_dungeon(self, True)
my.is_immune_to_fire(self, True)
my.is_burnable(self, True)
my.is_crushable(self, True)
my.is_described_when_hovering_over(self, True)
Expand Down
1 change: 1 addition & 0 deletions python/things/mobs/skel_mob.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def tp_init(name, text_long_name):
my.is_biome_dungeon(self, True)
my.is_biome_flooded(self, True)
my.is_biome_ice(self, True)
my.is_immune_to_fire(self, True)
my.is_biome_lava(self, True)
my.is_biome_swamp(self, True)
my.is_burnable(self, True)
Expand Down
5 changes: 4 additions & 1 deletion python/things/projectiles/projectile_fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@


def on_born(me, x, y):
selection_x, selection_y = my.thing_coords_get(me)
for it in my.level_get_all(me, selection_x, selection_y):
if my.thing_possible_to_attack(me, it):
my.thing_hit(0, me, it)
my.spawn_at_my_position(me, "explosion_fire")


Expand All @@ -28,7 +32,6 @@ def tp_init(name, text_long_name, text_short_name):
my.z_depth(self, my.MAP_DEPTH_OBJ)
my.z_prio(self, my.MAP_Z_PRIO_BEHIND)
# end sort marker

my.tile(self, ascii_fg_char="*", ascii_fg_col_name="orange", tile="nothing")
my.tile(self, ascii_fg_char="*", ascii_fg_col_name="red", tile="nothing")
my.tile(self, ascii_fg_char="*", ascii_fg_col_name="orange", tile="nothing")
Expand Down
2 changes: 1 addition & 1 deletion python/things/projectiles/projectile_magic_missile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def tp_init(name, text_long_name, text_short_name):
# begin sort marker
my.collision_check(self, True)
my.gfx_ascii_shown(self, True)
my.dmg_energy_dice(self, "1d10") # This is the damage when the monst attacks
my.dmg_energy_dice(self, "1d6")
my.dmg_chance_d1000_energy(self, 0, 1000)
my.is_able_to_be_teleported(self, True)
my.is_dead_on_falling(self, True)
Expand Down
1 change: 0 additions & 1 deletion python/things/staffs/staff_cold.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def tp_init(name, text_long_name, text_short_name):
my.gfx_targetted_projectile(self, "projectile_cold")
my.gold_value_dice(self, "300")
my.health_initial_dice(self, "20+1d10")
my.health_initial_dice(self, "50")
my.is_able_to_be_teleported(self, True)
my.is_able_to_fall(self, True)
# my.is_able_to_spawn_things(self, False) else we end up owning ice blocks
Expand Down
1 change: 0 additions & 1 deletion python/things/staffs/staff_descent.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def tp_init(name, text_long_name, text_short_name):
my.gfx_targetted_radial(self, "staff_descent_radial")
my.gold_value_dice(self, "500")
my.health_initial_dice(self, "20+1d10")
my.health_initial_dice(self, "50")
my.is_able_to_be_teleported(self, True)
my.is_able_to_fall(self, True)
my.is_bag_item(self, True)
Expand Down
1 change: 0 additions & 1 deletion python/things/staffs/staff_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def tp_init(name, text_long_name, text_short_name):
my.gfx_targetted_laser(self, "laser_energy")
my.gold_value_dice(self, "200")
my.health_initial_dice(self, "20+1d10")
my.health_initial_dice(self, "50")
my.is_able_to_be_teleported(self, True)
my.is_able_to_fall(self, True)
# my.is_able_to_spawn_things(self, False) else we end up owning fire
Expand Down
26 changes: 23 additions & 3 deletions python/things/staffs/staff_fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@ def on_targetted(me, x, y):
continue

my.place_at(me, "fire", x1, y1)
for it in my.level_get_all(me, x1, y1):
if my.thing_possible_to_attack(me, it):
my.thing_hit(0, me, it)


def on_targetted_radially(me, x, y):
radius = my.thing_effect_radius_get(me)
radius += 1

# my.con("targetted radially {} {:X}".format(my.thing_name_get(me), me))
my.spawn_things_around_me(me, "fire", radius)
for dx in range(-radius, radius + 1):
for dy in range(-radius, radius + 1):
if dx == 0 and dy == 0:
continue
x1 = x + dx
y1 = y + dy
distance = (((x1 - x)**2 + (y1 - y)**2)**0.5)
if distance > radius + 0.5:
continue

my.place_at(me, "fire", x1, y1)
for it in my.level_get_all(me, x1, y1):
if my.thing_possible_to_attack(me, it):
my.thing_hit(0, me, it)

my.thing_sound_play_channel(me, my.CHANNEL_EXPLOSION, "explosion_b")


Expand Down Expand Up @@ -83,6 +101,9 @@ def tp_init(name, text_long_name, text_short_name):
my.dmg_received_doubled_from_cold(self, True)
my.effect_has_blast_radius(self, True)
my.environ_dislikes_water(self, 100)
my.dmg_chance_d1000_fire(self, 1, 1000)
my.dmg_fire_dice(self, "1d10+10")
my.dmg_num_of_attacks(self, 1)
my.equip_carry_anim(self, "staff_fire_carry")
my.gfx_ascii_fade_with_dist(self, True)
my.gfx_ascii_shown(self, True)
Expand All @@ -91,10 +112,9 @@ def tp_init(name, text_long_name, text_short_name):
my.gfx_pixelart_shadow(self, True)
my.gfx_pixelart_shadow_short(self, True)
my.gfx_pixelart_show_highlighted(self, True)
my.gfx_targetted_projectile(self, "projectile_fire")
my.gfx_targetted_projectile(self, "staff_projectile_fire")
my.gold_value_dice(self, "300")
my.health_initial_dice(self, "20+1d10")
my.health_initial_dice(self, "50")
my.is_able_to_be_teleported(self, True)
my.is_able_to_fall(self, True)
# my.is_able_to_spawn_things(self, False) else we end up owning fire
Expand Down
1 change: 0 additions & 1 deletion python/things/staffs/staff_lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def tp_init(name, text_long_name, text_short_name):
my.gfx_targetted_laser(self, "staff_lightning_laser")
my.gold_value_dice(self, "300")
my.health_initial_dice(self, "20+1d10")
my.health_initial_dice(self, "50")
my.is_able_to_attack_owner(self, True)
my.is_able_to_be_teleported(self, True)
my.is_able_to_fall(self, True)
Expand Down
3 changes: 1 addition & 2 deletions python/things/staffs/staff_negation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def on_targetted(me, x, y):
def on_targetted_radially(me, x, y):
radius = my.thing_effect_radius_get(me)
radius += 1
# my.con("targetted radially {} {:X}".format(my.thing_name_get(me), me))

# my.con("targetted radially {} {:X}".format(my.thing_name_get(me), me))
for dx in range(-radius, radius + 1):
for dy in range(-radius, radius + 1):
if dx == 0 and dy == 0:
Expand Down Expand Up @@ -122,7 +122,6 @@ def tp_init(name, text_long_name, text_short_name):
my.gfx_targetted_radial(self, "staff_negation_radial")
my.gold_value_dice(self, "300")
my.health_initial_dice(self, "20+1d10")
my.health_initial_dice(self, "50")
my.is_able_to_be_teleported(self, True)
my.is_able_to_fall(self, True)
# my.is_able_to_spawn_things(self, False) else we end up owning effects
Expand Down
4 changes: 4 additions & 0 deletions python/things/staffs/staff_negation_laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import tp


#
# This is an internal only object to fire projectiles from staffs
#
def tp_init(name, text_long_name, text_short_name):
self = tp.Tp(name, text_long_name, text_short_name)
# begin sort marker
my.gfx_ascii_shown(self, True)
my.is_able_to_be_teleported(self, True)
my.is_laser(self, True)
my.is_loggable(self, True)
my.is_no_tile(self, True)
Expand Down
4 changes: 2 additions & 2 deletions src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void Game::place_player(void)
auto w = level->thing_new("staff_lightning", point(x, y));
t->carry(w, carry_options);
}
if (0) {
if (1) {
auto w = level->thing_new("staff_fire", point(x, y));
t->carry(w, carry_options);
}
Expand Down Expand Up @@ -346,7 +346,7 @@ void Game::place_player(void)
auto w = level->thing_new("map_beast", point(x, y));
t->carry(w, carry_options);
}
if (0) {
if (1) {
auto w = level->thing_new("staff_negation", point(x, y));
t->carry(w, carry_options);
}
Expand Down
12 changes: 11 additions & 1 deletion src/laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ Laser_::Laser_(Levelp level, ThingId thing_id, ThingId victim_id, LaserInfo info
//
tiles.resize(max_frames);

//
// Use the preferred name if set.
//
auto laser_tp = tp_find(name);
if (laser_tp) {
if (! laser_tp->gfx_targetted_laser().empty()) {
name = laser_tp->gfx_targetted_laser();
}
}

for (int frame = 0; frame < max_frames; frame++) {
tiles[ frame ].push_back(tile_find_mand(name + "." + std::to_string(frame + 1) + ".start"));
for (int mid = 0; mid < max_frames - 2; mid++) {
Expand Down Expand Up @@ -78,7 +88,7 @@ void Level::new_laser(ThingId id, ThingId victim_id, LaserInfo info, uint32_t du
//
// The ascii display is a bit slower, so to avoid not seeing the laser in all its glory, bump the duration.
//
dur *= 4;
dur *= 5;

info.ts_stop = now + dur;

Expand Down
8 changes: 4 additions & 4 deletions src/laser_ascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ void Level::display_ascii_lasers(point tl, point br)
auto tiles = &t->tp()->tiles;
auto tile = tile_n(tiles, frame);
if (tile) {
int x0 = tl.x + (start.x - minx);
int y0 = tl.y + (start.y - miny);
int x1 = tl.x + (stop.x - minx);
int y1 = tl.y + (stop.y - miny);
int x0 = tl.x + (start.x - minx) - (MAP_BORDER_ROCK - 1);
int y0 = tl.y + (start.y - miny) - (MAP_BORDER_ROCK - 1);
int x1 = tl.x + (stop.x - minx) - (MAP_BORDER_ROCK - 1);
int y1 = tl.y + (stop.y - miny) - (MAP_BORDER_ROCK - 1);

color c = tile->ascii_fg_col_value;
c.a = tile->ascii_fg_alpha;
Expand Down
1 change: 0 additions & 1 deletion src/level_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ int Level::total_monst_dmg_level(void)
damage += t->dmg_lightning_dice().max_roll();
damage += t->dmg_energy_dice().max_roll();
damage += t->dmg_negation_dice().max_roll();
damage += t->dmg_negation_dice().max_roll();
damage += t->dmg_acid_dice().max_roll();
damage += t->dmg_water_dice().max_roll();
damage += t->dmg_digest_dice().max_roll();
Expand Down
2 changes: 1 addition & 1 deletion src/my_game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ class Game
void wid_thing_info_add_dmg_heat(WidPopup *w, Thingp t, int index);
void wid_thing_info_add_dmg_lightning(WidPopup *w, Thingp t, int index);
void wid_thing_info_add_dmg_magic(WidPopup *w, Thingp t, int index);
void wid_thing_info_add_dmg_melee(WidPopup *w, Thingp t, int index);
void wid_thing_info_add_dmg_melee(WidPopup *w, Thingp t);
void wid_thing_info_add_dmg_missile(WidPopup *w, Thingp t, int index);
void wid_thing_info_add_dmg_nat_att(WidPopup *w, Thingp t, int index);
void wid_thing_info_add_dmg_necrosis(WidPopup *w, Thingp t, int index);
Expand Down
9 changes: 9 additions & 0 deletions src/projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ Projectile_::Projectile_(Levelp level, ThingId thing_id, ThingId victim_id, Proj
// "projectile_green.{frame}.15",
// "projectile_green.{frame}.16",
//
//
// Use the preferred name if set.
//
if (proj_tp) {
if (! proj_tp->gfx_targetted_projectile().empty()) {
name = proj_tp->gfx_targetted_projectile();
}
}

for (int frame = 0; frame < max_frames; frame++) {
tiles.push_back(tile_find_mand(name + "." + std::to_string(frame + 1)));
}
Expand Down
4 changes: 2 additions & 2 deletions src/projectile_ascii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void Level::display_ascii_projectiles(point tl, point br)
auto points = ::line(start, stop);
auto npoints = points.size();
auto index = (int) ((((float) npoints) / ((float) Projectile::max_frames)) * ((float) frame));
int x = tl.x + get(points, index).x;
int y = tl.y + get(points, index).y;
int x = tl.x + get(points, index).x - (MAP_BORDER_ROCK - 1);
int y = tl.y + get(points, index).y - (MAP_BORDER_ROCK - 1);

color c = tile->ascii_fg_col_value;
ascii_set(TILE_LAYER_FG_3, x, y, tile->ascii_fg_char);
Expand Down
8 changes: 4 additions & 4 deletions src/sdl_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void __attribute__((noinline)) sdl_event_keydown(SDL_Keysym *key, SDL_Eve
{
sdl.event_count++;

DBG("SDL: Keyboard: Key pressed keycode 0x%08" PRIX32 " = %s %d", event->key.keysym.sym,
CON("SDL: Keyboard: Key pressed keycode 0x%08" PRIX32 " = %s %d", event->key.keysym.sym,
to_string(event->key.keysym).c_str(), key->mod);

//
Expand All @@ -126,7 +126,7 @@ static void __attribute__((noinline)) sdl_event_keyup(SDL_Keysym *key, SDL_Event
{
sdl.event_count++;
if (g_grab_next_key) {
DBG("SDL: Keyboard: Grabbed 0x%08" PRIX32 " = %s / %s", event->key.keysym.sym,
CON("SDL: Keyboard: Grabbed 0x%08" PRIX32 " = %s / %s", event->key.keysym.sym,
to_string(event->key.keysym).c_str(), SDL_GetScancodeName(event->key.keysym.scancode));

g_grab_next_key = false;
Expand All @@ -142,7 +142,7 @@ static void __attribute__((noinline)) sdl_event_keyup(SDL_Keysym *key, SDL_Event

memset(&last_key_pressed, 0, sizeof(last_key_pressed));

DBG("SDL: Keyboard: Key released keycode 0x%08" PRIX32 " = %s", event->key.keysym.sym,
CON("SDL: Keyboard: Key released keycode 0x%08" PRIX32 " = %s", event->key.keysym.sym,
to_string(event->key.keysym).c_str());

key = &event->key.keysym;
Expand Down Expand Up @@ -241,7 +241,7 @@ void sdl_event(SDL_Event *event, bool &processed_mouse_motion_event)
case SDL_TEXTINPUT :
{
sdl.event_count++;
DBG("SDL: Keyboard: Text input \"%s\" in window %d", event->text.text, event->text.windowID);
CON("SDL: Keyboard: Text input \"%s\" in window %d", event->text.text, event->text.windowID);
break;
}
case SDL_MOUSEWHEEL :
Expand Down
27 changes: 17 additions & 10 deletions src/wid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5870,8 +5870,8 @@ void wid_key_down(const struct SDL_Keysym *key, int x, int y)
}
#endif
if (wid_focus && ! wid_is_hidden(wid_focus) && (wid_focus->on_key_down)) {

if ((wid_focus->on_key_down)(wid_focus, key)) {
CON("WID: key grabbed by focused wid: %s for (%d,%d)", wid_focus->name.c_str(), ascii_mouse_x, ascii_mouse_y);
sound_play("keypress");
//
// Do not raise, gets in the way of popups the callback creates.
Expand All @@ -5894,14 +5894,17 @@ void wid_key_down(const struct SDL_Keysym *key, int x, int y)
return;
}

if ((w->on_key_down)(w, key)) {
sound_play("click");

//
// Do not raise, gets in the way of popups the callback creates.
//
// CON("wid did not handle");
return;
{
CON("WID: key over by wid: %s for (%d,%d)", w->name.c_str(), ascii_mouse_x, ascii_mouse_y);
if ((w->on_key_down)(w, key)) {
CON("WID: key grabbed by wid: %s for (%d,%d)", w->name.c_str(), ascii_mouse_x, ascii_mouse_y);
sound_play("click");
//
// Do not raise, gets in the way of popups the callback creates.
//
// CON("wid did not handle");
return;
}
}

try_parent:
Expand All @@ -5914,6 +5917,7 @@ void wid_key_down(const struct SDL_Keysym *key, int x, int y)
while (w) {
if (w->on_key_down) {
if ((w->on_key_down)(w, key)) {
CON("WID: key grabbed by wid: %s for (%d,%d)", w->name.c_str(), ascii_mouse_x, ascii_mouse_y);
sound_play("click");
//
// Do not raise, gets in the way of popups the callback
Expand All @@ -5929,7 +5933,10 @@ void wid_key_down(const struct SDL_Keysym *key, int x, int y)
//
// If no-one handles it, feed it to the default handler, the console.
//
wid_receive_unhandled_input(key);
{
CON("WID: key is unhandled");
wid_receive_unhandled_input(key);
}
}

void wid_key_up(const struct SDL_Keysym *key, int x, int y)
Expand Down

0 comments on commit e04e4a0

Please sign in to comment.