Amon_PRC8/_module/nss/briarpipe_old.nss
Jaysyn904 c5cffc37af Initial Commit
Initial Commit [v1.01]
2025-04-03 19:00:46 -04:00

107 lines
4.4 KiB
Plaintext

#include "dmfi_dmw_inc"
#include "x2_inc_toollib"
#include "dmfi_execute"
#include "prc_inc_racial"
int GetHourTimeZero(int iYear = 99999, int iMonth = 99, int iDay = 99, int iHour = 99)
{
// Check if a specific Date/Time is forwarded to the function.
// If no or invalid values are forwarded to the function, the current Date/Time will be used
if (iYear > 30000)
iYear = GetCalendarYear();
if (iMonth > 12)
iMonth = GetCalendarMonth();
if (iDay > 28)
iDay = GetCalendarDay();
if (iHour > 23)
iHour = GetTimeHour();
//Calculate and return the "HourTimeZero"-TimeIndex
int iHourTimeZero = (iYear)*12*28*24 + (iMonth-1)*28*24 + (iDay-1)*24 + iHour;
return iHourTimeZero;
}
//Smoking Function by Jason Robinson
void Main()
{
// Script Settings (Variable Declaration)
int iLevelAffected = 1;
int iSmokeDelay = 2;
int iHostileRange = 30;
// Variable Declarations
object oPC = GetItemActivator();
object oActivator = GetItemActivator();
if (GetHourTimeZero() < GetLocalInt (oPC, "i_TI_LastSmoke") + iSmokeDelay)
{
AssignCommand (oPC, ClearAllActions());
SendMessageToPC (oPC, "You must wait " + IntToString (iSmokeDelay - (GetHourTimeZero() - GetLocalInt (oPC, "i_TI_LastSmoke"))) + " hour(s) before smoking again.");
}
else
{
object oCreature = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
if (iHostileRange == 0 || (iHostileRange != 0 && GetDistanceToObject(oCreature) <= IntToFloat(iHostileRange)))
{
string sEmote1 = "*puffs on a pipe*";
string sEmote2 = "*inhales from a pipe*";
string sEmote3 = "*pulls a mouthful of smoke from a pipe*";
float fHeight = 1.7;
float fDistance = 0.1;
// Set height based on race and gender
if (GetGender(oActivator) == GENDER_MALE)
{
switch (MyPRCGetRacialType(oActivator))
{
case RACIAL_TYPE_HUMAN:
case RACIAL_TYPE_HALFELF: fHeight = 1.7; fDistance = 0.12; break;
case RACIAL_TYPE_ELF: fHeight = 1.55; fDistance = 0.08; break;
case RACIAL_TYPE_GNOME:
case RACIAL_TYPE_HALFLING: fHeight = 1.15; fDistance = 0.12; break;
case RACIAL_TYPE_DWARF: fHeight = 1.2; fDistance = 0.12; break;
case RACIAL_TYPE_HALFORC: fHeight = 1.9; fDistance = 0.2; break;
}
}
else
{
// FEMALES
switch (MyPRCGetRacialType(oActivator))
{
case RACIAL_TYPE_HUMAN:
case RACIAL_TYPE_HALFELF: fHeight = 1.6; fDistance = 0.12; break;
case RACIAL_TYPE_ELF: fHeight = 1.45; fDistance = 0.12; break;
case RACIAL_TYPE_GNOME:
case RACIAL_TYPE_HALFLING: fHeight = 1.1; fDistance = 0.075; break;
case RACIAL_TYPE_DWARF: fHeight = 1.2; fDistance = 0.1; break;
case RACIAL_TYPE_HALFORC: fHeight = 1.8; fDistance = 0.13; break;
}
}
location lAboveHead = GetLocationAboveAndInFrontOf(oActivator, fDistance, fHeight);
// emotes
switch (d3())
{
case 1: AssignCommand(oActivator, ActionSpeakString(sEmote1)); break;
case 2: AssignCommand(oActivator, ActionSpeakString(sEmote2)); break;
case 3: AssignCommand(oActivator, ActionSpeakString(sEmote3));break;
}
// glow red
AssignCommand(oActivator, ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_LIGHT_RED_5), oActivator, 0.15)));
// wait a moment
AssignCommand(oActivator, ActionWait(3.0));
// puff of smoke above and in front of head
AssignCommand(oActivator, ActionDoCommand(ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), lAboveHead)));
// if female, turn head to left
if ((GetGender(oActivator) == GENDER_FEMALE) && (MyPRCGetRacialType(oActivator) != RACIAL_TYPE_DWARF))
AssignCommand(oActivator, ActionPlayAnimation(ANIMATION_FIREFORGET_HEAD_TURN_LEFT, 1.0, 5.0));
ExecuteScript ("NW_S0_CurModW", oActivator);
ExecuteScript ("nw_s0_regen", oActivator);
}
else
{ // Smoking IS NOT allowed
AssignCommand (oActivator, ClearAllActions()); // Prevent Smoking
SendMessageToPC (oActivator, "You cannot smoke. Hostiles nearby");
}
SetLocalInt (oPC, "i_TI_LastSmoke", GetHourTimeZero()); // Set Last Smoke Time
}}