Author Topic: MJ's global weather system.  (Read 312 times)

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
MJ's global weather system.
« on: August 15, 2013, 02:12:47 pm »


                Anyone here familiar with this ? It looks pretty nice all things considered, and pretty simple to modify... 
(This system is very old, but the easiest to begin with, I think... so I'll ask here because the chances of someone checking posts in the vault of this system nowadays is very small. (Last answered post from years ago) 

I just have a few problems understanding the logic of it. My module uses only Jungle climate (always hot/humid) so everywhere you go outside, you get your butt kicked by penalties. I'm trying to modify it so you have weapons against it (light clothing, water, if it's raining, a hat...) 

Here's something I just don't understand, 

                object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC); 
                switch (GetLocalInt(oMod, VAR_SEASON_STORE))
{                    case SEASON_SUMMER:
                     case SEASON_FALL: 
                     if (oArmor != OBJECT_INVALID && GetWeight(oArmor) > 25)
                            nElementFactor += 4; 
                     else
                            nElementFactor -= 4;

The logic behind the whole system seems to be that nElementFactor is a bad thing. (Hot climates add the factor variable) But to me this sentence looks strange. 

Converting it into how I understand it: If the armor is not heavier than 25lbs. you get ElementFactor +4... Object Invalid and >25 = "If it is not this." ? Or am I misunderstanding this ?

No wait... does this mean if the object is not armor at all ? I'm confused, I don't understand this code O.o

EDIT: I'm confused but... is this just an item loop that finds the armor you are wearing so it doesn't confuse it with other items = hence the object invalid ? I have never used && marks so I've no clue what this is... I'm guessing this infact means it's just a loop of items... But the whole part of the code has no "getnextitem" so is it then incomplete ? ummmmh... someone help my poor poor mangled brains.

*Tries to understand* It's trying to get the armor item... and then it checks if it's heavier than 25lbs... if it IS then it adds element factor ? In which case it makes no sense that there's further down a code part where it ADDS element factor when it rains... I imagine jungle people would welcome rain '<img'> Am I even -close- to understanding this ?
               
               

               


                     Modifié par JerrodAmolyan, 15 août 2013 - 01:22 .
                     
                  


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
MJ's global weather system.
« Reply #1 on: August 15, 2013, 02:24:47 pm »


               Also, can Integers go below 0 ? If not, then I can make decreasing element factor stuff without having to fear that suddenly you would die of cold.
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
MJ's global weather system.
« Reply #2 on: August 15, 2013, 06:21:54 pm »


               Yes, you can have negative integers.

That bit of code is checking a specific inventory slot (INVENTORY_SLOT_CHEST) for an item.  If the PC is not wearing any clothing or armor in that slot, it will return OBJECT_INVALID (because there's nothing valid in that slot).  It doesn't need a GetNextItemInInventory(), because it's not looping through...it's just checking that one specific slot.

&& basically means "and".  For instance:
if (d20(1) > 5 && GetCurrentHitPoints(oPC) < 10)
{
}
means if a roll on 1d20 is greater than 5 AND the PC has less than 10 hitpoints, then do whatever comes between the { } brackets.  If both conditions don't match, then whatever it is doesn't happen.

Some common NWScripting maths stuffs:
&&  AND (all of several requirements must be met)
||  OR (one of several requirements must be met)
==  EQUALS (exact match)
!=   DOES NOT EQUAL (anything but an exact match)
>=  GREATER THAN OR EQUAL TO
<=  LESS THAN OR EQUAL TO

As far as that weather system, I'm not familiar with it.

In that code snippet, it's doing a couple of things:
1. it's checking the module itself for a specific season variable (integer)
2. if the season is summer or fall:
   3. checks PC for an item in the chest/armor inventory slot
      4. if armor is a valid item (does not equal OBJECT_INVALID)
         5. checks armor weight
            6. if armor weight is greater than 25, add 4 to the nElementFactor variable
            6. if armor weight is less than 25, subtract 4 to the nElementFactor variable

In the case of this code, it's better to wear clothing or very light armor in summer/fall than it is to wear either heavier armor or to wear nothing at all.
               
               

               


                     Modifié par The Amethyst Dragon, 15 août 2013 - 05:23 .
                     
                  


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
MJ's global weather system.
« Reply #3 on: August 19, 2013, 09:38:26 am »


               Yeah, that's what I hoped. Thanks '<img'> Also, now I'm less confused when looking at this weather include. However, it seems that I can't make a water drinking bonus (lack of skill for me no doubt) decrease element factors / Add a good deal of resistance against the elements/weather. 

The Jungle climate is really harsh on this, have modified it to be less harsh, and basicly you have -no- way to completely evade the harsh penalties that are more irritating than valuable for RP... well currently I have the water bottle (when drank) remove the effects, which is a "good enough I suppose" thing. '<img'>

Since my whole module is jungle climate, whenever going outdoors you are going to be slowed/applied a heavy penalty or something of the kind,... 
               
               

               


                     Modifié par JerrodAmolyan, 19 août 2013 - 08:40 .
                     
                  


            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
MJ's global weather system.
« Reply #4 on: August 24, 2013, 03:42:38 am »


               While not specifically addressing your question, here are some things you might consider based on my experience, as I think I started with this system in my mod and have built onto it over the years to make it more customized for my world (apologies if this is not so relevant to your question):

1)  Make more climates - even if your world is mostly jungle, you can still have slightly different versions of it (a more swampy jungle with more heat vs a rainforest jungle with more rain).  That allows you to play around with weather as being a consideration while adventuring rather than being the same everywhere. Some areas can be more difficult than others, rather than all areas being equally difficult weather-wise.

2)  To make weather less of an annoyance and more of an enhancement, give PCs ample exosure time before harsh effects go into place.  Then, make initial DCs low and increment them over time/exposure to the climate.  Once they see that they are making (and succeeding) in DCs that are becoming ever-harder, they'll take measures to protect themselves but they'll also have had 'enough' time outside to be reasonable.  In Arenthyor, I allow PCs to be exposed to harsh climates for a generous number of rounds plus 2x their CON bonus.  DCs are also somewhat variable based on the PCs level.  That way, not everyone is being affected in the same way by the climate at the same time.

