PDA

View Full Version : force script


moda
09-28-2005, 06:40 AM
hey i tried to do a force crush script but i couldnt get it to work. this is what i cut it down to to stop alot of the errors



// DJS-OEI 1/2/2004
//case FORCE_POWER_FORCE_CRUSH:
//{
//SWFP_HARMFUL = TRUE;
//SWFP_PRIVATE_SAVE_TYPE = SAVING_THROW_FORT;

int nDice = GetHitDice(OBJECT_SELF);
// DJS-OEI 10/7/2004
// Removed damage level cap and changed to d10.
/*
if(nDice > 10)
{
nDice = 10;
}
*/
//SWFP_DAMAGE = Sp_CalcDamage( oTarget, nDice, 6 );
//SWFP_DAMAGE = Sp_CalcDamage( oTarget, nDice, 10 )*16;
//SWFP_DAMAGE = d6(nDamage);
// DJS-OEI 8/16/2004
// Damage type is now Unstoppable, although its define is still Acid.
//SWFP_DAMAGE_TYPE = DAMAGE_TYPE_UNIVERSAL;



please someone tell me what im doing wrong

Det. Bart Lasiter
09-28-2005, 11:53 AM
You commented nearly everything in the script with the "//" at the beginning of the line. So, basically this is what the compiler reads the script as:





int nDice = GetHitDice(OBJECT_SELF);

So basically, you need to uncomment the script to make it work, so try this:

case FORCE_POWER_FORCE_CRUSH:
{
SWFP_HARMFUL = TRUE;
SWFP_PRIVATE_SAVE_TYPE = SAVING_THROW_FORT;

int nDice = GetHitDice(OBJECT_SELF);
if (nDice > 10)
{
nDice = 10;
}

SWFP_DAMAGE = Sp_CalcDamage(oTarget, nDice, 10)*16; // Multiple damage amounts?
SWFP_DAMAGE_TYPE = DAMAGE_TYPE_UNIVERSAL;

Now, I actually don't have k_inc_force.nss on hand, so I'm not sure about the saves for this FP, or the K2 format of it(in terms of effect application), but you probably still need to apply the effects, which I'm assuming is in the later part of the case.

moda
09-28-2005, 12:12 PM
i tried that and it comes up with synax error at case and synax error at if. im using the ciompiling function in the kotor tool

Darkkender
09-28-2005, 01:02 PM
Your case statement is looking for a pre-defined variable named "FORCE_POWER_FORCE_CRUSH" if you haven't defined this elsewhere then it will shoot out many different syntax errors. Also in what manner are you trying to implement the script when you compile it?

moda
09-28-2005, 01:18 PM
ok ill just state whta ive been trying to do. what ive been trying to do is multiply the damage done by the power force crush by 16. i managed to do this ounce before some time ago and what i used previously is what i remember of the script that worked. most of the scripts i manage to get to work are pure trial and error nothing more nothing less

Det. Bart Lasiter
09-28-2005, 01:33 PM
Oh, just add "*16" to the damage variable, don't change the rest, and re-compile "k_sp1_generic", with the new "k_inc_force" in the same folder (or the "Override" folder, I can't remember). Just don't directly compile "k_inc_force", i.e it shouldn't be in the tree-view of KT's project manager.

Darkkender
09-28-2005, 01:43 PM
When it comes to Force Powers the above Force Crush power would be listed in the k_inc_force.nss file you would make a change in there and put the k_inc_force.nss file in your compile folder and recompile the proper script that is listed in spells.2da. If that helps any. I'm at work so I can't see the files you need to tweak here.

moda
09-28-2005, 01:53 PM
if i do that will it interfere with the mods i have installed. also can you please explain that to me a little better, i didnt quite understand the meaning of your words. ive only just managed to get kotor tool to work, so just give me a run down

moda
09-28-2005, 01:57 PM
i aplied the changes to the k_inc_force or wateva it is file, and it comes up with an error message saying its an unhandled thing

Det. Bart Lasiter
09-28-2005, 01:58 PM
Once you modify "k_inc_force.nss", the file with the FP's in it, save it to the same directory as another file you need, "k_sp1_generic.nss", then compile "k_sp1_generic.nss". As for the editing of the file, the damage amount is usually declared as "nDamage", so just add "*16" to that, for instance:

int nDamage = Sp_CalcDamage(oTarget, nDice, 10)*16;

Darkkender
09-28-2005, 02:11 PM
are you trying to recompile the k_sp1_generic.nss or k_inc_force.nss?

moda
09-28-2005, 02:11 PM
so i dont compile k_inc_force.nss or do i compile that and the other file simultaneously

Darkkender
09-28-2005, 02:13 PM
int nDamage = Sp_CalcDamage(oTarget, nDice, 10) * 16;


