/*
    PROJECT Q IV v4.00
    (c) 2022 by Pstemarie

    Stomach Area OnEnter Event Script

       Sets the value of the PW_SPACE variable based on the swallowed creature's
       size:

       +1 = Tiny
       +2 = Small
       +3 = Medium
       +4 = Large or Huge

    Version: 1.0
    Created: 28 Jan 2003
    Author:  Lacero
    v1.1:    2 Jun 2022 Pstemarie - streamlined coding
    v1.2:    18 June 2022 Pstemarie - updated for giant frogs

*/

#include "q_i0_worm"
#include "q_i0_giantfrog"

void main()
{
    object oPC = GetEnteringObject();
    object oWorm = GetLocalObject(oPC,"PW_INSIDE");
    int nSpace = GetLocalInt(oWorm,"PW_SPACE");
    int nSize;

    if (GetAppearanceType(oWorm) == APPEARANCE_TYPE_REMORHAZ ||
        GetAppearanceType(oWorm) == APPEARANCE_TYPE_PURPLE_WORM)
    {
        if (GetCreatureSize(oPC)==CREATURE_SIZE_TINY)
        {
            nSize = 1;
        }
        else if (GetCreatureSize(oPC)==CREATURE_SIZE_SMALL ||
                 GetCreatureSize(oPC)==CREATURE_SIZE_MEDIUM)
        {
            nSize = 2;
        }
        else if (GetCreatureSize(oPC)==CREATURE_SIZE_LARGE)
        {
            nSize = 4;
        }
        else
        {
            nSize = 16;
        }

        SetLocalInt(oWorm,"PW_SPACE",nSpace+nSize);
        pw_DigestionDamage(oPC);
    }
    else // Swallowed by a Giant Frog/Toad
    {
        if (GetCreatureSize(oPC)==CREATURE_SIZE_TINY)
        {
            nSize = 1;
        }
        else if (GetCreatureSize(oPC)==CREATURE_SIZE_SMALL ||
                 GetCreatureSize(oPC)==CREATURE_SIZE_MEDIUM)
        {
            nSize = 2;
        }
        else
        {
            nSize = 4; // can't be swallowed
        }

        SetLocalInt(oWorm,"PW_SPACE",nSpace+nSize);
        gf_DigestionDamage(oPC);
    }
}
