~armagetronad-ap/armagetronad/BattleMania

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
###################################################################
######                     Battle Mania                      ######
###################################################################
######  Script by: LOVER$BOY                                 ######
######  Description: Please leave this header. Thanks!       ######
######  Contact: zodiacsohma1@gmail.com                      ######
###################################################################

//  kill the player and send the killed message
function AttackInflictPlayer(Cycle $target, Player $attacker, Attack $attack, $kill = true)
{
    if ($kill)
    {
        con("0xff77ff".$target->player." is slain by ".strtolower($attacker)."'s ".strtolower($attack->name).".");
        $target->Kill();
    }

    $killed = $target->player;

    $killed_record = getRecord($killed->log);
    $killer_record = getRecord($attacker->log);

    //  check if the killed has a bounty on their head
    bountyTrigger($killed, $attacker, $killer_record);

    if ($killed->human && isset($killed_record) && ($killed_record instanceof Record))
    {
        $killed_record->kills->bkilled++;

        $loseExp = $killed_record->experience->loseExp($attack->death_factor);
        pm($killed, "0xaaaa77You lost ".$loseExp." exp.");
        playerLoseExp($killed, $killed_record, $loseExp);
    }
}

//  inflict the exp gain depending on the attack's offensive power factor
function AttackRewardPlayer(Player $attacker, Attack $attack)
{
    $killer_record = getRecord($attacker->log);
    if ($attacker->human && isset($killer_record) && !is_null($killer_record) && ($killer_record instanceof Record))
    {
        $killer_record->kills->killed++;

        $gainExp   = $killer_record->experience->gainExp($attack->power_factor);
        $gainMoney = $killer_record->money->Gain($attack->power_factor);

        pm($attacker, "0xffcc77You attacked a player 0xRESETT[ ".$gainExp." exp, $".$gainMoney." ]");

        playerGainExp($attacker, $killer_record, $gainExp);

        $killer_record->money->amount += $gainMoney;

        $killer_record->save();
    }
}

function AttackHitPlayer(ObjectZoneHack $zone, Cycle $target, Player $attacker, Attack $attack)
{
    $killed = $target->player;

    $killed_record = getRecord($killed->log);
    $killer_record = getRecord($attacker->log);

    if ($target->alive)
    {
        //  this is to keep the young/lower level players safe from the wrath of the experienced players
        if (
            (Base::$base->game_mode == 0) &&
            $killed->human && isset($killed_record) && ($killed_record instanceof Record) &&
            $attacker->human && isset($killer_record) && !is_null($killer_record) && ($killer_record instanceof Record)
        )
        {
            if (($killed_record->experience->level <= 15) && ($killer_record->experience->level > 50)) return;
        }

        if ((Base::$base->game_mode == 2) || (Base::$base->game_mode == 3))
        {
            //  stop attacks between team mates depending on the game mode
            if ($attacker->team == $target->team)
                return;

            //  process the type of interaction in the frontier battles mode
            if (Base::$base->game_mode == 3)
            {
                if (!KillTheKingInteractAllowed($attacker, $target->player, $attack))
                    return;
            }
        }

        switch ($attack->log)
        {
            case "healing_wave":
                $r_gain = ($target->rubber / 0.2) / 10;
                $target->SetRubber($r_gain);
                break;

            case "mega_discharge":
                if ($attacker == $target->player) return;

                $target->paralyzed = true;
                $target->paralyzed_max = 10;
                $target->paralyzed_counter = 0;
                $target->paralyzed_lasttime = Base::$base->TIMER->gameTimer();

                SpawnExplosion($zone->pos, $attack->power_factor, Color::RandomColorRGB());
                $zone->Collapse();

                SpawnSpeedZone("speed", 0, $target->pos, new Coord(), 3, $target->player->color, 0, false, 0, $target->paralyzed_name);
                break;

            case "exploders":
                if ($attacker == $target->player) return;

                SpawnExplosion($zone->pos, $attack->power_factor, Color::RandomColorRGB());
                $zone->Collapse();

                AttackInflictPlayer($target, $attacker, $attack);
                AttackRewardPlayer($attacker, $attack);
                break;

            case "poison_dart":
                if ($attacker == $target->player) return;

                SpawnExplosion($zone->pos, $attack->power_factor, Color::RandomColorRGB());
                $zone->Collapse();

                $target->poisoned = true;
                $target->poisoned_lasttime = Base::$base->TIMER->gameTimer();

                con($target->player->cname." 0xRESETTbecame poisoned.");
                AttackInflictPlayer($target, $attacker, $attack, false);

                break;

            default:
                if ($attacker == $target->player) return;

                SpawnExplosion($zone->pos, $attack->power_factor, Color::RandomColorRGB());
                $zone->Collapse();

                $rubber_lost = $attack->InflictDamage($attacker);
                $new_rubber  = $target->rubber + $rubber_lost;

                if ($new_rubber >= $target->total_rubber)
                {
                    $new_rubber = $target->total_rubber;
                    AttackInflictPlayer($target, $attacker, $attack);
                }
                else
                {
                    $rem_rubber = $target->total_rubber - $new_rubber;
                    if ($rem_rubber <= 0)
                    {
                        $new_rubber = $target->total_rubber;
                        AttackInflictPlayer($target, $attacker, $attack);
                    }
                    else
                    {
                        con("0x99cccc".$target->player." got hit by ".strtolower($attacker)."'s ".strtolower($attack->name)." 0xRESETT[ -".$rubber_lost." ]");
                    }
                }

                $target->SetRubber($new_rubber);

                AttackRewardPlayer($attacker, $attack);
                break;
        }
    }
}

//  $zone is the attacking zone
function AttackHitZone(ObjectZoneHack $zone, Zone $target, Player $attacker, Attack $attack)
{
    if (Base::$base->game_mode == 1)    //  works through the zombie mode
    {
        if ($target->name == "obj_zombie")
        {
            switch ($attack->log)
            {
                case "aqua_shield":
                    SpawnExplosion($target->pos, $attack->power_factor, Color::RandomColorRGB());
                    $target->Collapse();
                    break;

                default:
                    SpawnExplosion($zone->pos, $attack->power_factor, Color::RandomColorRGB());
                    SpawnExplosion($target->pos, $attack->power_factor, Color::RandomColorRGB());

                    $target->Collapse();
                    $zone->Collapse();

                    AttackRewardPlayer($attacker, $attack);
                    break;
            }
        }
    }
    else
    {
        if (startswith($target->name, "zsf_"))
        {
            $line = substr($target->name, 4);
            $pos = 0;

            $attack_name = extractNonCharString($line, "|", $pos);
            $player_name = substr($line, $pos + 1);

            $t_attack   = getAttack($attack_name);
            $t_attacker = getPlayerByLog($player_name);

            if (isset($t_attack) && !is_null($t_attack) && $t_attack instanceof Attack && isset($t_attacker) && !is_null($t_attacker) && $t_attacker instanceof Player)
            {
                switch ($attack->log)
                {
                    case "aqua_shield":
                        if ($t_attack->log != $attack->log)
                        {
                            SpawnExplosion($target->pos, $attack->power_factor, Color::RandomColorRGB());
                            $target->Collapse();
                        }
                        break;

                    default:
                        SpawnExplosion($zone->pos, $t_attack->power_factor, Color::RandomColorRGB());
                        SpawnExplosion($target->pos, $attack->power_factor, Color::RandomColorRGB());

                        $target->Collapse();
                        $zone->Collapse();
                        break;
                }
            }
        }
    }
}