Greetings,
Many times when i see some monster scripts like where you kill a MVP and get extra loots from. It is many times implemented as treasure chest monster that get summoned after MVP is killed and will trigger OnMobDie label. There it checks if he was the actual killer and is able to receive rewards.
If there are many players nearby trying to kill same MVP and spamming AOE skills. This treasure chest's event label will get triggered on the first one who got the kill. So players keep spamming AOE, and the actual player who has the right to claim the reward keeps spamming AOE or wait until all players leave or get a lucky hit on it.
How I implement this kind of event is by calling an NPC to that location and only the player who has access to the rewards will have a dialog open etc.
So, my question is (I'm interested) how would you proceed in this kind of situation? Would it be with a Treasure Monster or Treasure NPC or Not summoning a visual treasure and just open dialog on MVP kill?
Here is sample with monster unit:
- script Sample -1,{
OnInit:
monster "prontera",0,0,"--ja--",1093,1,strnpcinfo(0)+"::OnMobDie";
end;
OnMobDie:
getmapxy(.@map$,.@x,.@y,0);
monster .@map$,rand(.@x,.@x-3),rand(.@y-3,.@y),"--ja--",1324,1,strnpcinfo(0)+"::OnBoxKill";
end;
OnBoxKill:
// If checks your able to receive rewards
//...
// Else summon Treasure Chest again...
getmapxy(.@map$,.@x,.@y,0);
monster .@map$,rand(.@x,.@x-3),rand(.@y-3,.@y),"--ja--",1324,1,strnpcinfo(0)+"::OnBoxKill";
end;
}
Here is sample with npc unit:
- script Sample -1,{
OnInit:
monster "prontera",0,0,"--ja--",1093,1,strnpcinfo(0)+"::OnMobDie";
end;
OnMobDie:
// ... save players access data ...
// Get map coordinates for the Treasure Chest NPC
getmapxy(.event_map$, .event_x, .event_y);
.@index = 0; // Select what treasure npc to open
.@npc$ = "Treasure Chest#tc_"+ .@index;
donpcevent .@npc$ +"::OnEnable";
end;
}
// Treasure Chest NPC index = 0
prontera,0,0,5 script Treasure Chest#tc_0 1324,{
// If check player is able to receive rewards
//... dialogs ...
// If player received rewards, remove treasure NPC after close
close2;
.@index = 0;
.@npc$ = "Treasure Chest#tc_"+ .@index;
donpcevent .@npc$ +"::OnDisable";
end;
OnInit:
.@name$ = strnpcinfo(0);
getmapxy(.map$, .x, .y, UNITTYPE_NPC); // Save default position
disablenpc .@name$;
end;
OnDisable:
.@id = getnpcid(0);
.@name$ = strnpcinfo(0);
unitwarp( .@id, .map$, .x, .y ); // Return to default position
disablenpc( .@name$ );
end;
OnEnable:
.@id = getnpcid(0);
.@name$ = strnpcinfo(0);
// get coordinates from event npc
.@npc$ = "Sample";
.@map$ = getvariableofnpc(.event_map$, .@npc$);
.@x = getvariableofnpc(.event_x, .@npc$);
.@y = getvariableofnpc(.event_y, .@npc$);
enablenpc( .@name$ );
unitwarp( .@id, .@map$, .@x, .@y ); // Move to new position
end;
}
// You can also duplicate more treasure chests, if you need more
alberta,0,0,5 duplicate(Treasure Chest#tc_0) Treasure Chest#tc_1 1324
I would love to hear your thoughts and ideas.
Thanks ?