PDA

View Full Version : Force Disarm


StefanRode
10-04-2005, 07:56 AM
Mod Contents:
-------------
fp_disarm.ncs - The force disarm script
if_disarm.tga/.txi - The icon for force pull
k_search.ncs - The melee search script
spells.2da - list of force powers with Force Disarm on the end
source files - I've included the source .nss files for making it compatabile

Where are the source files?

Prime
10-04-2005, 11:02 AM
I don't really know what you are talking about. Have you tried contacting the mod's author?

Darth333
10-04-2005, 12:07 PM
You'll find the source code in the .rar file.

StefanRode
10-05-2005, 09:29 AM
I can't find the source code in the rar

Where can I download the mod Force Disarm with source code?

010_sWitch_010
10-06-2005, 02:04 AM
that's my bad

yeah sorry about that. I was going to put it in but i was in a rush when i posted it so i must have left it out. Here are the two files i made

fp_disarm.nss
//
//FORCE POWER: DISARM
//
//created by 010_sWitch_010
//July 2005


#include "k_inc_force"
#include "k_inc_gensupport"
#include "k_search"

int FORCE_POWER_DISARM = 282;

void main()
{
SWFP_HARMFUL = TRUE;
SWFP_PRIVATE_SAVE_TYPE = SAVING_THROW_REFLEX;
SWFP_PRIVATE_SAVE_VERSUS_TYPE = SAVING_THROW_TYPE_MIND_AFFECTING;

object oTarget = GetSpellTargetObject();
effect eLink1, eLink2;
effect eInvalid;

SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), SWFP_HARMFUL));
//Make Immunity Checks
int nResist = Sp_BlockingChecks(oTarget, eLink1, eLink2, eInvalid);
int nSaves;
if(nResist == 0)
{
nSaves = Sp_MySavingThrows(oTarget);
if(nSaves == 0)
{
//find what the target currently has equiped
int nWeaponType = 0;
object oWeapRight = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON,oTarget);
object oWeapLeft = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON,oTarget);
int nNPC_AI = GetNPCAIStyle(oTarget);

//determine weapon type
if ( GetIsObjectValid(oWeapRight) ){
nWeaponType = GN_GetWeaponTypeFromBaseItem(GetBaseItemType(oWeap Right));
}

//if weapon type is 2, then target has a ranged weapon
//can apply force power on target if ranged
if (nWeaponType == 2)
{
//tell target to unequip items in hands
AssignCommand(oTarget, ActionUnequipItem(oWeapLeft));
AssignCommand(oTarget, ActionUnequipItem(oWeapRight));

//effect to show it worked
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceFizzle(), oTarget);

//adjust NPC AI form
nNPC_AI = NPC_AISTYLE_MELEE_ATTACK;
SetNPCAIStyle(oTarget,nNPC_AI);

//search the targeted NPC's inventory for weapon then equip it.
oWeapRight = searchInventory(oTarget);
AssignCommand(oTarget, ActionEquipItem(oWeapRight, INVENTORY_SLOT_RIGHTWEAPON));
}
}
}
if(nResist > 0 || nSaves > 0)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceFizzle(), OBJECT_SELF);
}
}

k_search.nss
// ::k_search.nss::
//
//Searches the NPC's inventory and returns
//the first melee weapon it finds, otherwise
//returns a short sword
//
//created by 010_sWitch_010
//July 2005

#include "k_inc_gensupport"

int NOT_FOUND = 1;
int FOUND = 2;

void main(){

}

object searchInventory(object oTarget)
{
int found = NOT_FOUND;
int nWeaponType = 0;
object oWeapRight, oFirst, oSearch;

//get first item in inventory
oFirst = GetFirstItemInInventory(oTarget);

//determine weapon type
if (GetIsObjectValid(oFirst)){
nWeaponType = GN_GetWeaponTypeFromBaseItem(GetBaseItemType(oFirs t));
};


//nWeaponType = 1 should be a melee item
if (nWeaponType==1){
//stop searching and return found melee Item
oWeapRight = oFirst;
found = FOUND;
return oWeapRight;

} else{

//search rest of inventory.
while (found == NOT_FOUND){
//get next inventory item
oSearch = GetNextItemInInventory(oTarget);

//determine weapon type
if (GetIsObjectValid(oSearch)){
nWeaponType = 0;
nWeaponType = GN_GetWeaponTypeFromBaseItem(GetBaseItemType(oSear ch));
};

if (nWeaponType==1){
//stop searching and return found melee Item
oWeapRight = oSearch;
found = FOUND;
return oWeapRight;
};

if (oSearch==oFirst || oSearch== OBJECT_INVALID){
//done a complete circle or there are no more items to search
//then give the NPC a short sword
string sItemTag = "w_melee_01";
oWeapRight = CreateItemOnObject(sItemTag,oTarget,1,0);
found = FOUND;
return oWeapRight;
};
};

};
return oWeapRight;
}

StefanRode
10-06-2005, 08:08 AM
I want to compile the files but I get an Error!

C:\Programme\LucasArts\SWKotOR2>NWNNSSCOMP -co Override\* Override\
Modified NeverWinter Nights Script Compiler/Decompiler
Copyright 2002-2003, Edward T. Smith

