//Script Name:  onmoduleload
//////////////////////////////////////////
//Created By: Genisys (Guile)
//Created On:   7/23/08 (Updated 8/10/08)
/////////////////////////////////////////
/*
This script goes in your OnModuleLoad
Event found in the Module Properties
Event Tab.
*/
////////////////////////////////////////

//IMPORTANT SETTING!!!

//Set this to TRUE if you using the module for multiplayer!
const int MULTI_PLAYER = TRUE;

const string NWNX_DISCORD_URL = "/api/webhooks/709533785091342397/8Rsb8-or0Ticc5xDNxLP2tldtx_vPR4Zqu41rs_KzNq5stylkMECcEAIdEDDVXteaQmO/slack";

//Required Includes
#include "x2_inc_switches"
#include "x2_inc_restsys"
#include "nwnx_webhook"
#include "nwnx_util"

//Required Include for the DM Chat Control Options
#include "dm_chat_inc"

#include "_inc_color_text_"

//Required for SimTools
//#include "fky_chat_inc"

//If you are using NWNX2 You need to delete the // below this line!

//#include "se_inc_reset"


//Main Script
void main()
{
 ExecuteScript("prc_onmodload", OBJECT_SELF);
 //For Time Keeping...(This MUST BE HERE)
 SetLocalInt(GetModule(), "DELAY_OK", 1);

//Delay (in seconds) till Server Restarts...
//14400 = Ever 4 hours (Default)
//DelayCommand(14400.0, SetLocalString(GetModule(), "NWNX!RESETPLUGIN!SHUTDOWN", "1"));


//DISABLED
//SimTools
/*
    // Init placeholders for ODBC gateway
    SQLInit();
    // Init placeholders for chat gateway
    InitSpeech();
    SetModuleSwitch(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS ,TRUE);
*/
/////////////////////////////////////////////////////////////////////

//Set the module up as single or multiplayer..

SetLocalInt(GetModule(), "multi", MULTI_PLAYER);

/////////////////////////////////////////////////////////////////////
//The NWNX2 Server Reset Plugin Function
//the first # must be 1 month Higher than the current module month!
//see the script "se_inc_reset" to see how it works..
//Delete the // below this line to activate Server Reset for NWNX2

//SE_NWNX_ResetModuleCheck(7, 30.0, 120.0);

/////////////////////////////////////////////////////////////////////

//Stop the treasure generation on creatures, so they won't drop loot..
SetLocalInt(GetModule(), "X2_L_NOTREASURE", FALSE);

//IMPORTANT: This part is part of 2 color systems!
//It must be in your OnModuleLoad Event Script!!

//This set color to placeables in the module, it requires that the placeable
//tagged color is placed in the module somewhere out of reach.
string sColor = GetName(GetObjectByTag("COLORS"));

SetCustomToken(1001, GetSubString(sColor, 0, 6)); //white
SetCustomToken(1002, GetSubString(sColor, 6, 6)); //yellow
SetCustomToken(1003, GetSubString(sColor, 12, 6)); //magenta
SetCustomToken(1004, GetSubString(sColor, 18, 6)); //cyan
SetCustomToken(1005, GetSubString(sColor, 24, 6)); //red
SetCustomToken(1006, GetSubString(sColor, 30, 6)); //green
SetCustomToken(1007, GetSubString(sColor, 36, 6)); //blue

//More Custom Color Tokens By Genisys
//NOTE: These custom tokens go ONLY in conversation lines to colorize text
//The example below is everything that would go on a Conversation Line
/*******EXAMPLE CONVERSATION LINE**************

<CUSTOM101>This text of the conversation would be red<CUSTOM100>

IMPORTANT: You must use <CUSTOM100> At the end EVERY TIME!*/

    SetCustomToken(100, "</c>"); // CLOSE tag (Ends color, prevents run on!)

    SetCustomToken(101, "<c�  >"); // red
    SetCustomToken(102, "<c � >"); // green
    SetCustomToken(103, "<c  �>"); // blue
    SetCustomToken(104, "<c ��>"); // cyan
    SetCustomToken(105, "<c� �>"); // magenta
    SetCustomToken(106, "<c�� >"); // yellow
    SetCustomToken(107, "<c   >"); // black
    SetCustomToken(108, "<c�  >"); // dark red
    SetCustomToken(109, "<c � >"); // dark green
    SetCustomToken(110, "<c  �>"); // dark blue
    SetCustomToken(111, "<c ��>"); // dark cyan
    SetCustomToken(112, "<c� �>"); // dark magenta
    SetCustomToken(113, "<c�� >"); // dark yellow
    SetCustomToken(114, "<c���>"); // grey
    SetCustomToken(117, "<c���>"); // dark grey
    SetCustomToken(115, "<c�� >"); // orange
    SetCustomToken(116, "<c�� >"); // dark orange
    SetCustomToken(117, "<cڥ#>"); // brown
    SetCustomToken(118, "<c† >"); // dark brown
    SetCustomToken(119, "<c�k�>"); // Light Purple
    SetCustomToken(120, "<c � >"); // Neon Green
    SetCustomToken(121, "<c ��>"); // Light Blue
    SetCustomToken(122, "<c` �>"); // Purple
    SetCustomToken(123, "<c � >"); //Neon Green

//Set the name on the Rainbow Chest!
object oRainbow = GetObjectByTag("rainbowchest");
object oRainbow2 = GetObjectByTag("rainbowchest2");
SetName(oRainbow, ChaoticText(GetName(oRainbow, TRUE)));
SetName(oRainbow2, ChaoticText(GetName(oRainbow2, TRUE)));
////////////////////////////////////////////////////////////////////////////

 //Code added for the DM Chat Control Options..
 GetChatConfigurations();

/////////SPELL HOOKING BY Genisys (Guile)///////////////////////////////////
//This part sets a local variable on the module to allow you to edit
//spells through the "myhook" script, which will give you greater control
//over spell casting in your module, including items and area casting!

//SetLocalString(GetModule(), "X2_S_UD_SPELLSCRIPT", "myhook");

//To disable spell hooking simply type // at the start of the line above
////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
/////////////////AUTOMATIC CHARACTER SAVING FUCTION////////////////////////
//Note this function is Polymorphing Friendly (Designed for that purpose!)

//This feature stores All PC's location on the module ever 3 minutes...
//To deactivate this feature, simply type // at the start of the line below.


//DelayCommand(60.0, ExecuteScript("savepcinfo", OBJECT_SELF)); //:: PRC handles this now


//////////////////////////////////////////////////////////////////////////



//Your Code Goes here..


//////////////////////////////////////////////////////////////////////////////
//STANDARD BIOWARE XP2 FUNCTIONS/////////////////////////////////////////////
//////////////////////////////////////////MODULE SWITCHES///////////////////

   if (GetGameDifficulty() ==  GAME_DIFFICULTY_CORE_RULES || GetGameDifficulty() ==  GAME_DIFFICULTY_DIFFICULT)
   {
        // * Setting the switch below will enable a seperate Use Magic Device Skillcheck for
        // * rogues when playing on Hardcore+ difficulty. This only applies to scrolls
        SetModuleSwitch (MODULE_SWITCH_ENABLE_UMD_SCROLLS, FALSE);

       // * Activating the switch below will make AOE spells hurt neutral NPCS by default
        SetModuleSwitch (MODULE_SWITCH_AOE_HURT_NEUTRAL_NPCS, TRUE);
   }

   // * AI: Activating the switch below will make the creaures using the WalkWaypoint function
   // * able to walk across areas
    SetModuleSwitch (MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTS, TRUE);

   // * Spells: Activating the switch below will make the Glyph of Warding spell behave differently:
   // * The visual glyph will disappear after 6 seconds, making them impossible to spot
   // SetModuleSwitch (MODULE_SWITCH_ENABLE_INVISIBLE_GLYPH_OF_WARDING, TRUE);

   // * Craft Feats: Want 50 charges on a newly created wand? We found this unbalancing,
   // * but since it is described this way in the book, here is the switch to get it back...
   // SetModuleSwitch (MODULE_SWITCH_ENABLE_CRAFT_WAND_50_CHARGES, TRUE);

   // * Craft Feats: Use this to disable Item Creation Feats if you do not want
   // * them in your module
   // SetModuleSwitch (MODULE_SWITCH_DISABLE_ITEM_CREATION_FEATS, TRUE);

   // * Palemaster: Deathless master touch in PnP only affects creatures up to a certain size.
   // * We do not support this check for balancing reasons, but you can still activate it...
   // SetModuleSwitch (MODULE_SWITCH_SPELL_CORERULES_DMASTERTOUCH, TRUE);

   // * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
   // * did not fit into NWNs spell system and was confusing, so we took it out...
    SetModuleSwitch (MODULE_SWITCH_EPIC_SPELLS_HURT_CASTER, TRUE);

   // * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
   // * did not fit into NWNs spell system and was confusing, so we took it out...
    SetModuleSwitch (MODULE_SWITCH_RESTRICT_USE_POISON_TO_FEAT, TRUE);

    // * Spellcasting: Some people don't like caster's abusing expertise to raise their AC
    // * Uncommenting this line will drop expertise mode whenever a spell is cast by a player
     SetModuleSwitch (MODULE_VAR_AI_STOP_EXPERTISE_ABUSE, TRUE);


    // * Item Event Scripts: The game's default event scripts allow routing of all item related events
    // * into a single file, based on the tag of that item. If an item's tag is "test", it will fire a
    // * script called "test" when an item based event (equip, unequip, acquire, unacquire, activate,...)
    // * is triggered. Check "x2_it_example.nss" for an example.
    // * This feature is disabled by default.
      SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);

   if (GetModuleSwitchValue (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
   {
        // * If Tagbased scripts are enabled, and you are running a Local Vault Server
        // * you should use the line below to add a layer of security to your server, preventing
        // * people to execute script you don't want them to. If you use the feature below,
        // * all called item scrips will be the prefix + the Tag of the item you want to execute, up to a
        // * maximum of 16 chars, instead of the pure tag of the object.
        // * i.e. without the line below a user activating an item with the tag "test",
        // * will result in the execution of a script called "test". If you uncomment the line below
        // * the script called will be "1_test.nss"
        // SetUserDefinedItemEventPrefix("1_");

   }

   // * This initializes Bioware's wandering monster system as used in Hordes of the Underdark
   // * You can deactivate it, making your module load faster if you do not use it.
   // * If you want to use it, make sure you set "x2_mod_def_rest" as your module's OnRest Script
    SetModuleSwitch (MODULE_SWITCH_USE_XP2_RESTSYSTEM, TRUE);

   if (GetModuleSwitchValue(MODULE_SWITCH_USE_XP2_RESTSYSTEM) == TRUE)
   {

       // * This allows you to specify a different 2da for the wandering monster system.
       // SetWanderingMonster2DAFile("des_restsystem");

       //* Do not change this line.
       WMBuild2DACache();
   }
  // added in hopes of webhook/discord

  NWNX_WebHook_SendWebHookHTTPS("discordapp.com", NWNX_DISCORD_URL, "Good Morning Ascension.", "The Madman");
//NWNX_WebHook_SendWebHookHTTPS("discordapp.com", NWNX_Util_GetEnvironmentVariable("NWNX_WEBHOOK_DEVELOPER_CHANNEL"), "Good Morning Ascension.", "The Madman");
//Main Script End
}