viewing paste [Hercules] drop multiplier on mob s | Athena

Posted on the | Last edited on
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
//===== Hercules Script =======================================================
//= Multiple droprate on mob elements from a set (default set: elements).
//===== By: ===================================================================
//= jaBote
//===== Current Version: ======================================================
//= 0.9.0 alpha
//===== Changelog =============================================================
//= 0.9.0 Initial version [jaBote]
//===== Description: ==========================================================
//= Implements multiple drop rates on mob sets that change each week.
//===== Warning: ==============================================================
//= -> addmonsterdrop/delmonsterdrop script commands don't work well with mobs
//=    that drop the same item more than once.
//= -> Doesn't work well with @reloadscript and/or server restarts (it will
//=    reassign a new set).
//===== Additional information: ===============================================
//= Configurations are located from line 22 (OnInit label).
//=============================================================================
 
-   script  element_drops   -1,{
OnInit:
    // Configurations START.
    
    // Add in mob IDs on the place of the numbers
    setarray .set_0[0], 1001, 1002, 1004, 1005, 1007; // Neutral
    setarray .set_1[0], 1001, 1002, 1004, 1005, 1007; // Water
    setarray .set_2[0], 1001, 1002, 1004, 1005, 1007; // Earth
    setarray .set_3[0], 1001, 1002, 1004, 1005, 1007; // Fire
    setarray .set_4[0], 1001, 1002, 1004, 1005, 1007; // Wind
    setarray .set_5[0], 1001, 1002, 1004, 1005, 1007; // Poison
    setarray .set_6[0], 1001, 1002, 1004, 1005, 1007; // Holy
    setarray .set_7[0], 1001, 1002, 1004, 1005, 1007; // Shadow
    setarray .set_8[0], 1001, 1002, 1004, 1005, 1007; // Ghost
    setarray .set_9[0], 1001, 1002, 1004, 1005, 1007; // Undead
    
    // Set to the name of the type of each set of $@set_X
    // BEWARE! Number of set of this array MUST be the same than the total
    // amount of sets (which is quite obvious). This is VERY IMPORTANT.
    setarray .names$[0], "Neutral", "Water", "Earth", "Fire", "Wind", 
        "Poison", "Holy", "Shadow", "Ghost", "Undead";
 
    // Set to the multiplication rate of drops (should be >= 1)
    // Examples: 100 = x1 (useless); 200 = x2; 50 = x0.5
    // Based on final drop rates after battle conf calculations.
    .multiplicator = 200;
    
    // Force change of element each week? (1 = Yes; 0 = No)
    .force_change = 1;
    
    // Text message. You can change or translate it if you want, but be careful
    // not to touch the %s since you'll screw the dynamic formatting
    .announce_format$ = "The element %s has been doubled for this week.";
    
    // Atcommand name you want to use for keeping your users informed
    .atcommand$ = "ddw";
    
    // Configurations END. Don't touch unless you know what you're doing.
    
    // Bind an atcommand
    bindatcmd .atcommand$,strnpcinfo(3)+"::OnCommand";
    
    // Get the amount of sets and use an impossible set
    .amount = getarraysize(.names$);
    .set = -1;
    
    // Let it fall through the OnMon0000: label to assign first set on server
    // startup (or reloadscript)
OnMon0000:
    .@old_set = .set;
    
    // Force the change of set if required
    if (.force_change) {
        do {
            .set = rand(.amount);
        } while (.set == .@old_set);
    } else {
        .set = rand(.amount);
    }
    
    // Restore old drops and assign new ones... if set hasn't changed
    if (.@old_set != .set) {
        freeloop(1); // We could be needing it
        
        // Restoring old sets, just if there was an old set
        if (.@old_set >= 0) {
            .@old_set_size = getarraysize(getd( ".set_" + .@old_set));
            for (.@i = 0; .@i < .@old_set_size; .@i++) {
                // This is pretty ugly, but there's no other mean to do this.
                .@mobid = getd( ".set_" + .@old_set + "[" + .@i + "]" );
                .@drop_count = getd(".mobdrop_count_[" + .@i + "]");
                for (.@j = 0; .@j <= .@drop_count; .@j++) {
                    // We only have to restore previously saved originals
                    .@drop_item = getd(".mobdrop_item_" + .@i + "[" + .@j + "]");
                    .@drop_rate = getd(".mobdrop_rate_" + .@i + "[" + .@j + "]");
 
                    // This updates monster drop back to original state
                    addmonsterdrop(.@mobid, .@drop_item, .@drop_rate);
                }
            }
        }
        
        // Applying multiplicator to new set
        for (.@i = 0; .@i < getarraysize( getd( ".set_" + .set ) ); .@i++) {
            // Get original mob drops 
            .@mobid = getd( ".set_" + .set + "[" + .@i + "]" );
            getmobdrops(.@mobid);
            setd ".mobdrop_count_[" + .@i + "]", $@MobDrop_count; // We'll need it
            
            for (.@j = 0; .@j <= $@MobDrop_count; .@j++) {
                // We only have to save originals
                setd ".mobdrop_item_" + .@i + "[" + .@j + "]", $@MobDrop_item[.@i];
                setd ".mobdrop_rate_" + .@i + "[" + .@j + "]", $@MobDrop_rate[.@i];
                
                // Calculate new rate. If it gives a value out of bounds,
                // addmonsterdrop will then take care of capping it inbounds
                // along with a warning we can safely ignore.
                .@new_rate = ($@MobDrop_rate[.@i] * .multiplicator) / 100;
                
                // This updates monster drop item if the mob already drops it
                addmonsterdrop(.@mobid, $@MobDrop_item[.@i], .@new_rate);
            }
        }
        
        freeloop(0);
    }
    
    // Announce new set for everyone and finish.
    .@announce_text$ = sprintf(.announce_format$, .names$[.set]);
    announce .@announce_text$, bc_all|bc_blue;
    end;
 
OnCommand:
    // Announce set just for yourself and finish.
    .@announce_text$ = sprintf(.announce_format$, .names$[.set]);
    announce .@announce_text$, bc_self|bc_blue;
    end;
}
 
Viewed 1355 times, submitted by jaBote.