Compiling: fp_disarm.nss
fp_disarm.nss(10): Error: Unable to open the include file "k_search"
Compilation aborted with errors
Compiling: k_search.nss
k_search.nss(30): Error: Syntax error at "t"
k_search.nss(51): Error: Syntax error at "ch"
Compilation aborted with errors
Total Execution time = 31 ms

C:\Programme\LucasArts\SWKotOR2>pause
Drücken Sie eine beliebige Taste . . .

stoffe
10-06-2005, 08:28 AM
I want to compile the files but I get an Error!
k_search.nss(30): Error: Syntax error at "t"
k_search.nss(51): Error: Syntax error at "ch"
Compilation aborted with errors


The forum has messed up the code since it contained text longer than 50 characters without any whitespace in between. Remove the extra spaces it has inserted where it says oFirs t and oSear ch so it reads oFirst and oSearch.

Make sure you have the k_search.nss file in the same folder as nwnnsscomp.exe as well, or the compiler won't find it.

StefanRode
10-06-2005, 08:49 AM
New Error
d:\dokumente und Einstellungen\Stefan Rode_2\Desktop>NWNNSSCOMP -co Override\* O
verride\
Modified NeverWinter Nights Script Compiler/Decompiler
Copyright 2002-2003, Edward T. Smith

Compiling: fp_disarm.nss
fp_disarm.nss(14): Error: Syntax error at "("
fp_disarm.nss(41): Error: Syntax error at "Right"
fp_disarm.nss(70): Error: Unexpected end of file
Compilation aborted with errors
Total Execution time = 32 ms

d:\dokumente und Einstellungen\Stefan Rode_2\Desktop>pause
Drücken Sie eine beliebige Taste . . .

stoffe
10-06-2005, 11:28 AM
New Error
fp_disarm.nss(41): Error: Syntax error at "Right"


Same thing there, a line of code that was too long without any whitespaces, prompting the forum to forcibly insert spaces. Change oWeap Right to oWeapRight and it should work better. :)

010_sWitch_010
10-07-2005, 02:41 AM
bugger didn't notice those gaps, woops

StefanRode
10-07-2005, 06:23 AM
Hi 010_sWitch_010
can you send me a new source code without any errors.
Thank You.

StefanRode
10-07-2005, 06:25 AM
At this moment I have the following Errors!
d:\dokumente und Einstellungen\Stefan Rode_2\Desktop>NWNNSSCOMP -co Override\* O
verride\
Modified NeverWinter Nights Script Compiler/Decompiler
Copyright 2002-2003, Edward T. Smith

Compiling: fp_disarm1.nss
fp_disarm1.nss(14): Error: Syntax error at "("
fp_disarm1.nss(70): Error: Unexpected end of file
Compilation aborted with errors
Total Execution time = 31 ms

d:\dokumente und Einstellungen\Stefan Rode_2\Desktop>pause
Drücken Sie eine beliebige Taste . . .

stoffe
10-07-2005, 08:32 AM
At this moment I have the following Errors!
Compiling: fp_disarm1.nss
fp_disarm1.nss(14): Error: Syntax error at "("
fp_disarm1.nss(70): Error: Unexpected end of file
Compilation aborted with errors


You've probably made some mistake when saving the code. I just copied the code that was posted in this thread and made the above mentioned corrections and everything compiled just fine without any errors.

Try to copy the code again from the forum post to a new text file and see if it works better. :)

StefanRode
10-07-2005, 08:44 AM
NEW ERROR
d:\dokumente und Einstellungen\Stefan Rode_2\Desktop>NWNNSSCOMP -co Override\* O
verride\
Modified NeverWinter Nights Script Compiler/Decompiler
Copyright 2002-2003, Edward T. Smith

Compiling: fp_disarm.nss
k_search.nss(30): Error: Undeclared identifier "GN_GetWeaponTypeFromBaseItem"
k_search.nss(51): Error: Undeclared identifier "GN_GetWeaponTypeFromBaseItem"
k_search.nss(65): Error: Too many arguments specified in call to "CreateItemOnOb
ject"
fp_disarm.nss(41): Error: Undeclared identifier "GN_GetWeaponTypeFromBaseItem"
Compilation aborted with errors
Total Execution time = 47 ms

d:\dokumente und Einstellungen\Stefan Rode_2\Desktop>pause
Drücken Sie eine beliebige Taste . . .
Batchvorgang abbrechen (J/N)?

StefanRode
10-07-2005, 08:48 AM
Or can you sent me the corrected source codes as file (*nss)

stoffe
10-07-2005, 08:50 AM
Compiling: fp_disarm.nss
k_search.nss(30): Error: Undeclared identifier "GN_GetWeaponTypeFromBaseItem"

Make sure you have the include file k_inc_gensupport.nss in the same folder as your nwnnsscomp EXE. This is a standard include file that comes with the game and can be extracted from Scripts.bif with KotorTool.

GN_GetWeaponTypeFromBaseItem() is a custom function that is declared in that include file.

StefanRode
10-07-2005, 08:55 AM
ok. Thank You. everything compiled just fine without any errors.

Darth333
10-07-2005, 08:57 AM
If you look at the beginning of the script, it says:
#include "k_inc_force"
#include "k_inc_gensupport"
#include "k_search"

You have to extract k_inc_gensupport.nss and k_inc_force.nss in the same folder as the script you are trying to compile and nwnnsscomp.exe.

If you look at k_inc_gensupport, you will find "GN_GetWeaponTypeFromBaseItem".

Edit: stoffe beats me again :p