PDA

View Full Version : Offensive Force Power Script Help


Hando
12-09-2007, 10:34 AM
I've made a new force power for KOTOR1, and everything works, except the damage. It does no damage when I put in 20. Now, I'm a beginner at scripting, so I cannot see a flaw in my code.
#include "k_inc_force"

void main()
{
SWFP_DAMAGE_TYPE = DAMAGE_TYPE_ELECTRICAL;

object oSource = OBJECT_SELF;
object oTarget = GetSpellTargetObject();


effect eVFX = EffectVisualEffect(3011);
effect eDamage = EffectDamage(20);
ApplyEffectToObject(1, eVFX, oTarget, 4.0f);

}

Any help would be greatly appreciated.

Darth InSidious
12-09-2007, 11:14 AM
Well, you aren't applying the damage to your opponent. This should work:


#include "k_inc_force"

void main()
{
SWFP_DAMAGE_TYPE = DAMAGE_TYPE_ELECTRICAL;

object oSource = OBJECT_SELF;
object oTarget = GetSpellTargetObject();


effect eVFX = EffectVisualEffect(3011);
effect eDamage = EffectDamage(20);
ApplyEffectToObject(1, eVFX, oTarget, 4.0f);
ApplyEffectToObject(0, edamage, oTarget, 4.0f);

}


Hope that helps! :)

Hando
12-09-2007, 11:23 AM
Now I cannot compile. It says:
Error: Undeclared identifier "edamage"
Error: Required argument missing in call to "ApplyEffectToObject"

Darth InSidious
12-09-2007, 11:25 AM
Whoops.

Try "eDamage" instead, without the quotes.

Hando
12-09-2007, 11:29 AM
Thanks. Works perfectly now.

Darth InSidious
12-09-2007, 11:30 AM
Glad I was able to help. :)

Hando
12-12-2007, 03:38 AM
Can I also get the script for a knockdown and stun effect like in force wave?

stoffe
12-12-2007, 08:49 AM
Can I also get the script for a knockdown and stun effect like in force wave?

This variant should knock down and stun as well:


void main() {
object oTarget = GetSpellTargetObject();
effect eVFX = EffectVisualEffect(VFX_FNF_GRENADE_ION);
effect eDamage = EffectDamage(20, DAMAGE_TYPE_ELECTRICAL);
effect ePushy = EffectForcePushTargeted( GetLocation(oTarget) );

// ST: Trigger the SpellCastAt AI event on the victim as offensive power.
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), TRUE));

// ST: Check for Force immunity/resistance
if(!ResistForce(OBJECT_SELF, oTarget)) {
// ST: Show blast and apply the damage
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oTarget, 4.0f);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oTarget);

// ST: Knock down and stun victim if they fail a Reflex saving throw.
if (!ReflexSave(oTarget, GetSpellSaveDC())) {
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePushy, oTarget, 0.1);
DelayCommand(2.55, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectStunned(), oTarget, 6.0));
}
}
else {
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceFizzle(), OBJECT_SELF);
}
}

Darth InSidious
12-12-2007, 08:50 AM
The stun effect is fairly simple. If you want to put it into a script, the function and call should look something like this:


Object oObject = GetFirstPC();
Effect eStun = EffectStunned();

ApplyEffectToObject(1, eStun, oObject, 4.0f);

Please not that this is not a complete script as it is. I think there is an EffectKnockDown, although it may in fact be called EffectPushed. I would recommend searching through nwscript.nss to find the relevant script function, however. :)

EDIT: Beaten to it by stoffe!

Hando
12-13-2007, 07:35 PM
Thanks again, guys.
After a bit of trial and error, I managed to get force lightning to come out of both of the PC's hands, and I modified the damage level to be half of the PC's HP.
(Can barley see the lightning with the huge ion explosion.)