PDA

View Full Version : Problem with Force Script


harIII
09-17-2009, 09:00 AM
I'm only starting to play around with Force Power scripting. I'm able to make Force Power "beams" run between two objects if I declare it in the script but I want to make them universal. This is my script

void main() {

object oTarget = GetFirstObjectInShape( SHAPE_SPHERE, 15.00, GetLocation( OBJECT_SELF ), TRUE, OBJECT_TYPE_CREATURE );

effect eBeam1 = EffectBeam(2052, OBJECT_SELF, BODY_NODE_HAND_RIGHT, TRUE);
effect eBeam2 = EffectBeam(2061, OBJECT_SELF, BODY_NODE_HAND_LEFT, TRUE);
effect eBeam3 = EffectBeam(2026, OBJECT_SELF, BODY_NODE_CHEST, TRUE);

effect efVisual = EffectVisualEffect(1009, 0);

ApplyEffectSingle(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
ApplyEffectOnObject(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
ApplyEffectToObject(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
}

When I use it in the game the PC does the animations to start the power such as force push but nothing happens. Can somebody please tell me what is happening with the power, the idea is to have something similar to Force Lightning.

VarsityPuppet
09-17-2009, 10:39 AM
Okay, it would seem that you're casting this power... it's a ranged power, but it's taking effect around the PC

You're declaring the effect variables... good.

It seems you're only applying 1 of the effects though.

void main() {

object oTarget = GetFirstObjectInShape( SHAPE_SPHERE, 15.00, GetLocation( OBJECT_SELF ), TRUE, OBJECT_TYPE_CREATURE );

effect eBeam1 = EffectBeam(2052, OBJECT_SELF, BODY_NODE_HAND_RIGHT, TRUE);
effect eBeam2 = EffectBeam(2061, OBJECT_SELF, BODY_NODE_HAND_LEFT, TRUE);
effect eBeam3 = EffectBeam(2026, OBJECT_SELF, BODY_NODE_CHEST, TRUE);

effect efVisual = EffectVisualEffect(1009, 0);

while (GetIsEnemy(oTarget)){
ApplyEffectSingle(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
ApplyEffectOnObject(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
ApplyEffectToObject(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
oTarget = GetNextObjectInShape( SHAPE_SPHERE, 15.00, GetLocation( OBJECT_SELF ), TRUE, OBJECT_TYPE_CREATURE );}
}

It seems you're only applying the effect 1 to the the target... and actually you probably only need the last one "ApplyEffectToObject(etc, etc)"

Lastly, are you sure that effect 2052 is a valid beam effect?

EDIT: I forgot, but if you're trying to get the effects to apply to a number of enemies in the vicinity, you need to put it in a While function.. It should look something like that.

harIII
09-17-2009, 12:27 PM
Thanks for the script but unfortunately it's not working.

I keep getting an error message "Type mismatch in parameter 1 to call to "ApplyEffectToObject"

My script now looks like this:

void main() {

object oTarget = GetFirstObjectInShape( SHAPE_SPHERE, 15.00, GetLocation( OBJECT_SELF ), TRUE, OBJECT_TYPE_CREATURE );

effect eBeam1 = EffectBeam(2052, OBJECT_SELF, BODY_NODE_HAND_RIGHT, TRUE);
effect eBeam2 = EffectBeam(2061, OBJECT_SELF, BODY_NODE_HAND_LEFT, TRUE);
effect eBeam3 = EffectBeam(2026, OBJECT_SELF, BODY_NODE_CHEST, TRUE);

effect efVisual = EffectVisualEffect(1009, 0);

while (GetIsEnemy(oTarget)){
ApplyEffectToObject(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
ApplyEffectToObject(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
ApplyEffectToObject(oTarget, DURATION_TYPE_INSTANT, eBeam1, 1.5);
oTarget = GetNextObjectInShape( SHAPE_SPHERE, 15.00, GetLocation( OBJECT_SELF ), TRUE, OBJECT_TYPE_CREATURE );}
}

stoffe
09-17-2009, 12:49 PM
Thanks for the script but unfortunately it's not working.

I keep getting an error message "Type mismatch in parameter 1 to call to "ApplyEffectToObject"

My script now looks like this:

That script would stop looping through objects in the 15 meter radius around the caster if it encounters someone who's not hostile to the caster. Since the caster is included in this there is a fair chance they (or a party member) get returned first, which kills the loop.

Your post was somewhat unclear: do you want this power to target everyone around the caster, or just a single target?

If it's single-target then do:

void main() {

object oTarget = GetSpellTargetObject();

effect eBeam1 = EffectBeam(2052, OBJECT_SELF, BODY_NODE_HAND_RIGHT);
effect eBeam2 = EffectBeam(2061, OBJECT_SELF, BODY_NODE_HAND_LEFT);
effect eBeam3 = EffectBeam(2026, OBJECT_SELF, BODY_NODE_CHEST);
effect efVisual = EffectVisualEffect(1009);

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam1, oTarget, 1.5);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam2, oTarget, 1.5);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oTarget, 1.5);
ApplyEffectToObject(DURATION_TYPE_INSTANT, efVisual, oTarget);
}


If it's supposed to hit all enemies nearby then do:

void main() {
effect eBeam1 = EffectBeam(2052, OBJECT_SELF, BODY_NODE_HAND_RIGHT);
effect eBeam2 = EffectBeam(2061, OBJECT_SELF, BODY_NODE_HAND_LEFT);
effect eBeam3 = EffectBeam(2026, OBJECT_SELF, BODY_NODE_CHEST);
effect efVisual = EffectVisualEffect(1009);

location lLoc = GetLocation(OBJECT_SELF);

object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 15.0, lLoc);
while (GetIsObjectValid(oTarget)) {
if (GetIsEnemy(oTarget) && !GetIsDead(oTarget)) {
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam1, oTarget, 1.5);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam2, oTarget, 1.5);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oTarget, 1.5);
ApplyEffectToObject(DURATION_TYPE_INSTANT, efVisual, oTarget);
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 15.0, lLoc);
}
}

harIII
09-17-2009, 03:57 PM
I tried them but I'm not seeing the animations. At this point I'm just going to wait for my Force Power modder to do some of this stuff.