Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== rAthena Script =======================================
- //= Guard - Unit Controller
- //===== By: ==================================================
- //= Sehrentos
- //===== Current Version: =====================================
- //= 1.0
- //===== Compatible With: =====================================
- //= rAthena Project
- //===== Description: =========================================
- //= Summon a Guard that last for X time and help player.
- //===== Additional Comments: =================================
- //= 1.0 Initial script.
- //= Custom mob add '/db/import/mob_db.txt':
- // 4000,SNIPER,Sniper,Sniper,175,100000,0,0,0,9,900,900,40,40,119,119,119,119,199,119,10,12,1,7,20,669,150,900,500,300,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- //= Custom mob add '/db/import/mob_skill_db.txt':
- // 4000,Sniper@NPC_ALLHEAL,idle,687,1,3000,10000,30000,yes,self,myhpltmaxrate,50,,,,,,,
- // 4000,Sniper@NPC_ALLHEAL,walk,687,1,3000,10000,30000,yes,self,myhpltmaxrate,50,,,,,,,
- // 4000,Sniper@AC_CONCENTRATION,attack,45,10,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@HT_FREEZINGTRAP,attack,121,5,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@AC_CHARGEARROW,attack,148,1,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@AC_DOUBLE,attack,46,10,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@HT_BLITZBEAT,attack,129,5,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@SN_FALCONASSAULT,attack,381,5,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@SN_FALCONASSAULT,chase,381,5,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@HT_BLASTMINE,attack,122,5,2500,0,5000,yes,target,always,0,,,,,,,
- // 4000,Sniper@AC_CHARGEARROW,attack,148,1,2500,0,5000,yes,target,always,0,,,,,,,
- //= Custom mob add '/db/import/mob_avail.txt':
- // 4000,4012,1,7,3,1702,0,72,73,0,16,0 // SNIPER
- //============================================================
- prontera,155,164,4 script Guard#prt_01 95,3,3,{
- // NPC area of effect set to 3 x 3 cell range
- mes "[ " + strnpcinfo(1) + " ]";
- if ( unitexists(@GID_Guardian) ) {
- getunitdata(@GID_Guardian, .@udata);
- for (.@i = 0; .@i < getarraysize(.@udata); .@i++ ) {
- mes .UMOB_INDEX$[.@i] + " = " + .@udata[.@i];
- }
- .@npc_time_tick = getnpctimer(0); // 0
- .@npc_time_ticks = getnpctimer(1); // 1-6
- .@npc_time_count = getnpctimer(2); // 6
- .@menu_gm$ = ":";
- if ( getgmlevel() >= 50 )
- .@menu_gm$ = "Edit my Guard:";
- mes "Timer: " + .@npc_time_tick + " / " + .@npc_time_ticks + " / " + .@npc_time_count;
- mes "Active hours: ^777777" + (.@npc_time_tick / 3600000) + "^000000"; // Hours
- mes "Active minutes: ^777777" + " : " + (.@npc_time_tick / 60000) + "^000000"; // Minutes
- mes "Active seconds: ^777777" + " : " + (.@npc_time_tick / 1000) + "^000000"; // Seconds
- // Has active guard
- switch ( select( .@menu_gm$ + "Remove my Guard:Leave") ) {
- case 1: callsub S_EditGuard; break;
- case 2: callsub S_RemoveGuard; break;
- default: break;
- }
- } else {
- // Do NOT have a guard
- mes "I will protect the city from any hostile creatures!";
- if ( select("I need guard:Leave") == 1 ) {
- callsub S_RentGuard;
- }
- }
- mes "Good bye!";
- close;
- S_RemoveGuard:
- if ( unitexists(@GID_Guardian) ) {
- unitkill @GID_Guardian;
- }
- return;
- S_EditGuard:
- if ( unitexists(@GID_Guardian) && getgmlevel() >= 50 ) {
- next;
- mes "[ " + strnpcinfo(1) + " ]";
- mes "Edit guard attributes.";
- .@select = select(.UMOB_MENU$) - 1;
- mes "Write new ( " + .UMOB_INDEX$[.@select] + " ) value.";
- input .@val, 0, 1000000000;
- setunitdata @GID_Guardian, .@select, .@val;
- getunitdata(@GID_Guardian, .@udata);
- mes "New unit data is:" + .@udata[.@select];
- }
- return;
- S_RentGuard:
- // If unit exists
- if ( !unitexists(@GID_Guardian) ) {
- // Get player location
- getmapxy(.@map$, .@x, .@y, 0);
- // Summon monster
- monster "prontera", rand(.@x, .@x-3), rand(.@y-3, .@y), .MOB_NAME$, .MOB_ID, 1, strnpcinfo(1) + "::OnUnitDeath";
- // Get last summon GID
- @GID_Guardian = $@mobid[0];
- // Change unit data
- setunitdata @GID_Guardian, UMOB_MAXHP, 100000; // Max HP
- setunitdata @GID_Guardian, UMOB_MASTERAID, getcharid(3); // Master AID
- setunitdata @GID_Guardian, UMOB_SPEED, 100; // Speed
- setunitdata @GID_Guardian, UMOB_CRIT, 450; // Crit rate (1000=100%)
- setunitdata @GID_Guardian, UMOB_HIT, 250; // Hit rate (1000=100%)
- setunitname @GID_Guardian, getmonsterinfo(.MOB_ID, 0) + " (" + strcharinfo(0) + ")"; // Name
- unittalk @GID_Guardian, "Hey boss!", bc_area; // Talk
- // Setup timer
- //dispbottom "Your contract will last for 15 minutes.";
- message strcharinfo(0), "Your \"Guard\" contract will last for 15 minutes.";
- // Add timer to trigger after 10 minutes
- addtimer 600000, strnpcinfo(3) + "::On10mins";
- }
- return;
- OnInit:
- .NPC_NAME$ = strnpcinfo(0);
- .MOB_ID = 4000; // Eclipse=1093
- .MOB_NAME$ = "--ja--"; // getmonsterinfo(.MOB_ID, 0);
- setarray .UMOB_INDEX$[0],
- "Size","Level","Hp","Max Hp",
- "Master AID","Map ID","Map X","Map Y",
- "Speed","Mode","Ai","Scoption",
- "Sex","Class","Hair style","Hair color",
- "Head bottom","Head middle","Head top","Cloth color",
- "Shield","Weapon","Look dir","Can move tick",
- "Str","Agi","Vit","Int",
- "Dex","Luk","Slave cpymstrmd","Dmg immune",
- "Atk range","Atk min","Atk max","Matk min",
- "Matk max","Def","Mdef","Hit",
- "Flee","Pdodge","Crit","Race",
- "Ele type","Ele level","A-motion","A-delay",
- "D-motion";
- .UMOB_MENU$ = implode(.UMOB_INDEX$, ":");
- end;
- OnUnitDeath:
- debugmes .NPC_NAME$ + " Unit Death event";
- if ( !getattachedrid() ) {
- //stopnpctimer;
- end;
- }
- //stopnpctimer;
- @GID_Guardian = 0;
- end;
- OnPCDieEvent:
- debugmes .NPC_NAME$ + " PC Die event";
- if ( !getattachedrid() )
- end;
- if ( unitexists(@GID_Guardian) )
- @GID_Guardian = 0;
- end;
- // TIMERS
- On10mins:
- // After 10 minutes
- debugmes .NPC_NAME$ + " timer 10 min";
- if ( !getattachedrid() )
- end;
- if ( unitexists(@GID_Guardian) ) {
- message strcharinfo(0), "Your \"Guard\" contract will expire in 5 minute.";
- // Add next timer to trigger after 1 minute
- addtimer 60000, strnpcinfo(3) + "::On11mins";
- }
- end;
- On11mins:
- // After 11 minutes
- debugmes .NPC_NAME$ + " timer 11 min";
- if ( !getattachedrid() )
- end;
- if ( unitexists(@GID_Guardian) ) {
- message strcharinfo(0), "Your \"Guard\" contract will expire in 4 minute.";
- addtimer 60000, strnpcinfo(3) + "::On12mins";
- }
- end;
- On12mins:
- // After 12 minutes
- debugmes .NPC_NAME$ + " timer 12 min";
- if ( !getattachedrid() )
- end;
- if ( unitexists(@GID_Guardian) ) {
- message strcharinfo(0), "Your \"Guard\" contract will expire in 3 minute.";
- addtimer 60000, strnpcinfo(3) + "::On13mins";
- }
- end;
- On13mins:
- // After 13 minutes
- debugmes .NPC_NAME$ + " timer 13 min";
- if ( !getattachedrid() )
- end;
- if ( unitexists(@GID_Guardian) ) {
- message strcharinfo(0), "Your \"Guard\" contract will expire in 2 minute.";
- addtimer 60000, strnpcinfo(3) + "::On14mins";
- }
- end;
- On14mins:
- // After 14 minutes
- debugmes .NPC_NAME$ + " timer 14 min";
- if ( !getattachedrid() )
- end;
- if ( unitexists(@GID_Guardian) ) {
- message strcharinfo(0), "Your \"Guard\" contract will expire in 1 minute.";
- addtimer 60000, strnpcinfo(3) + "::On15mins";
- }
- end;
- On15mins:
- // After 15 minutes (STOP)
- debugmes .NPC_NAME$ + " timer 15 min";
- if ( !getattachedrid() )
- end;
- if ( unitexists(@GID_Guardian) ) {
- message strcharinfo(0), "Your \"Guard\" contract expired!";
- unitkill @GID_Guardian;
- @GID_Guardian = 0;
- }
- end;
- OnTouch:
- // Players attached
- end;
- OnTouchNPC:
- // Monsters attached
- .@UNIT_GID = getattachedrid();
- //.@UNIT_NAME$ = rid2name(.@UNIT_GID);
- //debugmes "Target unit name:" + .@UNIT_NAME$;
- // Get unit data
- getunitdata(.@UNIT_GID, .@data);
- .@MASTER_AID = .@data[4];
- // Unit has a master
- if ( .@MASTER_AID ) {
- .@MASTER_NAME$ = rid2name(.@MASTER_AID); // "MonsterName", "PlayerName"
- .@online = isloggedin(.@MASTER_AID); // Monster=0, Player=1
- // Do not target player's units
- if ( .@online ) {
- //debugmes "Unit name:" + .@UNIT_NAME$;
- //debugmes "Master name:" + .@MASTER_NAME$;
- end;
- }
- }
- // NPC emotion
- emotion 0;
- // Kill monster/unit
- //unitkill .@UNIT_GID;
- // Warp monster/unit away from the NPC
- unitwarp 0, "this", -1, -1;
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement