Jump to content
  • 0

Walking MVP Dropping items on Floor


Question

16 answers to this question

Recommended Posts

  • 1
Posted (edited)

I added that every item picked up from the mvp does expire and as long as you have one of the items in your inventory and are on the same map as the event mvp is, a buff is applied.

There are a few things to note though: 

  • The script is really resource heavy due to 3 loops, of which 2 run as long as the mob lives and one that runs infinite.
  • The buff will not immediately disappear once you leave the map or the item expires. It will run out with its normal expiration time.
  • Since there is no way to make rentals drop on the floor, the picked up item gets deleted and replaced by a rental version, that means it will seem as if a player picked up 2 items, even though he will have only one in the inventory, of course.
-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "morocc";
        .x = 154;
        .y = 92;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // <x, y>..
        setarray(.path, 158, 87, 162, 90, 166, 87, 161, 91, 156, 90);

        // Dropiteminfo
        .item = 6797;
        .repetition = 25; // How often the item drops per x hp percent
        .expiration_time = 15; // Expiration time in minutes

        // Buffinfo
        .skill_effect = 34; // The id of the buff skill
        .skill_effect_value = 0; // The value the skill effect shows, for example when the skill is heal. 
        .status_effetc_type = SC_BLESSING;
        .status_ticks = 240000;
        .status_value1 = 10;
        .status_value2 = 0;
        .status_value3 = 0;
        .status_value4 = 0;

        // CONFIG END //
        .move_count = getarraysize(.path) - 2;
        donpcevent("MVP_EVENT::OnBuffcheck");
		 
		.respawn_time *= 1000 * 60; 
		.expiration_time *= 60;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        .gid = $@mobid[0];

        setunitdata(.gid, UMOB_DMOTION, 0);
        setunitdata(.gid, UMOB_MODE, MD_CANMOVE | MD_NORANDOMWALK | MD_MVP | MD_KNOCKBACKIMMUNE | MD_STATUSIMMUNE | MD_TELEPORTBLOCK);

        .curr_pointer = -2; 
        donpcevent("MVP_EVENT::OnDestinationReached");

        .@next_drop_percent = 100 - .percent;
        .@last_hp_percent = 100;

        freeloop(1);
        while(unitexists(.gid)) {
            getunitdata(.gid, .@mvp_data);
            .@curr_hp_percent = .@mvp_data[UMOB_HP] * 100 / .@mvp_data[UMOB_MAXHP];

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(100);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = (.@curr_hp_percent / .percent) * .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                donpcevent("MVP_EVENT::OnDrop");
                .@next_drop_percent -= .percent;
            }

            sleep(100);
        }
        freeloop(0);

        sleep(.respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;

    OnDrop:
        for(.@i = 0; .@i < .repetition; .@i++) {
            getunitdata(.gid, .@mvp_data);
            makeitem(.item, 1, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X], .@mvp_data[UMOB_Y], 1);
            sleep(100);
        }
        end;

    OnDestinationReached:
        if(!unitexists(.gid)) end;

        if(.move_count == .curr_pointer)
            .curr_pointer = 0;
        else
            .curr_pointer += 2;

        unitwalk(.gid, .path[.curr_pointer], .path[.curr_pointer + 1], "MVP_EVENT::OnDestinationReached");
        end;

    OnBuffcheck:
        freeloop(1);
        while(true) {
            addrid(5, 0, .map$);

            .@item_count = countitem(.item);
            if(.@item_count > 0) {
                getinventorylist(getcharid(0));
                for(.@i = 0; .@i < @inventorylist_count; .@i++) {
                    if(@inventorylist_id[.@i] == .item && @inventorylist_expire[.@i] == 0) {
                        delitemidx(@inventorylist_idx[.@i], @inventorylist_amount[.@i]);
                        break;
                    }
                }

                for(.@i = 0; .@i < .@item_count; .@i++)
                    rentitem(.item, .expiration_time);
            }

            if(rentalcountitem(.item) > 0 && getstatus(.status_effetc_type) == 0) { 
                sc_start4(.status_effetc_type, .status_ticks, .status_value1, .status_value2, .status_value3, .status_value4);
                skilleffect(.skill_effect, .skill_effect_value);
            }

            detachrid;
            sleep(100);
        }
        freeloop(0);
}

 

