even more cosmetix
[k8-i-v-a-n.git] / src / game / items / hellsdevice.cpp
blob95a690128f2afca05b2a64b89d7f589c9f721d02
1 #ifdef HEADER_PHASE
2 ITEM(hellsdevice, item) {
3 public:
4 virtual truth IsAppliable (ccharacter *User) const override;
5 virtual truth Apply (character *User) override;
6 //virtual truth IsZappable (ccharacter *User) const override;
7 //virtual truth Zap (character *User, v2 curpos, int Direction) override;
9 private:
10 void explode (character *User, v2 pos);
14 #else
16 truth hellsdevice::IsAppliable (ccharacter *User) const { return true; }
17 //truth hellsdevice::IsZappable (ccharacter *User) const { return true; }
20 truth hellsdevice::Apply (character *User) {
21 // cannot be broken
22 //if (IsBroken()) { ADD_MESSAGE("%s is totally broken.", CHAR_NAME(DEFINITE)); return false; }
24 v2 FireBallPos = ERROR_V2;
25 beamdata Beam(
26 User,
27 CONST_S("killed by the spells of ")+User->GetName(INDEFINITE),
28 YOURSELF,
31 ADD_MESSAGE("This could be loud...");
33 v2 Input = game::PositionQuestion(CONST_S("Where do you wish to send the fireball? [direction keys move cursor, space accepts]"), User->GetPos(), &game::TeleportHandler, 0, false);
35 if (Input == ERROR_V2) {
36 // esc pressed
37 ADD_MESSAGE("You choose not to summon a fireball... phew!");
38 return false;
41 lsquare *Square = GetNearLSquare(Input);
44 if ((Input-User->GetPos()).GetLengthSquare() <= User->GetTeleportRangeSquare()) {
45 if (!User->IsFreeForMe(Square) || (Input == User->GetPos())) {
46 //User->EditExperience(INTELLIGENCE, 100, 1 << 10);
47 FireBallPos = Input;
48 } else {
49 ADD_MESSAGE("The spell must target creatures, %s.", game::Insult());
50 //FireBallPos = User->GetPos(); // Better not. It's a little bit wtf for the player to understand
51 return;
53 } else {
54 ADD_MESSAGE("You cannot concentrate yourself enough to send a fireball that far.");
55 //FireBallPos = ERROR_V2;
56 //if (User->GetNearestEnemy()) FireBallPos = User->GetNearestEnemy()->GetPos(); else
57 if (!(RAND()%3)) {
58 ADD_MESSAGE("Something very wrong happens with the spell.");
59 FireBallPos = User->GetPos();
60 Square = GetNearLSquare(User->GetPos());
61 } else {
62 return;
67 FireBallPos = Input;
69 if (FireBallPos == ERROR_V2) {
70 //Square = GetNearLSquare(GetLevel()->GetRandomSquare(User));
71 return false;
74 if (Square->GetPos() == User->GetPos()) ADD_MESSAGE("The scroll explodes in your face!");
76 User->EditExperience(INTELLIGENCE, 150, 1<<12);
77 //Square->DrawParticles(RED);
78 //!Square->FireBall(Beam);
79 //GetLevel()->Explosion(User, Beam.DeathMsg, FireBallPos, /*75+RAND()%25-RAND()%25*/400+RAND()%100);
80 explode(User, FireBallPos);
82 return true;
87 truth hellsdevice::Zap (character *User, v2 curpos, int Direction) {
88 User->EditExperience(PERCEPTION, 150, 1<<10);
90 beamdata Beam (
91 User,
92 CONST_S("killed by ")+GetName(INDEFINITE)+" zapped @bk",
93 User->GetPos(),
94 YELLOW, // beam color
95 BEAM_FIRE_BALL,
96 Direction,
97 400,
98 0//GetSpecialParameters()
101 (GetLevel()->*level::GetBeam(GetBeamStyle()))(Beam);
103 return true;
108 void hellsdevice::explode (character *User, v2 pos) {
109 festring dmsg = CONST_S("killed by the spells of ")+User->GetName(INDEFINITE);
110 lsquare *Square = GetNearLSquare(pos);
111 if (Square) {
112 Square->DrawParticles(RED);
113 GetLevel()->Explosion(User, dmsg, pos, /*75+RAND()%25-RAND()%25*/400+RAND()%100);
115 for (int f = 0; f < 8; ++f) {
116 if (RAND()%100 > 30) {
117 v2 dest = pos+game::GetMoveVector(f);
118 Square = GetNearLSquare(dest);
119 if (Square) {
120 Square->DrawParticles(RED);
121 GetLevel()->Explosion(User, dmsg, dest, /*75+RAND()%25-RAND()%25*/400+RAND()%100);
128 #endif