3)  Consider how you can make 2 key parts to a weather system work together in your world - the harshness of the weather (how long a PC can be in the environment before taking damage) and damage (how damaging that exposure is).  I choose to make different climates have variations for each.  One might have a low threshold for exposure, but also lower damage than one with a higher threshold for exposure with higher damage.

4)  Something specifically worth mentioning is that I made magical cloaks offer protection based on the value of the item (over a certain threshold).  This protection is minimally better than what the nonmagical 'winter cloaks' offer.  My thinking is that one of the latent properties of a magical cloak would be protection from weather.  I did not want to disadvantage players for upgrading from a mundane winter cloak to a magical cloak of protection that did not actually help protect them from weather-related cold/heat (note that these cloaks don't offer protection from the damage of the heat...they just help extend the time that PCs can be exposed to the weather).

5)  One thing I found helpful was to create a chart with heat/cold on the x-axis and wet/dry on the y axis and then plot where I wanted climates to be.  This was immensely helpful to visualize how all the climates of the world related to one another (e.g. how more cold is a polar environment than a high mountain one) and made implementing them in the code easier.

6)  I rewrote code to eliminate 'base' constant percentages for rain/clear/snow for each climate or season.  If didn't seem reasonable to me that each climate had a minimum % for a clear day that spanned the seasons.  Now, each climate and each season within each climate has its own unique chance for clear/rain/snow.  I have climates where it rains 100% of the time, yet are still hot (like a jungle rainforest).  Others where the chance of rain is variable based on the season.

7)  Consider that this is probably one of the most used script systems you have because it runs all the time.  Look for ways to minimize the overhead (such as only affecting areas where PCs are present and making sure that lightning storms/hail storms, etc... are ended if no PCs are present - in the base system I used, there was a memory leak that caused inclement weather to continue forever in areas, even after PCs left the area).  I also removed a lot of calculations from the heartbeat function after I realized that it was continually recalculating integers for the module that only needed to be done at module load.  Those I put into a separate function that only got re-called and calculated if the season changed (since each of my climates has different weather chances besed on the season).

Hope that helps.