Script/Code help

A refuge for those migrating from the fallen DXEditing.com and a place for general discussion relating to Deus Ex editing (coding, mapping, etc).
User avatar
Lork
NSF
Posts: 58
Joined: Wed Mar 25, 2009 6:33 pm
Location: The Great White North

Re: Script/Code help

Post by Lork »

That's exactly what I needed, thanks.
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Script/Code help

Post by DDL »

Mind you, only works in maps that HAVE a missionscript (which is, admittedly, almost all of them).

There are a variety of pretravel-esque functions in the playerclass as well, if you're worried.
User avatar
Lork
NSF
Posts: 58
Joined: Wed Mar 25, 2009 6:33 pm
Location: The Great White North

Re: Script/Code help

Post by Lork »

I'm working on a Thief style ledge grab/mantling system and I could use some help. The hardest part is detecting the ledges themselves, so you can imagine how happy I was to discover that someone had already done the hard work for me.

In ScriptedPawn:

Code: Select all

function bool CheckWaterJump(out vector WallNormal)
{
	local actor HitActor;
	local vector HitLocation, HitNormal, checkpoint, start, checkNorm, Extent;

	if (CarriedDecoration != None)
		return false;
	checkpoint = vector(Rotation);
	checkpoint.Z = 0.0;
	checkNorm = Normal(checkpoint);
	checkPoint = Location + CollisionRadius * checkNorm;
	Extent = CollisionRadius * vect(1,1,0);
	Extent.Z = CollisionHeight;
	HitActor = Trace(HitLocation, HitNormal, checkpoint, Location, false, Extent);
	if ( (HitActor != None) && (Pawn(HitActor) == None) )
	{
		WallNormal = -1 * HitNormal;
		start = Location;
		start.Z += 1.1 * MaxStepHeight + CollisionHeight;
		checkPoint = start + 2 * CollisionRadius * checkNorm;
		HitActor = Trace(HitLocation, HitNormal, checkpoint, start, true, Extent);
		if (HitActor == None)
			return true;
	}

	return false;
}
By harvesting the code from this, I was able to develop a system for mantling: If the jump button is held down and a ledge is detected, the player is launched up and onto it. The problem is how fast to launch the player. Right now my solution is to set the player's Z velocity to a flat amount. With a certain amount of fine tuning I can get a value that covers most scenarios, but there will always be cases where the value is either too high and the player hits their head on the ceiling, or worse, too low, and they don't even get over the ledge.

What I want is to always set the player's velocity to exactly the right amount to cover the ledge, and no more. I know it's possible to get that value using the information gathered by the above function, but to be honest, although I get the gist of it, I don't completely understand all the math going on there. Even if I did, there are other factors to consider as well (what's the Deus Ex equivalent to g?).

If someone could help me out with this, I'd be very grateful.
DDL
Traditional Evil Scientist
Traditional Evil Scientist
Posts: 3791
Joined: Mon Oct 17, 2005 10:03 am

Re: Script/Code help

Post by DDL »

Unreal's gravity is specified by zonegravity, a vector that is by default (0,0,-950), though I'm not entirely sure how the actually relates to acceleration under gravity (950 uunits per second per second?).

What the function you posted is doing, is essentially generating a virtual square the width and height of the pawn, and extending it in the direction of the pawn by the pawn's collisionradius: if it finds an actor within this 'box' thus generated (remember, the level itself is an actor), it does the next check, which is exactly the same, only shifted directly upwards by maxstepheight * 1.1, and checking forward by double the collisionradius. If this does NOT find an actor, then success:

essentially, is there anything that could be a potential ledge directly in front of us? If yes, then is there anything that could stop it acting as a ledge up where we'd be standing, were we to use it as a ledge? If no, it's a ledge!

The problem is that you want very precise locational information about where the top of this ledge is, presumably, whereas this function is only determining that it's "not greater than 1.1 maxstepheights above our location". You could always work out the value of velocity needed to just get a pawn over a height of 1.1 maxstepheights, I suppose, since it would never require MORE than that..
User avatar
Lork
NSF
Posts: 58
Joined: Wed Mar 25, 2009 6:33 pm
Location: The Great White North

Re: Script/Code help

Post by Lork »

DDL wrote:Unreal's gravity is specified by zonegravity, a vector that is by default (0,0,-950), though I'm not entirely sure how the actually relates to acceleration under gravity (950 uunits per second per second?).

What the function you posted is doing, is essentially generating a virtual square the width and height of the pawn, and extending it in the direction of the pawn by the pawn's collisionradius: if it finds an actor within this 'box' thus generated (remember, the level itself is an actor), it does the next check, which is exactly the same, only shifted directly upwards by maxstepheight * 1.1, and checking forward by double the collisionradius. If this does NOT find an actor, then success:

essentially, is there anything that could be a potential ledge directly in front of us? If yes, then is there anything that could stop it acting as a ledge up where we'd be standing, were we to use it as a ledge? If no, it's a ledge!

The problem is that you want very precise locational information about where the top of this ledge is, presumably, whereas this function is only determining that it's "not greater than 1.1 maxstepheights above our location". You could always work out the value of velocity needed to just get a pawn over a height of 1.1 maxstepheights, I suppose, since it would never require MORE than that..
Yeah, I got that part, it's just the specifics of how it determined the height of the second trace that I wasn't clear on. Regardless, I somehow managed to get it into my head that the size of the 'box' would vary, when that's obviously not the case. I think I was up too late tracking down that goddamned ricochet bug. Now that I have a clearer head, I can see that the velocity used by JumpOutOfWater() (which is what uses CheckWaterJump() in turn) is probably exactly the value you speak of. On testing it, it always gets you high enough, and contrary to what I thought before for some reason, it never takes you too high either. So it's a happy ending, I guess.
User avatar
Lork
NSF
Posts: 58
Joined: Wed Mar 25, 2009 6:33 pm
Location: The Great White North

Re: Script/Code help

Post by Lork »

Here's a sort of silly one: What's the escape sequence for double quotes in strings? I mean, surely one exists, right? But it isn't \" like any sane language would use, or |" like the use of |n in the existing strings would suggest, so I'm at a loss. Does anybody know?
User avatar
NVShacker
Off Topic Productions
Off Topic Productions
Posts: 178
Joined: Sun Sep 03, 2006 4:14 am

Re: Script/Code help

Post by NVShacker »

There's no escape sequence ("|n" isn't even a language level escape sequence, just a convention) but you can use Object's Chr method to get a string that contains a quote, it returns a string containing a character based on what I believe is the ascii value of the parameter, double quote is 34 so you'll want to do something along the lines of:

Code: Select all

function string quote(string text)
{
local string quote;
quote = chr(34);
return quote $ text $ quote;
}
If you want to figure out the values just log through in a loop, I wrote up a simple commandlet that'll do the trick

Code: Select all

class CharacterListCommandlet extends Commandlet;
 
event int Main(string arg)
{
	local int i, max;
	max = int(arg);
	if(max<=0)
		max=256;
	log("Character list:");
	for(i=0;i<max;i++)
		log(i @ "::" @ chr(i));
}
The parameter was just in case unicode values were supported, don't think they were.
NVShacker
Are you still there?
User avatar
Lork
NSF
Posts: 58
Joined: Wed Mar 25, 2009 6:33 pm
Location: The Great White North

Re: Script/Code help

Post by Lork »

I'll try that out, thanks.
Post Reply