Author Topic: Shoot the Moon  (Read 718 times)

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Shoot the Moon
« Reply #15 on: December 21, 2014, 03:23:52 am »


               <sneaking in...>


It wasn't bad at all, in fact it was what I've been getting at. :-P


What's been throwing me is why destroy and create the placeable...?. I'm not getting that.


Anyway, just to be clear, I'm really happy you've been posting this stuff, because these kind of threads are so valuable to our knowledgebase. I'd rather you pull some hair out (and I yank on my beard a bit) than no dialog at all.


<...a little forumula>
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Shoot the Moon
« Reply #16 on: December 21, 2014, 06:47:12 am »


               

...why destroy and create the placeable...?. I'm not getting that....




I have to admit that I didn't expect SetFacing to work for dynamic placeables, but it does!


 


I guess the misconception arises because placeables can't move to a new location.



               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Shoot the Moon
« Reply #17 on: December 21, 2014, 06:24:13 pm »


               

<initializing...>


 


Ok, I have this on area onEnter. It initializes the temple array based on month, day, hour and the moons variable setting iMoonPeriod (how long it takes to pass through all phases - default 28 days) and iMoonCycle (time from one moonrise to the next - default 23 hours): It will rotate the moon to the correct position on the moon dial, set it activated if up, deactivated if set and do the same for the sun:


 



   Spoiler
   


 

Note: This is working fine. Placeables can not be set static, but do not need to be useable.

 

Next up is to put in something to track the time while the PC is in the temple and rise/set the orbs by time of day... ideas?

 

Edit: this would only check the hours to determine whether to activate/deactivate the orbs... it wouldn't need to advance rotation, as I don't see the need to cover the possibility of a PC waiting 24 hours just to see the moon inch a bit around the dial... :-P

 


<...an update>



               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Shoot the Moon
« Reply #18 on: December 21, 2014, 07:30:22 pm »


               

<tries to still...>


 


Here's my first approach. This is on the Area Hb. It compares the current hour against a a variable stored on the area (initially null) and, if they don't match, it updates the sun & moon states.


 



   Spoiler
   


 

This works, though I can't help but feel there is a more elegant way to do this.

 

But I sat in the temple and watched the sun rise and the moon set and the sun set and then the moon rise... Was nice with the changing light values... :-)

 

Edit: Added demo mod. Experiment with the calendar and time and the period/cycle settings... nifty :-)

 


<...his beating heart>



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Shoot the Moon
« Reply #19 on: December 21, 2014, 08:41:54 pm »


               

Rolo, I just put a version of the CelestialOrbs module in the dropbox folder we share. Let me know if you can't find it.   I took your script above and put it in a framework to run from the area HB.  It can additionally run in the area enter sctript to make the update happen without waiting for the first HB after there's a PC in the area since the script won't do anything in that case.


 


It still allows for the period to be changed but it won't work quite right if you change it (back pedaling on my initial comment in this thread). It does not really allow for the cycle to change anymore since the moonrise time is really a function of the phase. I.e. you get full moon rise at sunset. You can't have a full moon while the sun is in the sky.  The code in there is an approximation of that.


 


One note, it looks like the moon should not go down quite as far when it is off. It looks like it settles into the floor a bit and flickers sometimes.


 


And there is debug print out enabled which you may want to remove.


 


Edit: Here's a public link to it in case anyone else wants to poke at it:


https://db.tt/IUQ7IL8B



               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Shoot the Moon
« Reply #20 on: December 21, 2014, 09:59:35 pm »


               

<playing with...>


 


I'm liking that a lot, Meaglyn :-)


Didn't find it in dropbox, btw... ;-/


 


I put wrappers around the debug statements, but otherwise left it as is... replacing the demo mod now...


 


<...stars>



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Shoot the Moon
« Reply #21 on: December 21, 2014, 10:59:52 pm »


               


<playing with...>


 


I'm liking that a lot, Meaglyn :-)


Didn't find it in dropbox, btw... ;-/


 


I put wrappers around the debug statements, but otherwise left it as is... replacing the demo mod now...


 


<...stars>




 


You found it in the public link I assume. That other folder was one you shared with me a long time ago, maybe defunct. I'll just remove it from there...


               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Shoot the Moon
« Reply #22 on: December 21, 2014, 11:58:48 pm »


               

I think I may have a better way of doing this and it doesn't involve the Heartbeat event, only OnEnter and OnExit for the area. I haven't the time to fully implement and test this at the moment but here is a pseudo-code version.


 


OnEnter script

 

main

 

set variable bNotInArea to false

set moon to current position

set sun to current position

calc time to next moon rise/set

calc time to next sun rise/set

 

