Jump to content
  • 0
Sign in to follow this  
simhr

Automatic Bloody Branch Spawn

Question

Hello,

 

currently i'm trying to develop a script that automatically spawns one random boss monster (out of bloody branch) on a given map. As soon as it gets killed it should wait for one hour to respawn another random boss monster.

 

Does anyone know why:

1. I'm not able to use the 'strnpcinfo'-commands below. I get an error that no player is attached, but i don't understand why there should be one, since i'm just querying the map of the npc and its unique name?

2. As soon as a boss monster is killed there should also spawn a tomb at the position where the monster was killed. It should disappear as soon as another boss monster spawns on the map. Is there a command to spawn a tomb? (Or to spawn and to remove a random self-scriped npc? I only found a code snippet for spawning a tomb in the map.c source file)

 

Here's my script:

-	script	SpawnPvE	FAKE_NPC,{
OnInit:
	// init map
	callfunc("mobspawn", 0, strnpcinfo(NPC_MAP), strnpcinfo(NPC_NAME_UNIQUE));
	end;
	
// when a player kills a monster
OnMonsterDead:
	callfunc("mobspawn", 3600000, strnpcinfo(NPC_MAP), strnpcinfo(NPC_NAME_UNIQUE));
	end;
}

function	script	mobspawn	{
	.@timeout = getarg(0);
	.@map$ = getarg(1);
	.@npcname$ = getarg(2);
	
	if (mobcount(.@map$, "all") < 1) {
		sleep(.@timeout);
		// bloody branch spawn
		monster(.@map$,0,0,--en--,-3,1,.@npcname$+"::OnMonsterDead");
	}	
}

pvp_n_3-1,0,0,0	duplicate(SpawnPvE)	SpawnPvE#1	FAKE_NPC
pvp_n_3-2,0,0,0	duplicate(SpawnPvE)	SpawnPvE#2	FAKE_NPC
pvp_n_3-3,0,0,0	duplicate(SpawnPvE)	SpawnPvE#3	FAKE_NPC
pvp_n_3-4,0,0,0	duplicate(SpawnPvE)	SpawnPvE#4	FAKE_NPC
pvp_n_3-5,0,0,0	duplicate(SpawnPvE)	SpawnPvE#5	FAKE_NPC

 

Thanks for your help!

-simh

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0

You just forget to put some " :)

--ja--, is suppose to be a string, here you're trying to access the --ja-- player variable. That's why it throw you a "no player is attached" :)

Juste change --ja-- to "--ja--" and it will be ok

Share this post


Link to post
Share on other sites
  • 0

You just forget to put some " :)

--ja--, is suppose to be a string, here you're trying to access the --ja-- player variable. That's why it throw you a "no player is attached" :)

Juste change --ja-- to "--ja--" and it will be ok

 

Thanks for your reply, but i still get an error. In the meantime i replaced NPC_MAP with 4 and NPC_NAME_UNIQUE with 3. Now i don't get the error that a character is not attached. Instead i get the error that the map "" can't be found.

 

There must still be some issue with the strnpcinfo()-command in my script, but i don't know which.

Edited by simh

Share this post


Link to post
Share on other sites
  • 0

You should go back to NPC_MAP and NPC_NAME_UNIQUE, this is recommended way of scripting.

 

Your error is just because of your main npc, the one which is duplicate. He also hit the OnInit label, so as you didn't set a map for this one you're getting your error :)

 

Just put something like this:

if(strnpcinfo(NPC_MAP) == "") end;

Just after the OnInit label.

Share this post


Link to post
Share on other sites
  • 0

You should go back to NPC_MAP and NPC_NAME_UNIQUE, this is recommended way of scripting.

 

Your error is just because of your main npc, the one which is duplicate. He also hit the OnInit label, so as you didn't set a map for this one you're getting your error :)

 

Just put something like this:

if(strnpcinfo(NPC_MAP) == "") end;

Just after the OnInit label.

 

Thank you :) Now i put the following line in my OnInit-Event and it works.

if(strnpcinfo(3) == "" || strnpcinfo(4) == "") end;

If i put one of the values NPC_MAP, NPC_NAME_UNIQUE or "NPC_MAP" and "NPC_NAME_UNIQUE" it throws the error that no character is attached.

 

