Jump to content

Home

force power woes: Force Grab (TSL)


newbiemodder

Recommended Posts

I'm working on a new force power..Force Grab...hopefully it allows the pc to take the weapons of his/her attacker..ie Darth Vader taking Han's blaster at Cloud City...except w/o actually seeing the weapon fly through the air.

 

I have this compiled script:

 

#include "k_inc_force"

 

int FORCE_POWER_FORCE_GRAB = 284;

 

 

void main() {

 

object oTarget = GetLastHostileTarget();

 

 

 

 

 

 

 

SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), FALSE));

ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON, oTarget), TRUE);

ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON, oTarget), TRUE);

effect eVis2 = EffectVisualEffect( VFX_IMP_STUN );

ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis2, GetLocation(oTarget));

 

 

}

 

It hasn't worked yet in game. When I check the combat feedback..it sometimes says a will or fortitude save...but not always.

 

2 questions:

 

1. Is what I'm trying to do even possible within structure of the game, and

2. if it is possible, could someone fix my script to make it better?

 

Any help is appreciated.

Link to comment
Share on other sites

I'm working on a new force power..Force Grab...hopefully it allows the pc to take the weapons of his/her attacker..ie Darth Vader taking Han's blaster at Cloud City...except w/o actually seeing the weapon fly through the air.

 

You'd need to transfer the wielded weapon from the victim to the force user as well, your script was only unequipping it from what I could see. You also need to verify that the weapon isn't an undroppable NPC-only weapon that the player isn't supposed to be able to get.

 

Further you should allow the victim to use Force Resistance and a saving throw (reflex makes most sense I think) to avoid the effects. This would be a pretty powerful power when used against most opponents since it pretty much permanently stops them from attacking, after all, and I doubt the combat AI would handle their predicament gracefully. :)

 

Implementing the above the script could be something like this (untested, but in theory it should work :))

 

#include "k_inc_force"

int ST_SnatchWeapon(object oWeapon, object oGiveTo=OBJECT_SELF);

void main() {
   object oTarget = GetSpellTargetObject();

   // ST: Signal AI event so the enemy knows they just got attacked.
   SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), TRUE));

   // ST: Give victim a chance to resist the force power
   if(ResistForce(OBJECT_SELF, oTarget)) {
       DisplayFeedBackText(oTarget, 0);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceResisted(OBJECT_SELF), oTarget);
       return;
   }

   // ST: Allow reflex save to avoid the effect
   SWFP_PRIVATE_SAVE_TYPE = SAVING_THROW_REFLEX;
   if (Sp_MySavingThrows(oTarget) == FALSE) {
       object oRight = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON, oTarget);
       object oLeft = GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON, oTarget);

       int bSuccess = FALSE;
       // ST: Snatch the off-hand weapon first if dual-wielding, otherwise the mainhand one.
       if (ST_SnatchWeapon(oLeft)) {
           bSuccess = TRUE;
       }
       else if (ST_SnatchWeapon(oRight)) {
           bSuccess = TRUE;
       }

       if (bSuccess) {
           // ST: Disorient the victim briefly when their weapon gets snatched
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCutSceneStunned(), oTarget, 2.0);         
       }
       else {
           // ST: Victim had no weapon to steal; the power fizzles.
           ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceFizzle(), OBJECT_SELF);   
       }
   }   
}


int ST_SnatchWeapon(object oWeapon, object oGiveTo=OBJECT_SELF) {
   if (GetIsObjectValid(oWeapon)) {
       string sTag = GetTag(oWeapon);
       object oOwner = GetItemPossessor(oWeapon);


       // ST: Check that the weapon isn't an undroppable NPC-only weapon.
       if ((GetStringLowerCase(GetSubString(sTag, 0, 4)) != "prop")
           && (GetStringLowerCase(GetSubString(sTag, 0, 8)) != "g_w_null")) 
       {
           AssignCommand(oOwner, GiveItem(oWeapon, oGiveTo));
           SendMessageToPC(oGiveTo, "Pulled weapon " + GetName(oWeapon) + " from " + GetName(oOwner) + "!");
           return TRUE;
       }
   }
   return FALSE;
}

Link to comment
Share on other sites

script compiles...doesn't seem to be working...a couple of times the attacker had a reflex save..but there was a couple reflex failure saves and nothing happened.

 

Well, I did say it was untested. :p Now you've made me dig out my old TSL discs to try this out properly. Seems like a few things didn't quite work as I remembered it, must have mixed it up with NWScript behavior from Neverwinter Nights. :)

 

Anyway, this one is fixed, tested and works in my game at least:

#include "k_inc_force"

int ST_SnatchWeapon(object oWeapon, object oGiveTo=OBJECT_SELF);

void main() {
   object oTarget = GetSpellTargetObject();

   // ST: Signal AI event so the enemy knows they just got attacked.
   SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId(), TRUE));

   // ST: Give victim a chance to resist the force power
   if(ResistForce(OBJECT_SELF, oTarget)) {
       DisplayFeedBackText(oTarget, 0);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceResisted(OBJECT_SELF), oTarget);
       return;
   }

   // ST: Allow reflex save to avoid the effect
   SWFP_PRIVATE_SAVE_TYPE = SAVING_THROW_REFLEX;
   if (Sp_MySavingThrows(oTarget) == FALSE) {
       object oRight = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON, oTarget);
       object oLeft = GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON, oTarget);

       int bSuccess = FALSE;
       // ST: Snatch the off-hand weapon first if dual-wielding, otherwise the mainhand one.
       if (ST_SnatchWeapon(oLeft)) {
           bSuccess = TRUE;
       }
       else if (ST_SnatchWeapon(oRight)) {
           bSuccess = TRUE;
       }

       if (bSuccess) {
           // ST: Disorient the victim briefly when their weapon gets snatched
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCutSceneStunned(), oTarget, 2.0);         
       }
       else {
           // ST: Victim had no weapon to steal; the power fizzles.
           ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectForceFizzle(), OBJECT_SELF);   
       }
   }   
}


int ST_SnatchWeapon(object oWeapon, object oGiveTo=OBJECT_SELF) {
   if (GetIsObjectValid(oWeapon)) {
       string sTag = GetTag(oWeapon);
       object oOwner = GetItemPossessor(oWeapon);


       // ST: Check that the weapon isn't an undroppable NPC-only weapon.
       if ((GetStringLowerCase(GetSubString(sTag, 0, 4)) != "prop")
           && (GetStringLowerCase(GetSubString(sTag, 0, 8)) != "g_w_null")) 
       {
           AssignCommand(oOwner, GiveItem(oWeapon, oGiveTo));
           SendMessageToPC(oGiveTo, "Pulled weapon " + GetName(oWeapon) + " from " + GetName(oOwner) + "!");
           return TRUE;
       }
   }
   return FALSE;
}

It allows force resistance, a reflex saving throw and then pulls a weapon from the victim. If they're dual wielding it will take the off-hand weapon, if they're not (or if their off-hand weapon got taken by a previous cast) it takes their main hand weapon.

Link to comment
Share on other sites

the only way to make it awesomer would be to figure out how to actually make the gun travel from opponent to caster.

 

If there was a way to make projectile models.. I believe there is (SithSpecter's Cheese gun for instance)... you could make a projectile that's a clone of the gun and have it shoot towards the caster and play a "catching animations".

 

Idk, am I on to something here, or am I just dreaming?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...