Jump to content
  • 0

Need help with monster summoning inside a custom instance


Question

Posted (edited)
demon_lair,99,101,1    script    #Demon_Tomb    565,{
    mes "[Tomb]";
    mes "This is the resting place of a great demon";
    mes "named Azhura.";
    next;
    mes "You can summon him thru";
    mes "Nightmarish Ornament and Evil Energy";
    next;
    mes "Put the Nightmarish Ornament";
    mes "and Evil Energy.";
    menu "Yes",yes,"No",-;
    next;
        mes "[Tomb]";
        mes "Come back when you are decided.";
        close;
        end;
yes:
if( countitem(41001) < 2 )
    mes "You didnt have required item!";
else{
    delitem 41001,2;
    mapannounce .Map$, "Prepare for the unleashed evil!!", bc_map;
    goto SummonAzhura;
    }
    end;
    
SummonAzhura:
    monster .Map$,99,106,"Great Demon Azhura",1973,1,strnpcinfo(0)+"::OnKilledAzhura";
    end;

OnKilledAzhura:
    disablenpc "#Demon_Tomb";
    end;

OnInit:
    .Map$ = "demon_lair";
    end;

}

This is my code, the map announce and monster is not being summoned.

No error on Map server

Edited by Ruhn
updated the code

11 answers to this question

Recommended Posts

  • 0
Posted

Well, normally you'd use what you did "--en--", or "--ja--". But if you want to pick the names yourself, you can do this:

prontera,99,101,1	script	Demon Tomb	565,{
	mes "stuff...";
	setarray .@mobIds, 1002, 1003, 1004, 1005, 1006;
	setarray .@mobNames$, "Poring 1", "Poring 2", "Poring 3", "Poring 4", "Poring 5";
	
	.@mobIdx = rand(getarraysize(.@mobIds));
	.@mobId = .@mobIds[.@mobIdx];
	.@mobName$ = .@mobNames[.@mobIdx];
	monster .@map$,99,107,.@mobName$,.@mobId,1,.@label_boss$,2;
	end;
}

If you prefer, you can use this approach below as well, same thing (I find it easier to handle in larger scripts, but there's really no difference).

prontera,99,101,1	script	Demon Tomb	565,{
	mes "stuff...";
	setarray .@mobIds, 1002, 1003, 1004, 1005, 1006;

	.@mobId = .@mobIds[rand(getarraysize(.@mobIds))];
	monster .@map$,99,107,'mobNames$[.@mobId],.@mobId,1,.@label_boss$,2;
	end;
OnInstanceInit:
	'mobNames$[1002] = "Poring 1";
	'mobNames$[1003] = "Poring 2";
	'mobNames$[1004] = "Poring 3";
	'mobNames$[1005] = "Poring 4";
	'mobNames$[1006] = "Poring 5";
	end;
}

 

  • MVP 1
  • 0
Posted

Try this

demon_lair,99,101,1    script    #Demon_Tomb    565,{
    mes "[Tomb]";
    mes "This is the resting place of a great demon named Azhura.";
    next;
    mes "You can summon him through Nightmarish Ornament and Evil Energy.";
    next;
    mes "Put the Nightmarish Ornament and Evil Energy.";
    menu "Yes", L_yes, "No", L_no;
    
L_no:
    mes "[Tomb]";
    mes "Come back when you have decided.";
    close;

L_yes:
    if (AzhuraSpawned) {
        mes "The Great Demon Azhura is already here!";
        close;
    }
    if (countitem(41001) < 2) {
        mes "You don't have the required items!";
        close;
    }
    delitem 41001, 2;
    mapannounce .Map$, "Prepare for the unleashed evil!!", bc_map;
    set AzhuraSpawned, 1;
    monster .Map$, 99, 106, "Great Demon Azhura", 1973, 1, strnpcinfo(0) + "::OnKilledAzhura";
    close;

OnKilledAzhura:
    set AzhuraSpawned, 0;
    end;

OnInit:
    .Map$ = "demon_lair";
    set AzhuraSpawned, 0;
    end;
}

 

  • Love 1
  • 0
