Neverwinter Nights > NwN Building

Probably basic but im lost

<< < (4/4)

Calia:
OK hope this is my last request for a while i think 420 might attempt to have me murdered at the rate i been going lol >.<,

Attempting to use Shayan's subrace engine with the leto NWNX2 stuff going, I have coded the custom subrace and everything but nothign seems to happen I have pasted the same code int the demo mod that came with the .rar file i have  and it worked perfectly....... so its some where I had been merging the needed liens of code into my best guess is its either in my onenter or my Onmodload  sections.

Onenter

--- Code: ---#include "dl_magic"
#include "__kw_io_func"
#include "sha_subr_methds"
#include "tomkin_database"
#include "include_thrall"

int EnforceBan( object oPC );
int ExamineNumPlayers( object oPC );
string GetClass( object oPC );
string GetRace( object oPC );
void LogEntry( object oPC );

string SCHIBICD = "";
string STOMKINCD = "";


// Check for associates the PC may have created
void CheckForAssociates( object oPC );

void CheckForAssociates( object oPC )
{
    // Set a spcial variable on the server itself to take into account server
    // reboots where thralls may spawn over the life of the server!
    // SetLocalInt( GetModule(), GetPCPublicCDKey( oPC ) + "Thrall", 1 );
    // DBSaveString( "ThrallMaster", GetPCPublicCDKey( oPC ) + GetStringLeft( GetName( oPC ), 10 ), oPC );

    // Check to see if the PC has created an associate
    string sThrallCheck = DBGetString( "ThrallMaster", oPC );

    if( sThrallCheck != "" )
    {
        // Associate exists, let's see if the server has reset. This event
        // will be signified by a stored variable on the server itself. If
        // the variable is not found, then the PCs thrall needs to be recreated.
        int nThrall = GetLocalInt( GetModule(), GetPCPublicCDKey( oPC ) + "Thrall" );
        location locPC = DBGetLocation( "LOCATION", oPC );

        // PCs thrall still exists on the server somewhere, do not recreate!
        if( nThrall == 1 ) return;

        // Get all the values from the PCs database
        string sMaster = DBGetString( "ThrallMaster", oPC );
        string sType = DBGetString( "ThrallType", oPC );
        string sBones1 = DBGetString( "ThrallBones1Res", oPC );
        string sBones2 = DBGetString( "ThrallBones2Res", oPC );
        string sSkull = DBGetString( "ThrallSkullRes", oPC );
        string sClaws = DBGetString( "ThrallClawsRes", oPC );
        string sSpecial = DBGetString( "ThrallSpecialRes", oPC );

        // Create the associate itself
        object oThrall = CreateObject( OBJECT_TYPE_CREATURE,
            sType, locPC );

        // Apply any effects to the associate as necessary, add them as
        // a PCs henchman, and level them up to their appropriate power.
        if( GetStringLeft( sType, 5 ) == "necro" )
            DelayCommand( 0.5f, ApplyNecroEffects( sBones1, sBones2, sSkull,
                sClaws, sSpecial, oThrall ) );
        else if( GetStringLeft( sType, 5 ) == "champ" )
            DelayCommand( 0.5f, ApplyChampionEffects( sBones1, sBones2, sSkull,
                sClaws, sSpecial, oThrall ) );

        DelayCommand( 0.7f, AddHenchman( oPC, oThrall ) );
        DelayCommand( 1.0f, LevelUpThrall( oThrall, GetHitDice( oPC ) ) );

        // Save the information on the associate!
        sBones1 = GetStringLowerCase( GetStringLeft( sBones1, 16 ) );
        sBones2 = GetStringLowerCase( GetStringLeft( sBones2, 16 ) );
        sSkull = GetStringLowerCase( GetStringLeft( sSkull, 16 ) );
        sClaws = GetStringLowerCase( GetStringLeft( sClaws, 16 ) );
        sSpecial = GetStringLowerCase( GetStringLeft( sSpecial, 16 ) );

        SetLocalString( oThrall, "Master", GetPCPublicCDKey( oPC ) + GetSubString( GetName( oPC ), 0, 10 ) );
        SetLocalString( oThrall, "ThrallType", sType );
        SetLocalString( oThrall, "Bones1Res", sBones1 );
        SetLocalString( oThrall, "Bones2Res", sBones2 );
        SetLocalString( oThrall, "SkullRes", sSkull );
        SetLocalString( oThrall, "ClawsRes", sClaws );
        SetLocalString( oThrall, "SpecialRes", sSpecial );

        SendMessageToPC(oPC,"THRALLTYPE:"+sType);
        SendMessageToPC(oPC,"THRALLBONES1:"+sBones1);
        SendMessageToPC(oPC,"THRALLBONES2:"+sBones2);
        SendMessageToPC(oPC,"THRALLSKULL :"+sSkull);
        SendMessageToPC(oPC,"THRALLCLAWS :"+sClaws);
        SendMessageToPC(oPC,"THRALLSPECL :"+sSpecial);
    }
}


