Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

ForcePushed(); effect not working

Page: 1 of 1
 moda
03-25-2011, 12:29 PM
#1
I am trying to make a power which should push the target some distance away before doing damage, as it stands the push effect is not being applied
pvoid main() {

object oCaster = OBJECT_SELF;

if( GetGoodEvilValue( oCaster ) < 51 ) {
int nForce, nFP, nHP;
effect costDamage;
effect push = EffectForcePushed();
push = EffectLinkEffects( push, EffectVisualEffect( VFX_IMP_FORCE_PUSH ) );
effect ecaster, eDamage;
object oTarget = GetSpellTargetObject();
while( GetIsObjectValid( oTarget ) ) {
if( !GetIsDead(oTarget) && GetIsEnemy(oTarget) ) {
nForce = GetCurrentForcePoints( oCaster ) * 2;
nFP = GetCurrentForcePoints( oTarget ) / 5;
nHP = GetCurrentHitPoints( oTarget );
ecaster = EffectHeal( nHP );
ecaster = EffectLinkEffects( ecaster, EffectDamageForcePoints(20));
eDamage = EffectDamageForcePoints( nForce );
eDamage = EffectLinkEffects( eDamage, EffectDamage( nForce, DAMAGE_TYPE_DARK_SIDE ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, push, oTarget, 0.2);
ActionWait(0.3);
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oTarget );
ApplyEffectToObject( DURATION_TYPE_INSTANT, ecaster, oCaster );

ActionWait(0.5);
if( GetIsDead( oTarget ) ) {
AdjustCreatureAttributes( oCaster, Random(6), 1 );
AddBonusForcePoints( oCaster, nFP );
}
}

}
}
}
 TimBob12
03-25-2011, 1:00 PM
#2
Is your character darkside?

Sounds obvious but its the little things that people miss.
 moda
03-25-2011, 1:10 PM
#3
yes, i have also tried using DelayCommand(); to make the damage portion fire after the push has finnished but that only causes my game to freeze


nevermind managed to fix
included below is the source i used incase anyone has trouble with this sort of thing again, and yes by turning an If Statement into its own function i was able to delay it using DelayCommand();
void Getdead (int nFP, object oTarget, object oCaster)
{
if(GetIsDead(oTarget))
{
AdjustCreatureAttributes( oCaster, Random(6), 1 );
AddBonusForcePoints( oCaster, nFP );
}
}

void main() {

object oCaster = OBJECT_SELF;

if( GetGoodEvilValue( oCaster ) < 11 )
{
int nForce, nFP, nHP;
effect costDamage;
effect push = EffectForcePushed();
push = EffectLinkEffects( push, EffectVisualEffect( VFX_IMP_FORCE_PUSH ) );
effect ecaster, eDamage;
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 25.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_CREATURE );
while( GetIsObjectValid( oTarget ))
{
if(GetIsEnemy(oTarget))
{
nForce = GetCurrentForcePoints( oCaster ) * 4;
nFP = GetCurrentForcePoints( oTarget ) / 5;
nHP = GetCurrentHitPoints( oTarget );
ecaster = EffectHeal( nHP );
ecaster = EffectLinkEffects( ecaster, EffectDamageForcePoints(20));
eDamage = EffectDamageForcePoints( nForce );
eDamage = EffectLinkEffects( eDamage, EffectDamage( nForce, DAMAGE_TYPE_DARK_SIDE ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, push, oTarget, 0.8);
DelayCommand(0.9, ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oTarget ));
DelayCommand(0.9, ApplyEffectToObject( DURATION_TYPE_INSTANT, ecaster, oCaster ));
DelayCommand(1.5, Getdead(nFP, oTarget, oCaster));

}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 25.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_CREATURE );

}
}
}

and the single target version
void Getdead (int nFP, object oTarget, object oCaster)
{
if(GetIsDead(oTarget))
{
AdjustCreatureAttributes( oCaster, Random(6), 1 );
AddBonusForcePoints( oCaster, nFP );
}
}

void main() {

object oCaster = OBJECT_SELF;

if( GetGoodEvilValue( oCaster ) < 51 ) {
int nForce, nFP, nHP;
effect costDamage;
effect push = EffectForcePushed();
push = EffectLinkEffects( push, EffectVisualEffect( VFX_IMP_FORCE_PUSH ) );
effect ecaster, eDamage;
object oTarget = GetSpellTargetObject();
nForce = GetCurrentForcePoints( oCaster ) * 2;
nFP = GetCurrentForcePoints( oTarget ) / 5;
nHP = GetCurrentHitPoints( oTarget );
ecaster = EffectHeal( nHP );
ecaster = EffectLinkEffects( ecaster, EffectDamageForcePoints(20));
eDamage = EffectDamageForcePoints( nForce );
eDamage = EffectLinkEffects( eDamage, EffectDamage( nForce, DAMAGE_TYPE_DARK_SIDE ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, push, oTarget, 0.8);
DelayCommand(0.9, ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oTarget ));
DelayCommand(0.9, ApplyEffectToObject( DURATION_TYPE_INSTANT, ecaster, oCaster ));
DelayCommand(2.5, Getdead(nFP, oTarget, oCaster));





}
}
void SP_MyApplyEffectToObject(int nDurationType, effect eEffect, object oTarget, float fDuration=0.0);
Page: 1 of 1