Genesis Forums
https://www.genesismud.org/forums/

Kill all <target> <2-100> alias
https://www.genesismud.org/forums/viewtopic.php?f=14&t=4185
Page 1 of 1

Author:  bashere [ 14 Nov 2017 23:37 ]
Post subject:  Kill all <target> <2-100> alias

For the Web Ui.

Enjoy!

/*
Description: Script to kill up to 100 targets. The alias requires at least
one argument, kill <human> or within single quotes 'dark elf', 'blue goblin', etc.
The second argument is used to kill a certain range of targets such as,
kill 'dark elf' 5, will attack the first 5 dark elves in the room.

Alias Command: ka
Script Type: Javascript

Synopsis:
Usage: ka target (defaults to the first 10 targets) ka target 1-100

Examples:
ka human (defaults to 10) . # this will attack the first 10 'humans' in the room
ka human 2 # will attack the first 2 humans
ka 'dark elf' 100 # will attack 100 dark elves in the room. ** Note the single quotes **

*/

var target = args[1];
var bodycount = args[2];
var special = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth'];
var deca = ['twent', 'thirt', 'fort', 'fift', 'sixt', 'sevent', 'eight', 'ninet'];

if (! bodycount) {
bodycount = 10; // Change this to modify the default number of kills
}

function stringifyNumber(n) {
if (n < 20) return special[n];
if (n%10 === 0) return deca[Math.floor(n/10)-2] + 'ieth';
return deca[Math.floor(n/10)-2] + 'y-' + special[n%10];
}

// kill up to 100
for (var i=0; i<bodycount; i++) gwc.connection.send('kill ' + (stringifyNumber(i) + ' ' + target));

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/