605 |
return ITEM_KILL; // remove from inventory |
return ITEM_KILL; // remove from inventory |
606 |
} |
} |
607 |
void message(const string &msg, const Value &/*val*/) { |
void message(const string &msg, const Value &/*val*/) { |
608 |
if (msg == "ignite") |
if (msg == "ignite" || msg == "expl") |
609 |
SetItem(get_pos(), MakeItem("it-explosion1")); |
SetItem(get_pos(), MakeItem("it-explosion1")); |
610 |
} |
} |
611 |
bool on_laserhit(Direction) { |
bool on_laserhit(Direction) { |
639 |
} |
} |
640 |
} |
} |
641 |
|
|
642 |
void animcb() { explode(); } |
void explode () { |
643 |
void explode (); |
GridPos p = get_pos(); |
644 |
|
SendExplosionEffect(p, DYNAMITE); |
645 |
|
play_sound("explosion2"); |
646 |
|
SetItem(p, new Explosion(Explosion::MEDIUM)); |
647 |
|
} |
648 |
|
|
649 |
|
|
650 |
|
void animcb() { explode(); } |
651 |
void message(const string &msg, const Value &/*val*/) { |
void message(const string &msg, const Value &/*val*/) { |
652 |
if (msg == "ignite") |
if (msg == "ignite" || msg == "expl" || msg == "bombstone") |
653 |
change_state(BURNING); |
change_state(BURNING); |
654 |
else if (msg == "explode") |
else if (msg == "explode") // currently unused in c++ code |
655 |
explode(); |
explode(); |
656 |
} |
} |
|
|
|
657 |
bool on_laserhit(Direction) { |
bool on_laserhit(Direction) { |
658 |
change_state(BURNING); |
change_state(BURNING); |
659 |
return false; // block light |
return false; // block light |
660 |
} |
} |
|
|
|
661 |
void on_drop(Actor *) { change_state(BURNING); } |
void on_drop(Actor *) { change_state(BURNING); } |
|
|
|
662 |
bool actor_hit(Actor *) { |
bool actor_hit(Actor *) { |
663 |
// don't pick up burning dynamite |
// don't pick up burning dynamite |
664 |
return (state == IDLE); |
return (state == IDLE); |
670 |
}; |
}; |
671 |
} |
} |
672 |
|
|
673 |
void |
// ------------- |
674 |
Dynamite::explode() |
// Bomb |
675 |
{ |
// ------------- |
676 |
GridPos p = get_pos(); |
// base class for BlackBomb and WhiteBomb |
|
|
|
|
// ignite nearby objects |
|
|
SendMessage(GetItem(move(move(p, NORTH), EAST)), "ignite"); |
|
|
SendMessage(GetItem(move(move(p, NORTH), WEST)), "ignite"); |
|
|
SendMessage(GetItem(move(p, NORTH)), "ignite"); |
|
|
SendMessage(GetItem(move(move(p, SOUTH), EAST)), "ignite"); |
|
|
SendMessage(GetItem(move(move(p, SOUTH), WEST)), "ignite"); |
|
|
SendMessage(GetItem(move(p, SOUTH)), "ignite"); |
|
|
SendMessage(GetItem(move(p, EAST)), "ignite"); |
|
|
SendMessage(GetItem(move(p, WEST)), "ignite"); |
|
|
|
|
|
SendMessage(GetStone(move(p, NORTH)), "ignite"); |
|
|
SendMessage(GetStone(move(p, SOUTH)), "ignite"); |
|
|
SendMessage(GetStone(move(p, EAST)), "ignite"); |
|
|
SendMessage(GetStone(move(p, WEST)), "ignite"); |
|
|
|
|
|
play_sound("explosion2"); |
|
|
SetItem(p, new Explosion(Explosion::MEDIUM)); |
|
|
} |
|
|
|
|
|
//---------------------------------------- |
|
|
// BlackBomb. |
|
|
//---------------------------------------- |
|
|
|
|
|
/** \page it-blackbomb Black Bomb |
|
|
|
|
|
When black bombs explode, they destroy the floor tile underneath them. |
|
|
|
|
|
\image html it-blackbomb.png |
|
|
*/ |
|
677 |
|
|
678 |
namespace |
namespace { |
679 |
{ |
class Bomb : public Item { |
|
class BlackBomb : public Item { |
|
|
CLONEOBJ(BlackBomb); |
|
680 |
public: |
public: |
681 |
BlackBomb() : Item("it-blackbomb"), m_burning(false) {} |
Bomb(const char *kind) : Item(kind), m_burning(false) {} |
682 |
|
|
683 |
private: |
private: |
684 |
// Variables |
// Variables |
685 |
bool m_burning; |
bool m_burning; |
686 |
|
|
687 |
// Private methods |
// Private methods |
688 |
void explode(); |
void explode() { |
689 |
void burn(); |
GridPos p = get_pos(); |
690 |
|
SendExplosionEffect(p, BOMB); |
691 |
|
play_sound("explosion1"); |
692 |
|
SetItem(p, MakeItem("it-explosion3")); |
693 |
|
} |
694 |
|
|
695 |
|
void burn() { |
696 |
|
if (!m_burning) { |
697 |
|
m_burning = true; |
698 |
|
set_anim(burn_anim()); |
699 |
|
} |
700 |
|
} |
701 |
|
|
702 |
void animcb() { explode (); } |
void animcb() { explode (); } |
703 |
|
|
704 |
void message(const string &msg, const Value &) { |
void message(const string &msg, const Value &) { |
705 |
if (msg == "ignite") |
if (msg == "ignite" || msg == "expl") |
706 |
burn(); |
burn(); |
707 |
|
else if (msg == "bombstone") { |
708 |
|
KillItem(get_pos()); |
709 |
|
} |
710 |
else if (msg == "explode") |
else if (msg == "explode") |
711 |
explode(); |
explode(); |
712 |
} |
} |
718 |
bool actor_hit(Actor *) { return false; } |
bool actor_hit(Actor *) { return false; } |
719 |
|
|
720 |
void on_stonehit(Stone *st) { |
void on_stonehit(Stone *st) { |
721 |
if (!st->is_kind("st-wood")) { // st-wood does not blow bombs (tested with oxyd1) |
switch (enigma::GameCompatibility) { |
722 |
explode(); |
case GAMET_OXYD1: |
723 |
|
case GAMET_OXYDMAGNUM: |
724 |
|
if (!st->is_kind("st-wood")) // st-wood does not blow bombs |
725 |
|
explode(); |
726 |
|
break; |
727 |
|
default : |
728 |
|
explode(); |
729 |
|
break; |
730 |
} |
} |
731 |
} |
} |
732 |
|
|
733 |
void send_effect(GridPos p) { |
virtual const char *burn_anim() const = 0; |
|
if (Stone *stone = GetStone(p)) { |
|
|
SendMessage(stone, "ignite"); |
|
|
SendMessage(stone, "expl"); |
|
|
} |
|
|
|
|
|
if (Item *item = GetItem(p)) |
|
|
SendMessage(item, "ignite"); |
|
|
else |
|
|
SetItem(p, new Explosion(Explosion::WEAK)); |
|
|
} |
|
734 |
}; |
}; |
735 |
} |
} |
736 |
|
|
737 |
void BlackBomb::burn() |
//---------------------------------------- |
738 |
{ |
// BlackBomb. |
739 |
if (!m_burning) { |
//---------------------------------------- |
|
m_burning=true; |
|
|
set_anim("it-blackbomb-burning"); |
|
|
} |
|
|
} |
|
740 |
|
|
741 |
void BlackBomb::explode() |
/** \page it-blackbomb Black Bomb |
|
{ |
|
|
GridPos p = get_pos(); |
|
742 |
|
|
743 |
send_effect(move(p, NORTH)); |
When black bombs explode, they destroy the floor tile underneath them. |
744 |
send_effect(move(p, SOUTH)); |
|
745 |
send_effect(move(p, EAST)); |
\image html it-blackbomb.png |
746 |
send_effect(move(p, WEST)); |
*/ |
747 |
|
|
748 |
play_sound("explosion1"); |
namespace |
749 |
SetItem(p, MakeItem("it-explosion3")); |
{ |
750 |
|
class BlackBomb : public Bomb { |
751 |
|
CLONEOBJ(BlackBomb); |
752 |
|
public: |
753 |
|
BlackBomb() : Bomb("it-blackbomb") {} |
754 |
|
private: |
755 |
|
const char *burn_anim() const { return "it-blackbomb-burning"; } |
756 |
|
}; |
757 |
} |
} |
758 |
|
|
759 |
//---------------------------------------- |
//---------------------------------------- |
770 |
|
|
771 |
namespace |
namespace |
772 |
{ |
{ |
773 |
class WhiteBomb : public Item { |
class WhiteBomb : public Bomb { |
774 |
CLONEOBJ(WhiteBomb); |
CLONEOBJ(WhiteBomb); |
775 |
public: |
public: |
776 |
WhiteBomb() : Item("it-whitebomb"), m_burning(false) {} |
WhiteBomb() : Bomb("it-whitebomb") {} |
777 |
|
|
778 |
private: |
private: |
779 |
bool m_burning; |
const char *burn_anim() const { return "it-whitebomb-burning"; } |
|
|
|
|
void animcb() { explode (); } |
|
|
void explode(); |
|
|
void burn() { |
|
|
if (m_burning) { |
|
|
m_burning = true; |
|
|
set_anim("it-whitebomb-burning"); |
|
|
} |
|
|
} |
|
|
|
|
|
void message(const string &msg, const Value &) { |
|
|
if (msg == "ignite") |
|
|
burn(); |
|
|
else if (msg == "explode") |
|
|
explode(); |
|
|
} |
|
|
|
|
|
bool on_laserhit(Direction) { |
|
|
explode(); |
|
|
return false; // block light |
|
|
} |
|
|
bool actor_hit(Actor */*a*/) { return false; } |
|
|
void on_stonehit(Stone *st) { |
|
|
if (!st->is_kind("st-wood")) { // st-wood does not blow bombs (tested with oxyd1) |
|
|
explode(); |
|
|
} |
|
|
} |
|
|
|
|
|
void send_effect(GridPos p) { |
|
|
if (Stone *stone = GetStone(p)) { |
|
|
SendMessage(stone, "ignite"); |
|
|
SendMessage(stone, "expl"); |
|
|
} |
|
|
|
|
|
if (Item *item = GetItem(p)) |
|
|
SendMessage(item, "ignite"); |
|
|
else |
|
|
SetItem(p, new Explosion(Explosion::STRONG)); |
|
|
} |
|
|
void explosion (const GridPos &p); |
|
780 |
}; |
}; |
781 |
} |
} |
782 |
|
|
|
void WhiteBomb::explosion (const GridPos &p) |
|
|
{ |
|
|
SendMessage(GetStone(p), "ignite"); |
|
|
SendMessage(GetStone(p), "expl"); |
|
|
if (Item *it = GetItem(p)) |
|
|
SendMessage(it, "ignite"); |
|
|
else |
|
|
SetItem(p, MakeItem("it-explosion3")); |
|
|
} |
|
|
|
|
|
void WhiteBomb::explode() |
|
|
{ |
|
|
GridPos p = get_pos(); |
|
|
|
|
|
send_effect(move(p, NORTH)); |
|
|
send_effect(move(p, SOUTH)); |
|
|
send_effect(move(p, EAST)); |
|
|
send_effect(move(p, WEST)); |
|
|
play_sound("explosion1"); |
|
|
|
|
|
SetItem(p, MakeItem("it-explosion3")); |
|
|
} |
|
|
|
|
783 |
//---------------------------------------- |
//---------------------------------------- |
784 |
// Sensor. |
// Sensor. |
785 |
//---------------------------------------- |
//---------------------------------------- |