Jump to content

Home

NEW FORCE POWER: turn ennemies into allies


Recommended Posts

  • Replies 54
  • Created
  • Last Reply

Darth Khasei, are you trying to fix you rforce powers so that they only do damage to the enemy you are looking at? Because I love youyr forcepowers, but they would be even better if you could figure out how to fix that because sometimes when I use your force powers I accidentally kill a shop vendor or a innocent passerby...lol anyway good luck!

Link to comment
Share on other sites

That is not a problem anymore Maverick :) what we are trying to fix is the targetting system during battle. When you have a group of ennemies (example Star Forge) the power does not target the nearest ennemy but the second closest ennemy.

 

Darth Khasei if you find the solution, pls let us know :)

Link to comment
Share on other sites

Strange --

 

Here's a way to do it without the break; statement. Maybe that was causing something to go awry.

 

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

   int nBreak=0;
   while (nBreak==0 && GetIsObjectValid(oTarget)) {
      if (!GetIsFriend(oTarget)) {
         if (GetRacialType(oTarget) != RACIAL_TYPE_DROID ) {
            nBreak==1;
         }
      }
      if (nBreak==0) {
         oTarget = GetNextObjectInShape(SHAPE_SPHERE, 17.0, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE);        
      }
   } 

Link to comment
Share on other sites

Thx TK! I tried that and the result is the same. I also tried adjusting the 17 meter distance and found something very interesting. The powers work a little better the shorter the distance. I changed it down to 5 meters and the results were promising if not perfect.

 

The powers no longer targets that distant shop keeper, but if you are facing a group of enemies and more than one is within the target zone, the second one still gets targeted about 80% of the time. Not perfect but better.

 

I also wanted to ask you something about script commands and get your thoughts. The GetFirstObject statement targets your first guy picked in the FP target box. Then if that target is valid it seems to read GetNextObject in that shape. I think that is where the issue lies as it seems regardless of the validity of the first object, after the check it just targets the "next" shape and does not go back to that original target picked. I hope you follow what I am saying.

 

Is there a way to script it so that after that first object is checked and is valid that the script refers back to that original object without moving to the next unless the first object is "invalid". Just asking because my scripting prowess is VERY limited.

 

Oh BTW, I also tried just changing the GetNextObject to GetFirstObject, but the result was the same(ie. it gets the second object). Cheers.

Link to comment
Share on other sites

I know what you mean DK.

 

Maybe the answer is to break apart the spell effect for the 1st object.

 

The logic would be

  1. GetFirstObjectInShape
  2. Is this Object Valid? If so, is this Object a non-friend and is this Object a non-droid? If so, then call spell effect function.
  3. GetNextObjectInShape
  4. Is this Object Valid? If so, is this Object a non-friend and is this Object a non-droid? If so, then call spell effect function.
  5. Loop back to step 3 until GetIsObjectValid returns FALSE.

So, for the first object, Steps 1 and 2 explicitly handle the spell effects outside of the while loop (steps 3-5). The other steps handle all other objects. If that type of script doesn't work.... :p

Link to comment
Share on other sites

See that was my problem back in college when I took programming darn it! I can verbally explain these concepts and even understand them fairly well, but when it comes to actually placing that concept to code/script, I get serious brain farts that get in the way on me making the code work, without endless trial and error argh! :evanpiel:

Link to comment
Share on other sites

Originally posted by Darth333

I never tryied to do that but yes, it can be done quite easily.

You could try using some of these (just examples):

 

 

ApplyEffectToObject(nDurationType, eEffect, oTarget, fDuration);

 

EffectAbilityDecrease(ABILITY_CONSTITUTION, 4)

EffectAbilityDecrease(ABILITY_STRENGTH, 4)

EffectAbilityDecrease(ABILITY_DEXTERITY, 4)

EffectSavingThrowIncrease(SAVING_THROW_REFLEX, 2)

EffectSavingThrowIncrease(SAVING_THROW_WILL, 2)

EffectAbilityIncrease(ABILITY_DEXTERITY, 2)

EffectAbilityIncrease(ABILITY_INTELLIGENCE, 2)

EffectAbilityIncrease(ABILITY_STRENGTH, 2)

EffectAbilityIncrease(ABILITY_WISDOM, 2)

 

D333 : would these changes be able to be made randomly ? ie you use the power and a random stat increase

Link to comment
Share on other sites

Maverick and Deathstrike123: the new fp is a level 9 force power so it will not be selectable in the level up screen until your character reaches this level. There is no need to start a new game.

 

Jackel: due to family obligations Ididn't have time to really look at what the script would be but yes, it would be possible to have a random stats increase.

 

I'm currently working in a new ls fp that will be called "force mirror": the PC will be able to return to the ennemy the same fp that was casted by the ennemy (even if the PC does not have the power originally).

 

Darth Khasei: thanks for the info, i'll try that.

Link to comment
Share on other sites

Jackel:

you could do that using the Random function.

 

example

void main(){
 effect eRandom;
 int nRandom=Random(3);  //random # 0-2
 switch (nRandom)
 {
  case 0:
  {    
  eRandom = EffectAbilityIncrease(ABILITY_DEXTERITY, 2);
  }
  case 1:
  {
  eRandom = EffectAbilityIncrease(ABILITY_STRENGTH, 2);
  }
  case 2:
  {
  eRandom = EffectAbilityIncrease(ABILITY_WISDOM, 2);
  }
 }
 ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eRandom, GetFirstPC(), 30.0);
}

Link to comment
Share on other sites

Darth333, finally got the targeting correct about 95% of the time for large groups and 100% for smaller groups.

 

Moving the powers to the offensive menu and cutting the spell distance helped out alot. I eliminated the second check for objects since the object targeted in the offensive menu is the one we want anyway. I also changed the ObjectValid statement to Enemy and it worked like a charm, once I got the scripting right that is:D

 

When I release the update I'll have the script ready for you to look at.

Link to comment
Share on other sites

Finally I found what was wrong. In fact, we were trying to make things complicated where they shouldn't be. We were heading in the wrong direction.

 

The mod has been updated at PCgamemods: http://www.pcgamemods.com/5904/ (make sure you download version 2.0) or at my website (click my sig)

 

Here is what nwscript.nss says about the GetFirstObjectInShape function:

128: Get the first object in nShape
// - nShape: SHAPE_*
// - fSize:
//   -> If nShape == SHAPE_SPHERE, this is the radius of the sphere
//   -> If nShape == SHAPE_SPELLCYLINDER, this is the radius of the cylinder
//   -> If nShape == SHAPE_CONE, this is the widest radius of the cone
//   -> If nShape == SHAPE_CUBE, this is half the length of one of the sides of
//      the cube
// - lTarget: This is the centre of the effect, usually GetSpellTargetPosition(),
//   or the end of a cylinder or cone.
// - bLineOfSight: This controls whether to do a line-of-sight check on the
//   object returned.
//   (This can be used to ensure that spell effects do not go through walls.)
// - nObjectFilter: This allows you to filter out undesired object types, using
//   bitwise "or".
//   For example, to return only creatures and doors, the value for this
//   parameter would be OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR
// - vOrigin: This is only used for cylinders and cones, and specifies the
//   origin of the effect(normally the spell-caster's position).
// Return value on error: OBJECT_INVALID
object GetFirstObjectInShape(int nShape, float fSize, location lTarget, int bLineOfSight=FALSE, int nObjectFilter=OBJECT_TYPE_CREATURE, vector vOrigin=[0.0,0.0,0.0]);

So the target is the first object located at the centre of the area effect, which is not what we want for a power like Mind Trick. If you look at k_inc_force, you'll see that this function is only used with force powers that affect multiple ennemies.

 

So I removed the following lines from the script:

object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 17.0, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE);
   while (GetIsObjectValid(oTarget)) {
       if (!GetIsFriend(oTarget) && GetRacialType(oTarget) != RACIAL_TYPE_DROID) {	break;}
       oTarget = GetNextObjectInShape(SHAPE_SPHERE, 17.0, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_CREATURE);



   }
   if (GetIsObjectValid(oTarget))

 

and simply replaced them by:

object oTarget = GetSpellTargetObject();

Spells 2da takes care of the rest :D

and it works flawlessly

Link to comment
Share on other sites

Right. You only need the whole Area of Effect spell for when you have a semi-hostile spell as a 'Friendly' force power. That's because Friendly force powers have no other way of targeting.

 

Sorry, I could've pointed you in the right direction a long time ago... :p I was clueless...

Link to comment
Share on other sites

Sorry, I could've pointed you in the right direction a long time ago... I was clueless...

Don't be sorry, finding this out was part of the fun of making this mod :D

 

Originally posted by tk102

By the way, that's the reason mgnails keeps killing himself with 'Friendly' powers. Because the PC is the SpellTarget of a Friendly Force Power!

:D :D :D

 

off topic:

What more than 550 posts and I'm a RANCOR????? :mad: How insulting! :D

Link to comment
Share on other sites

I love you guys and gals!. This is what a modding community is all about! Funny I ended up refining my scripts by taking that out too. Only I did not replace it with a script that is as efficient and effective as this one! Salute to you Darth333.

 

Now, back to make a quick change on the scripts, get the photos up to the site for the new powers and spawn on demand characters..... Oh, I guess I have a little work to do:D

 

------Edit

PS! OH MY GOSH THIS IS AWESOME! 100% PERFECT REGARDLESS OF THE NUMBER OF ENEMIES YIPPIE!!!!!!!!!

Link to comment
Share on other sites

The SPHERE_SHAPE thing and my post above would also explain why targetting would improve when reducing the distance: by reducing the distance, you reduce the radius of the shape and and get fewer ennemies caught in the area of effect :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...