Edited by Winterfox
  • Upvote 1
  • Like 1
  • 0
Posted
-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "prontera";
        .x = 150;
        .y = 150;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // Dropiteminfo
        .item = 7959;
        .amount = 5;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        
        .@gid = $@mobid[0];
        getunitdata(.@gid, .@mvp_data);
        .@max_hp = .@mvp_data[UMOB_MAXHP];

        freeloop(1);
        while(unitexists(.@gid)) {
            getunitdata(.@gid, .@mvp_data);
            .@curr_hp_percent = ceil((.@mvp_data[UMOB_HP] * 100 / .@max_hp) - .percent, .percent);

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(500);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = .@curr_hp_percent - .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                makeitem(.item, .amount, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X], .@mvp_data[UMOB_Y], 1);
                .@next_drop_percent -= .percent;
            }

            sleep(500);
        }
        freeloop(0);

        sleep(1000 * 60 * .respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;
}

 

  • 0
Posted (edited)
11 hours ago, Winterfox said:
-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "prontera";
        .x = 150;
        .y = 150;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // Dropiteminfo
        .item = 7959;
        .amount = 5;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        
        .@gid = $@mobid[0];
        getunitdata(.@gid, .@mvp_data);
        .@max_hp = .@mvp_data[UMOB_MAXHP];

        freeloop(1);
        while(unitexists(.@gid)) {
            getunitdata(.@gid, .@mvp_data);
            .@curr_hp_percent = ceil((.@mvp_data[UMOB_HP] * 100 / .@max_hp) - .percent, .percent);

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(500);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = .@curr_hp_percent - .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                makeitem(.item, .amount, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X], .@mvp_data[UMOB_Y], 1);
                .@next_drop_percent -= .percent;
            }

            sleep(500);
        }
        freeloop(0);

        sleep(1000 * 60 * .respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;
}

 

on my orignal trunk i got this error FIXED ERROR https://github.com/rathena/rathena/commit/2eebafb70330e37dd69a384ce0af52570b4956c2

image.thumb.png.aea9e0393734c7dfa26bb38a91ad58b5.png

so test latest  rathena is working but

monster just like normal summon 

i can request to monster using unitwalk just like on the video monster only WALKING  so monster walk only the giving coordinate

1st Respawn

        .map$ = "new_1-4";
        .x = 11;
        .y = 188;


once summoned monster will move 

1st waypoint then 2nd waypoint and so on then repeat until the monster reach last waypoint then repeat again the loop

2nd Request


can you make it drop shower?  tell say 5x5 ?

 

Edited by Bringer
  • 0
Posted
-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "morocc";
        .x = 154;
        .y = 92;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // <x, y>..
        setarray(.path, 158, 87, 162, 90, 166, 87, 161, 91, 156, 90);

        // Dropiteminfo
        .item = 7959;
        .repetition = 5; // How often the item drops per x hp percent
        .stack_size = 5; // Stacksize per drop


        // CONFIG END //
        .move_count = getarraysize(.path) - 2;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        .gid = $@mobid[0];

        .curr_pointer = -2; 
        donpcevent("MVP_EVENT::OnDestinationReached");

        .@next_drop_percent = 100 - .percent;
        .@last_hp_percent = 100;

        freeloop(1);
        while(unitexists(.gid)) {
            getunitdata(.gid, .@mvp_data);
            .@curr_hp_percent = .@mvp_data[UMOB_HP] * 100 / .@mvp_data[UMOB_MAXHP];

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(500);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = (.@curr_hp_percent / .percent) * .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                donpcevent("MVP_EVENT::OnDrop");
                .@next_drop_percent -= .percent;
            }

            sleep(500);
        }
        freeloop(0);

        sleep(1000 * 60 * .respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;

    OnDrop:
        for(.@i = 0; .@i < .repetition; .@i++) {
            getunitdata(.gid, .@mvp_data);
            makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-1, 1), .@mvp_data[UMOB_Y] + rand(-1, 1), 1);
        }

        end;

    OnDestinationReached:
        if(!unitexists(.gid)) end;

        if(.move_count == .curr_pointer)
            .curr_pointer = 0;
        else
            .curr_pointer += 2;

        unitwalk(.gid, .path[.curr_pointer], .path[.curr_pointer + 1], "MVP_EVENT::OnDestinationReached");
        end;
}

