Jump script

Moderator: Event DM

Post Reply
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

Jump script

Post by Final Shinryuu » Tue May 24, 2005 2:23 pm

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?
Image
User avatar
Talwin Hawkins
Team Member; Retired with Honors
Posts: 3980
Joined: Fri Aug 27, 2004 7:56 pm
Timezone: GMT+1
Location: London - England GMT

Post by Talwin Hawkins » Tue May 24, 2005 2:26 pm

*waits for Krator to answer*
Woodsmaster Talon Blade
Battle Sergeant of Le'Nofaythen'T'Nanshi
Former Hero of of Lonovanen'Hirefya
____________________
Deider wrote: Michelle Pfeiffer - I'd drink her bathwater.
http://twitter.com/AJDSullivan
User avatar
Marleh
Demigod of Posts
Posts: 8650
Joined: Mon Jun 07, 2004 5:34 pm
Location: GMT -8

Post by Marleh » Tue May 24, 2005 4:06 pm

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.
User avatar
Kinarr
CCC
CCC
Posts: 978
Joined: Sat Jun 26, 2004 5:39 pm
Timezone: GMT-8
Location: Oregon

Post by Kinarr » Tue May 24, 2005 4:23 pm

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.
User avatar
Marleh
Demigod of Posts
Posts: 8650
Joined: Mon Jun 07, 2004 5:34 pm
Location: GMT -8

Post by Marleh » Tue May 24, 2005 5:14 pm

Ohh, you're right! Wrong script on my part.

I've seen this script mentioned in the lexicon, but never tested it myself.
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

Post by Final Shinryuu » Tue May 24, 2005 6:04 pm

Thanks, Kinarr! I'll try getting something like that to work. You're a huge help!
Image
User avatar
Krator
Elder Sage
Posts: 4935
Joined: Thu Jun 10, 2004 6:44 pm
Timezone: GMT
Location: Amsterdam

Post by Krator » Tue May 24, 2005 6:30 pm

Talwin Hawkins wrote:*waits for Krator to answer*
Sorry, having an official toolset break.

*quickly minimizes the toolset before anyone notices*
Playing as: Sir Douglas Hope of Gorethar, old school paladin | Krator Blackfist, gold mage | Warren, half nymph barbarian
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

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

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?
Image
User avatar
Jonezie
Team Member; Retired with Honors
Posts: 3905
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

Post by Jonezie » Tue May 24, 2005 11:49 pm

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.
User avatar
Kinarr
CCC
CCC
Posts: 978
Joined: Sat Jun 26, 2004 5:39 pm
Timezone: GMT-8
Location: Oregon

Post by Kinarr » Wed May 25, 2005 2:09 am

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.
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

Post by Final Shinryuu » Wed May 25, 2005 2:27 am

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.
Image
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

Post by Final Shinryuu » Wed May 25, 2005 3:03 am

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!
Image
User avatar
Jonezie
Team Member; Retired with Honors
Posts: 3905
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

Post by Jonezie » Wed May 25, 2005 7:32 am

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.
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

Post by Final Shinryuu » Wed May 25, 2005 5:18 pm

I'll test that out right away, Jonezie! Thanks!
Image
User avatar
Kinarr
CCC
CCC
Posts: 978
Joined: Sat Jun 26, 2004 5:39 pm
Timezone: GMT-8
Location: Oregon

Post by Kinarr » Wed May 25, 2005 11:03 pm

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
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

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

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.
Image
User avatar
Alphonse
Master Sage
Posts: 5302
Joined: Wed Nov 03, 2004 8:26 am
Location: GMT

Post by Alphonse » Wed May 25, 2005 11:23 pm

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
User avatar
Final Shinryuu
Sage
Posts: 2060
Joined: Thu Jun 24, 2004 3:20 am
Location: http://hades.mercuric.net/

Post by Final Shinryuu » Wed May 25, 2005 11:48 pm

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!
Image
Post Reply