outside = GetBoolean(player.parent, "outside")
inside = not outside
There are responses for "bat commands" that vary based on three separate conditions - inside/outside, time of day, and whether the bats are even there or not.
<function name="PlayerIsInside" type="boolean">
return (DoesInherit(player.parent, "InsideType"))
</function>
<type name="xaninside">
<insideroom type="script">
SetObjectFlagOn (Xanadu, "inside")
</insideroom>
</type>
<function name="PlayerIsInside" type="boolean">
return (DoesInherit(game.pov.parent, "xaninside"))
// you can replace 'game.pov.parent' with 'Xanadu.parent', if you want, though if you got other Player Objects that you switch to during your game, then you must use the 'game.pov.parent'. If you decide to change your Player's name to something else, then if you used 'Xanadu.parent', it'll obviously now produce an error (or won't work, won't do anything). Using 'game.pov.parent' is a great way to avoid all of these issues, though if you want to do stuff or apply stuff to only a specific Player Object, then you do NOT want to use the 'game.pov' for that situation, obviously.
</function>
<type name="xaninside">
</type>
<object name="example_room_x">
<inherit name="xaninside" />
</object>
// checks if the Object has the Object Type (as an 'inherited' Attribute), 'xaninside', :
<function name="PlayerIsInside" type="boolean">
return (DoesInherit(game.pov.parent, "xaninside"))
// you can replace 'game.pov.parent' with 'Xanadu.parent', if you want, though if you got other Player Objects that you switch to during your game, then you must use the 'game.pov.parent'. If you decide to change your Player's name to something else, then if you used 'Xanadu.parent', it'll obviously now produce an error (or won't work, won't do anything). Using 'game.pov.parent' is a great way to avoid all of these issues, though if you want to do stuff or apply stuff to only a specific Player Object, then you do NOT want to use the 'game.pov' for that situation, obviously.
</function>
// checks if the Object has the Boolean Attribute, 'inside', and if its value is, 'true', and then, if so, the Function returns 'true', which can then be used in a script, just like Jay's Function. Both Functions achieve the exact same thing, so here's the Function for checking the Boolean Attribute:
<function name="xxx" type="boolean">
return (GetBoolean (game.pov.parent, "inside"))
// you can replace 'game.pov.parent' with 'Xanadu.parent', if you want, though if you got other Player Objects that you switch to during your game, then you must use the 'game.pov.parent'. If you decide to change your Player's name to something else, then if you used 'Xanadu.parent', it'll obviously now produce an error (or won't work, won't do anything). Using 'game.pov.parent' is a great way to avoid all of these issues, though if you want to do stuff or apply stuff to only a specific Player Object, then you do NOT want to use the 'game.pov' for that situation, obviously.
</function>
// -----------------------------------------
// this is how to directly add the attribute:
//
// any Object that you give an Object Type to (via the 'inherited' Attribute), will get the Attributes in the Object Type, and your 'SetObjectFlagOn(Object_name, "inside")' Attribute 'inside', is just a Boolean Attribute, which can be, is, added this way in code (done within the Object Type of course):
//
// <attr name="Attribute's name" type="Attribute's type">Attribute's value</attr>
//
// <attr name="inside" type="boolean">true</attr>
//
// so... (see below)
<type name="xaninside">
<attr name="inside" type="boolean">true</attr>
</type>
// ----------------------------------------
<object name="example_room_x">
<inherit name="xaninside" />
</object>
XanMag wrote:Okay...
Let me know if this is how it would work for Xanadu being "inside".<type name="xaninside">
<insideroom type="script">
SetObjectFlagOn (Xanadu, "inside")
</insideroom>
</type>
Then, I assign all rooms that are "inside" this object type, right? This would allow me to add all rooms to this object type so whenever 'Xanadu' is in one of these rooms the flag "inside" is set, yes?
XanMag wrote:
Now... the whole goal is to have bats move to ALL outside rooms IF Xanadu is "inside". I want this because I want the bats outside if the player moves outside and IF they were present inside ("presentin").
XanMag wrote:So, I think I have a "presentin" conflict. Whenever bats are present when "xaninside" is true, I need the bats to be present outside as well.
XanMag wrote:
I cannot set the script that controls this to run on "presentin" because it will totally mess up my printed messages. So, my solution is this: If 'presentin' is true, then I'll need to create a "present" flag to be true as well. Then I need move "bats" to rooms that do NOT contain "xaninside" attribute AND where bats "present" is true.
XanMag wrote:
That way, "presentin" messages print as needed AND the bats are outside if Xanadu goes from inside to outside.
XanMag wrote:
Note that different bat objects (average bat, bats, enormous bats) are present at different times of the day (dusk, evening, midnight, dawn). So, this would be an enormously complex if/else if script with nesting upon nesting...
XanMag wrote:
What I currently have working:
A. I already have my time of day turn script set and it runs smoothly.
B. I have my random bats script working (bats arrive with frequencies related to the time of day, messages print when bats arrive/depart when Xanadu is inside/outside)... EXCEPT for when Xanadu transitions from inside to outside or outside to inside.
My point is (I think!??):
1. I need help scripting how to move the proper bats to NOT "xaninside" rooms (outside) whenever Xanadu is "inside" and vice versa.
2. Is there an easier way to set this up? I'm half tempted to scrap it and try to start over with all my F&%&!NG bat scripts, but if there is something easier than restarting, I'm all for it. Setting up what I have so far has taken a LONG time but it is the running theme of the entire game.
Thanks.
XanMag
if (GetBoolean(twentyfourhours, "midnight")) {
if (GetBoolean(Xanadu, "inside")) {
if (bats2.presentin = true) {
if (RandomChance(5)) {
msg ("<br/>The hellish bat composed percussion beyond the walls has faded for now.")
bats2.presentin = false
}
}
else {
if (RandomChance(95)) {
msg ("<br/>The gnawing, clawing, and shrieking bats seem to reverberate through the walls and into the room.")
bats2.presentin = true
}
}
}
else {
if (bats2.presentin = true) {
if (RandomChance(5)) {
msg ("<br/>The sky above silences as the bats disappear in pursuit of some unfortunate prey.")
MoveObject (bats, Item Warehouse)
bats2.presentin = false
MoveObject (bats2, Item Warehouse)
MoveObject (small bats, Item Warehouse)
MoveObject (large bats, Item Warehouse)
MoveObject (enormous bats, Item Warehouse)
}
}
else {
if (RandomChance(95)) {
msg ("<br/>The screeching above you is about all you can hear and the sky above you looks like a black, rippling ocean.")
MoveObjectHere (bats)
bats2.presentin = true
MoveObjectHere (bats2)
MoveObjectHere (small bats)
MoveObjectHere (large bats)
MoveObjectHere (enormous bats)
}
}
}
}
This is the part I keep getting confused about. Wouldn't you want the bats outside as well if they're present? As far as I know, "presentin" means "they became present when Xanadu was inside", but I still don't know why it matters where Xanadu was when the bats showed up. All that matters is that they're present. (Even what you say next doesn't help. )
I'm assuming here that "bats" is a single object that follows Xanadu? If so, then do you mean you need to move the bats into a room that Xanadu enters when they're present and he's outside?
I think the transition from inside to outside is immaterial. If you move outside and then move to another outside room, you still need to move the bats. So it's not the inside-outside transition that matters - it's moving from anywhere into a room that happens to be outside when the bats are present. Is that correct?
You can simplify this by having a "current_bats" attribute somewhere, maybe on the game object. You would set that to average bats, bats or enormous bats depending on the time of day (probably in your turn script), and then just reference "game.current_bats" everywhere instead of checking the time of day every time you need to manipulate the bats.
jaynabonne wrote:Yes, I get that part. It's what happens when Xanadu is outside that is causing the grief.
For example, in the code above, when the bats are not "presentin" and your RandomChance(95) fires, then you move all the bats into the same room as the player. Perhaps that's the code that's wrong...
<object name="evening">
<dirtpathdescription>The market to the east is completely deserted, save the bats.</dirtpathdescription>
<bats type="object">evening bats</bats>
<startinside type="script">
MsgWithBr ("The room has grown quite cold. Despite the growing darkness in the room, you can see a cloud of microscopic water crystals every time you exhale.")
</startinside>
<startoutside type="script">
MsgWithBr ("The sun has fully retreated leaving the dark sky and the stars to keep you company. It is quite chilly out here now.")
</startoutside>
</object>
<changedcurrenttime type="script">
Setcurrentbats (this.currenttime.bats)
if (XanaduIsInside()) {
do (this.currenttime, "startinside")
}
else {
do (this.currenttime, "startoutside")
}
</changedcurrenttime>
<turnscript name="Random Bats TS">
<enabled />
<script>
if (not GetAttribute(game, "currentbats") = null) {
if (BatsArePresent()) {
if (RandomChance(game.currentbats.leavechance)) {
BatsLeave
}
}
else {
if (RandomChance(game.currentbats.arrivechance)) {
BatsArrive
}
}
}
</script>
</turnscript>
<arrivechance type="int">80</arrivechance>
<leavechance type="int">20</leavechance>
<arriveinside>A terrible chewing and scuttling noise can be heard from beyond the outermost wall.</arriveinside>
<leaveinside>The incessant gnawing and flapping outside have subsided for now.</leaveinside>
<arriveoutside>As if by command, the bats are flying in unison toward the northern horizon.</arriveoutside>
<leaveoutside>The shrieking bats have disappeared into the northern dawning sky.</leaveoutside>
<type name="Outside">
<enter type="script">
if (BatsArePresent()) {
BatsFlyToXanadu
}
</enter>
</type>
jaynabonne wrote: Also you had bat objects that weren't used (large bats, small bats, enormous bats). They were moved to the Item Warehouse but never out of it. Not sure what was supposed to happen with those. Maybe work in progress...
if (not GetAttribute(game, "currentbats") = null) {
if (BatsArePresent()) {
if (RandomChance(game.currentbats.leavechance)) {
BatsLeave
}
}
else {
if (RandomChance(game.currentbats.arrivechance)) {
BatsArrive
}
}
}
<function name="BatsArrive">
if (not BatsArePresent()) {
game.batspresent = true
SayBatText ("arrive")
BatsFlyToXanadu
}
</function>
<function name="BatsArrive">
if (not BatsArePresent()) {
game.batspresent = true
SayBatText ("arrive")
if (not XanaduIsInside()) {
BatsFlyToXanadu
}
}
</function>