Do you know a way to spawn a tomb? I couldn't find a different "monster" command to spawn an MvP. (Since permanent mvp spawns are marked as bossmonsters, i think this is the reason why no tomb is spawned upon death of my spawned mvp)

Edited by simh

Share this post


Link to post
Share on other sites
  • 0

You should update your emulator, if using constant like NPC_MAP throw a "no character is attached" it may be because they are not defined (because you don't have an updated version of the emulator :) ) and so it tries to get a player variable with the name NPC_MAP (and so it throw an error).

 

You can't have a tomb with a monster spawn with the *monster command, because of they way its coded in the emulator. You need to make a permanent monster spawn using boss_monster, unless you specify this boss_monster, you won't have your tomb.

 

I looked to see if you could spawn it with a permanent monster spawn, but here the problem would be to spawn a "Bloody Dead Branch" mob since you can't put a "-3"

 id for a permanent monster spawn.

Share this post


Link to post
Share on other sites
  • 0

You should update your emulator, if using constant like NPC_MAP throw a "no character is attached" it may be because they are not defined (because you don't have an updated version of the emulator :) ) and so it tries to get a player variable with the name NPC_MAP (and so it throw an error).

Thanks, i think that will fix it! (I can't try it though, because i have merge conflicts and don't know how to solve them yet without losing most of my changes)

You can't have a tomb with a monster spawn with the *monster command, because of they way its coded in the emulator. You need to make a permanent monster spawn using boss_monster, unless you specify this boss_monster, you won't have your tomb.

Yes.. I feared that :/

I looked to see if you could spawn it with a permanent monster spawn, but here the problem would be to spawn a "Bloody Dead Branch" mob since you can't put a "-3"

 id for a permanent monster spawn.

I thought about that, but came to the same solution :(

 

So the only thing i could do is to customize the *monster-command so that i can choose to summon a monster as boss_monster. Or to spawn tomb-npcs by hand (if this is possible).

 

Thank you very much for your help! :)

Edited by simh

Share this post


Link to post
Share on other sites
  • 0

Daaaaaamn, never tough about spawning tomb npc xD Don't know why ^^'

 

So yeah you can do this, i checked in src and it appears that you can use MOB_TOMB as sprite id for your npc :)

So you can build and customize your own tomb :)

Share this post


Link to post
Share on other sites
  • 0

Daaaaaamn, never tough about spawning tomb npc xD Don't know why ^^'

 

So yeah you can do this, i checked in src and it appears that you can use MOB_TOMB as sprite id for your npc :)

So you can build and customize your own tomb :)

 

No problem :D Thanks again! I'm still at the beginning of learning how to create some custom scripts, so i just threw some random ideas in :D

 

Do you know the commands for spawning and removing a npc from the map?

Share this post


Link to post
Share on other sites
  • 0

You just need to write your npc as a normal npc, then you disable it with *disablenpc, and you can enable it with *enablenpc :)

You can also look for Dastgir duplicate-npc plugins

Share this post


Link to post
Share on other sites
  • 0

You just need to write your npc as a normal npc, then you disable it with *disablenpc, and you can enable it with *enablenpc :)

You can also look for Dastgir duplicate-npc plugins

 

Ahh thank you, so i can only enable and disable it :/

 

I think i will better try to change the monster command in the source-file. Because my 'extended' requirement was to be able to spawn a random MVP on a random map. If i do this with the enablenpc and disablenpc commands i'd have to write a duplicate-npc for every map (though only one npc is active at the same time) and move that npc to the coordinates of the defeated mvp. That would make my script way more complicated..

 

Thank you so much for your help!

Share this post


Link to post
Share on other sites
  • 0

No problem :)

 

By the way here is a little gift, give a try to this: http://pastebin.com/WLVXSjRe

 

You'll need to change the constant to number if you didn't update your emulator yet :)

 

NPC_NAME = 0

NPC_NAME_HIDDEN = 2

NPC_MAP = 4

PC_NAME = 0

 

Thanks again :D I guess you saved me hours of time. I will try it and give you feedback as soon as possible (I'm currently on a business trip).

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.