This will make the mob move and allows configuring how often an item is dropped per percent threshold and how often the item is stacked.
The movement is sadly a bit limited. You will have to set several waypoints, for the mob to follow, and the mob will stop permanently when attacked.

I didn't find a fix for the problem of stopping, so I will leave it like this. Maybe someone else can help you fix this issue.

  • MVP 2
  • 0
Posted
4 hours ago, Winterfox said:

This will make the mob move and allows configuring how often an item is dropped per percent threshold and how often the item is stacked.
The movement is sadly a bit limited. You will have to set several waypoints, for the mob to follow, and the mob will stop permanently when attacked.

I didn't find a fix for the problem of stopping, so I will leave it like this. Maybe someone else can help you fix this issue.

100% Working Thank So Much !!

my Custom mob Setup
Can Move
No Random Walk
MVP
Knockback Immune
Status Immune
4 hours ago, Winterfox said:

The movement is sadly a bit limited. You will have to set several waypoints, for the mob to follow, and the mob will stop permanently when attacked.
I didn't find a fix for the problem of stopping, so I will leave it like this. Maybe someone else can help you fix this issue.

dMotion = 0
how long it is before the monster/player can move again. Endure is dMotion = 0, obviously.

  • 0
Posted (edited)
6 hours ago, Bringer said:

100% Working Thank So Much !!

my Custom mob Setup
Can Move
No Random Walk
MVP
Knockback Immune
Status Immune

dMotion = 0
how long it is before the monster/player can move again. Endure is dMotion = 0, obviously.

I thought about it, maybe it would be good to add MD_TELEPORTBLOCK, too. Since some mobs tend to teleport.

For anyone interested, I also applied the changes mentioned above here for a final version:
 

-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "morocc";
        .x = 154;
        .y = 92;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // <x, y>..
        setarray(.path, 158, 87, 162, 90, 166, 87, 161, 91, 156, 90);

        // Dropiteminfo
        .item = 7959;
        .repetition = 5; // How often the item drops per x hp percent
        .stack_size = 5; // Stacksize per drop


        // CONFIG END //
        .move_count = getarraysize(.path) - 2;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        .gid = $@mobid[0];

        setunitdata(.gid, UMOB_DMOTION, 0);
        setunitdata(.gid, UMOB_MODE, MD_CANMOVE | MD_NORANDOMWALK | MD_MVP | MD_KNOCKBACKIMMUNE | MD_STATUSIMMUNE | MD_TELEPORTBLOCK);

        .curr_pointer = -2; 
        donpcevent("MVP_EVENT::OnDestinationReached");

        .@next_drop_percent = 100 - .percent;
        .@last_hp_percent = 100;

        freeloop(1);
        while(unitexists(.gid)) {
            getunitdata(.gid, .@mvp_data);
            .@curr_hp_percent = .@mvp_data[UMOB_HP] * 100 / .@mvp_data[UMOB_MAXHP];

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(500);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = (.@curr_hp_percent / .percent) * .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                donpcevent("MVP_EVENT::OnDrop");
                .@next_drop_percent -= .percent;
            }

            sleep(500);
        }
        freeloop(0);

        sleep(1000 * 60 * .respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;

    OnDrop:
        for(.@i = 0; .@i < .repetition; .@i++) {
            getunitdata(.gid, .@mvp_data);
            makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-1, 1), .@mvp_data[UMOB_Y] + rand(-1, 1), 1);
        }

        end;

    OnDestinationReached:
        if(!unitexists(.gid)) end;

        if(.move_count == .curr_pointer)
            .curr_pointer = 0;
        else
            .curr_pointer += 2;

        unitwalk(.gid, .path[.curr_pointer], .path[.curr_pointer + 1], "MVP_EVENT::OnDestinationReached");
        end;
}

 

Edited by Winterfox
  • Upvote 1
  • MVP 1
  • 0
Posted
3 hours ago, Winterfox said:

I thought about it, maybe it would be good to add MD_TELEPORTBLOCK, too. Since some mobs tend to teleport.