Posted (edited)
17 hours ago, Poring King said:

Try this

demon_lair,99,101,1    script    #Demon_Tomb    565,{
    mes "[Tomb]";
    mes "This is the resting place of a great demon named Azhura.";
    next;
    mes "You can summon him through Nightmarish Ornament and Evil Energy.";
    next;
    mes "Put the Nightmarish Ornament and Evil Energy.";
    menu "Yes", L_yes, "No", L_no;
    
L_no:
    mes "[Tomb]";
    mes "Come back when you have decided.";
    close;

L_yes:
    if (AzhuraSpawned) {
        mes "The Great Demon Azhura is already here!";
        close;
    }
    if (countitem(41001) < 2) {
        mes "You don't have the required items!";
        close;
    }
    delitem 41001, 2;
    mapannounce .Map$, "Prepare for the unleashed evil!!", bc_map;
    set AzhuraSpawned, 1;
    monster .Map$, 99, 106, "Great Demon Azhura", 1973, 1, strnpcinfo(0) + "::OnKilledAzhura";
    close;

OnKilledAzhura:
    set AzhuraSpawned, 0;
    end;

OnInit:
    .Map$ = "demon_lair";
    set AzhuraSpawned, 0;
    end;
}

 

Im getting this
And monster still doesnt show.

 

edit: managed to remove the error by adding $ but mobs still wont get summoned.
image.png.12f47b4635dd3cd6796c3fcf57e465fa.png

Edited by Ruhn
update
  • 0
Posted

Btw this is the whole code of the supposedly instance dungeon for summoning custom boss

@Poring King

 

prontera,156,162,5	script	Sample	757,{
	.@instance_name$ = "Demon Vanquisher";
	if (!is_party_leader()) end;
	switch(select(
		"Create",
		"Enter",
		"Destroy"
	)) {
		case 1:
			instance_create(.@instance_name$, IM_PARTY);
			break;
		case 2:
			switch(instance_enter(.@instance_name$)) {
				case IE_NOMEMBER:
					mes "ERROR: Party not found.";
					break;
				case IE_NOINSTANCE:
					mes "ERROR: Party does not have an instance.";
					break;
				case IE_OTHER:
					mes "ERROR: Unknown error.";
					break;
				default:
					break;
			}
			break;
		case 3:
			instance_destroy(instance_id(IM_PARTY));
			break;
	}
	end;
}

demon_lair,99,101,1	script	Demon Tomb	565,{
    mes "[Tomb]";
    mes "This is the resting place of a great demon named Azhura.";
    next;
    mes "You can summon him through Nightmarish Ornament and Evil Energy.";
    next;
    mes "Put the Nightmarish Ornament and Evil Energy.";
    menu "Yes", L_yes, "No", L_no;
    
L_no:
    mes "[Tomb]";
    mes "Come back when you have decided.";
    close;

L_yes:
    if ($AzhuraSpawned) {
        mes "The Great Demon Azhura is already here!";
        close;
    }
    if (countitem(41001) < 2) {
        mes "You don't have the required items!";
        close;
    }
    delitem 41001, 2;
    mapannounce .Map$, "Prepare for the unleashed evil!!", bc_map;
    set $AzhuraSpawned, 1;
    monster .Map$, 99, 106, "Great Demon Azhura", 1973, 1, strnpcinfo(0) + "::OnKilledAzhura";
    close;

OnKilledAzhura:
    set $AzhuraSpawned, 0;
    end;

OnInit:
    .Map$ = "demon_lair";
    set $AzhuraSpawned, 0;
    end;
}

 

  • 0
Posted (edited)

Fixed with these code

thanks @Poring King

