Select Ladder?

Asset Information and Discussion for Scripting, Area Design, and More

Moderators: Moderator, Developer, DM

Eclypticon
Posts: 1009
Joined: Mon May 30, 2011 7:26 pm
Location: USA

Select Ladder?

Unread post by Eclypticon »

I am trying how to figure out solving a problem with the walk grid. Anyway, I would like to make the ladder selectable and have it jump the PC to another part of the walk grid. What do I need to do exactly?
Luna
Retired Admin
Posts: 7945
Joined: Sat May 16, 2009 3:00 pm

Re: Select Ladder?

Unread post by Luna »

Grab this module.
http://nwvault.ign.com/View.php?view=NW ... 912&id=218

The map with the boats.
Look at the boat as it lets you jump to another area.

It is set at USABLE + PLOT. STATIC is removed.

There should be an on used script.

You want that.
And just look at the conversation the boat calls.
Just copy that conversation and mod as needed.
Eclypticon
Posts: 1009
Joined: Mon May 30, 2011 7:26 pm
Location: USA

Re: Select Ladder?

Unread post by Eclypticon »

I downloaded the mod and had a look at it.

Actually, I have a walk grid that is below another walk grid on the same area; so, I am not sure I want to call the action to ga_jump_players or do I? I just want to make it jump the PC to the top of the ladder from the bottom. For some reason, these tiles have a habit of knocking PCs off the grid, and I know that will piss people off.

Image

Thanks again.
Luna
Retired Admin
Posts: 7945
Joined: Sat May 16, 2009 3:00 pm

Re: Select Ladder?

Unread post by Luna »

I think in his on used script, then you would execute the jump in that script and not have it call/open a converstation.
Take a look at Markshires climbing hak if you need an example.
That script is just check DC, if passed, jump to new location.

http://nwvault.ign.com/View.php?view=nw ... ail&id=103
User avatar
gedweyignasia
Custom Content
Posts: 1353
Joined: Sat Nov 23, 2013 11:27 pm
Location: EST/UTC-4

Re: Select Ladder?

Unread post by gedweyignasia »

A simple solution would be to use a walkmesh trigger and you can paint the ladder as an unwalkable region. Then paint two triggers and set the On Enter script to teleport you to the other region. (To keep from teleporting back and forth continually, you'll want to set a local integer on the player to 2, and have the On Exit script decrement it. Remember, you'll want to exit both regions before you can be teleported again.)

Untested Code:

On Enter:

Code: Select all

object oPC = GetEnteringObject();
string sMyTag = GetTag(OBJECT_SELF);

if (GetLocalInt(oPC, "onladder") == 0) {
    SetLocalInt(oPC, "onladder", 2);
    object oTarget = GetNearestObjectByTag(sMyTag, OBJECT_SELF, 2);
    location lTarget = GetLocation(oTarget);
    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, ActionJumpToLocation(lTarget));
}
On Exit:

Code: Select all

object oPC = GetEnteringObject();
int iOnLadder = GetLocalInt(oPC, "onladder");
if (iOnLadder > 0) {
    SetLocalInt(oPC, "onladder", iOnLadder-1);
}
If you don't want NPCs to use this ladder, you might do an extra check to make sure that the entering object is either a PC or is DM-possessed.

Edit: Whoops, didn't read the problem! You probably want something more like this.

Untested Code

OnUsed:

Code: Select all

void main() {

// Get the PC's location information
object oPC = GetLastUsedBy();
location lPC = GetLocation(oPC);
vector vPC = GetPosition(oPC);
object oAreaOfPC = GetArea(oPC);

// Get the ladder's position and the direction from player to ladder
vector vLadder = GetPosition(OBJECT_SELF);
vector vFacing = GetAngleBetweenLocations(lPC,lLadder);
float fFacing = VectorToAngle(vFacing);

// You want to move twice the distance from you to the ladder
// i.e. You want to be on the other side of the ladder
vector vDestination = vPC + 2.0 * (vLadder - vPC);
// vector vDestination += 0.5 * vFacing;    // Fudge factor in case PC is inside ladder. Use as needed

// Generate a new Location and send the PC there
location lNew = Location(oAreaOfPC, vDestination, fFacing);
AssignCommand(oPC,JumpToLocation(lNew));

}
Don't forget to still paint that walkmesh so the player can't just waltz across the ladder. It might be tricky to paint it close enough that they can use the ladder but can't step on it. (My code will work prettiest if the ladder is in the exact middle of the walkmesh; you won't need the fudge factor at all, if that's the case, so you can leave that line commented out.)

Return to “NWN2 Toolset Development”