Jump to content
  • 0

Spawn a warp portal npc when kill the boss


angelwarrior

Question


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   0
  • Joined:  02/21/16
  • Last Seen:  

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
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   0
  • Joined:  02/21/16
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

^ like Panda said.

Replace npc map and position with a dash (-).

Good luck with scripting. It's a fun adventure. :)

Link to comment
Share on other sites

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.

×
×
  • Create New...