Skip to content

Commit eaf7810

Browse files
committed
Saving progress so far: PARTY object - script updates - ephemeral rooms - procedural mazes
1 parent d21fa12 commit eaf7810

File tree

30 files changed

+1768
-130
lines changed

30 files changed

+1768
-130
lines changed

_datafiles/guides/building/scripting/FUNCTIONS_ACTORS.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ActorObjects are the basic object that represents Users and NPCs
1616
- [ActorObject.GetLevel() int](#actorobjectgetlevel-int)
1717
- [ActorObject.GetStat(statName string) int](#actorobjectgetstatstatname-string-int)
1818
- [ActorObject.SetTempData(key string, value any)](#actorobjectsettempdatakey-string-value-any)
19+
- [ActorObject.SetResetRoomId(roomId int)](#actorobjectsetresetroomidroomid-int)
1920
- [ActorObject.GetTempData(key string) any](#actorobjectgettempdatakey-string-any)
2021
- [ActorObject.SetMiscCharacterData(key string, value any)](#actorobjectsetmisccharacterdatakey-string-value-any)
2122
- [ActorObject.GetMiscCharacterData(key string) any](#actorobjectgetmisccharacterdatakey-string-any)
@@ -25,16 +26,19 @@ ActorObjects are the basic object that represents Users and NPCs
2526
- [ActorObject.GetRoomId() int](#actorobjectgetroomid-int)
2627
- [ActorObject.HasQuest(questId string) bool](#actorobjecthasquestquestid-string-bool)
2728
- [ActorObject.GiveQuest(questId string)](#actorobjectgivequestquestid-string)
28-
- [ActorObject.GetPartyMembers() \[\]Actor](#actorobjectgetpartymembers-actor)
29+
- [ActorObject.GetParty(\[excludeSelf bool\])](#actorobjectgetpartyexcludeself-bool)
30+
- [ActorObject.GetPartyPresent(\[excludeSelf bool\])](#actorobjectgetpartypresentexcludeself-bool)
31+
- [ActorObject.GetPartyMissing()](#actorobjectgetpartymissing)
2932
- [ActorObject.AddGold(amt int \[, bankAmt int\])](#actorobjectaddgoldamt-int--bankamt-int)
3033
- [ActorObject.AddHealth(amt int) int](#actorobjectaddhealthamt-int-int)
34+
- [ActorObject.AddMana(amt int) int](#actorobjectaddmanaamt-int-int)
3135
- [ActorObject.Sleep(seconds int)](#actorobjectsleepseconds-int)
3236
- [ActorObject.Command(cmd string \[, waitTurns int\])](#actorobjectcommandcmd-string--waitturns-int)
3337
- [ActorObject.CommandFlagged(cmd string, flag int \[, waitTurns int\])](#actorobjectcommandflaggedcmd-string-flag-int--waitturns-int)
3438
- [ActorObject.IsTameable() bool](#actorobjectistameable-bool)
3539
- [ActorObject.TrainSkill(skillName string, skillLevel int)](#actorobjecttrainskillskillname-string-skilllevel-int)
3640
- [ActorObject.GetSkillLevel(skillName string)](#actorobjectgetskilllevelskillname-string)
37-
- [ActorObject.MoveRoom(destRoomId int \[, leaveCharmedMobsBehind bool\] )](#actorobjectmoveroomdestroomid-int--leavecharmedmobsbehind-bool-)
41+
- [ActorObject.MoveRoom(destRoomId int )](#actorobjectmoveroomdestroomid-int-)
3842
- [ActorObject.UpdateItem(itemId ItemObject)](#actorobjectupdateitemitemid-itemobject)
3943
- [ActorObject.GiveItem(itemId ItemObject)](#actorobjectgiveitemitemid-itemobject)
4044
- [ActorObject.TakeItem(itemId ItemObject)](#actorobjecttakeitemitemid-itemobject)
@@ -118,7 +122,7 @@ Retrieves a ActorObject for a given mobInstanceId.
118122
| createIfMissing | If true and mob isn't found, the mob will be created and returned. |
119123

120124
## [ActorObject.UserId() int](/internal/scripting/actor_func.go)
121-
Returns the userId of the ActorObject.˚
125+
Returns the userId of the ActorObject.
122126

123127
_Note: Only useful for User ActorObjects - Returns zero otherwise._
124128

@@ -173,6 +177,16 @@ _Note: This is useful for saving/retrieving data that an ActorObject can carry a
173177
| key | A unique identifier for the data. |
174178
| value | What you will be saving. If null, frees from memory. |
175179

180+
## [ActorObject.SetResetRoomId(roomId int)](/internal/scripting/actor_func.go)
181+
Sets the "Reset Room Id" a player will be sent to if they log out.
182+
183+
_Note: This is only useful if the player is being sent to an ephemeral chunk._
184+
185+
| Argument | Explanation |
186+
| --- | --- |
187+
| roomId | The RoomId the player should be sent to. |
188+
189+
176190
## [ActorObject.GetTempData(key string) any](/internal/scripting/actor_func.go)
177191
Gets temporary data for the ActorObject.
178192

@@ -235,14 +249,28 @@ Get whether a ActorObject has a quest/progress.
235249
| questId | The quest identifier string to check, such as `3-start`. |
236250

237251
## [ActorObject.GiveQuest(questId string)](/internal/scripting/actor_func.go)
238-
Grants a quest or progress on a quest to a ActorObject. If they are in a party, grants to the party members as well.
252+
Grants a quest or progress on a quest to a ActorObject.
239253

240254
| Argument | Explanation |
241255
| --- | --- |
242256
| questId | The quest identifier string to give, such as `3-start`. |
243257

244-
## [ActorObject.GetPartyMembers() []Actor](/internal/scripting/actor_func.go)
245-
Returns a list of actors in the party, both players and mobs.
258+
## [ActorObject.GetParty([excludeSelf bool])](/internal/scripting/actor_func.go)
259+
Returns a Party object that operates on the entire party and charmed mobs.
260+
261+
| Argument | Explanation |
262+
| --- | --- |
263+
| excludeSelf | If true, excludes the actor from the operating list. |
264+
265+
## [ActorObject.GetPartyPresent([excludeSelf bool])](/internal/scripting/actor_func.go)
266+
Returns a Party object that operates on the party members and charmed mobs in the same room.
267+
268+
| Argument | Explanation |
269+
| --- | --- |
270+
| excludeSelf | If true, excludes the actor from the operating list. |
271+
272+
## [ActorObject.GetPartyMissing()](/internal/scripting/actor_func.go)
273+
Returns a Party object that operates on the party members and charmed mobs missing from the room.
246274

247275
## [ActorObject.AddGold(amt int [, bankAmt int])](/internal/scripting/actor_func.go)
248276
Update how much gold an ActorObject has
@@ -259,6 +287,13 @@ Update how much health an ActorObject has, and returns the actual amount their h
259287
| --- | --- |
260288
| amt | A positive or negative amount of health to alter the actors health by. |
261289

290+
## [ActorObject.AddMana(amt int) int](/internal/scripting/actor_func.go)
291+
Update how much mana an ActorObject has, and returns the actual amount their mana changed.
292+
293+
| Argument | Explanation |
294+
| --- | --- |
295+
| amt | A positive or negative amount of mana to alter the actors mana by. |
296+
262297

263298
## [ActorObject.Sleep(seconds int)](/internal/scripting/actor_func.go)
264299
Force a mob to wait this many seconds before executing any additional behaviors
@@ -309,13 +344,14 @@ Returns the current skil level for the skillName, or zero if none.
309344
| skillName | The name of the skill to train, such as `map` or `backstab`. |
310345

311346

312-
## [ActorObject.MoveRoom(destRoomId int [, leaveCharmedMobsBehind bool] )](/internal/scripting/actor_func.go)
347+
## [ActorObject.MoveRoom(destRoomId int )](/internal/scripting/actor_func.go)
313348
Quietly moves an ActorObject to a new room
314349

315350
| Argument | Explanation |
316351
| --- | --- |
317352
| destRoomId | The room id to move them to. |
318-
| leaveCharmedMobsBehind | If true, does not also move charmed mobs with the user. |
353+
354+
319355

320356
## [ActorObject.UpdateItem(itemId ItemObject)](/internal/scripting/actor_func.go)
321357
Accepts an ItemObject to update in the players backpack. If the item does not already exist in the players backpack, it is ignored.
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# PartyObject
2+
3+
PartyObjects represent collections of actors (users and NPCs) that are grouped together. They provide convenient methods to perform operations on multiple actors at once.
4+
5+
- [PartyObject](#partyobject)
6+
- [PartyObject.GetMembers() \[\]ActorObject](#partyobjectgetmembers-actorobject)
7+
- [PartyObject.SendText(msg string)](#partyobjectsendtextmsg-string)
8+
- [PartyObject.SetResetRoomId(roomId int)](#partyobjectsetresetroomidroomid-int)
9+
- [PartyObject.GiveQuest(questId string)](#partyobjectgivequestquestid-string)
10+
- [PartyObject.AddGold(amt int \[, bankAmt int\])](#partyobjectaddgoldamt-int--bankamt-int)
11+
- [PartyObject.AddHealth(amt int)](#partyobjectaddhealthamt-int)
12+
- [PartyObject.AddMana(amt int)](#partyobjectaddmanaamt-int)
13+
- [PartyObject.Command(cmd string \[, waitSeconds float\])](#partyobjectcommandcmd-string--waitseconds-float)
14+
- [PartyObject.TrainSkill(skillName string, skillLevel int)](#partyobjecttrainskillskillname-string-skilllevel-int)
15+
- [PartyObject.MoveRoom(destRoomId int)](#partyobjectmoveroomdestroomid-int)
16+
- [PartyObject.AddEventLog(category string, message string)](#partyobjectaddeventlogcategory-string-message-string)
17+
- [PartyObject.GiveBuff(buffId int, source string)](#partyobjectgivebuffbuffid-int-source-string)
18+
- [PartyObject.CancelBuffWithFlag(buffFlag string)](#partyobjectcancelbuffwithflagbuffflag-string)
19+
- [PartyObject.RemoveBuff(buffId int)](#partyobjectremovebuffbuffid-int)
20+
- [PartyObject.ChangeAlignment(alignmentChange int)](#partyobjectchangealignmentalignmentchange-int)
21+
- [PartyObject.LearnSpell(spellId string)](#partyobjectlearnspellspellid-string)
22+
- [PartyObject.SetHealth(amt int)](#partyobjectsethealthamt-int)
23+
- [PartyObject.SetAdjective(adj string, addIt bool)](#partyobjectsetadjectiveadj-string-addit-bool)
24+
- [PartyObject.GiveTrainingPoints(ct int)](#partyobjectgivetrainingpointsct-int)
25+
- [PartyObject.GiveStatPoints(ct int)](#partyobjectgivestatpointsct-int)
26+
- [PartyObject.GiveExtraLife()](#partyobjectgiveextralife)
27+
- [PartyObject.GrantXP(xpAmt int, reason string)](#partyobjectgrantxpxpamt-int-reason-string)
28+
- [PartyObject.TimerSet(name string, period string)](#partyobjecttimersetname-string-period-string)
29+
30+
31+
32+
33+
## [PartyObject.GetMembers() []ActorObject](/internal/scripting/party_func.go)
34+
Returns an array of all ActorObjects in the party based on the party configuration.
35+
36+
_Note: This includes both party members and their charmed creatures, filtered by presence/absence based on how the party object was created._
37+
38+
## [PartyObject.SendText(msg string)](/internal/scripting/party_func.go)
39+
Sends a message to all members of the party.
40+
41+
| Argument | Explanation |
42+
| --- | --- |
43+
| msg | the message to send to all party members |
44+
45+
## [PartyObject.SetResetRoomId(roomId int)](/internal/scripting/party_func.go)
46+
Sets the "Reset Room Id" for all user party members (where they will be sent if they log out).
47+
48+
_Note: Only affects user party members, not NPCs. This is only useful if players are being sent to ephemeral chunks._
49+
50+
| Argument | Explanation |
51+
| --- | --- |
52+
| roomId | The RoomId all party members should be sent to |
53+
54+
## [PartyObject.GiveQuest(questId string)](/internal/scripting/party_func.go)
55+
Grants a quest or progress on a quest to all party members.
56+
57+
| Argument | Explanation |
58+
| --- | --- |
59+
| questId | The quest identifier string to give, such as `3-start` |
60+
61+
## [PartyObject.AddGold(amt int [, bankAmt int])](/internal/scripting/party_func.go)
62+
Updates how much gold all party members have.
63+
64+
| Argument | Explanation |
65+
| --- | --- |
66+
| amt | A positive or negative amount of gold to alter each party member's gold by |
67+
| bankAmt (optional) | A positive or negative amount of gold to alter each party member's bank gold by |
68+
69+
## [PartyObject.AddHealth(amt int)](/internal/scripting/party_func.go)
70+
Updates how much health all party members have.
71+
72+
| Argument | Explanation |
73+
| --- | --- |
74+
| amt | A positive or negative amount of health to alter each party member's health by |
75+
76+
## [PartyObject.AddMana(amt int)](/internal/scripting/party_func.go)
77+
Updates how much mana all party members have.
78+
79+
| Argument | Explanation |
80+
| --- | --- |
81+
| amt | A positive or negative amount of mana to alter each party member's mana by |
82+
83+
## [PartyObject.Command(cmd string [, waitSeconds float])](/internal/scripting/party_func.go)
84+
Forces all party members to execute a command as if they entered it.
85+
86+
_Note: Don't underestimate the power of this function! Complex and interesting behaviors or interactions can emerge from using it._
87+
88+
| Argument | Explanation |
89+
| --- | --- |
90+
| cmd | The command to execute such as `look west` or `say goodbye` |
91+
| waitSeconds (optional) | The number of seconds to wait before executing the command |
92+
93+
## [PartyObject.TrainSkill(skillName string, skillLevel int)](/internal/scripting/party_func.go)
94+
Sets a skill level for all party members, if it's greater than what they already have.
95+
96+
| Argument | Explanation |
97+
| --- | --- |
98+
| skillName | The name of the skill to train, such as `map` or `backstab` |
99+
| skillLevel | The skill level to train to |
100+
101+
## [PartyObject.MoveRoom(destRoomId int)](/internal/scripting/party_func.go)
102+
Quietly moves all party members to a new room.
103+
104+
| Argument | Explanation |
105+
| --- | --- |
106+
| destRoomId | The room id to move them all to |
107+
108+
## [PartyObject.AddEventLog(category string, message string)](/internal/scripting/party_func.go)
109+
Adds a line to all party members' Event Log (`history`).
110+
111+
| Argument | Explanation |
112+
| --- | --- |
113+
| category | A short single word category |
114+
| message | A single line describing the event |
115+
116+
## [PartyObject.GiveBuff(buffId int, source string)](/internal/scripting/party_func.go)
117+
Grants all party members a Buff.
118+
119+
| Argument | Explanation |
120+
| --- | --- |
121+
| buffId | The ID of the buff to give them |
122+
| source | The source of the buff, "item", "spell", "trap", "curse", etc. or empty |
123+
124+
## [PartyObject.CancelBuffWithFlag(buffFlag string)](/internal/scripting/party_func.go)
125+
Cancels any buffs that have the flag provided for all party members.
126+
127+
| Argument | Explanation |
128+
| --- | --- |
129+
| buffFlag | The buff flag to check [see buffspec.go](../buffs/buffspec.go) |
130+
131+
## [PartyObject.RemoveBuff(buffId int)](/internal/scripting/party_func.go)
132+
Remove a buff from all party members without triggering onEnd.
133+
134+
| Argument | Explanation |
135+
| --- | --- |
136+
| buffId | The ID of the buff to remove |
137+
138+
## [PartyObject.ChangeAlignment(alignmentChange int)](/internal/scripting/party_func.go)
139+
Updates the alignment of all party members by a relative amount. Caps result at -100 to 100.
140+
141+
| Argument | Explanation |
142+
| --- | --- |
143+
| alignmentChange | The alignment adjustment, from -200 to 200 |
144+
145+
## [PartyObject.LearnSpell(spellId string)](/internal/scripting/party_func.go)
146+
Adds the spell to all party members' spellbooks.
147+
148+
| Argument | Explanation |
149+
| --- | --- |
150+
| spellId | The ID of the spell |
151+
152+
## [PartyObject.SetHealth(amt int)](/internal/scripting/party_func.go)
153+
Sets all party members' health to a specific amount. If this exceeds their maximum health, sets to their maximum health.
154+
155+
| Argument | Explanation |
156+
| --- | --- |
157+
| amt | number of hitpoints to set them to |
158+
159+
## [PartyObject.SetAdjective(adj string, addIt bool)](/internal/scripting/party_func.go)
160+
Adds or removes a specific text adjective to all party members' names.
161+
162+
| Argument | Explanation |
163+
| --- | --- |
164+
| adj | Adjective such as "sleeping", "crying" or "busy" |
165+
| addIt | `true` to add it. `false` to remove it |
166+
167+
## [PartyObject.GiveTrainingPoints(ct int)](/internal/scripting/party_func.go)
168+
Increases training points for all party members.
169+
170+
| Argument | Explanation |
171+
| --- | --- |
172+
| ct | How many training points to give |
173+
174+
## [PartyObject.GiveStatPoints(ct int)](/internal/scripting/party_func.go)
175+
Increases stat points for all party members.
176+
177+
| Argument | Explanation |
178+
| --- | --- |
179+
| ct | How many stat points to give |
180+
181+
## [PartyObject.GiveExtraLife()](/internal/scripting/party_func.go)
182+
Increases extra lives by 1 for all party members.
183+
184+
## [PartyObject.GrantXP(xpAmt int, reason string)](/internal/scripting/party_func.go)
185+
Gives experience points to all party members.
186+
187+
| Argument | Explanation |
188+
| --- | --- |
189+
| xpAmt | How much experience to grant |
190+
| reason | Short reasons such as "combat", "trash cleanup" |
191+
192+
## [PartyObject.TimerSet(name string, period string)](/internal/scripting/party_func.go)
193+
Starts a new Round timer for all party members.
194+
195+
| Argument | Explanation |
196+
| --- | --- |
197+
| name | A string identifier. Reusing names will overwrite previously assigned names |
198+
| period | How long until the timer expires. `1 real hour`, `1 hour`, etc |

_datafiles/guides/building/scripting/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ See [Spell Scripting](SCRIPTING_SPELLS.md)
2121

2222
[ActorObject Functions](FUNCTIONS_ACTORS.md) - Functions that query or alter user/mob data.
2323

24+
[ActorObject Functions](FUNCTIONS_PARTY.md) - Functions that operate on the whole party.
25+
2426
[RoomObject Functions](FUNCTIONS_ROOMS.md) - Functions that query or alter room data.
2527

2628
[ItemObject Functions](FUNCTIONS_ITEMS.md) - Functions that query or alter item data.

_datafiles/sample-scripts/mobs/item-gold-quest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function onAsk(mob, room, eventDetails) {
5555
//
5656
// Give them the start quest id
5757
//
58-
user.GiveQuest(QUEST_START_ID);
58+
user.GetParty().GiveQuest(QUEST_START_ID);
5959

6060
}
6161

@@ -129,7 +129,7 @@ function onGive(mob, room, eventDetails) {
129129
//
130130
// Give them the next step of the quest
131131
//
132-
user.GiveQuest(QUEST_NEXT_STEP_ID);
132+
user.GetParty().GiveQuest(QUEST_NEXT_STEP_ID);
133133

134134
return true;
135135
}
@@ -179,7 +179,7 @@ function onGive(mob, room, eventDetails) {
179179
//
180180
// They have now completed the entire quest, all steps are complete.
181181
//
182-
user.GiveQuest(QUEST_END_ID);
182+
user.GetParty().GiveQuest(QUEST_END_ID);
183183

184184
return true;
185185
}

_datafiles/world/default/mobs/frostfang/scripts/2-guard-hungry.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function onAsk(mob, room, eventDetails) {
2323
mob.Command("say I forgot my lunch today, and I'm so hungry.");
2424
mob.Command("say Do you think you could find a cheese sandwich for me?");
2525

26-
user.GiveQuest("4-start");
26+
user.GetParty().GiveQuest("4-start");
2727

2828
} else if ( user.HasQuest("4-end") ) {
2929
mob.Command("sayto @" + String(user.UserId()) + " Thanks, but you've done enough. Too much, really.");
@@ -70,7 +70,7 @@ function onGive(mob, room, eventDetails) {
7070

7171
if ( user.HasQuest("4-start") ) {
7272

73-
user.GiveQuest("4-end");
73+
user.GetParty().GiveQuest("4-end");
7474
mob.Command("say Thanks! I can get on with my day now.");
7575
mob.Command("eat !"+String(eventDetails.item.ItemId) );
7676

_datafiles/world/default/mobs/frostfang/scripts/26-frostfang_citizen-locketsadness.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function onAsk(mob, room, eventDetails) {
3030
mob.Command("emote sighs deeply.");
3131
mob.Command("say I lost my locket. I think it was when I was gardening.");
3232

33-
user.GiveQuest("1-start");
33+
user.GetParty().GiveQuest("1-start");
3434

3535
return true;
3636
}
@@ -78,7 +78,7 @@ function onGive(mob, room, eventDetails) {
7878
mob.Command("give !20033 @" + String(eventDetails.sourceId)); // Give it to the player using shorthand
7979
}
8080

81-
user.GiveQuest("1-end");
81+
user.GetParty().GiveQuest("1-end");
8282

8383
return true;
8484

_datafiles/world/default/mobs/frostfang/scripts/26-frostfang_citizen-rattrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function onAsk(mob, room, eventDetails) {
1919

2020
mob.Command("say Thanks for picking it up!");
2121

22-
user.GiveQuest("7-gettrap");
22+
user.GetParty().GiveQuest("7-gettrap");
2323

2424
return true;
2525
}

0 commit comments

Comments
 (0)