For anyone interested, I also applied the changes mentioned above here for a final version:
 

-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "morocc";
        .x = 154;
        .y = 92;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // <x, y>..
        setarray(.path, 158, 87, 162, 90, 166, 87, 161, 91, 156, 90);

        // Dropiteminfo
        .item = 7959;
        .repetition = 5; // How often the item drops per x hp percent
        .stack_size = 5; // Stacksize per drop


        // CONFIG END //
        .move_count = getarraysize(.path) - 2;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        .gid = $@mobid[0];

        setunitdata(.gid, UMOB_DMOTION, 0);
        setunitdata(.gid, UMOB_MODE, MD_CANMOVE | MD_NORANDOMWALK | MD_MVP | MD_KNOCKBACKIMMUNE | MD_STATUSIMMUNE | MD_TELEPORTBLOCK);

        .curr_pointer = -2; 
        donpcevent("MVP_EVENT::OnDestinationReached");

        .@next_drop_percent = 100 - .percent;
        .@last_hp_percent = 100;

        freeloop(1);
        while(unitexists(.gid)) {
            getunitdata(.gid, .@mvp_data);
            .@curr_hp_percent = .@mvp_data[UMOB_HP] * 100 / .@mvp_data[UMOB_MAXHP];

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(500);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = (.@curr_hp_percent / .percent) * .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                donpcevent("MVP_EVENT::OnDrop");
                .@next_drop_percent -= .percent;
            }

            sleep(500);
        }
        freeloop(0);

        sleep(1000 * 60 * .respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;

    OnDrop:
        for(.@i = 0; .@i < .repetition; .@i++) {
            getunitdata(.gid, .@mvp_data);
            makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-1, 1), .@mvp_data[UMOB_Y] + rand(-1, 1), 1);
        }

        end;

    OnDestinationReached:
        if(!unitexists(.gid)) end;

        if(.move_count == .curr_pointer)
            .curr_pointer = 0;
        else
            .curr_pointer += 2;

        unitwalk(.gid, .path[.curr_pointer], .path[.curr_pointer + 1], "MVP_EVENT::OnDestinationReached");
        end;
}

 

im curious about this script and tried it but ive got this error

1.png

  • 0
Posted
12 minutes ago, GM Winter said:

im curious about this script and tried it but ive got this error

1.png

You use an outdated version of rathena.
You need to change:
 

 makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-1, 1), .@mvp_data[UMOB_Y] + rand(-1, 1), 1);

to
 

 makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-1, 1), .@mvp_data[UMOB_Y] + rand(-1, 1));

 

  • Upvote 1
  • 0
Posted
5 minutes ago, Winterfox said:

You use an outdated version of rathena.
You need to change:
 

 makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-1, 1), .@mvp_data[UMOB_Y] + rand(-1, 1), 1);

to
 

 makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-1, 1), .@mvp_data[UMOB_Y] + rand(-1, 1));

 

thank you sir 

  • 0
Posted
3 hours ago, GM Winter said:

i think this script also can be abused by letting the mvp heal it self then attack again to gain the drop items then wait again to full hp recovery

It depends on how it is done.

I actually build a check so that the mob drops the items again after a heal.

Otherwise, it would only drop them once every x percent and even if the hp were raised again would only drop the items at the percentage it would have dropped them without the heal.

  • 0
Posted
6 hours ago, Winterfox said:

I added that every item picked up from the mvp does expire and as long as you have one of the items in your inventory and are on the same map as the event mvp is, a buff is applied.

There are a few things to note though: 

  • The script is really resource heavy due to 3 loops, of which 2 run as long as the mob lives and one that runs infinite.
  • The buff will not immediately disappear once you leave the map or the item expires. It will run out with its normal expiration time.
  • Since there is no way to make rentals drop on the floor, the picked up item gets deleted and replaced by a rental version, that means it will seem as if a player picked up 2 items, even though he will have only one in the inventory, of course.