demon_lair,99,100,1	script	Demon Tomb	565,{
    mes "[Tomb]";
    mes "This is the resting place of a great demon named Azhura.";
    next;
    mes "You can summon him through Nightmarish Ornament and Evil Energy.";
    next;
    mes "Put the Nightmarish Ornament and Evil Energy.";
    menu "Yes", L_yes, "No", L_no;
    
L_no:
    mes "[Tomb]";
    mes "Come back when you have decided.";
    close;

L_yes:
    if ($AzhuraSpawned) {
        mes "The Great Demon Azhura is already here!";
        close;
    }
    if (countitem(41001) < 2) {
        mes "You don't have the required items!";
        close;
    }
    delitem 41001, 2;
	hideonnpc "Demon Tomb";
    mapannounce .Map$, "Prepare for the unleashed evil!!", bc_map;
	set $AzhuraSpawned, 1;
    monster .Map$, 99, 105, "Great Demon Azhura", 1864, 1, strnpcinfo(0) + "::OnKilledAzhura";
    end;

OnKilledAzhura:
    set $AzhuraSpawned, 0;
	enablenpc "Demon Tomb";
    end;

OnInit:
    .Map$ = "demon_lair";
    set $AzhuraSpawned, 0;
    end;
}

 

Edited by Ruhn
  • 0
Posted

A couple things to learn here:

  • OnInit applies when the script is loaded, while OnInstanceInit applies when the instance is created. So in your case, you want to use OnInstanceInit.
  • "demon_lair" is the base map, but that's not the map inside your instance. You want to use instance_mapname("demon_lair");
  • Likewise, when you're setting up the event label, it is attempting to call it on the base NPC, not the instanced NPC. So you want to use
    instance_npcname(strnpcinfo(0)) + "::OnKilledAzhura"
  • "set" is a very much outdated command, use "=" instead.
  • "$AzhuraSpawned" is a global, permanent, variable. It is kept when your server restarts and it is also shared between instances. You want to use 'variable instead.

So your script would look something like this (and using menu is weird):

demon_lair,99,101,1	script	Demon Tomb	565,{
	mes "[Tomb]";
	mes "This is the resting place of a great demon named Azhura.";
	next;
	mes "[Tomb]";
	mes "You can summon him through Nightmarish Ornament and Evil Energy.";
	next;
	mes "[Tomb]";
	mes "Put the Nightmarish Ornament and Evil Energy.";
	next;
	
	switch(select("Yes.:No.")) {
		case 1:
			if ('AzhuraSpawned) {
				mes "The Great Demon Azhura is already here!";
				close;
			}
			
			if (countitem(41001) < 2) {
				mes "You don't have the required items!";
				close;
			}
			
			delitem 41001, 2;
			mapannounce .Map$, "Prepare for the unleashed evil!!", bc_map;
			'AzhuraSpawned = 1;
			monster .Map$, 99, 106, "Great Demon Azhura", 1973, 1, instance_npcname(strnpcinfo(0)) + "::OnKilledAzhura";
			close;
		case 2:
			mes "[Tomb]";
			mes "Come back when you have decided.";
			close;
	}
	
	end;
OnKilledAzhura:
	'AzhuraSpawned = 0;
	end;
OnInstanceInit:
	.Map$ = instance_mapname("demon_lair");
	end;
}

 

  • Love 1
  • 0
Posted
2 hours ago, Tokei said:

A couple things to learn here:

  • OnInit applies when the script is loaded, while OnInstanceInit applies when the instance is created. So in your case, you want to use OnInstanceInit.
  • "demon_lair" is the base map, but that's not the map inside your instance. You want to use instance_mapname("demon_lair");
  • Likewise, when you're setting up the event label, it is attempting to call it on the base NPC, not the instanced NPC. So you want to use
    instance_npcname(strnpcinfo(0)) + "::OnKilledAzhura"
  • "set" is a very much outdated command, use "=" instead.
  • "$AzhuraSpawned" is a global, permanent, variable. It is kept when your server restarts and it is also shared between instances. You want to use 'variable instead.

So your script would look something like this (and using menu is weird):