// Check and enforce the ban state of the PC!
int EnforceBan( object oPC )
{
    string sCDKey = GetPCPublicCDKey( oPC );
    int nBan = GetCampaignInt( "KRYNN", sCDKey, oPC );

    if( nBan == 3 ) { BootPC( oPC ); return 1; }

    // NOT banned
    return 0;
}


/*******************************************************************************
    GETS THE NUMBER OF PLAYERS CURRENTLY PLAYING THE MODULE.
    IF THE PLAYER LOGGING ON IS NOT A DM, ME, OR THE WIFE THEN
    INCREMENT THE NUMBER OF PLAYERS PLAYING BY ONE, AND SAVE
    THE NEW VALUE IN THE MODULE, RETURNING THE # OF PLAYERS.
*/
int ExamineNumPlayers( object oPC )
{
    if( GetIsDM( oPC ) ) return 0;
    if( GetPCPublicCDKey( oPC ) == STOMKINCD ) return 0;
    if( GetPCPublicCDKey( oPC ) == SCHIBICD ) return 0;

    int nPlayers = 0;
    string sCDKey;
    string sName;
    oPC = GetFirstPC();
    while( oPC != OBJECT_INVALID )
    {
        nPlayers++;

        sCDKey = GetPCPublicCDKey( oPC );
        if(
            GetIsDM( oPC ) ||
            sCDKey == STOMKINCD ||
            sCDKey == SCHIBICD
          )
        {
            nPlayers--;
        }

        oPC = GetNextPC();
    }

    return nPlayers;
}
//******************************************************************************

void LogEntry( object oPC )
{
    string sPrint = "Entering Player: " + GetName( oPC ) + " | " + GetPCPlayerName( oPC ) + " | IP: "
        + GetPCIPAddress(oPC);
    // Tell all the DMs that someone is logging on!
    SendMessageToAllDMs( sPrint );

    // Now add CDKey information and log it to the logfile.
    sPrint = sPrint + " | CDKey: " + GetPCPublicCDKey( oPC );
    sPrint = sPrint + " | TIME: " + IntToString( GetTimeHour() )
        + ":" + IntToString( GetTimeMinute() ) + ":"
        + IntToString( GetTimeSecond() );

    string sPrint2 = "Player Info: " + GetName( oPC ) + " | " + GetPCPlayerName( oPC ) + " | "
        + GetClass( oPC ) + " | " + IntToString( GetHitDice( oPC ) ) + " | " + GetRace( oPC );


    WriteTimestampedLogEntry( sPrint );
    WriteTimestampedLogEntry( sPrint2 );
}