Might I recomend putting a space in between the multiply & 16 Jmac as the compiler may be trying to read a pointer which will throw an error.

Darkkender
09-28-2005, 02:14 PM
so i dont compile k_inc_force.nss or do i compile that and the other file simultaneously

k_inc_force.nss is an include file and cannot be compiled. In fact the compiler will throw it back out and say that it is and Include file and cannot be compiled in a error message.

If a script is missing a "void Main {}" statement it is an include file.

stoffe
09-28-2005, 08:09 PM
as the compiler may be trying to read a pointer which will throw an error.

NWScript does not have pointers or any memory management functionality. It's a scripting language with a higher level of abstraction originally designed to prevent any potentially dangerous operations that might make the engine crash or become unstable (though that might still happen due to bugs in the script engine and various functions :)).


hey i tried to do a force crush script but i couldnt get it to work. this is what i cut it down to to stop alot of the errors


Your problem is that you have taken a snippet of code out of its context without adapting it to running as its own script. You have no main function, you have a case outside of a switch statement and you have lots of variables and (unless you include k_inc_force) functions undefined.

If you turn it into its own independent script by adding what is missing and removing the parts not necessary you might end up with something like this:

int ST_CalcDamage(object oTarget, int nNumDice, int nSizeDice, int nNonRandom = 0);
int ST_BlockingChecks(object oTarget, effect eEffect1, effect eEffect2);
int ST_SavingThrows(object oTarget, int nSaveType, int nSaveCat = SAVING_THROW_TYPE_ALL, int nDC = 0);

void main() {
object oTarget = GetSpellTargetObject();
int nDmg = ST_CalcDamage(oTarget, GetHitDice(OBJECT_SELF), 10) * 16;
effect eCrush = EffectCrush();
effect eDamage = EffectDamage(nDmg, DAMAGE_TYPE_ACID);
effect eDrop = EffectForcePushed();

if (ST_BlockingChecks(oTarget, eCrush, eDamage)) {
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceFizzle(), OBJECT_SELF);
return;
}

if (ST_SavingThrows(oTarget, SAVING_THROW_FORT))
eDamage = EffectDamage(nDmg/2, DAMAGE_TYPE_ACID);

SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), TRUE));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eCrush, oTarget, 2.0);
DelayCommand(1.64, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oTarget));
DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDrop, oTarget));

}


// ---------------------------------------------------------------------
// Support functions (from include)
// ---------------------------------------------------------------------

int ST_SavingThrows(object oTarget, int nSaveType, int nSaveCat = SAVING_THROW_TYPE_ALL, int nDC = 0) {
nDC = (nDC > 0 ? nDC : GetSpellSaveDC());

// Modifiers due to force user's Form
if (IsFormActive( OBJECT_SELF, FORM_FORCE_IV_MASTERY ))
nDC += 2;

// Modifiers due to target's Form
if (IsFormActive( oTarget, FORM_SABER_II_MAKASHI ) || IsFormActive( oTarget, FORM_FORCE_I_FOCUS ))
nDC -= 2;
else if (IsFormActive( oTarget, FORM_SABER_VI_NIMAN ))
nDC -= 1;
else if (IsFormActive( oTarget, FORM_SABER_VII_JUYO ) || IsFormActive( oTarget, FORM_FORCE_IV_MASTERY ))
nDC += 4;

nDC = (nDC < 1 ? 1 : nDC);

int nSave;
switch (nSaveType) {
case SAVING_THROW_FORT: nSave = FortitudeSave(oTarget,nDC, nSaveCat); break;
case SAVING_THROW_REFLEX: nSave = ReflexSave(oTarget, nDC, nSaveCat); break;
case SAVING_THROW_WILL: nSave = WillSave(oTarget, nDC, nSaveCat); break;
}

if (nSave > 0) {
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceResisted(OBJECT_SELF), oTarget);
if (nSave == 1)
DisplayFeedBackText(oTarget, 2);
else if (nSave == 2)
DisplayFeedBackText(oTarget, 1);
}
return nSave;
}


int ST_BlockingChecks(object oTarget, effect eEffect1, effect eEffect2) {
if(GetIsLinkImmune(oTarget, eEffect1) || GetIsLinkImmune(oTarget, eEffect2)) {
DisplayFeedBackText(oTarget, 1);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceResisted(OBJECT_SELF), oTarget);
return TRUE;
}

if(ResistForce(OBJECT_SELF, oTarget)) {
DisplayFeedBackText(oTarget, 0);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceResisted(OBJECT_SELF), oTarget);
return TRUE;
}

return FALSE;
}