-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "morocc";
        .x = 154;
        .y = 92;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // <x, y>..
        setarray(.path, 158, 87, 162, 90, 166, 87, 161, 91, 156, 90);

        // Dropiteminfo
        .item = 6797;
        .repetition = 25; // How often the item drops per x hp percent
        .expiration_time = 15; // Expiration time in minutes

        // Buffinfo
        .skill_effect = 34; // The id of the buff skill
        .skill_effect_value = 0; // The value the skill effect shows, for example when the skill is heal. 
        .status_effetc_type = SC_BLESSING;
        .status_ticks = 240000;
        .status_value1 = 10;
        .status_value2 = 0;
        .status_value3 = 0;
        .status_value4 = 0;

        // CONFIG END //
        .move_count = getarraysize(.path) - 2;
        donpcevent("MVP_EVENT::OnBuffcheck");
		 
		.respawn_time *= 1000 * 60; 
		.expiration_time *= 60;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        .gid = $@mobid[0];

        setunitdata(.gid, UMOB_DMOTION, 0);
        setunitdata(.gid, UMOB_MODE, MD_CANMOVE | MD_NORANDOMWALK | MD_MVP | MD_KNOCKBACKIMMUNE | MD_STATUSIMMUNE | MD_TELEPORTBLOCK);

        .curr_pointer = -2; 
        donpcevent("MVP_EVENT::OnDestinationReached");

        .@next_drop_percent = 100 - .percent;
        .@last_hp_percent = 100;

        freeloop(1);
        while(unitexists(.gid)) {
            getunitdata(.gid, .@mvp_data);
            .@curr_hp_percent = .@mvp_data[UMOB_HP] * 100 / .@mvp_data[UMOB_MAXHP];

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(100);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = (.@curr_hp_percent / .percent) * .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                donpcevent("MVP_EVENT::OnDrop");
                .@next_drop_percent -= .percent;
            }

            sleep(100);
        }
        freeloop(0);

        sleep(.respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;

    OnDrop:
        for(.@i = 0; .@i < .repetition; .@i++) {
            getunitdata(.gid, .@mvp_data);
            makeitem(.item, 1, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X], .@mvp_data[UMOB_Y], 1);
            sleep(100);
        }
        end;

    OnDestinationReached:
        if(!unitexists(.gid)) end;

        if(.move_count == .curr_pointer)
            .curr_pointer = 0;
        else
            .curr_pointer += 2;

        unitwalk(.gid, .path[.curr_pointer], .path[.curr_pointer + 1], "MVP_EVENT::OnDestinationReached");
        end;

    OnBuffcheck:
        freeloop(1);
        while(true) {
            addrid(5, 0, .map$);

            .@item_count = countitem(.item);
            if(.@item_count > 0) {
                getinventorylist(getcharid(0));
                for(.@i = 0; .@i < @inventorylist_count; .@i++) {
                    if(@inventorylist_id[.@i] == .item && @inventorylist_expire[.@i] == 0) {
                        delitemidx(@inventorylist_idx[.@i], @inventorylist_amount[.@i]);
                        break;
                    }
                }

                for(.@i = 0; .@i < .@item_count; .@i++)
                    rentitem(.item, .expiration_time);
            }

            if(rentalcountitem(.item) > 0 && getstatus(.status_effetc_type) == 0) { 
                sc_start4(.status_effetc_type, .status_ticks, .status_value1, .status_value2, .status_value3, .status_value4);
                skilleffect(.skill_effect, .skill_effect_value);
            }

            detachrid;
            sleep(100);
        }
        freeloop(0);
}

 

thank you sir ❤️

  • 0
Posted
7 hours ago, Winterfox said:

I added that every item picked up from the mvp does expire and as long as you have one of the items in your inventory and are on the same map as the event mvp is, a buff is applied.

There are a few things to note though: 

  • The script is really resource heavy due to 3 loops, of which 2 run as long as the mob lives and one that runs infinite.
  • The buff will not immediately disappear once you leave the map or the item expires. It will run out with its normal expiration time.
  • Since there is no way to make rentals drop on the floor, the picked up item gets deleted and replaced by a rental version, that means it will seem as if a player picked up 2 items, even though he will have only one in the inventory, of course.
