Jump to content
  • 0

Spawn a warp portal npc when kill the boss


Question

Posted (edited)

Hi, I need a script that spawn a warp portal when the users kill a boss. this warp dissapear when pass 1 minute. I were looking for commands to make it possible.

I think with:

OnNPCkillEvent :

                   

But i don´t know how combine it correctly. Adding i have a noob question, the script i should to put in a npc? is it global? idk.

 

thx

prontera,157,169,5	script	Espadachín2	119,{
OnNPCKillEvent:
if (killedrid == 1002) { 
     getmapxy(.@mapa$,.@x,.@y,0);
     if (.@mapa$ == "prontera") {
         sleep2 10000;
		atcommand "@addwarp morocc 156 93 boss01";
		sleep2 10000;
		atcommand "@unloadnpc boss01";
         set LQuests, LQuests | 1; 
     } // End if
} // End if
end;
}

I make it, but i think that it can be improved. because if people kill monster one time they can click npc and it execute anyways... =/

Warp appears off me

Edited by angelwarrior

4 answers to this question

Recommended Posts

  • 0
Posted

Put an `end;` after the first line to prevent the player from executing the script by clicking on the NPC.

prontera,157,169,5	script	Espadachín2	119,{
end;
OnNPCKillEvent:
if (killedrid == 1002) { 
     getmapxy(.@mapa$,.@x,.@y,0);
     if (.@mapa$ == "prontera") {
         sleep2 10000;
		atcommand "@addwarp morocc 156 93 boss01";
		sleep2 10000;
		atcommand "@unloadnpc boss01";
         LQuests = LQuests | 1; 
     } // End if
} // End if
end;
}


By the way, your script has multiple flaws.

  • When multiple Porings get killed in Prontera at the same time, the warp NPC's name from @addwarp won't be boss01 anymore because there can't be more than one "boss01" NPC. Adding a permanent warp NPC and play around with `enablenpc` and `disablenpc` is a better practice.
     
  • I see the `LQuests` variable, so this is a quest NPC, right? If there's another NPC spawning a Poring for this quest. You better use an event label for mob instead of OnNPCKillEvent. Example below.
//My Example
prontera,160,169,5	script	PoringSpawner	118,{
	mes "I'm just a Poring Spawner.";
	mes "Beware, that Poring will kill you with its cuteness.";
	close2;
	monster "prontera",160,165,"Kill me please",1002,1,"PoringSpawner::OnPoringDead";
	end;
	
OnPoringDead:
	getitem 512,1; //Get an apple!
	enablenpc "PoringWarp";
	sleep 10000;
	disablenpc "PoringWarp";
	end;

//Disable the warp when the server starts.
OnInit:
	disablenpc "PoringWarp";
	end;
}

//Warp NPC
prontera,165,169,0	warp	PoringWarp	1,1,morocc,156,93

//Your Original NPC with some modifications
prontera,157,169,5	script	Espadachín2	119,{
end;

OnNPCKillEvent:
if (killedrid == 1002) { 
     getmapxy(.@mapa$,.@x,.@y,0);
     if (.@mapa$ == "prontera") {
         sleep2 10000;
		atcommand "@addwarp morocc 156 93 boss01";
		sleep2 10000;
		atcommand "@unloadnpc boss01";
         set LQuests, LQuests | 1; 
     } // End if
} // End if
end;
}
  • Upvote 2
  • 0
Posted (edited)

Put an `end;` after the first line to prevent the player from executing the script by clicking on the NPC.

prontera,157,169,5	script	Espadachín2	119,{
end;
OnNPCKillEvent:
if (killedrid == 1002) { 
     getmapxy(.@mapa$,.@x,.@y,0);
     if (.@mapa$ == "prontera") {
         sleep2 10000;
		atcommand "@addwarp morocc 156 93 boss01";
		sleep2 10000;
		atcommand "@unloadnpc boss01";
         LQuests = LQuests | 1; 
     } // End if
} // End if
end;
}

By the way, your script has multiple flaws.

  • When multiple Porings get killed in Prontera at the same time, the warp NPC's name from @addwarp won't be boss01 anymore because there can't be more than one "boss01" NPC. Adding a permanent warp NPC and play around with `enablenpc` and `disablenpc` is a better practice.

     

  • I see the `LQuests` variable, so this is a quest NPC, right? If there's another NPC spawning a Poring for this quest. You better use an event label for mob instead of OnNPCKillEvent. Example below.
//My Example
prontera,160,169,5	script	PoringSpawner	118,{
	mes "I'm just a Poring Spawner.";
	mes "Beware, that Poring will kill you with its cuteness.";
	close2;
	monster "prontera",160,165,"Kill me please",1002,1,"PoringSpawner::OnPoringDead";
	end;
	
OnPoringDead:
	getitem 512,1; //Get an apple!
	enablenpc "PoringWarp";
	sleep 10000;
	disablenpc "PoringWarp";
	end;

//Disable the warp when the server starts.
OnInit:
	disablenpc "PoringWarp";
	end;
}

//Warp NPC
prontera,165,169,0	warp	PoringWarp	1,1,morocc,156,93

//Your Original NPC with some modifications
prontera,157,169,5	script	Espadachín2	119,{
end;

OnNPCKillEvent:
if (killedrid == 1002) { 
     getmapxy(.@mapa$,.@x,.@y,0);
     if (.@mapa$ == "prontera") {
         sleep2 10000;
		atcommand "@addwarp morocc 156 93 boss01";
		sleep2 10000;
		atcommand "@unloadnpc boss01";
         set LQuests, LQuests | 1; 
     } // End if
} // End if
end;
}

I put a poring as example monster. But it should be a mvp in dungeon. I will try with that, and i tell you. Thanks!

 

ahh: There is a way to make it without npc? a event that execute in a map? where I should put it? same way?

Edited by angelwarrior

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...