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 .