Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions _datafiles/guides/building/scripting/FUNCTIONS_ACTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ActorObjects are the basic object that represents Users and NPCs
- [ActorObject](#actorobject)
- [ActorNames(actors \[\]ActorObject) string ](#actornamesactors-actorobject-string-)
- [GetUser(userId int) ActorObject ](#getuseruserid-int-actorobject-)
- [GetMob(mobInstanceId int) ActorObject ](#getmobmobinstanceid-int-actorobject-)
- [GetMob(mobInstanceId int \[,createIfMissing bool\]) ActorObject ](#getmobmobinstanceid-int-createifmissing-bool-actorobject-)
- [ActorObject.UserId() int](#actorobjectuserid-int)
- [ActorObject.InstanceId() int](#actorobjectinstanceid-int)
- [ActorObject.MobTypeId() int](#actorobjectmobtypeid-int)
Expand Down Expand Up @@ -104,12 +104,13 @@ Retrieves a ActorObject for a given userId.
| --- | --- |
| userId | The target user id to get. |

## [GetMob(mobInstanceId int) ActorObject ](/internal/scripting/actor_func.go)
## [GetMob(mobInstanceId int [,createIfMissing bool]) ActorObject ](/internal/scripting/actor_func.go)
Retrieves a ActorObject for a given mobInstanceId.

| Argument | Explanation |
| --- | --- |
| mobInstanceId | The target mobInstanceId to get. |
| createIfMissing | If true and mob isn't found, the mob will be created and returned. |

## [ActorObject.UserId() int](/internal/scripting/actor_func.go)
Returns the userId of the ActorObject.˚
Expand Down
29 changes: 23 additions & 6 deletions _datafiles/guides/building/scripting/FUNCTIONS_ROOMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
- [RoomObject.GetItems() \[\]ItemObject](#roomobjectgetitems-itemobject)
- [RoomObject.DestroyItem(itm ScriptItem) ](#roomobjectdestroyitemitm-scriptitem-)
- [RoomObject.SpawnItem(itemId int, inStash bool) \[\]ItemObject](#roomobjectspawnitemitemid-int-instash-bool-itemobject)
- [RoomObject.GetMobs() \[\]int](#roomobjectgetmobs-int)
- [RoomObject.GetPlayers() \[\]int](#roomobjectgetplayers-int)
- [RoomObject.GetMob(mobId int) Actor](#roomobjectgetmobmobid-int-actor)
- [RoomObject.GetMobs(\[mobId int\]) \[\]Actor](#roomobjectgetmobsmobid-int-actor)
- [RoomObject.GetPlayers() \[\]Actor](#roomobjectgetplayers-actor)
- [RoomObject.GetAllActors() \[\]Actor](#roomobjectgetallactors-actor)
- [RoomObject.GetContainers() \[\]string](#roomobjectgetcontainers-string)
- [RoomObject.GetExits() \[\]object](#roomobjectgetexits-object)
- [GetMap(mapRoomId int, mapZoom, mapHeight int, mapWidth int, mapName string, showSecrets bool \[,mapMarker string, mapMarker string\]) string](#getmapmaproomid-int-mapzoom-mapheight-int-mapwidth-int-mapname-string-showsecrets-bool-mapmarker-string-mapmarker-string-string)
Expand Down Expand Up @@ -113,11 +115,26 @@ Spawns an item in the room.
| itemId | ItemId to spawn. |
| inStash | If true, spawns stashed instead of visible. |

## [RoomObject.GetMobs() []int](/internal/scripting/room_func.go)
Returns an array of `mobInstanceIds` in the room.

## [RoomObject.GetPlayers() []int](/internal/scripting/room_func.go)
Returns an array of `userIds` in the room.
## [RoomObject.GetMob(mobId int) Actor](/internal/scripting/room_func.go)
Returns the first mob that matches the provided MobId type (Note: NOT MOB INSTANCE ID!)

| Argument | Explanation |
| --- | --- |
| mobId | MobId to match. |

## [RoomObject.GetMobs([mobId int]) []Actor](/internal/scripting/room_func.go)
Returns an array of mob `Actor`s in the room.

| Argument | Explanation |
| --- | --- |
| mobId (optional) | Only get mobs of the provided MobId type. (Note: NOT MOB INSTANCE ID!) |

## [RoomObject.GetPlayers() []Actor](/internal/scripting/room_func.go)
Returns an array of player `Actor`s in the room.

## [RoomObject.GetAllActors() []Actor](/internal/scripting/room_func.go)
Returns an array of all `Actor`s in the room.

## [RoomObject.GetContainers() []string](/internal/scripting/room_func.go)
Gets a list of container names in the room.
Expand Down
38 changes: 38 additions & 0 deletions _datafiles/world/default/items/other-0/101-arcane_flute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

const MUSIC_DESCRIPTIONS = [
"a silvery trill dances on the breeze. ♪♪ ♫",
"a cascade of notes unravels into open air. ♫ ♪♪",
"a soft melody fills the air. ♪♫ ♪",
];

const RAT_MOB_IDS = [1, 12];

function onCommand_play(user, item, room) {

var randomPhrase = MUSIC_DESCRIPTIONS[UtilDiceRoll(1, MUSIC_DESCRIPTIONS.length)-1];

if ( UtilIsDay() ) {
SendUserMessage(user.UserId(), "You attempt to play the flute, but only succeed in producing a shrill noise");
SendRoomMessage(room.RoomId(), user.GetCharacterName(true)+" attempts to play their <ansi fg=\"item\">"+item.Name(true)+"</ansi> and a horrible, shrill sound fills the air.", user.UserId());

return true;
}

SendUserMessage(user.UserId(), "You surprisingly find yourself able to play the flute effortlessly, and "+randomPhrase);
SendRoomMessage(room.RoomId(), user.GetCharacterName(true)+" plays their <ansi fg=\"item\">"+item.Name(true)+"</ansi> and "+randomPhrase, user.UserId());

// NOTE: This is not charming the mob. This is a special pacify and force follow.
// The rats will not follow the behavior of charmed mobs.
for( var i in RAT_MOB_IDS ) {
var ratMobs = room.GetMobs(RAT_MOB_IDS[i]);
for ( var j in ratMobs ) {
ratMobs[j].Command(`break`); // Break off any combat
ratMobs[j].Command(`follow ` + user.ShorthandId() + ` sunrise`); // follow whoever played the flute until sunrise
ratMobs[j].ChangeAlignment(user.GetAlignment()); // Set alignment to the flute player
}
}


return true;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
itemid: 101
value: 10000
hands: 0
name: arcane flute
namesimple: arcane flute
description: A flute with faintly glowing markings all along it. Maybe you can <ansi fg="command">play</ansi> it.
type: object
subtype: generic
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hostile: false
groups:
- frostfang-npc
idlecommands:
- 'say type `list` to see my wares'
- 'say type <ansi fg="command">list</ansi> to see my wares'
- 'say If you''re looking to sell something, I may be interested... as long as it''s not too special or unique'
- emote is counting his coins
- emote watches you carefully
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hostile: false
groups:
- frostfang-npc
idlecommands:
- 'say type `list` to see my wares'
- 'say type <ansi fg="command">list</ansi> to see my wares'
- 'say If you''re looking to sell something, I may be interested... as long as it''s not too special or unique'
- emote shuffles some papers
- emote is counting her coins
Expand Down
2 changes: 1 addition & 1 deletion _datafiles/world/default/mobs/frostfang/5-armorer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hostile: false
groups:
- frostfang-npc
idlecommands:
- 'say type `list` to see my wares'
- 'say type <ansi fg="command">list</ansi> to see my wares'
- 'say If you''re looking to sell something, I may be interested... as long as it''s not too special or unique'
- emote shuffles some papers
- emote is counting his coins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hostile: false
groups:
- frostfang-npc
idlecommands:
- 'say type `list` to see what magical objects I have for sale'
- 'say type <ansi fg="command">list</ansi> to see what magical objects I have for sale'
activitylevel: 10
character:
name: moilyn the wizard
Expand Down
5 changes: 2 additions & 3 deletions _datafiles/world/default/mobs/mystarion/46-herbalist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ groups:
- mystarion-npc
activitylevel: 40
idlecommands:
- say type `list` to see my wares
- say If you're looking to sell something, I may be interested... as long as it's
not too special or unique
- say type <ansi fg="command">list</ansi> to see my wares
- say If you're looking to sell something, I may be interested... as long as it's not too special or unique
- emote is watching you
combatcommands:
- 'say How dare you attack the citizens of Mystarion! We do not forget!'
Expand Down
5 changes: 2 additions & 3 deletions _datafiles/world/default/mobs/mystarion/47-brewer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ groups:
- mystarion-npc
activitylevel: 40
idlecommands:
- say type `list` to see my wares
- say If you're looking to sell something, I may be interested... as long as it's
not too special or unique
- say type <ansi fg="command">list</ansi> to see my wares
- say If you're looking to sell something, I may be interested... as long as it's not too special or unique
- emote is watching you
combatcommands:
- 'say How dare you attack the citizens of Mystarion! We do not forget!'
Expand Down
5 changes: 2 additions & 3 deletions _datafiles/world/default/mobs/mystarion/48-gardener.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ groups:
- mystarion-npc
activitylevel: 40
idlecommands:
- say type `list` to see my wares
- say If you're looking to sell something, I may be interested... as long as it's
not too special or unique
- say type <ansi fg="command">list</ansi> to see my wares
- say If you're looking to sell something, I may be interested... as long as it's not too special or unique
- emote is watching you
combatcommands:
- 'say How dare you attack the citizens of Mystarion! We do not forget!'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ groups:
- mystarion-npc
activitylevel: 40
idlecommands:
- say type `list` to see my wares
- say If you're looking to sell something, I may be interested... as long as it's
not too special or unique
- say type <ansi fg="command">list</ansi> to see my wares
- say If you're looking to sell something, I may be interested... as long as it's not too special or unique
- emote is watching you
combatcommands:
- 'say How dare you attack the citizens of Mystarion! We do not forget!'
Expand All @@ -31,6 +30,8 @@ character:
quantitymax: 1
- itemid: 23
quantitymax: 8
- itemid: 101
quantitymax: 1
equipment:
weapon:
itemid: 10018
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,7 @@ function onDie(mob, room, eventDetails) {

room.SendText( mob.GetCharacterName(true) + " crumbles to dust." );

teacherMob = getTeacher(room);
room.GetMob(teacherMobId, true);

teacherMob.Command('say You did it! Head <ansi fg="exit">west</ansi> to complete your training.');
}


function getTeacher(room) {

var mobActor = null;

mobIds = room.GetMobs();

for (var i in mobIds ) {
mobActor = GetMob(mobIds[i]);
if ( mobActor.MobTypeId() == teacherMobId ) {
return mobActor;
}
}

mobActor = room.SpawnMob(teacherMobId);
mobActor.SetCharacterName(teacherName);

return mobActor;
}
3 changes: 1 addition & 2 deletions _datafiles/world/default/rooms/dark_forest/558.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ spawninfo:
- mobid: 43
message: A small faerie enters the clearing.
idlecommands:
- emote procures a piece of a mushrom, and with a wave of their hand, restore it
to a new mushroom.
- emote procures a piece of a mushrom, and with a wave of their hand, restore it to a new mushroom.
- emote nods to themselves, pleased with their work.
scripttag: clearing
respawnrate: 1 real minutes
25 changes: 13 additions & 12 deletions _datafiles/world/default/rooms/frostfang/166.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@

function onCommand_vault(rest, user, room) {

guard_present = false;
var presentMob = null;

mobs = room.GetMobs();
for (i = 0; i < mobs.length; i++) {
if ( (mob = GetMob(mobs[i])) == null ) {
continue;
}
var roomMobs = room.GetMobs();
for (i = 0; i < roomMobs.length; i++) {
var mob = roomMobs[i];
mobName = mob.GetCharacterName(false);
if ( mobName.indexOf("guard") !== -1 ) {
guard_present = true;
presentMob = mob;
break;
}
}

hidden = user.HasBuffFlag("hidden");

if (guard_present && !hidden) {
SendUserMessage(user.UserId(), "A guard blocks you from entering the vault.");
SendRoomMessage(room.RoomId(), "A guard blocks "+user.GetCharacterName(true)+" from entering the vault.", user.UserId());
if ( user.HasBuffFlag("hidden") ) {
return false;
}

if ( presentMob != null ) {
SendUserMessage(user.UserId(), presentMob.GetCharacterName(true) + " blocks you from entering the vault.");
SendRoomMessage(room.RoomId(), presentMob.GetCharacterName(true) + " blocks " + user.GetCharacterName(true) + " from entering the vault.", user.UserId());
presentMob.Command(`sayto ` + user.ShorthandId() + ` not on my watch, pal.`, 1.0);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion _datafiles/world/default/rooms/mirror_caves/242.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

function onCommand_out(rest, user, room) {

mobs = room.GetMobs();
var mobs = room.GetMobs();
if ( mobs.length > 0 ) {
SendUserMessage(user.UserId(), "The way out is block by denizens of the cave.");
return true;
Expand Down
35 changes: 5 additions & 30 deletions _datafiles/world/default/rooms/tutorial/900.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,52 +110,27 @@ function onEnter(user, room) {
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.', 5.0);
}


function onExit(user , room) {
// Destroy the guide (cleanup)
destroyTeacher(room);
}



function onLoad(room) {
canGoEast = false;
commandNow = 0;
}



function getTeacher(room) {

var mobActor = null;

mobIds = room.GetMobs();

for ( var i in mobIds ) {
mobActor = GetMob(mobIds[i]);
if ( mobActor.MobTypeId() == teacherMobId ) {
return mobActor;
}
}

mobActor = room.SpawnMob(teacherMobId);
var mobActor = room.GetMob(teacherMobId, true);
mobActor.SetCharacterName(teacherName);

return mobActor;
}

function destroyTeacher(room) {

var mobActor = null;

mobIds = room.GetMobs();

for ( var i in mobIds ) {
mobActor = GetMob(mobIds[i]);
if ( mobActor.MobTypeId() == teacherMobId ) {
mobActor.Command(`suicide vanish`);
}
}
var mobActor = room.GetMob(teacherMobId);
if ( mobActor != null ) {
mobActor.Command(`suicide vanish`);
}
}

function sendWorkingCommands(user) {
Expand Down
Loading
Loading