PDA

View Full Version : force power woes: Force Grab (TSL)


newbiemodder
09-04-2009, 01:57 PM
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_LEF TWEAPON, oTarget), TRUE);
ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIG HTWEAPON, 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.

jonathan7
09-04-2009, 02:13 PM
I can't really help with the scripting as I'm not a scripter, that said I don't see why its not possible considering you can throw a lightsaber/grenade and see it fly, and follow its course. I did want to say also that this is an awesome idea :)

VarsityPuppet
09-04-2009, 09:19 PM
If you mean making it LOOK like you're taking your opponent's gun away, I'm not sure it's possible...

as far as fixing your script, I can't help you, I would have scripted it much differently

stoffe
09-05-2009, 08:04 AM
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;
}

newbiemodder
09-05-2009, 02:04 PM
Stoffe..you're awesome...I'll give it a try.

Slstoev
09-05-2009, 03:16 PM
Any luck yet?

newbiemodder
09-05-2009, 08:05 PM
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.

VarsityPuppet
09-05-2009, 09:07 PM
Stoffe comes to the rescue with a beautiful-looking script! er.. it's not working though???

stoffe
09-06-2009, 06:12 AM
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.

newbiemodder
09-06-2009, 09:41 AM
cool..I'll give it a try


EDIT:
Great job Stoffe...this one works..you are the best...we'd be lost without your scripting help...now get some sleep, you've been up way too long

deathdisco
09-06-2009, 11:49 PM
Kudos to Stoffe for sitting through an install of TSL to help out a fellow modder. :thmbup1:
Always going above and beyond. :)

Great idea for a new FP newbiemodder!

VarsityPuppet
09-07-2009, 12:39 AM
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?

R2-X2
09-07-2009, 03:53 PM
You might could try to edit the lightsaber throw effect to use it with a gun, and cast the effect from the target to the caster.