-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 492: Merge 597_decaying_light_source to master
Related work items: #597
- Loading branch information
Allen B. Cummings
committed
Apr 25, 2019
1 parent
7e0eb2d
commit 2d78ee6
Showing
6 changed files
with
373 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//***************************************************************************** | ||
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See | ||
// the accompanying LICENSE file for details. | ||
//***************************************************************************** | ||
inherit "/lib/environment/items/baseItem.c"; | ||
|
||
private int currentFireState; | ||
private string *fireDescriptions = ({}); | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
protected nomask varargs void addFireDescriptions(string *descriptions) | ||
{ | ||
if (pointerp(descriptions) && sizeof(descriptions) && | ||
stringp(descriptions[0])) | ||
{ | ||
fireDescriptions = descriptions + ({}); | ||
} | ||
else | ||
{ | ||
raise_error("ERROR in baseFire.c: The fire descriptions " | ||
"must be an array of strings.\n"); | ||
} | ||
} | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
public void decayFire(string state, object environment) | ||
{ | ||
remove_call_out("decayFire"); | ||
|
||
if (lightSourceIsActive(state, environment)) | ||
{ | ||
if (currentFireState <= 1) | ||
{ | ||
deactivateLightSource(state, environment); | ||
currentFireState = 0; | ||
} | ||
else | ||
{ | ||
currentFireState--; | ||
|
||
descriptionData["active light sources"][environment]["template"] = | ||
fireDescriptions[currentFireState]; | ||
descriptionData["active light sources"][environment]["magnitude"] = | ||
currentFireState; | ||
|
||
call_out("decayFire", 150, state, environment); | ||
} | ||
} | ||
} | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
protected int processLightSourceActivation(string state, object environment) | ||
{ | ||
currentFireState = 0; | ||
if (canActivateLightSource(state) && sizeof(fireDescriptions) > 1) | ||
{ | ||
currentFireState = sizeof(fireDescriptions) - 1; | ||
|
||
descriptionData["active light sources"][environment]["template"] = | ||
fireDescriptions[currentFireState]; | ||
|
||
call_out("decayFire", 150, state, environment); | ||
} | ||
return currentFireState; | ||
} | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
protected string getDescriptionFromSet() | ||
{ | ||
object environment = ((member(inherit_list(previous_object()), | ||
"lib/environments/environment.c") > -1) || !this_player()) ? | ||
previous_object() : | ||
environment(this_player()); | ||
|
||
return capitalize( | ||
(member(descriptionData, "active light sources") && | ||
member(descriptionData["active light sources"], environment)) ? | ||
descriptionData["active light sources"][environment]["template"] : | ||
getSourceOfLightTemplate(State, currentFireState, environment)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//***************************************************************************** | ||
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See | ||
// the accompanying LICENSE file for details. | ||
//***************************************************************************** | ||
inherit "/lib/environment/items/baseFire.c"; | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
public void Setup() | ||
{ | ||
Name("camp fire"); | ||
addAlias("fire"); | ||
addAlias("campfire"); | ||
suppressEntryMessage(); | ||
|
||
addDescriptionTemplate("there are charred cinders and the ashen remains " | ||
"of a small campfire"); | ||
addActiveSourceOfLight(8, "flickering tendrils of flame roil out from the " | ||
"newly-added logs of a small camp fire"); | ||
|
||
addFireDescriptions(({ | ||
"there are charred cinders and the ashen remains of a small campfire", | ||
"faint light emanates from the ashen embers of a small camp fire", | ||
"occasional flickers of red flame emanate from the faintly glowing red " | ||
"coals of a small camp fire", | ||
"faint flickers of red flame emanate from the nearly-spent logs of a " | ||
"small camp fire, its red coals feverishly glowing", | ||
"hisses come from the low flames of a small camp fire, its bed of coals " | ||
"hues of red, orange, and blue", | ||
"flames greedily wrap around the charred logs of a " | ||
"small camp fire, its bed of coals brilliant yellow and blue", | ||
"flames greedily ascend from a small camp fire that " | ||
"hisses and pops as water vapor escapes the logs it is consuming", | ||
"flickering tendrils of flame roil out from the slightly-charred logs of a " | ||
"small camp fire", | ||
"flickering tendrils of flame roil out from the newly-added logs of a " | ||
"small camp fire" | ||
})); | ||
|
||
addItemTemplate("the area around the campfire has been cleared away to " | ||
"place a barrier between the fire and other combustible objects. " | ||
"##UseDescriptionSet##"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.