string GetClass( object oPC )
{
    int i;
    int nClass = 0;
    int nSLen = 0;
    string sClass = "";
    string sCDKey = GetPCPublicCDKey( oPC );

    for( i = 0; i < 4; i++ )
    {
        nClass = GetClassByPosition(i, oPC);
        switch( nClass )
        {
            case CLASS_TYPE_ARCANE_ARCHER: sClass = sClass + "/Arcane Archer"; break;
            case CLASS_TYPE_ASSASSIN: sClass = sClass + "/Assassin"; break;
            case CLASS_TYPE_BARBARIAN: sClass = sClass + "/Barbarian"; break;
            case CLASS_TYPE_BARD: sClass = sClass + "/Bard"; break;
            case CLASS_TYPE_BLACKGUARD: sClass = sClass + "/Blackguard"; break;
            case CLASS_TYPE_CLERIC: sClass = sClass + "/Cleric"; break;
            case CLASS_TYPE_DIVINECHAMPION: sClass = sClass + "/Divine Champion"; break;
            case CLASS_TYPE_DRAGONDISCIPLE: sClass = sClass + "/Dragon Disciple"; break;
            case CLASS_TYPE_DWARVENDEFENDER: sClass = sClass + "/Dwarven Defender"; break;
            case CLASS_TYPE_DRUID: sClass = sClass + "/Druid"; break;
            case CLASS_TYPE_FIGHTER: sClass = sClass + "/Fighter"; break;
            case CLASS_TYPE_HARPER: sClass = sClass + "/Harper"; break;
            case CLASS_TYPE_MONK: sClass = sClass + "/Monk"; break;
            case CLASS_TYPE_PALADIN: sClass = sClass + "/Paladin"; break;
            case CLASS_TYPE_PALEMASTER: sClass = sClass + "/Pale Master"; break;
            case CLASS_TYPE_RANGER: sClass = sClass + "/Ranger"; break;
            case CLASS_TYPE_ROGUE: sClass = sClass + "/Rogue"; break;
            case CLASS_TYPE_SHADOWDANCER: sClass = sClass + "/Shadow Dancer"; break;
            case CLASS_TYPE_SHIFTER: sClass = sClass + "/Shifter"; break;
            case CLASS_TYPE_SORCERER: sClass = sClass + "/Sorcerer"; break;
            case CLASS_TYPE_WEAPON_MASTER: sClass = sClass + "/Weapon Master"; break;
            case CLASS_TYPE_WIZARD: sClass = sClass + "/Wizard"; break;
            default: break;
        }
    }

    nSLen = GetStringLength( sClass );
    nSLen--;
    sClass = GetSubString(sClass, 1, nSLen);

    return sClass;
}

string GetRace( object oPC )
{
    string sRace = "";

    sRace = GetSubRace( oPC );
    if( sRace != "" ) return sRace;

    if( GetRacialType( oPC ) == RACIAL_TYPE_DWARF ) return "Dwarf";
    if( GetRacialType( oPC ) == RACIAL_TYPE_ELF ) return "Elf";
    if( GetRacialType( oPC ) == RACIAL_TYPE_GNOME ) return "Gnome";
    if( GetRacialType( oPC ) == RACIAL_TYPE_HALFELF ) return "Half-Elf";
    if( GetRacialType( oPC ) == RACIAL_TYPE_HALFLING ) return "Kender";
    if( GetRacialType( oPC ) == RACIAL_TYPE_HALFORC ) return "Half-Orc";
    if( GetRacialType( oPC ) == RACIAL_TYPE_HUMAN ) return "Human";

    return "Invalid";

}


/*******************************************************************************
    MAIN ROUTINE BEGINS...
*/

