Page 1 of 1

Jump script

Posted: Tue May 24, 2005 2:23 pm
by Final Shinryuu
Hey all. I have about 0 knowledge of NWscript, and am trying to teach myself to do something by just looking at all the other scripts, but it's pretty damn hard. :(

So, I figure, why do something myself, when I can just have some other kind soul do it for me! :roll:

I'm trying to make a script, that when a specific item's power is activated, will prompt the PC to select any target area, and then jump the PC (with the jumping animation, straight up into the air), and make then fly down at the targeted location.

Could someone help me with this?

Posted: Tue May 24, 2005 2:26 pm
by Talwin Hawkins
*waits for Krator to answer*

Posted: Tue May 24, 2005 4:06 pm
by Marleh
Download the player housing demo, it has all those scripts already available. The script you want to look for is called jump_pc_2wp.

If you want the script that only jumps a character who is carrying a certain key, use jump_pc_2wp_xtra.

The explanation for how to set it up is in the code, click on the script, click edit, and its written in green.

Posted: Tue May 24, 2005 4:23 pm
by Kinarr
I think Final wants an item that will make the pc "fly" from one spot to another. If that's the case then give this a try.

Make your item and give it the property Cast Spell: Unique Power. Don't use the Self Only option because you want to be able to target it.

Give your item a unique tag, something like PC_FLY. The name can be whatever you want.

Save the script the same name as the tag of your item, PC_FLY.

Code: Select all

#include "x2_inc_switches"

void main()
{
    int nEvent =GetUserDefinedItemEventNumber();
    object oTarget = GetItemActivatedTarget();
    object oPC=GetItemActivator();
    effect eFly = EffectDisappearAppear(GetLocation(oTarget));
    float fDuration = 5.0;  //How long to be "in the air"

    if (nEvent ==  X2_ITEM_EVENT_ACTIVATE)
    {
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFly, oPC, fDuration);
    }
}
I didn't test it, but that should do it, assuming tag based scripting is not disabled in your module.

Posted: Tue May 24, 2005 5:14 pm
by Marleh
Ohh, you're right! Wrong script on my part.

I've seen this script mentioned in the lexicon, but never tested it myself.

Posted: Tue May 24, 2005 6:04 pm
by Final Shinryuu
Thanks, Kinarr! I'll try getting something like that to work. You're a huge help!

Posted: Tue May 24, 2005 6:30 pm
by Krator
Talwin Hawkins wrote:*waits for Krator to answer*
Sorry, having an official toolset break.

*quickly minimizes the toolset before anyone notices*

Posted: Tue May 24, 2005 10:07 pm
by Final Shinryuu

Code: Select all

#include "x2_inc_switches"

void main()
{
    int nEvent =GetUserDefinedItemEventNumber();
    object oTarget = GetItemActivatedTarget();
    object oPC=GetItemActivator();
    effect eFly = EffectDisappearAppear(GetLocation(oTarget));
    float fDuration = 5.0;  //How long to be "in the air"

    if (nEvent ==  X2_ITEM_EVENT_ACTIVATE)
    {
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFly, oPC, fDuration);
    }
}
Drat. I've been working on it, but I can't get this to work.
I was able to get the script to fire, but it's just not doing anything.
I named the script "itm_fly" and the item was tagged "fly".
I added a line in the script to make the PC say a line of text when the script fires, so I know it worked.
The rest of the script just doesen't do anything.
Any help?

Posted: Tue May 24, 2005 11:49 pm
by Jonezie
EDIT: Bleh - misinterpreted your post. Try targeting it at a placable object (a chair or something, or another creature). I'm not sure if targeting it at the ground will work.

Posted: Wed May 25, 2005 2:09 am
by Kinarr
Oops, that's what I get for not testing it. Okay, this will work.

Code: Select all

#include "x2_inc_switches"

void main()
{
    int nEvent =GetUserDefinedItemEventNumber();
    location lTarget = GetItemActivatedTargetLocation();
    object oPC=GetItemActivator();
    effect eFly = EffectDisappearAppear(lTarget);
    float fDuration = 5.0;  //How long to be "in the air"

    if (nEvent ==  X2_ITEM_EVENT_ACTIVATE)
    {
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFly, oPC, fDuration);
    }
}
I tested it and it looks pretty sweet, too.

Strange thing though, it seems the Activate_Item is set to short range in the Avlis hak. I don't know if that's an error or intentional. But if you are using a basic module you should be able to use your item to fly at long range.

Posted: Wed May 25, 2005 2:27 am
by Final Shinryuu
Thanks, Kinarr. I love you.
I'm making this for the Abyss 404 module, and so it is also set to short range. Maybe there's some way to get around it, I'll fiddle around a bit.

Posted: Wed May 25, 2005 3:03 am
by Final Shinryuu
Kinarr, I got around the range problem.
If instead of giving the item the activated abilty "Cast Spell: Unique Power", you give it "Cast Spell: Use: Activate Item, long range" that will do it.

One more issue. As is, it only works when a selectable object or creature is chosen as the target. Is there any way to make it work anywhere? Just to jump the character to any clicked area?
If not, oh well, I'll deal.
Thanks!

Posted: Wed May 25, 2005 7:32 am
by Jonezie
If you change the line:

Code: Select all

object oTarget = GetItemActivatedTarget(); 
To:

Code: Select all

location lTarget = GetItemActivatedTargetLocation(); 
And:

Code: Select all

effect eFly = EffectDisappearAppear(GetLocation(oTarget)); 
To:

Code: Select all

effect eFly = EffectDisappearAppear(lTarget); 
It ought to work on any target location.

Posted: Wed May 25, 2005 5:18 pm
by Final Shinryuu
I'll test that out right away, Jonezie! Thanks!

Posted: Wed May 25, 2005 11:03 pm
by Kinarr
Yep, those are the changes I made in my last post. ;)

I had never noticed the property Activate Item (long range) before. That worked great.

An interesting side effect of this is that it allows you to cross otherwise impassable terrain like water or a hill with cliffs.

Oh! Forget about flying, this would be perfect for a gnomish catapult to fling you across a chasm. Add a smoke vfx to trail behind the PC and a knockdown effect when they "land". :D

Posted: Wed May 25, 2005 11:21 pm
by Final Shinryuu

Code: Select all

void main()
{
    location lTarget = GetItemActivatedTargetLocation();
    object oPC = GetItemActivator();
    effect eFly = EffectDisappearAppear(lTarget);
    float fDuration = 5.0;
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFly, oPC, fDuration);
}
This is it! Perfectly working, much shorter version of this script. This one gets around the target problem, allowing the character to jump to any target location.

Posted: Wed May 25, 2005 11:23 pm
by Alphonse
Kinarr wrote:Oh! Forget about flying, this would be perfect for a gnomish catapult to fling you across a chasm. Add a smoke vfx to trail behind the PC and a knockdown effect when they "land". :D
*Yoink*

This idea has been confiscated and may now be used in Deglos

Posted: Wed May 25, 2005 11:48 pm
by Final Shinryuu
Alphonse wrote:
Kinarr wrote:Oh! Forget about flying, this would be perfect for a gnomish catapult to fling you across a chasm. Add a smoke vfx to trail behind the PC and a knockdown effect when they "land". :D
*Yoink*

This idea has been confiscated and may now be used in Deglos
Yes! Yes! Yes! Please do!
A whole system of gnomish catapults to navagate PC's through a city, even!