-	script	MVP_EVENT	FAKE_NPC,{
    OnInit:
        // Mobinfo
        .mob = 1159;
        .map$ = "morocc";
        .x = 154;
        .y = 92;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 10; // Item drop every x hp percent.

        // <x, y>..
        setarray(.path, 158, 87, 162, 90, 166, 87, 161, 91, 156, 90);

        // Dropiteminfo
        .item = 6797;
        .repetition = 25; // How often the item drops per x hp percent
        .expiration_time = 15; // Expiration time in minutes

        // Buffinfo
        .skill_effect = 34; // The id of the buff skill
        .skill_effect_value = 0; // The value the skill effect shows, for example when the skill is heal. 
        .status_effetc_type = SC_BLESSING;
        .status_ticks = 240000;
        .status_value1 = 10;
        .status_value2 = 0;
        .status_value3 = 0;
        .status_value4 = 0;

        // CONFIG END //
        .move_count = getarraysize(.path) - 2;
        donpcevent("MVP_EVENT::OnBuffcheck");
		 
		.respawn_time *= 1000 * 60; 
		.expiration_time *= 60;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        .gid = $@mobid[0];

        setunitdata(.gid, UMOB_DMOTION, 0);
        setunitdata(.gid, UMOB_MODE, MD_CANMOVE | MD_NORANDOMWALK | MD_MVP | MD_KNOCKBACKIMMUNE | MD_STATUSIMMUNE | MD_TELEPORTBLOCK);

        .curr_pointer = -2; 
        donpcevent("MVP_EVENT::OnDestinationReached");

        .@next_drop_percent = 100 - .percent;
        .@last_hp_percent = 100;

        freeloop(1);
        while(unitexists(.gid)) {
            getunitdata(.gid, .@mvp_data);
            .@curr_hp_percent = .@mvp_data[UMOB_HP] * 100 / .@mvp_data[UMOB_MAXHP];

            if(.@curr_hp_percent == .@last_hp_percent) {
                sleep(100);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = (.@curr_hp_percent / .percent) * .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                donpcevent("MVP_EVENT::OnDrop");
                .@next_drop_percent -= .percent;
            }

            sleep(100);
        }
        freeloop(0);

        sleep(.respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;

    OnDrop:
        for(.@i = 0; .@i < .repetition; .@i++) {
            getunitdata(.gid, .@mvp_data);
            makeitem(.item, 1, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X], .@mvp_data[UMOB_Y], 1);
            sleep(100);
        }
        end;

    OnDestinationReached:
        if(!unitexists(.gid)) end;

        if(.move_count == .curr_pointer)
            .curr_pointer = 0;
        else
            .curr_pointer += 2;

        unitwalk(.gid, .path[.curr_pointer], .path[.curr_pointer + 1], "MVP_EVENT::OnDestinationReached");
        end;

    OnBuffcheck:
        freeloop(1);
        while(true) {
            addrid(5, 0, .map$);

            .@item_count = countitem(.item);
            if(.@item_count > 0) {
                getinventorylist(getcharid(0));
                for(.@i = 0; .@i < @inventorylist_count; .@i++) {
                    if(@inventorylist_id[.@i] == .item && @inventorylist_expire[.@i] == 0) {
                        delitemidx(@inventorylist_idx[.@i], @inventorylist_amount[.@i]);
                        break;
                    }
                }

                for(.@i = 0; .@i < .@item_count; .@i++)
                    rentitem(.item, .expiration_time);
            }

            if(rentalcountitem(.item) > 0 && getstatus(.status_effetc_type) == 0) { 
                sc_start4(.status_effetc_type, .status_ticks, .status_value1, .status_value2, .status_value3, .status_value4);
                skilleffect(.skill_effect, .skill_effect_value);
            }

            detachrid;
            sleep(100);
        }
        freeloop(0);
}

 

 

1.png

  • 0
Posted (edited)
Spoiler