void main()
{
    object oPC = GetEnteringObject();
    if( !GetIsPC( oPC ) ) return;

    // Check the ban on the PC
    // 0 = not banned
    // 1 = banned!
    if( EnforceBan( oPC ) == 1 ) return;

    //***** DM RESERVE SCRIPT! *************************************************
    //Check to make sure that the maximum number of players has not been reached.
    //
    int nPlayers = ExamineNumPlayers( oPC );
    if( nPlayers > 25 )
    {
        //All players will get autobooted.. DMs proceed

        DelayCommand( 4.0f, FloatingTextStringOnCreature( "Server limit reached, remaining slots for DMs only, auto-booting.", oPC, FALSE ) );
        DelayCommand( 7.0f, FloatingTextStringOnCreature( "Server limit reached, remaining slots for DMs only, auto-booting.", oPC, FALSE ) );
        DelayCommand( 15.0f, BootPC( oPC ) );
        return;
    }
    //**** END OF RESERVE SCRIPT ***********************************************

    // Begin PC processing
    SetLocalInt( oPC, "ENTERCHK", 0 );

    // Log and announce player entry.
    LogEntry( oPC );

    // Set the players recall point...also changed in OnAquireItem.
    SetRecall( oPC );

    // Clean the PC of contraband
    CleanPC( oPC );

    // Grant them any "module" items they do not have already
    GrantItems( oPC );

    //Last thing that we do is look for the death token from the player...
    // *MOVED TO _START_ONENTER AS WELL
    if( GetTag( GetArea( oPC ) ) != "START" )
    {
        object oToken = GetItemPossessedBy( oPC, "DeathToken" );
        if( GetIsObjectValid( oToken ) )
        {
            //the entering player has a token.. kill them!
            effect eDie = EffectDeath( TRUE, TRUE );
            FloatingTextStringOnCreature( "The Gods are displeased with you!", oPC, FALSE );

            AssignCommand( oPC, ClearAllActions() ); // Clears all actions of the PC
            DelayCommand( 0.2f, SetCommandable( FALSE, oPC ) );
            DelayCommand( 3.0f, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDie, oPC ) );
            DelayCommand( 4.0f, SetCommandable( TRUE, oPC ) );
        }
    }

 //Optional --- Support for NWNX added for Shayan's Subraces. (Remember to setup and import the neccessary files
//              for NWNX. The scripts are not included in the Subraces package).
//ExecuteScript("aps_onload", GetModule());

//--End NWNX

//----Modification for Shayan's Subrace Engine
   DelayCommand(2.0, ExecuteScript("sha_on_modload", GetModule()));
//----End Modification.

    // Look at the PC and determine of they have an associate saved!
    CheckForAssociates( oPC );

    // End of PC processing
    SetLocalInt( oPC, "ENTERCHK", 1 );
}
--- End code ---

OnModLoad


--- Code: ---#include "x2_inc_switches"
#include "x2_inc_restsys"

void main()
{
    SetModuleOverrideSpellscript( "02_rokspellhook" );


//----Modification for Shayan's Subrace Engine
   DelayCommand(2.0, ExecuteScript("sha_on_modload", GetModule()));
//----End Modification.

    // Tells the module use tag based scripts for item activate events.
    SetModuleSwitch( MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE );

    // Tells the module to use the random monster encounter on the rest system
    SetModuleSwitch( MODULE_SWITCH_USE_XP2_RESTSYSTEM, TRUE );
    // Use a different 2da for the wandering monster system.
    // SetWanderingMonster2DAFile("des_restsystem");
    WMBuild2DACache();

    // Make rogues do a UMD skill check when using scrolls
    SetModuleSwitch( MODULE_SWITCH_ENABLE_UMD_SCROLLS, TRUE );

    // Make epic spells hurt their caster, if required
    SetModuleSwitch( MODULE_SWITCH_EPIC_SPELLS_HURT_CASTER, TRUE );

    // Prevent spellcaster's abusing expertise to raise their AC, drops
    // expertise whenever a spell is cast by a player
    SetModuleSwitch( MODULE_VAR_AI_STOP_EXPERTISE_ABUSE, TRUE );

    // Make creatures use mobile animations after they spawn.
    SetModuleSwitch( CREATURE_VAR_USE_SPAWN_AMBIENT, TRUE );

    // Hurt neutral NPCs
    SetModuleSwitch( MODULE_SWITCH_AOE_HURT_NEUTRAL_NPCS, TRUE );


}
--- End code ---

so yeah heeh sowwie again for my lack of ability but I really have been trying at this one for two days ask Mo lol

Navigation

[0] Message Index

[*] Previous page

Go to full version