//:://///////////////////////////////////////////// //:: Intelligent Weapon Include File //:: x2_inc_intweapon //:: Copyright (c) 2003 Bioware Corp. //::////////////////////////////////////////////// /* Central include file for the intelligent weapon functionality in Hordes of the Underdark */ //::////////////////////////////////////////////// //:: Created By: Georg Zoeller //:: Created On: 2003-09-04 //:: Modified : 2003-10-11 //::////////////////////////////////////////////// #include "x2_i0_spells" // ---------------------------------------------------------------------------- // Configuration Constants // ---------------------------------------------------------------------------- const int X2_IW_INTERJECTION_CHANCE_EQUIP = 25; const int X2_IW_INTERJECTION_TYPE_EQUIP = 1; const int X2_IW_INTERJECTION_EQUIP_COUNT = 5; const int X2_IW_INTERJECTION_CHANCE_UNEQUIP = 25; const int X2_IW_INTERJECTION_TYPE_UNEQUIP = 2; const int X2_IW_INTERJECTION_UNEQUIP_COUNT = 5; const int X2_IW_INTERJECTION_CHANCE_BATTLECRY = 8; const int X2_IW_INTERJECTION_TYPE_BATTLECRY = 3; const int X2_IW_INTERJECTION_BATTLECRY_COUNT = 20; const int X2_IW_INTERJECTION_CHANCE_ONHIT_CRE = 20; const int X2_IW_INTERJECTION_TYPE_ONHIT_CRE = 4; const int X2_IW_INTERJECTION_TYPE_TRIGGER = 5; const int X2_IW_CURSE_ENHANCEMENT_DURATION = 10; // ---------------------------------------------------------------------------- // Prototypes // ---------------------------------------------------------------------------- // * Return the Dialog ResRef Name of the intelligent weapon passed in. string IWGetWeaponDialogName(object oWeapon); // * Wrapper to use IWSpawnInWeaponCreature with Delaycommand void IWSWrapper(object oPlayer, object oWeapon); // * Spawns in a null human creature for oWeapon worn by oPlayer. object IWSpawnInWeaponCreature(object oPlayer, object oWeapon, int bEquip = TRUE); // * Start a conversation with the intelligent weapon. This will make the // * weapon jump out of the players hands onto a null human and start the conv. void IWStartIntelligentWeaponConversation(object oPlayer,object oWeapon); // * End an intelligent weapon conversation, despawning the null human that wields // * the weapon and moving the weapon back into the players hands. This should be // * called on the OnEnd and OnAbort scripts of the weapon dialog void IWEndIntelligentWeaponConversation(object oWeaponCreature , object oPlayer); // * Returns TRUE if oPlayer is currently engaged in a conversation with his // * intelligent weapon int IWGetIsInIntelligentWeaponConversation(object oPlayer); // * Sets the starting conditions for the next intelligent weapon conversation void IWSetConversationCondition(object oPlayer,int nType, int nValue); // * Gets the starting conditions for current intelligent weapon conversation int IWGetConversationCondition(object oPlayer,int nType); // * Clear current intelligent weapon starting conditions void IWClearConversationConditions(object oPlayer); void IWSetCreatureHadOneLiner(object oCreature, int bValue); void IWPlayRandomEquipComment(object oPlayer,object oWeapon); void IWPlayRandomUnequipComment(object oPlayer,object oWeapon); void IWPlayRandomHitQuote(object oPlayer, object oWeapon, object oTarget); object IWGetIntelligentWeaponEquipped(object oPlayer); // * Transforms the weapon passed in oWeapon into an intelligent weapon, preserving // * all item properties stored on the weapon. // * nLevel - The power level of the weapon - unused at the moment (1 = default) void IWCreateIntelligentWeapon(object oWeapon, int nLevel =1 ); void IWSetEnhancementAndDrainLevel(object oWeapon, int nAddition, int bRemove = FALSE); int IWGetStaticEnhancementBonus(object oWeapon); // * Sets the number of times a player has talked to the intelligent weapon // * This information is stored on the player void IWSetTalkedTo(object oPlayer, string sWeaponTag, int nNumTimes = 1); // * Gets the number of times a player has talked to the intelligent weapon // * This information is stored on the player int IWGetTalkedTo(object oPlayer, string sWeaponTag); // * Sets the asked flag for question no. nQuestion, in sWeaponTag's conversation // * on the Player void IWSetQuestionAsked(object oPlayer, string sWeaponTag,int nQuestion); // * Returns the asked flag for question no. nQuestion, in sWeaponTag's conversation // * on the Player int IWGetQuestionAsked(object oPlayer, string sWeaponTag,int nQuestion); // * Helper Function. Returns TRUE if we currently play Hordes of the Underdark // * Chapter 1 int IWGetIsHotUChapter1(); // * Helper Function. Returns TRUE if we currently play Hordes of the Underdark // * Chapter 2 int IWGetIsHotUChapter2(); // * Helper Function. Returns TRUE if we currently play Hordes of the Underdark // * Chapter 3 int IWGetIsHotUChapter3(); // ----------------------------------------------------------------------------- // Return the Dialog ResRef Name of the intelligent weapon passed in. // ----------------------------------------------------------------------------- string IWGetWeaponDialogName(object oWeapon) { return GetTag(oWeapon); } // ----------------------------------------------------------------------------- // Spawns in a null human creature for oWeapon worn by oPlayer. // ----------------------------------------------------------------------------- object IWSpawnInWeaponCreature(object oPlayer, object oWeapon, int bEquip = TRUE) { /* object oSummon = CreateObject(OBJECT_TYPE_CREATURE,"theintelligentwe",GetLocation(oPlayer)); if (!GetIsObjectValid(oSummon)) { // * Intentionally returning here return oSummon; } if (bEquip) { object oNew = CopyItem(oWeapon,oSummon,TRUE); SetDroppableFlag(oNew, FALSE); SetPlotFlag(oSummon,TRUE); if (GetIsInCombat(oPlayer)) { //AssignCommand(oSummon,SpeakString("Not Now, we have to fight!")); return OBJECT_INVALID; } effect eInvis = EffectCutsceneGhost(); ApplyEffectToObject(DURATION_TYPE_PERMANENT,eInvis,oSummon); DelayCommand(0.9f,AssignCommand(oSummon, ActionEquipItem(oNew, INVENTORY_SLOT_RIGHTHAND))); DelayCommand(1.0f,ActionStartConversation(oSummon,IWGetWeaponDialogName(oWeapon),FALSE,FALSE)); } SetLocalInt(oPlayer,"X2_L_IN_INTWEAPON_CONVERSATION",TRUE); SetLocalObject(oSummon,"CREATOR",oPlayer); SetLocalObject(oSummon,"BLADE",oWeapon); SetLocalObject(oPlayer,"X2_O_INTWEAPON_SPIRIT",oSummon); return oSummon;*/ return OBJECT_INVALID; } // ----------------------------------------------------------------------------- // Wrapper to use IWSpawnInWeaponCreature with Delaycommand // ----------------------------------------------------------------------------- void IWSWrapper(object oPlayer, object oWeapon) { IWSpawnInWeaponCreature(oPlayer,oWeapon); } // ----------------------------------------------------------------------------- // Start a conversation with the intelligent weapon. This will make the // weapon jump out of the players hands onto a null human and start the conv. // ----------------------------------------------------------------------------- void IWStartIntelligentWeaponConversation(object oPlayer,object oWeapon) { //SetLocalInt(oWeapon,"X2_L_INTWEAPON_EQUIP",1); // ActionUnequipItem(oWeapon); SetLocalInt(oPlayer,"X2_L_IN_INTWEAPON_CONVERSATION",TRUE); object oCreate = CreateObject(OBJECT_TYPE_PLACEABLE,"x2_plc_intwp",GetLocation(OBJECT_SELF)); DelayCommand(0.9f,AssignCommand(oPlayer,ClearAllActions(TRUE))); DelayCommand(1.0,AssignCommand(oPlayer,ActionStartConversation(oCreate, IWGetWeaponDialogName(oWeapon)))); // DelayCommand(1.0f,IWSWrapper(oPlayer,oWeapon)); // ClearAllActions(); } // ----------------------------------------------------------------------------- // End an intelligent weapon conversation, // This should be called on the OnEnd and OnAbort scripts of the weapon dialog // ----------------------------------------------------------------------------- void IWEndIntelligentWeaponConversation(object oWeaponCreature , object oPlayer) { /* object oCreator = GetLocalObject(oWeaponCreature,"CREATOR"); object oBlade = GetLocalObject(oWeaponCreature,"BLADE"); effect eInvis = EffectVisualEffect(VFX_DUR_CUTSCENE_INVISIBILITY); AssignCommand(oCreator,ClearAllActions()); DelayCommand(0.3f,ApplyEffectToObject(DURATION_TYPE_PERMANENT,eInvis,oWeaponCreature)); SetLocalInt(oBlade,"X2_L_INTWEAPON_EQUIP",1); DelayCommand(0.5f,AssignCommand(oCreator,ActionEquipItem(oBlade,INVENTORY_SLOT_RIGHTHAND))); effect eDis = EffectDisappear(); ApplyEffectToObject(DURATION_TYPE_INSTANT,eDis,oWeaponCreature); DeleteLocalObject(oPlayer,"X2_O_INTWEAPON_SPIRIT"); IWClearConversationConditions(oPlayer);*/ DeleteLocalInt(oPlayer,"X2_L_IN_INTWEAPON_CONVERSATION"); } // ----------------------------------------------------------------------------- // Returns TRUE if oPlayer is currently engaged in a conversation with his // intelligent weapon // ----------------------------------------------------------------------------- int IWGetIsInIntelligentWeaponConversation(object oPlayer) { int nRet = GetLocalInt(oPlayer,"X2_L_IN_INTWEAPON_CONVERSATION"); return nRet; } // ----------------------------------------------------------------------------- // Sets the starting conditions for the next intelligent weapon conversation // ----------------------------------------------------------------------------- void IWSetConversationCondition(object oPlayer,int nType, int nValue) { SetLocalInt(oPlayer,"X2_L_INTWEAPON_CONV_TYPE", nType); SetLocalInt(oPlayer,"X2_L_INTWEAPON_CONV_NUMBER", nValue); } // ----------------------------------------------------------------------------- // Clear current intelligent weapon starting conditions // ----------------------------------------------------------------------------- void IWClearConversationConditions(object oPlayer) { DeleteLocalInt(oPlayer,"X2_L_INTWEAPON_CONV_TYPE"); DeleteLocalInt(oPlayer,"X2_L_INTWEAPON_CONV_NUMBER"); } // ----------------------------------------------------------------------------- // Gets the starting conditions for current intelligent weapon conversation // ----------------------------------------------------------------------------- int IWGetConversationCondition(object oPlayer,int nType) { int nRet = FALSE; if (GetLocalInt(oPlayer,"X2_L_INTWEAPON_CONV_TYPE") == nType && nType != 0) { nRet = GetLocalInt(oPlayer,"X2_L_INTWEAPON_CONV_NUMBER"); } return nRet; } void IWPlayRandomEquipComment(object oPlayer,object oWeapon) { if (GetLocalInt(oWeapon,"X2_L_INTWEAPON_EQUIP") == 1) { DeleteLocalInt(oWeapon,"X2_L_INTWEAPON_EQUIP"); return; } if (Random(100)+1 10) { return; } itemproperty ip = ItemPropertyDecreaseAbility(ABILITY_CONSTITUTION,nCurse); int nEnhancement = IWGetStaticEnhancementBonus(oWeapon); nEnhancement += nAddition; if (nEnhancement>20) { nEnhancement = 20; } itemproperty ip2 = ItemPropertyEnhancementBonus(nEnhancement); itemproperty ip3 = ItemPropertyVisualEffect(ITEM_VISUAL_EVIL); float fTime = RoundsToSeconds(X2_IW_CURSE_ENHANCEMENT_DURATION); IPSafeAddItemProperty(oWeapon,ip3,fTime, X2_IP_ADDPROP_POLICY_IGNORE_EXISTING); IPSafeAddItemProperty(oWeapon,ip2,fTime, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, FALSE,TRUE); IPSafeAddItemProperty(oWeapon,ip,fTime, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,FALSE,FALSE); }