demon_lair,99,101,1	script	Demon Tomb	565,{
	mes "[Tomb]";
	mes "This is the resting place of a great demon named Azhura.";
	next;
	mes "[Tomb]";
	mes "You can summon him through Nightmarish Ornament and Evil Energy.";
	next;
	mes "[Tomb]";
	mes "Put the Nightmarish Ornament and Evil Energy.";
	next;
	
	switch(select("Yes.:No.")) {
		case 1:
			if ('AzhuraSpawned) {
				mes "The Great Demon Azhura is already here!";
				close;
			}
			
			if (countitem(41001) < 2) {
				mes "You don't have the required items!";
				close;
			}
			
			delitem 41001, 2;
			mapannounce .Map$, "Prepare for the unleashed evil!!", bc_map;
			'AzhuraSpawned = 1;
			monster .Map$, 99, 106, "Great Demon Azhura", 1973, 1, instance_npcname(strnpcinfo(0)) + "::OnKilledAzhura";
			close;
		case 2:
			mes "[Tomb]";
			mes "Come back when you have decided.";
			close;
	}
	
	end;
OnKilledAzhura:
	'AzhuraSpawned = 0;
	end;
OnInstanceInit:
	.Map$ = instance_mapname("demon_lair");
	end;
}

 

Thanks for the input, managed to figure it out mate. 

I'm doing now is how to make it summon a random boss, like i have 5 bosses in array. xD

  • 0
Posted

How can i make the npc summon a random mob id

for example this list of mob ids

mobid 1, mobid 2, mobid 3, mobid 4, mobid 5

name 1, name 2, name 3, name 4, name 5

 

then if the system pick mobid 3 the name should be name 3

monster .@map$,99,107,"--en--",.@MobID,1,.@label_boss$,2;

  • 0
Posted
On 6/27/2024 at 7:16 AM, Tokei said:

Well, normally you'd use what you did "--en--", or "--ja--". But if you want to pick the names yourself, you can do this:

prontera,99,101,1	script	Demon Tomb	565,{
	mes "stuff...";
	setarray .@mobIds, 1002, 1003, 1004, 1005, 1006;
	setarray .@mobNames$, "Poring 1", "Poring 2", "Poring 3", "Poring 4", "Poring 5";
	
	.@mobIdx = rand(getarraysize(.@mobIds));
	.@mobId = .@mobIds[.@mobIdx];
	.@mobName$ = .@mobNames[.@mobIdx];
	monster .@map$,99,107,.@mobName$,.@mobId,1,.@label_boss$,2;
	end;
}

If you prefer, you can use this approach below as well, same thing (I find it easier to handle in larger scripts, but there's really no difference).

prontera,99,101,1	script	Demon Tomb	565,{
	mes "stuff...";
	setarray .@mobIds, 1002, 1003, 1004, 1005, 1006;

	.@mobId = .@mobIds[rand(getarraysize(.@mobIds))];
	monster .@map$,99,107,'mobNames$[.@mobId],.@mobId,1,.@label_boss$,2;
	end;
OnInstanceInit:
	'mobNames$[1002] = "Poring 1";
	'mobNames$[1003] = "Poring 2";
	'mobNames$[1004] = "Poring 3";
	'mobNames$[1005] = "Poring 4";
	'mobNames$[1006] = "Poring 5";
	end;
}

 

thanks @Tokei , the second one works fine. the first one does not give names.

  • 0
Posted

?@Tokei, on this part in which the boss got killed, how can i make this reward every party member in the instance?, also for example the summoned boss is "poring 1" it should only give "poring 1 loot" then for "poring 2" it should only give "poring loot 2" ?

 

	// spawn mobs
	setarray .@mobIds, 20570, 20571, 20572, 20573, 20574;
	
	.@mobId = .@mobIds[rand(getarraysize(.@mobIds))];
	.@map$        = instance_mapname("demon_lair");
	.@label_boss$ = instance_npcname(strnpcinfo(0))+"::OnMyBossDead";
	monster .@map$,99,107,'mobNames$[.@mobId],.@mobId,1,.@label_boss$,2;
	unittalk $@mobid[0],"Die ! You insolent fool!!";
	end;

OnMyBossDead:  //
	specialeffect2 EF_MVP;
	getitem 41000,50; //


	// trigger other events
	.@map$   = instance_mapname("demon_lair");
	mapannounce .@map$,"He will resurrect, soon!",bc_map;
	donpcevent instance_npcname("Reinfred#fin")+"::OnEnable";
	end;
}

 

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