Jump to content
  • 0

Customizable Death Announcer


Mumbles

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

I'd like to create an NPC that uses a death announcer similar to the ones included in AnnieRuru's posts in a different thread for the purpose of helping event GMs keep a track of deaths while maintaining a creative flair. Ideally, the announcements would be local broadcast and configured by the GM upon whispering anything to npc:death. In theory, it'd look a little something like this:

-	script	death	-1,{

OnInit:
set .npcname$,"[Death Announcer]";	// Define the NPC's name

OnWhisperGlobal:
if (getgmlevel() >= 40) {
AnnounceMenu:
	mes .npcname$;
	mes "There are several settings for this controller.";
	mes "Only one announcer may be active at all times.";
	mes "What would you like to do?";
	menu "Set Flavor Text",FlavorText,"Mob Announcer",MobAnnouncer,"PK Announcer",PKAnnouncer,"Nothing",Nothing;

Nothing:
	close;

FlavorText:
	next;
	mes .npcname$;
	mes "Pleae input the text you would like to appear when a player is killed.";
	mes "^AAAAAAExample: Player <had his brains eaten>!^000000"; // @FlavorText$ would replace < >
	input @FlavorText$;
	next;
	mes .npcname$;
	mes "The message that will be broadcasted when a player dies is:";
	mes "^FF0000Player "+@FlavorText$+"!^000000";
	mes " ";
	mes "Is that correct?";
	menu "Yes, that's fine",CorrectFlavor,"No, let me change it",FlavorText,"Nevermind",Nothing;

CorrectFlavor:
	set $flavor,1;	// At this point, Flavor Text has been defined
	goto AnnounceMenu;

MobAnnouncer:
	if ($flavor != 1) {	// Check if Flavor Text has been defined yet
		next;
		mes .npcname$;
		mes "I'm sorry, but you haven't set the Flavor Text yet!";
		next;
		goto AnnounceMenu;
	}
	else {
		if ($mobactive == 1) {
			next;
			mes .npcname$;
			mes "The Mob Announcer is currently active.";
			mes "Would you like to disable it?";
			menu "Yes",DeactivateMob,"No",AnnounceMenu;

DeactivateMob:
			next;
			mes .npcname$;
			mes "The Mob Announcer has been deactivated.";
			set $mobactive,0;	// Define the Mob Announcer as "inactive"
			goto AnnounceMenu;
		}
		else {
			next;
			mes .npcname$;
			mes "Would you like to enable the Mob Announcer?";
			mes "This will broadcast player deaths when they're killed by monsters.";
			menu "Yes",ActivateMob,"No",AnnounceMenu;

ActivateMob:
			next;
			mes .npcname$;
			mes "The Mob Announcer has been activated.";
			set $pkactive,0;	// Define the PK Announcer as "inactive"
			set $mobactive,1;	// Define the Mob Announcer as "active"
			goto AnnounceMenu;
		}

PKAnnouncer:
		if ($flavor != 1) {	// Check if Flavor Text has been defined yet
			next;
			mes .npcname$;
			mes "I'm sorry, but you haven't set the Flavor Text yet!";
			next;
			goto AnnounceMenu;
		}
		else {
			if ($pkactive == 1) {
				next;
				mes .npcname$;
				mes "The PK Announcer is currently active.";
				mes "Would you like to disable it?";
				menu "Yes",DeactivatePK,"No",AnnounceMenu;

DeactivatePK:
				next;
				mes .npcname$;
				mes "The PK Announcer has been deactivated.";
				set $pkactive,0;	// Define the PK Announcer as "inactive"
				goto AnnounceMenu;
			}
			else {
				next;
				mes .npcname$;
				mes "Would you like to enable the PK Announcer?";
				mes "This will broadcast player deaths when they're killed by other players.";
				menu "Yes",ActivatePK,"No",AnnounceMenu;

ActivatePK:
				next;
				mes .npcname$;
				mes "The PK Announcer has been activated.";
				set $mobactive,0;	// Define the Mob Announcer as "inactive"
				set $pkactive,1;	// Define the PK Announcer as "active"
				goto AnnounceMenu;
			}

			// Announcers
			if ($mobevent == 1) {
OnPCDieEvent:
				announce strcharinfo(0) + @FlavorText$ +"!",bc_map;	// Announce player death by monster
				end;
			}
			else {
				if ($pkevent == 1) {
OnPCKillEvent:
					set .@name$, strcharinfo(0);
					attachrid killedrid;
					announce strcharinfo(0)+" "+@FlavorText$+" by "+.@name$+"!",bc_map;	// Announce player death by PK
					end;
				}
			}
		}
	}
}
else {
	dispbottom "You are not authorized to use this feature.";	// Reject player access
	end;
}	
}

