Hoods



  • Many thanks to Deloril. 🙂

    @coa_deloril:

    This is the main logic, the all it needs is for the script to be called, you don't need to pass any other commands like on or off. IE, for dot commands, if you have a hood on, .hood (example) will remove the hood, but if you aren't wearing one, the same command will equip it.

    //Written by Deloril. Toggles a hood on or off using a predefined variable to restore the old head.//
    void main()
    {
        object oPC = GetLastSpeaker();
        int RACIAL_TYPE = GetRacialType(oPC);
        int OLD_HEAD = //GetLocalInt(oPC, NAME_OF_VARIABLE_STORING_HEAD_NUM); a variable storing the PCs native head type
    
        switch(RACIAL_TYPE)
        {
            case IP_CONST_RACIALTYPE_HALFELF:
                //Half Elf and human are handled the same: allow to fall through (no break)//
    
            case IP_CONST_RACIALTYPE_HUMAN:
                if(GetGender(oPC) == GENDER_MALE)
                {
                    if(GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) == 2)
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, OLD_HEAD, oPC);
                    }
                    else
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, 2, oPC);
                    }
                }
                else
                {
                    if(GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) == 12)
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, OLD_HEAD, oPC);
                    }
                    else
                    {
                    SetCreatureBodyPart(CREATURE_PART_HEAD, 12, oPC);
                    }
                }
                break;
    
            case IP_CONST_RACIALTYPE_ELF:
                if(GetGender(oPC) == GENDER_MALE)
                {
                    if(GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) == 15)
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, OLD_HEAD, oPC);
                    }
                    else
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, 15, oPC);
                    }
                }
                else
                {
                    if(GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) == 14)
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, OLD_HEAD, oPC);
                    }
                    else
                    {
                    SetCreatureBodyPart(CREATURE_PART_HEAD, 14, oPC);
                    }
                }
                break;
    
            case IP_CONST_RACIALTYPE_HALFLING:
                if(GetGender(oPC) == GENDER_MALE)
                {
                    if(GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) == 9)
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, OLD_HEAD, oPC);
                    }
                    else
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, 9, oPC);
                        //apply hooded head//
                    }
                }
                else
                {
                    if(GetCreatureBodyPart(CREATURE_PART_HEAD, oPC) == 10)
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, OLD_HEAD, oPC);
                    }
                    else
                    {
                        SetCreatureBodyPart(CREATURE_PART_HEAD, 10, oPC);
                        //apply hooded head//
                    }
                }
                break;
    
            case IP_CONST_RACIALTYPE_DWARF:
                //return error message: Dwarves dont have hoods//
                break;
    
            case IP_CONST_RACIALTYPE_HALFORC:
                //return error message: Half Orcs don't have hoods//
                break;
    
            case IP_CONST_RACIALTYPE_GNOME:
                //return error message: Gnomes don't have hoods//
                break;
    
            default:
            //something went terribly wrong, the race used isn't one of the default playable races. Either they got an app accepted, that changed their default race,
            //or the script failed. either way, debug here.
        }
    }
    

    You also need to create the variable to be stored, preferably at char creation, this command should do it. (assuming you have other on creation scripts that set up other variables)

    int Head_Num = GetCreatureBodyPart(CREATURE_PART_HEAD , oPC);
    SetLocalInt(oPC, 'variable storing head number', Head_Num);
    
    


  • Doesn't work for all subraces, that's why we never put it in before.


Log in to reply