-    script    MVP_EVENT    FAKE_NPC,{
    OnInit:
        // Mobinfo
    bindatcmd "walk",strnpcinfo(3)+"::OnSpawn",99,99;
        .mob = 20581;
        .map$ = "morocc";
        .x = 154;
        .y = 92;
        .respawn_time = 15; // Respawntime in minutes
        .percent = 1; // Item drop every x hp percent.

        // <x, y>..
        setarray(.path, 158, 87, 162, 90, 166, 87, 161, 91, 156, 90);

        // Dropiteminfo
        .item = 7227;
        .repetition = 30; // How often the item drops per x hp percent
        .expiration_time = 1; // Expiration time in minutes
        .stack_size = 1; // Stacksize per drop

        // Buffinfo
        .skill_effect = 34; // The id of the buff skill
        .skill_effect_value = 0; // The value the skill effect shows, for example when the skill is heal. 
        .status_effetc_type = SC_BLESSING;
        .status_ticks = 240000;
        .status_value1 = 10;
        .status_value2 = 0;
        .status_value3 = 0;
        .status_value4 = 0;                   
        // CONFIG END //
        .move_count = getarraysize(.path) - 2;
    donpcevent("MVP_EVENT::OnBuffcheck");

    .respawn_time *= 1000 * 60; 
    .expiration_time *= 60;

    OnSpawn:
        monster(.map$, .x, .y, strmobinfo(1, .mob), .mob, 1);
        .gid = $@mobid[0];

        .curr_pointer = -2; 
        donpcevent("MVP_EVENT::OnDestinationReached");

        .@next_drop_percent = 100 - .percent;
        .@last_hp_percent = 100;

        freeloop(1);
        while(unitexists(.gid)) {
            getunitdata(.gid, .@mvp_data);
            .@curr_hp_percent = .@mvp_data[UMOB_HP] * 100 / .@mvp_data[UMOB_MAXHP];

                if(.@curr_hp_percent == .@last_hp_percent) {
                    sleep(500);
                continue;
            }

            if(.@curr_hp_percent > .@last_hp_percent)
                .@next_drop_percent = (.@curr_hp_percent / .percent) * .percent;

            .@last_hp_percent = .@curr_hp_percent;

            if(.@next_drop_percent >= .@curr_hp_percent) {
                donpcevent("MVP_EVENT::OnDrop");
                .@next_drop_percent -= .percent;
            }

            sleep(500);
        }
        freeloop(0);

        sleep(.respawn_time);
        donpcevent("MVP_EVENT::OnSpawn");
        end;

    OnDrop:
        for(.@i = 0; .@i < .repetition; .@i++) {
        getunitdata(.gid, .@mvp_data);
        //makeitem(.item, 1, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X], .@mvp_data[UMOB_Y], 1);
        makeitem(.item, .stack_size, mapid2name(.@mvp_data[UMOB_MAPID]), .@mvp_data[UMOB_X] + rand(-8, 8), .@mvp_data[UMOB_Y] + rand(-8, 8), 8);
    }

        end;

    OnDestinationReached:
        if(!unitexists(.gid)) end;

        if(.move_count == .curr_pointer)
            .curr_pointer = 0;
        else
            .curr_pointer += 2;

        unitwalk(.gid, .path[.curr_pointer], .path[.curr_pointer + 1], "MVP_EVENT::OnDestinationReached");
        end;

    OnBuffcheck:
        freeloop(1);
        while(true) {
            addrid(5, 0, .map$);

            .@item_count = countitem(.item);
            if(.@item_count > 0) {
                getinventorylist(getcharid(0));
                for(.@i = 0; .@i < @inventorylist_count; .@i++) {
                    if(@inventorylist_id[.@i] == .item && @inventorylist_expire[.@i] == 0) {
                        delitemidx(@inventorylist_idx[.@i], @inventorylist_amount[.@i]);
                        break;
                    }
                }

                for(.@i = 0; .@i < .@item_count; .@i++)
                    rentitem(.item, .expiration_time);
            }

            if(rentalcountitem(.item) > 0 && getstatus(.status_effetc_type) == 0) { 
                sc_start4(.status_effetc_type, .status_ticks, .status_value1, .status_value2, .status_value3, .status_value4);
                skilleffect(.skill_effect, .skill_effect_value);
            }

            detachrid;
            sleep(100);
        }
        freeloop(0);
}

Here my Script @Winterfox

the buffs fuction is Working 

how about i have different drops let say

Red Potion,Yellow Potion,OrangePotion,BluePotion,GreenPotion

will it give me different buffs according to item i picked up, is this possible?

and buffs can be stack let say pickup RedPotion Buffs is STR + 10, then i pick again another red potion it will add up and will make it now 20str, till it reach maximum level 10

Edited by Bringer

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...