Status:

I wrote this myself lol, it's not fully functional. The way its written, it does broadcast upon death, but it's excluding the @FlavorText$ input and announces twice; my intent for two announcements is so that if one is activated, the other is deactivated immediately. In addition, the NPC's name doesn't show up and the AnnouncerMain dialogue floods the previous window. If anyone can provide some constructive feedback in favor of fixing this script, I'd really appreciate it.

Edited by Via
Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Like this?

-	script	death	-1,{
OnInit:
set .npcname$,"[Death Announcer]"; // Define the NPC's name

OnWhisperGlobal:
if (getgmlevel() >= 40) {
AnnounceMenu:
	mes .npcname$;
	mes "There are several settings for this controller.";
	mes "Only one announcer may be active at all times.";
	mes "What would you like to do?";
	menu "Set Flavor Text",FlavorText,"Mob Announcer",MobAnnouncer,"PK Announcer",PKAnnouncer,"Nothing",Nothing;

Nothing:
	close;

FlavorText:
	next;
	mes .npcname$;
	mes "Pleae input the text you would like to appear when a player is killed.";
	mes "^AAAAAAExample: Player <had his brains eaten>!^000000"; // @FlavorText$ would replace < >
	input @FlavorText$;
	next;
	mes .npcname$;
	mes "The message that will be broadcasted when a player dies is:";
	mes "^FF0000Player "+@FlavorText$+"!^000000";
	mes " ";
	mes "Is that correct?";
	menu "Yes, that's fine",CorrectFlavor,"No, let me change it",FlavorText,"Nevermind",Nothing;

CorrectFlavor:
	set $flavor,1; // At this point, Flavor Text has been defined
	goto AnnounceMenu;

MobAnnouncer:
	if ($flavor != 1) { // Check if Flavor Text has been defined yet
		next;
		mes .npcname$;
		mes "I'm sorry, but you haven't set the Flavor Text yet!";
		next;
		goto AnnounceMenu;
	}
	else {
		if ($mobactive == 1) {
			next;
			mes .npcname$;
			mes "The Mob Announcer is currently active.";
			mes "Would you like to disable it?";
			menu "Yes",DeactivateMob,"No",AnnounceMenu;

DeactivateMob:
			next;
			mes .npcname$;
			mes "The Mob Announcer has been deactivated.";
			set $mobactive,0; // Define the Mob Announcer as "inactive"
			goto AnnounceMenu;
		}
		else {
			next;
			mes .npcname$;
			mes "Would you like to enable the Mob Announcer?";
			mes "This will broadcast player deaths when they're killed by monsters.";
			menu "Yes",ActivateMob,"No",AnnounceMenu;

ActivateMob:
			next;
			mes .npcname$;
			mes "The Mob Announcer has been activated.";
			set $pkactive,0; // Define the PK Announcer as "inactive"
			set $mobactive,1; // Define the Mob Announcer as "active"
			goto AnnounceMenu;
		}

PKAnnouncer:
		if ($flavor != 1) { // Check if Flavor Text has been defined yet
			next;
			mes .npcname$;
			mes "I'm sorry, but you haven't set the Flavor Text yet!";
			next;
			goto AnnounceMenu;
		}
		else {
			if ($pkactive == 1) {
				next;
				mes .npcname$;
				mes "The PK Announcer is currently active.";
				mes "Would you like to disable it?";
				menu "Yes",DeactivatePK,"No",AnnounceMenu;

DeactivatePK:
				next;
				mes .npcname$;
				mes "The PK Announcer has been deactivated.";
				set $pkactive,0; // Define the PK Announcer as "inactive"
				goto AnnounceMenu;
			}
			else {
				next;
				mes .npcname$;
				mes "Would you like to enable the PK Announcer?";
				mes "This will broadcast player deaths when they're killed by other players.";
				menu "Yes",ActivatePK,"No",AnnounceMenu;

ActivatePK:
				next;
				mes .npcname$;
				mes "The PK Announcer has been activated.";
				set $mobactive,0; // Define the Mob Announcer as "inactive"
				set $pkactive,1; // Define the PK Announcer as "active"
				goto AnnounceMenu;
			}

			// Announcers
OnPCDieEvent:
			if ($mobevent == 1) {announce strcharinfo(0) + @FlavorText$ +"!",bc_map;}
			end;
OnPCKillEvent:
			if ($pkevent == 1) {set .@name$, strcharinfo(0);attachrid killedrid;announce strcharinfo(0)+" "+@FlavorText$+" by "+.@name$+"!",bc_map;}
			end;
		}
	}
}
} else {dispbottom "You are not authorized to use this feature.";end;}
}

