Jump to content

JK2SP Assembly Hacks :D


Recommended Posts

Posted

Hello everyone, long time JK fan here. I'm not much of a modder or content generator. However, I recently got overly absorbed into assembly hacking using Cheat Engine :D. I was really excited to start hacking JK2 because there are certain cheats I've always wanted, but could never use because they don't exist as console commands or simple mods. There are several aspects of the game that always made NPC Jedis seem more powerful than Kyle could ever be (if it weren't for their predictable AI). My aim is to give Kyle the perks of being a boss-level NPC Jedi (ala Luke or Desann). Of course, all of this is blatant cheating. I'm not saying the SP experience is unfair, or bad, or too hard. I love the game as is without cheats. I just wanted some satisfying uber-jedi abilities.

 

Here is my progress. I've gotten many of the main cheats working. I hope somebody is interested in using this, since it's something I've always wanted from JK2:

 

At the moment I could make a cheap trainer out of what I have, but I'd like to make a nice one where you don't have to disable/enable the cheats every time you load a save or a new map (any LUA scripters out there who can make a GUI? :blink: ). As it is now, there are many micro-cheats that are parts of a larger cheat. I'm not sure if I want to combine them all, since I feel that some of these micro features may not be as appealing to some players who would prefer the option of not using it. Additionally, there still features I haven't implemented yet. Some may not be possible, while others I just haven't gotten around to.

 