delayCommand( call MoonTimePseudoHB(MoonTime))

delayCommand( call SunTimePseudoHB(SunTime))

 

END Main

 

MoonTimePseudoHB(MoonTime)

 

if(bNotInArea)

EXIT

toggle moon up/down

calc time to next moon rise/set

delayCommand( call MoonTimePseudoHB(MoonTime))

 

END MoonTimePseudoHB

 

SunTimePseudoHB(SunTime)

 

if(bNotInArea)

      EXIT

toggle moon up/down

calc time to next sun rise/set

delayCommand( call SunTimePseudoHB(SunTime))

 

END SunTimePseudoHB

 

------------------------------------------------------------------------

 

OnExit script

 

main

 

set variable bNotInArea to true

 

END Main

 

------------------------------------------------------------------------

 

As you can see the onenter script uses a pair of pseudo-heartbeat functions. This allows for the moon to be in the sky at the same time as the sun, just like in real life.

 

Anyway, what do you think?

 

TR


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Shoot the Moon
« Reply #23 on: December 22, 2014, 12:26:31 am »


               

A PHB would work fine.  The HB is not very intensive as it only really does anything if there are PCs in the area and then only does something at most every hour.  This could be tracked by a variable as you are doing on enter/exit instead of searching, which would make it a bit more efficient.   You'll want the bNotInArea to be a counter, though, for MP cases. Right now tracking if a PC is in the area or not is a function of how many PCs there are in the module. In single player that's 1 obviously.



The sun and the moon can be in the sky at the same time already. Just not the FULL moon.  I.e. if you can see both the sun and the moon the there must be part of the moon you can see (or facing you at least) that is not being lit by the sun, hence not full.


 


The pseudo code you posted only deals with rise and set, not phase. You'd need another to run once a day to move the moon...


 


BTW, I was not meaning to step on toes. I just got interested and took Rolo's posting as a starting point.


               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Shoot the Moon
« Reply #24 on: December 22, 2014, 12:38:29 am »


               

<hopping about...>


 


Ow! Ow! Ow! *hams it up*


 


Actually, Tarot's approach has merit.


 


Also, thinking about it, I've been treating phase and state as independent things, but really, phase is driven by moonrise.


When the moon rises at sunrise, the moon is new.


When the moon rises at sunset, the moon is (Edit) FULL.


 


So we use the modulo approach combined with a moon-defined cycle local variable to determine moonrise and use moonrise to determine phase.


 


That way, systems with more than one moon can use the same script, yet have very different periods.


 


<...holding his foot>



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Shoot the Moon
« Reply #25 on: December 22, 2014, 02:02:06 am »


               

@meaglyn you're not stepping on anybodies toes, the more the merrier. As I have never knowingly (accidentally might be another matter) written code for mp, I'll bow to your knowledge there. For sp I would think my boolean is probably more efficient (but for such a tiny thing efficiency probably doesn't matter). When I was doing my experiments earlier in this thread I did find that a heartbeat for one area could appear to be still be working when you are another area. I had the PC speaking a set of numbers (vector) and I was getting the results from a different areas hb script until I disabled that particular hb. Which is one of the reasons I suggest going with a phb. 


 


TR



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Shoot the Moon
« Reply #26 on: December 22, 2014, 03:26:49 am »


               

Okay, okay...  I've uploaded a new version that works on a single PHB which runs every hour so that it can update the positions when the day changes etc. It starts on PC enter if not already running. And then checks if there are PCs in the area before rescheduling itself. No need mess with a counter, which can get out of sync if a PC dies in there (of course there won't be any violence in such a place, right?).


 


Rolo, I moved the initial moon position back to south because for some reason the first SetFacing, which is to 347.xxx does not apply if it is too close to the painted position.  If it was at least two "ticks" away from 347 it did fine. Later ones seemed to be better but I did not advance many days.  This is unrelated to the change to PHB however since all the code for this is the same as it was before.  I tried a hack of making the first move farther away and then to the right place but it didn't work.  Putting it here won't really solve the problem since that could be near the right location when someone does enter.  But it makes the demo look better '<img'>


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Shoot the Moon
« Reply #27 on: December 22, 2014, 01:43:48 pm »


               

This one is better https://db.tt/hGJZrBWM. The one last night seems to have been the old one, at least that's what I got from dropbox when I downloaded it. This one runs the PHB every 6 seconds until the first hour tick and then goes to every hour. The other one could have been up to almost an hour slow in doing rises/sets depending on when the first PC entered the area.  It's not completely tested because there is only one area so there's always a PC in the area.


 


It looks like the rotation just does not like to work when it is a small amount. Getfacing reports the new setting but the placeable does not rotate. May need to poke at that a bit.