Edited by Brian
[codebox]
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

Like this?

Can you point out exactly what changes you made? Either way, it still doesn't work; in fact, it doesn't even broadcast anymore lol. I'm running my server on eAthena, by the way. If anyone else has a solution, please let me know.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

/ok

- script death -1,{
OnInit:
set .npcname$,"[Death Announcer]"; // Define the NPC's name

OnWhisperGlobal:
if (getgmlevel() >= 40) {
AnnounceMenu:
	mes .npcname$;
	mes "There are several settings for this controller.";
	mes "Only one announcer may be active at all times.";
	mes "What would you like to do?";
	next;
	menu "Set Flavor Text",FlavorText,"Mob Announcer",MobAnnouncer,"PK Announcer",PKAnnouncer,"Nothing",Nothing;

Nothing:
	close;

FlavorText:
	next;
	mes .npcname$;
	mes "Pleae input the text you would like to appear when a player is killed.";
	mes "^AAAAAAExample: Player <had his brains eaten>!^000000"; // @FlavorText$ would replace < >
	input @FlavorText$;
	next;
	mes .npcname$;
	mes "The message that will be broadcasted when a player dies is:";
	mes "^FF0000Player "+@FlavorText$+"!^000000";
	mes " ";
	mes "Is that correct?";
	next;
	menu "Yes, that's fine",CorrectFlavor,"No, let me change it",FlavorText,"Nevermind",Nothing;

CorrectFlavor:
	set $flavor,1; // At this point, Flavor Text has been defined
	goto AnnounceMenu;

MobAnnouncer:
	if ($flavor != 1) { // Check if Flavor Text has been defined yet
		next;
		mes .npcname$;
		mes "I'm sorry, but you haven't set the Flavor Text yet!";
		next;
		goto AnnounceMenu;
	} else {
		if ($mobactive == 1) {
			next;
			mes .npcname$;
			mes "The Mob Announcer is currently active.";
			mes "Would you like to disable it?";
			menu "Yes",DeactivateMob,"No",AnnounceMenu;

DeactivateMob:
			next;
			mes .npcname$;
			mes "The Mob Announcer has been deactivated.";
			set $mobactive,0; // Define the Mob Announcer as "inactive"
			goto AnnounceMenu;
		} else {
			next;
			mes .npcname$;
			mes "Would you like to enable the Mob Announcer?";
			mes "This will broadcast player deaths when they're killed by monsters.";
			menu "Yes",ActivateMob,"No",AnnounceMenu;

ActivateMob:
			next;
			mes .npcname$;
			mes "The Mob Announcer has been activated.";
			set $pkactive,0; // Define the PK Announcer as "inactive"
			set $mobactive,1; // Define the Mob Announcer as "active"
			goto AnnounceMenu;
		}

PKAnnouncer:
		if ($flavor != 1) { // Check if Flavor Text has been defined yet
			next;
			mes .npcname$;
			mes "I'm sorry, but you haven't set the Flavor Text yet!";
			next;
			goto AnnounceMenu;
		} else {
			if ($pkactive == 1) {
				next;
				mes .npcname$;
				mes "The PK Announcer is currently active.";
				mes "Would you like to disable it?";
				menu "Yes",DeactivatePK,"No",AnnounceMenu;

DeactivatePK:
				next;
				mes .npcname$;
				mes "The PK Announcer has been deactivated.";
				set $pkactive,0; // Define the PK Announcer as "inactive"
				goto AnnounceMenu;
			} else {
				next;
				mes .npcname$;
				mes "Would you like to enable the PK Announcer?";
				mes "This will broadcast player deaths when they're killed by other players.";
				menu "Yes",ActivatePK,"No",AnnounceMenu;

ActivatePK:
				next;
				mes .npcname$;
				mes "The PK Announcer has been activated.";
				set $mobactive,0; // Define the Mob Announcer as "inactive"
				set $pkactive,1; // Define the PK Announcer as "active"
				goto AnnounceMenu;
			}

			// Announcers
OnPCDieEvent:
			if ($mobactive == 1) {announce strcharinfo(0) +" "+ @FlavorText$ +"!",bc_map;}
			end;
OnPCKillEvent:
			if ($pkactive == 1) {set .@name$, strcharinfo(0);attachrid killedrid;announce strcharinfo(0)+" "+@FlavorText$+" by "+.@name$+"!",bc_map;}
			end;
		}
	}
} else {dispbottom "You are not authorized to use this feature.";end;}
}