Some of you might be wondering why I'm making assembly hacks instead of modifying the source code. I can read/write C; and I can read/tinker with C++. I'm sure I could easily implement these changes in the source code (since they're so minor); but I understand it's a real bitch to compile it as is. I know that OpenJK has made it easier to compile (in fact I'm considering playing around with that soon ;) ). I just really seem to enjoy going through memory and assembly code. It's like detective work  :lol:. After a while, I did start using the source code to help me find the features I was looking for. That was more like detective work with obvious clues, but still enjoyable since I got the results I was after.

 

Anyway, on to the changes. I'll cover the minor mechanics I was interested in changing. If you're interested in the actual implementation, then I recommend you download Cheat Engine 6.3 and load up my cheat table (the link is in the YouTube description). Read the comments in the scripts. Most of them have descriptions for how/why the code was changed. I believe I even reference some of the lines in the source code, which makes it easier to follow along. These cheat descriptions below apply the ones I made in Cheat Engine.

 

Unlimited force jump height:

Technically it's limited, but to a very high value. This cheat is kind of silly looking because you move upward at a constant velocity (no acceleration) for the most part. If you've ever watched the NPCs, you might notice that their force jumps work differently. They basically have a launch speed and trajectory with no mid-air movement. They can jump as high as is necessary to reach you. I didn't give the player this behavior (I don't know if it's even possible); but I did let the player jump as high as they want to at least.

 

Always dodge disruptors:

There is no more chance that the player will dodge snipers with force speed. It will happen every time. There are many small parts to this cheat. The game will apply force speed to the player when the dodge animation occurs. It lasts for 500 units of game time. During this time, you cannot use force speed again. The game will not do another dodge while you're still in speed. If you're up against several snipers (or if they do that random double shot) you will still get hit. I reduced the time of that speed from 500 to 1. However, the FOV, timescale, and thirdPersonRange were still changing for a split second, which made for some minor visual distortion whenever you dodge. So I prevented those from changing when you're in force speed.

 

The problem with that fix is that now the FOV, timescale, and thirdPersonRange don't change when you use speed normally, which makes speed useless. The player doesn't move faster in speed (I know it does in MP, but apparently it works differently in SP). The timescale change during speed slows everything except the player. If the timescale doesn't change during speed, then the player and everyone else are still moving at normal speed. My proposed solution to all this is to have those parameters change only when you dodge a disruptor. I can have them change right before you dodge. The hard part is figuring out where in the code to change them back to normal.

 

Possible addition: Right now you don't automatically jump when a shot hits your legs. This is good and bad. It means you can still get hit by snipers. But it also means that you're not automatically jumping, possibly to your death. I'm not sure how to implement the jump anyway. When NPCs do the jump evasion, they do that weird style force jump I mentioned above. This does not work on the player, so it'd have to work differently.

 

Short force throw (push/pull) debounce interval:

I'm using the dev's terminology here. In the source code comments, they always refer to the downtime between actions (usually due to animations) as debounce time.

 

If you've ever used mind control level 4 (or control in console) to control an NPC, then you might have noticed that they can spam force throw really quickly. In the source code, the devs explicitly mention that the NPCs are supposed to be able to do it faster than the player. This was probably so that they could more effectively repel rockets and pushable projectiles. I changed it so that the player's debounce interval is identical to the NPCs'.

 

Possible addition: Make the player automatically repel rockets with push like the NPCs. If it's at all similar to how the game handles force grip on Desann, it might be possible.

 

Can force grip Desann:

Ever hate how Desann immediately pushes you when you try to grip him? It turns out that it's not just boss-level reaction timing; the game actually just makes him push instead of get gripped. I changed it to treat Desann no differently than an ordinary Jedi. So you can grip him, but he'll use force push randomly throughout the grip. One side effect is that it's now possible for other NPCs to grip him. That never happens though, because only dark side Jedi use grip.

 

Can't be gripped:

As it's set up now, this is an alternative to the cheat above; they cannot be active simultaneously (well, they can, but I'd have to put them both in the same script. Right now they would overwrite each other's code, causing instability). This cheat makes the game treat you like Desann when you get gripped. Kyle will automatically use force push whenever someone uses grip. It's pretty awesome; but it has a large drawback: non-Jedi NPCs can not be gripped anymore. They can't use force push, but they're also not grippable. The game treats Kyle the same as non-Jedi when he gets gripped. When Jedi NPCs get gripped, the game uses force push automatically, at random intervals. The player has to use push manually if they want to get out of grip. That's why the game treats them like non-Jedi.

 

As far as I can tell, there's no easy way to distinguish Kyle from non-Jedi NPCs in this section of code. It might be possible to check if it's the player through some other means. I haven't looked into it too thoroughly yet.

 

Always throw HARD:

When you use force throw on an opponent, they will either go flying, fall down in place, or block it completely. The game checks for flying first. This cheat makes the player always win in this check. No matter who you throw, they get thrown hard.

 

Always win (weak) force throw:

An alternative to the above cheat is this one. If you fail the condition for the opponent to go flying, then it checks what type of resistance they get. They'll either fall in place or block it completely. This cheat makes it so that they never block it completely. They'll either go flying (if that wins first) or they'll fall in place (most common).

 

Always block force throw:

Straightforward. You will never be thrown, unless it's from behind. I made a cheat for that too though :D

 

Never get pushed out of grip:

Even if you've got the above cheat on, you will get knocked out of force grip if someone pushes you. That's because there's a check when you get pushed to see if you're gripping. This cheat bypasses that, which allows you to block the push. However, the blocking animation makes you drop the opponent. That's why I had to implement the next cheat:

 

Can grip while in other animations:

This removes the check that determines if Kyle is able to start using grip. Whether you're in a force blocking animation or not, you'll be able to grip. So if you're gripping someone and they use push on you, you'll block it, and immediately regrab them without dropping them.

 

Refinement: I think this doesn't perfectly attain the effect I'm looking for. It can take really long to kill a Jedi-NPC because they push so frequently; and each time you reset the grip the damage doesn't start right away. I noticed when Desann grips you, you take continuous (and massive) damage, even as he blocks your pushes... gotta be like Desann... he's too strong!

 

Player blocks lightning:

If you ever watch Luke and Desann when you shoot lightning at them, they seem to just block it without making any pain noises. I learned from the source code that this is actually what is happening. It plays the force push block animation and sets the lightning damage to zero. I basically included Kyle in the statement that checks if the lightning recipient is Desann or Luke.

 

Player "knocks thrown sabers aside"

I put it in quotes because that's what the devs call it. When you throw your lightsaber at Luke, Desann, or galak_mech, the saber just bounces off of them, presumably to avoid cheap kills. They don't even need to have their saber out; they're basically immune to saber throw. As with the lightning, I simply added Kyle to the list.

 

 

WHEW* That's it for now. This ended up longer than I anticipated. I hope somebody is interested in these hacks despite how old the game is. I've had a lot of fun making these so far. There's still more to be done. So far, the changes have mostly revolved around force powers. There are some lightsaber mechanics that give an advantage to Luke, Tavion, and Desann (ever notice how you can't swing for a while after you block a strong attack?). I'd like to see what I can do about that. I also want to find a way to be able to do those acrobatic tricks like cartwheels and butterflies (without changing animations). I might have to buckle down and make a source code fork for this though  :wacko:. I don't think it's possible right now.

Futuza, Raz0r, Grab and 5 others like this
Posted

This is pretty cool I got to say.  Though, just saying it might be far easier to just make source code changes directly (though they'd be more permanent).  If the original source code is giving you nasty errors just use open jk.

JKG Developer

Posted

I never tried compiling the original source code. I wouldn't even know where to start. I guess I would get a free version of Visual Studio and... look for the game's project file? I don't think I saw one. I'm sure I'd rather use OpenJK anyway. It has a noob-friendly instructions page. Other than that, the only issue I would have (besides laziness) would be testing my changes. Wouldn't I have to recompile it every time I want to test it? How long does a game like this take to compile? I suppose I should just dive in and find out.

 

Impressive work, sir.

Thank you!

Posted

Use CMake to generate the project files, which can be on any version of Visual Studio, 2003 and up. (2010 is recommended) For OpenJK, of course. You have to rework the game code to be modern-compiler friendly.

Stoiss likes this
Posted

I'm pretty new to OOP concepts. I've only ever done simple procedural programming for school (VB, C, and Matlab). Right now I'm teaching myself Java to get started with OOP. Anyway, I forked your plain JK2 source code eeztreet. After reading the source a little more, I'm starting to notice that there aren't really any classes in the JK2 source code. Did they really do the whole game with structs?

 

This off-topic question might warrant another thread.

Posted

To an extent. They based it off of Quake 3's C code and retrofitted it to run in C++. There's some things which are definitely C++, but mostly in the engine. Mostly structs though, ya.

Posted

As far as JKA goes though, we've mostly turned it into C++ code, for Jedi Knight Galaxies.  I say we and I really mean eezstreet by that.

JKG Developer

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...