int ST_CalcDamage(object oTarget, int nNumDice, int nSizeDice, int nNonRandom = 0) {
int nDamage = 0;

if (nNonRandom == 0) {
switch(nSizeDice) {
case 2: nDamage = d2(nNumDice); break;
case 3: nDamage = d3(nNumDice); break;
case 4: nDamage = d4(nNumDice); break;
case 6: nDamage = d6(nNumDice); break;
case 8: nDamage = d8(nNumDice); break;
case 10: nDamage = d10(nNumDice); break;
case 12: nDamage = d12(nNumDice); break;
case 20: nDamage = d20(nNumDice); break;
case 100: nDamage = d100(nNumDice); break;
default:
nDamage = Random(nNumDice * nSizeDice) + 1;
if (nDamage < nNumDice)
nDamage = nNumDice;
break;
}
}
else {
nDamage = nNonRandom;
}

if(IsFormActive(OBJECT_SELF, FORM_FORCE_I_FOCUS)) {
nDamage += 3;
}
else if(IsFormActive(OBJECT_SELF, FORM_FORCE_II_POTENCY)) {
nDamage += ( nDamage * 30 ) / 100;
}

return nDamage;
}


Save the script as forcecrush.nss and compile it with nwnnsscomp.exe with a commandline like:

nwnnsscomp.exe -c -g 2 forcecrush.nss


Put the resulting forcecrush.ncs in your override folder, then alter the impactscript column for line 177 in your spells.2da file to read forcecrush and save the modified 2da in override as well.

Darkkender
09-29-2005, 12:35 AM
NWScript does not have pointers or any memory management functionality. It's a scripting language with a higher level of abstraction originally designed to prevent any potentially dangerous operations that might make the engine crash or become unstable (though that might still happen due to bugs in the script engine and various functions :))

I had mentioned this because in the compiler design portion of the book mentioned in my sig that was something advised to watch out for when developing a scripting language. So I was using that same logic with my above comment.
*On a side note I've almost got the first chunk of the conversion of my script compiler done to support "nss" files. I'm actually rebuilding the compiler from the bottom back up to support multiple scripting languages. However at 1-2 hours a day to work on it, it's going slow.*

moda
09-29-2005, 04:32 AM
so the file i put into the override is k_sp1_generic file after ive compiled it with k_inc_force.nss in the same directory

moda
09-29-2005, 06:33 AM
ok can somebody please just tell me what i have to have as script to multiply the damage done by force crush, ie the eact .nss file i need to compile, and how would i use a script to increase the powers range

stoffe
09-29-2005, 06:58 AM
ok can somebody please just tell me what i have to have as script to multiply the damage done by force crush, ie the eact .nss file i need to compile, and how would i use a script to increase the powers range

Is there anything wrong with the answer I provided two posts above? If my english is too incomprehensible let me know and I'll remember to leave answering your questions to those who can make themselves understood. :)

moda
09-29-2005, 07:17 AM
sorry, i went back through all the post again and i payed more attention to the details. thankyou it worked. but which of those values is the range

stoffe
09-29-2005, 07:37 AM
sorry, i went back through all the post again and i payed more attention to the details. thankyou it worked. but which of those values is the range

The damage range? It's set on the line that looks like:

int nDmg = ST_CalcDamage(oTarget, GetHitDice(OBJECT_SELF), 10) * 16;


As it reads above you get (level)d10 * 16 damage. I.e. the second parameter to the CalcDamage() function is the number of dice to throw for damage, which is equal to the character level of the force user (which you get with the GetHitDice() function), and the third parameter sets that 10 sided dice are used. So a Level 20 character would do 20d10, or 20-200 damage, when using Force Crush.

The * 16 multiplicator is the extra damage that you asked for in one of your posts above, which would make the power do 320-3200 damage when used by a level 20 character. A touch overkill if you ask me since it would kill anyone in one use even if they make their saving throw, but it's your choice. :)

moda
09-29-2005, 09:06 AM
yeah i know its overkill. i wanted the script to make the power equivalent to the foes you encounter with the hardcore mod, so you can kill them far more quickly. but by range i meant the distance the power can be used at

stoffe
09-29-2005, 09:19 AM
yeah i know its overkill. i wanted the script to make the power equivalent to the foes you encounter with the hardcore mod, so you can kill them far more quickly. but by range i meant the distance the power can be used at

That is not set in the script, but in the range column in spells.2da for the line of each power (force crush is line 177). You can set that column to one of the following values:


value meaning
----- ---------
P Personal, affects the force user.
T Touch, will be used at melee range, 2 meters from target
S Short range, used at most 10 meters from the target
M Medium range, can use 15 meters from the target
L Long, can be used 28 meters from the target
W Weapon throw range, 15 meters from target