summaryrefslogtreecommitdiff
path: root/npc/functions/mobpoint.txt
blob: f7d6b7880d286d1fe091ab430064481c0ec9c4da (plain) (blame)
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
// TMW2 Scripts
// Author: Crazyfefe
//         Jesusalva
// Desc:   Mob Points for Aidan & Ishi. You will gain MONSTER-LEVEL mob points.

// fix_mobkill(mobID) → Manual fix for scripted mobs
function	script	fix_mobkill	{
    killedrid=getarg(0);
    doevent "#mobptsys::OnNPCKillEvent";
    return;
}

function	script	mobpoint	{
    if (!MPQUEST)
        return;
    if (!killedrid) // A bug!
        return;

    .@moblv=strmobinfo(3,killedrid);
    // You get MobLv + 20% as MobPoints.
    // So a level 100 monster gives you 120 MobPt. Slimes gives -20% mobpt.
    if (compare("slime", strtolower(strmobinfo(1, killedrid)))) {
        if (!(compare("mother", strtolower(strmobinfo(1, killedrid)))))
            .@addval=.@moblv*8/10;
        else
            .@addval=.@moblv;
    } else {
        .@addval=.@moblv*12/10;
    }

    // Penalty/Bonus
    .@base=(.@moblv-BaseLevel);
    // NOTE: MAX_LEVEL is the compile time instruction, NOT the exp table one
    // They currently coincide, but if that's ever modified, this won't work
    .@fix1=1000 * BaseLevel / MAX_LEVEL; // 1000 at max
    .@fix2=1000 * readparam(bInt) / getbattleflag("max_parameter"); // 1000 at max
    .@intf=(.@fix2 - .@fix1); // Ranges from -995 to "+994"
    // fix1{5,1000} fix2{6,1000} intf{-995,1,994}

    // Rebirth exploit correction
    if (.@base > 20 && REBIRTH && BaseLevel < 16)
        .@base = 20;

    if (BaseLevel < .@moblv) {
        // Target is stronger, +3% per monster level, capped at +75%
        .@addval = .@addval * limit(100, 100+(.@base*3), 175) / 100;
    } else if (BaseLevel > .@moblv) {
        // Target is weaker, -1% per monster level, capped at -50%
        .@addval = .@addval * limit(50, 101+.@base, 100) / 100;
    }

    // Your intelligence correction, makes it vary up to 50%
    .@intf = (.@intf + 2000) / 2;
    .@addval = .@addval * .@intf / 990; // use 990 instead of 1000 (pro ludio)

    // Sanitization (don't allow negative mobpoint gain)
    .@addval=max(0, .@addval);

    // Events (+10% Mob Points)
    if ($EVENT$ == "Rebirth" || $EVENT$ == "Siege")
        .@addval = .@addval * 11 / 10;

    // Hardcore Server special rules (3× Monster Points)
    if ($HARDCORE)
        .@addval *= 3;

    // Grant you the Monster Points
    Mobpt = Mobpt + .@addval;
    return;

}

-	script	#mobptsys	NPC_HIDDEN,{
    end;

OnUnlock:
    if (checkpcblock() & PCBLOCK_ATTACK)
        setpcblock(PCBLOCK_HARD, false);
    end;

OnNPCKillEvent:
    $MONSTERS_KILLED+=1;
    MONSTERS_KILLED+=1;

    // Remove undue Job exp
    // The check is probably correct, but setparam is not working =/
    /*
    */
    if (strmobinfo(7, killedrid) == 0 && readparam(JobExp) > 0) {
        //setparam(JobExp, readparam(JobExp)-1);
        JobExp-=1;
    }

    // Sanitize some bug...
    if (isequipped(ExplosiveArrow)) {
        .@wpn = getequipid(EQI_HAND_R);
        if (getiteminfo(.@wpn, ITEMINFO_SUBTYPE) != W_BOW) {
            unequipbyid(ExplosiveArrow);
            if (@hacktol)
                end; // Will not count for anything else
            @hacktol = true;
        }
    }

    // killedrid was not set, so we skip
    if (!killedrid)
        end;

    // call functions
    callfunc "mobpoint";
    callfunc "mobhunter";
    callfunc "SQuest_Hasan";
    callfunc "SaggyMobCount";
    callfunc "dausen_mobtutorial";
    callfunc "Guardhouse_RandQuestCheck";
    callfunc "AuroraMobkill";
    callfunc "ChocolateDay";
    callfunc "CoffeeDay";
    callfunc "FSFDay";
    callfunc "CraftmasterDay";
    callfunc "CadisQuestCheck";
    callfunc "GeminiKill";
    callfunc "SK_drops";
    callfunc "BonusEXP";

    // Other updates
    $@MK_TRIGGERED=true;
    if (strmobinfo(3,killedrid) >= 100)
        @bloodykill[killedrid] += 1;
    // Unset killedrid. This affects multiple calls of this function
    // But it is in overall more reliable imao
    killedrid=0;
    end;

// When you kill a player, some special care is needed
// Only a few maps will give you experience for PK: Tulimshar's Guards Arena,
// Frostia Imperial PVP Arena, Call Of Dusty, Arena Quirino Voraz.
OnPCKillEvent:
    // call functions
    callfunc "HUB_PvP";
    end;

}