Jump to content

  •  

Photo

Automatic Bloody Branch Spawn


Best Answer Khazou, 21 November 2016 - 01:09 AM

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.

Go to the full post


  • Please log in to reply
12 replies to this topic

#1 simh

simh

    Member

  • Members
  • PipPip
  • 16 posts

Posted 18 November 2016 - 10:27 PM

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



#2 Khazou

Khazou

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 20 November 2016 - 12:18 PM

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



#3 simh

simh

    Member

  • Members
  • PipPip
  • 16 posts

Posted 20 November 2016 - 07:52 PM

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, 20 November 2016 - 07:54 PM.


#4 Khazou

Khazou

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 21 November 2016 - 01:09 AM   Best Answer

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.



#5 simh

simh

    Member

  • Members
  • PipPip
  • 16 posts

Posted 21 November 2016 - 10:12 AM

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, 21 November 2016 - 10:15 AM.


#6 Khazou

Khazou

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 21 November 2016 - 11:59 AM

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.



#7 simh

simh

    Member

  • Members
  • PipPip
  • 16 posts

Posted 21 November 2016 - 02:12 PM

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, 21 November 2016 - 02:18 PM.


#8 Khazou

Khazou

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 21 November 2016 - 04:33 PM

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 :)



#9 simh

simh

    Member

  • Members
  • PipPip
  • 16 posts

Posted 21 November 2016 - 06:56 PM

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?



#10 Khazou

Khazou

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 22 November 2016 - 10:10 AM

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



#11 simh

simh

    Member

  • Members
  • PipPip
  • 16 posts

Posted 22 November 2016 - 05:03 PM

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!



#12 Khazou

Khazou

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 22 November 2016 - 06:25 PM

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



#13 simh

simh

    Member

  • Members
  • PipPip
  • 16 posts

Posted 23 November 2016 - 02:59 PM

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






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users


This topic has been visited by 35 user(s)