Edited by Brian
[codebox]
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Well I post my fix too I also have try lol

-    script    death    -1,{

OnWhisperGlobal:
   if( getgmlevel() < 40 ) {
       dispbottom "You are not authorized to use this feature.";    // Reject player access
       end;
   }
   set .@npcname$,"[Death Announcer]";    // Define the NPC's name

AnnounceMenu:
   mes .@npcname$;
   mes "There are several settings for this controller.";
   mes "Only one announcer may be active at all times.";
   mes "What would you like to do?";
   menu "Set Flavor Text",FlavorText,"Mob Announcer",MobAnnouncer,"PK Announcer",PKAnnouncer,"Nothing",-;
   close;

FlavorText:
   next;
   mes .@npcname$;
   mes "Pleae input the text you would like to appear when a player is killed.";
   mes "^AAAAAAExample: Player <had his brains eaten>!^000000"; // $FlavorText$ would replace < >
   input .@test$;

   next;
   mes .@npcname$;
   mes "The message that will be broadcasted when a player dies is:";
   mes "^FF0000Player "+ .@test$ +"!^000000";
   mes " ";
   mes "Is that correct?";

   next;
   menu "Yes, that's fine",CorrectFlavor,"No, let me change it",FlavorText,"Nevermind",-;
   close;

CorrectFlavor:
   set $FlavorText$, .@test$;
   set $global_flavor, $global_flavor | 1;    // At this point, Flavor Text has been defined
   goto AnnounceMenu;

MobAnnouncer:
   if( $global_flavor & 1 ) {    // Check if Flavor Text has been defined yet
       if( $global_flavor & 2 ) {
           next;
           mes .@npcname$;
           mes "The Mob Announcer is currently active.";
           mes "Would you like to disable it?";
           next;
           menu "Yes",-,"No",AnnounceMenu;

           mes .@npcname$;
           mes "The Mob Announcer has been deactivated.";
       } else {
           next;
           mes .@npcname$;
           mes "Would you like to enable the Mob Announcer?";
           mes "This will broadcast player deaths when they're killed by monsters.";
           next;
           menu "Yes",-,"No",AnnounceMenu;

           mes .@npcname$;
           mes "The Mob Announcer has been activated.";
           if( $global_flavor & 4 )
               set $global_flavor, $global_flavor ^ 4;    // Define the PK Announcer as "inactive" / "active"
       }
       set $global_flavor, $global_flavor ^ 2;    // Define the Mob Announcer as "active"/"inactive"
   } else {
       next;
       mes .@npcname$;
       mes "I'm sorry, but you haven't set the Flavor Text yet!";
   }
   next;
   goto AnnounceMenu;

PKAnnouncer:
   if( $global_flavor & 1 ) {    // Check if Flavor Text has been defined yet
       if( $global_flavor & 4 ) {
           next;
           mes .@npcname$;
           mes "The PK Announcer is currently active.";
           mes "Would you like to disable it?";
           next;
           menu "Yes",-,"No",AnnounceMenu;

           mes .@npcname$;
           mes "The PK Announcer has been desactivated.";
       } else {
           next;
           mes .@npcname$;
           mes "Would you like to enable the PK Announcer?";
           mes "This will broadcast player deaths when they're killed by other players.";
           next;
           menu "Yes",-,"No",AnnounceMenu;

           mes .@npcname$;
           mes "The PK Announcer has been activated.";
           if( $global_flavor & 2 )
               set $global_flavor, $global_flavor ^ 2;    // Define the Mob Announcer as "inactive" / "active"
       }
       set $global_flavor, $global_flavor ^ 4;    // Define the PK Announcer as "inactive" / "active"
   } else {
       next;
       mes .@npcname$;
       mes "I'm sorry, but you haven't set the Flavor Text yet!";
   }
   next;
   goto AnnounceMenu;

// Announcers
OnPCDieEvent:
   if( $global_flavor & 2 && killerrid > 3000000 )
       announce strcharinfo(0) + $FlavorText$ +"!",bc_map;    // Announce player death by monster
   end;

OnPCKillEvent:
   if( $global_flavor & 4 ) {
       set .@name$, strcharinfo(0);
       attachrid killedrid;
       announce strcharinfo(0)+" "+$FlavorText$+" by "+.@name$+"!",bc_map;    // Announce player death by PK
   }
   end;

}

but it's excluding the @FlavorText$ input and announces twice;

"@" - A temporary variable attached to the character.

@FlavorText$ was only attached to your GM.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Ahh should it be global or npc scope?

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Other variables are permanent - like $mobactive in his script. If he log out, @FlavorText$ will be empty >> troublesome.

If he doesn't often change its setting, npc scope and set option in his NPC would be better.

If he doesn't want to be bored, global permanent scope.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  127
  • Reputation:   36
  • Joined:  01/21/13
  • Last Seen:  

Thanks a million Capuche; your revision got the main functions working, and I only came across a few problems:

  • The NPC broadcasts regardless of where you were killed
  • Missing a "space" when the player is announced dead by monster kill
  • The broadcaster cannot be reset

What I did:

  • Added a setting to allow the GM to define what map would be broadcasted on
  • Added a check to make sure a map was defined
  • Changed the announcements to only be broadcasted on the defined map
  • Added a check to make sure the person killed was on the defined map before announcing
  • Added a status dialogue upon calling the NPC to display which modes are active on what map
  • Add a reset option to completely reset the NPC for the next GM to use
  • Added status display in the menu to show changes made instantly

Again, thank you; you've been a big help. I've released the finished version for free in the Script Releases forum. Enjoy! (:

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