For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Some help modding X-Com: Enforcer

Post Reply
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

Hello :) First post here. The nice folks at UT99.org recommended me these forums for a couple of questions I have in regards to modding X-Com: Enforcer, so... here goes :)

As I'm sure you know, Enforcer uses a weird third-person camera placed behind and slightly above the main character and then angled down on him. This considerably limits visibility; even when using the game's auto-aim, there are times when it's just not enough. Basically, it's always set to this; the reticule/crosshair will move up and down but the the camera won't follow vertical mouse movement (it only does so horizontally):

Image

I've managed to edit a level's ZoneInfo, in particular, the Camera Distance and CameraPitch both to 0, which at least simulate a first-person perspective. But I'm still nowhere close to finding out how to change the default aiming behavior, where the camera does not follow mouse input on the vertical axis beyond a certain point. This means I can "see" through an FPS angle but can't fully play it as one.

To make matters trickier, the game's camera height is always placed above the main character, making him seem taller than what he is when playing in first-person. I've been looking for EyeHeight values and making some (timid) changes but none seem to influence it. I can change the player's DrawScale but this merely reduces the mesh size; it works at first but doesn't hold water in the long run.

The 'Ghost' cheat command seems to adjust to an average height, along with allowing full movement and aiming, but I'm not sure how I could adapt it to standard play.

I was wondering if anyone could provide some insight or any help into how I might change these? I have been reading the BeyondUnreal wiki but my programming skills are virtually none, and this is the first time I've tried messing about with Unreal's guts, so this has been hard.

If necessary I can post Enforcer's Classes so anyone can take a better look at them.

Thanks in advance for any help on this matter!
User avatar
Leo T_C_K
OldUnreal Member
Posts: 3660
Joined: Sat Aug 27, 2005 6:24 pm

Re: Some help modding X-Com: Enforcer

Post by Leo T_C_K »

I don't know how much help you will get honestly. But I really think changing the code or subclassing is the only way to go. I do not have this game and given that this game is the reason for x com alliance cancellation/buyout by hasbro, it's not very well received among many fans. I helped recover the UK version of the game before the developement went to the US team and it has bean floating around, but its difficult to get the game running either way (I can't anymore). There was some kind of faint promise of making UT mod based on the contents but its honestly quite unrealistic given the amount of work needed, it would require a dedicated team and it often felt like I bit too much than I could chew on especially when it came to the Unreal PSX Rework.

But another possibility of course would be instead of making UT mod to port x com alliance into x com enforcer which makes more sense. Just I never played or tried it.

EDIT: You can of course post the code and see what we can do.
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Re: Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

Hi Leo, thank you for the response :)

I know that Enforcer isn't really seen very well. Personally, I don't like the game either but decided to see how bad it was after getting the X-Com bundle from GOG. It was then I realized it also included its own version of UnrealEd, so I was trying to change/improve some things.

Enforcer seems to be developed backward, in the sense that all the nice features of Unreal Tournament were obfuscated in favor of much less interesting weapons and a terrible perspective, so I'm not sure it would be a good idea to port Alliance to it. It would need a less cluttered UE/UT base... Maybe Deus Ex as a base, as it features similar mechanics? Squad control seems to be the main feature missing.

I can't run Alliance anymore either :( I can check the maps in UEd but not play them.

Thank you once again for your reply and help :) As I mentioned before I'm not a programmer. The best I can do is post here the Classes I suspect might be handling the perspective/control issues. Here's a Pastebin for PlayerPawn; if any other Class is necessary let me know:

https://pastebin.com/X0GL83bF

Thanks in advance for any help :)
User avatar
Leo T_C_K
OldUnreal Member
Posts: 3660
Joined: Sat Aug 27, 2005 6:24 pm

Re: Some help modding X-Com: Enforcer

Post by Leo T_C_K »

You don't understand, the enforcer classes can be ignored effectively, but it is X-Com game and I was told some textures were recycled from Alliance developement even. Plus it is the X-Com franchise. We're trying to minimize any legal issues here. I mean it also used to be case that its completely legal to port Unreal content from one game to another, the same will probably apply with X-Com, if you do that with Deus Ex you are in a more risky area. You get what I mean.
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Re: Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

Oh, reworking Alliance stuff into Enforcer is way beyond my scope; let alone using Deus Ex for that. I was just wondering here.

In any case, I found a way to simulate a first-person perspective in Enforcer but there's an issue I can't solve. It start with editing the User.ini with something so trivial as assigning a key to bExtra 0, which activates Freelook. This isn't on by default in the game, and was never accessible in the menus for some reason.

Activating this ingame does what I wanted: full, FPS-like movement and aiming. But...

For some reason, when activating Freelook, the game reverts to the same initial camera position (up and behind the player, looking down). So while I now cam move and aim in first-person, the reticule is never centered because it's offset by this new state/position after turning Freelook on.

Picture 1 is the initial state. Mouselook works. Can move the reticule, but camera is fixed on the horizontal axis, so I can never aim beyond the visible edges. Picture 2 is right after activating Freelook. Notice how far it's from the center of the screen.

Image Image

I'll give this another day or two but then it's maybe better to call it quits.
User avatar
Leo T_C_K
OldUnreal Member
Posts: 3660
Joined: Sat Aug 27, 2005 6:24 pm

Re: Some help modding X-Com: Enforcer

Post by Leo T_C_K »

What is beyond the class playerpawn there? Honestly the only reliable way would be to see all the code, because class playerpawn is a very generic playerpawn class and is shared between most unreal engine games. So any true enforcer related code must be of the child class.
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Re: Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

*Pawn
> Defend Object
> Dummy Ethereal
> Huge Saucer
*PlayerPawn
> Camera
> EnforcerPlayer
*Spectator
> MessagingSpectator
> DemoRecSpectator
*ScriptedPawn (enemies, basically)
* Pilot (which I think is used for 1 single cutscene)

So, directly nested after EnforcerPlayer are the Camera (an empty script) and the Spectator subclasses. Could the game be using the Spectator cam?

Enforcer's main Spectator code
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Re: Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

I figured out the "snap" is relative to the SnapToLevel boolean. I can toggle the snapping off by toggling bExtra 0 during play, but can't find a way to start with that value turned on by default without using a button toggle for it.

Regardless, there's still the issue with the crosshair being terribly off-center and for this, I can't tell if it's related to EyeHeight, Weapon values, or what.

So, I guess it's time to give up.
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Some help modding X-Com: Enforcer

Post by []KAOS[]Casey »

Not yet, check the PlayerCalcView function in the pawn you possess (or it's parents)

it's probably trying to calculate some offsets based on it assuming the camera to always be third person, which is why the crosshair is wrong.

edit: dumb question... you have tried the "behindview 0" command, yeah? "behindview" in base Unreal toggles/sets third person camera.
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Re: Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

Hi. Yes, behindview was the first thing I tried. If disabled, the camera remains in the same position although the character simply disappears.

I didn't say this earlier but I got freelook running. I couldn't find a way to coax it through the *.ini's, so instead, I smuggled "bExtra0 = 1" into the "PlayerWalking" state. Now it runs with full mouse directional movement at startup without needing to toggle it.

About the camera position... Haven't had any luck with the PlayerCalc values but I'll be sure to try messing with them again.

I did notice earlier the 'Ghost' command does something interesting: it defaults the crosshair to a standard level. But I can't quite trace what the command does in full. Looking at the function, it sets a number of collision booleans off and immediately sets the game into a first-person mode, with the crosshair properly set... Unfortunately, since the world collision is off, its height is also reduced...

Code for XGhost (Enforcer's version of Ghost):

Code: Select all

exec function XGhost()
{
	if( !CanICheat() )
		return;

//	if ( !bAdmin && (Level.Netmode != NM_Standalone) )
//		return;
	
	UnderWaterTime = -1.0;	
	ClientMessage("You feel ethereal");
	SetCollision(false, false, false);
	bCollideWorld = false;
	GotoState('CheatFlying');
}
Code for 'CheatFlying' state:

Code: Select all

{
ignores SeePlayer, HearNoise, Bump, TakeDamage;
		
	function AnimEnd()
	{
		PlaySwimming();
	}
	
	function ProcessMove(float DeltaTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)	
	{
		Acceleration = Normal(NewAccel);
		Velocity = Normal(NewAccel) * 300;
		AutonomousPhysics(DeltaTime);
	}

	event PlayerTick( float DeltaTime )
	{
		if ( bUpdatePosition )
			ClientUpdatePosition();

		PlayerMove(DeltaTime);
	}

	function PlayerMove(float DeltaTime)
	{
		local rotator newRotation;
		local vector X,Y,Z;

		GetAxes(ViewRotation,X,Y,Z);

		aForward *= 0.1;
		aStrafe  *= 0.1;
		aLookup  *= 0.24;
		aTurn    *= 0.24;
		aUp	 *= 0.1;
	
		Acceleration = aForward*X + aStrafe*Y + aUp*vect(0,0,1);  

		UpdateRotation(DeltaTime, 1);

		if ( Role < ROLE_Authority ) // then save this move and replicate it
			ReplicateMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
		else
			ProcessMove(DeltaTime, Acceleration, DODGE_None, rot(0,0,0));
	}

	function BeginState()
	{
		EyeHeight = BaseEyeHeight;
		SetPhysics(PHYS_Flying);
		if  ( !IsAnimating() ) PlaySwimming();
		// log("cheat flying");
	}
}
Is it safe to assume it's disabling something like Pawn.Owner? I also noticed the Inventory class has a say about the crosshair positioning...
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Re: Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

So, after having spent the better part of the last days on this, I'm done.

The main issues are 1) I'm not a programmer and lot of this involved a lot of playtesting and hair-pulling, and 2) the UnrealEd version included with Enforcer is actually inferior compared to the original. There's not even a search function in scripting, which just slows down things a lot. Besides, some classes seem impossible to extract and/or edit; UED doesn't export them, and UCC and UMake simply throw up errors of missing files *which are actually there and are not even required to compile*.

Regardless, I've gotten close twice. For reference, here are the methods I've tried.

The safest but less fruitful is:

Code: Select all

		bExtra0 = 1;		       // mouse FPS movement
		ViewTarget = Self;	       // view self
Full FPS mouse movement and camera centered on Self. It works, but barely: I can't find a proper formula for Camera Height (nothing seems to work very well, if at all), and aiming is capped at some angle I cannot reason with. By this I mean that at some point I can't move further along the Z axis. I suspect it's tied to the crosshair (part of the HUD) and Alt Fire (which in this game translates to holding the right mouse button to move the crosshair, to counter the default locked perspective).

The one that got very close but can't seem to fully realize it:

Code: Select all

	bExtra0 = 1;
	bCollideWorld = false; 
	Enable('Tick');
	Enable('Bump');
	Enable('Touch');
	SetCollisionSize (45, 45);
	EyeHeight = 50;
Pros:
* Full FPS movement, not capped at any angle;
* Disables the ridiculous mess that is the crosshair movement;
* Can properly define camera height.

Cons:
* I die as soon as I hit anything.

I thought Tick, Touch and Bump would somewhat counter the loss of collision but they don't do much. Soon as I hit a wall, or land after a jump, it's game over. As I mentioned before, setting collisions off actually sets it into an FPS view, and the crosshair is not constricted by their idea of aiming, but I can't do anything with this. Not that I know of, at least.

UTPT was helpful in getting some information that I was missing but... The developers seemed to have gone to great lengths to make spaghetti out of all of it:

EnforcerPlayer.uc

Just search for "event Player Input" or "function Rotator AdjustAim" and you'll see what I mean. No chance in hell for me to entangle that. I'm out :)

Still, thank you both for your time :)
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Some help modding X-Com: Enforcer

Post by []KAOS[]Casey »

Code: Select all

event PlayerCalcView (out Actor ViewActor, out Vector CameraLocation, out Rotator CameraRotation)
{
  local Pawn PTarget;
 
  if ( ViewTarget != None )
  {
    ViewActor = ViewTarget;
    CameraRotation = ViewActor.Rotation;
    CameraLocation = ViewActor.Location;
    CameraLocation.Z += EyeHeight - BaseEyeHeight;
    return;
  }
  ViewActor = self;
  CameraLocation = Location;
  DoCrossHairStuff();
  if ( bCollideWorld )
  {
    CalcEnforcerView(CameraLocation,CameraRotation,150.0);
  } else {
    CameraRotation = ViewRotation;
    CameraLocation.Z += EyeHeight;
    CameraLocation += WalkBob;
  }
}
playercalcview changes behavior on whether or not you're in ghost (bCollideWorld = false), so all you should need to do is override it.
User avatar
Leo T_C_K
OldUnreal Member
Posts: 3660
Joined: Sat Aug 27, 2005 6:24 pm

Re: Some help modding X-Com: Enforcer

Post by Leo T_C_K »

I just wonder why he didn't post "EnforcerPlayer" instead of the PlayerPawn class still, but w/e.

As for inferior editor version, I don't know what he means either. I suppose he doesn't know anything below version 2.0?

He can search for strings there by pressing "EDIT" while the window is focused, the menu changes depending on what is focused, but I suppose its not clear it does that as the script window doesn't have drop-down menus on itself...
Orbis_Tertius
OldUnreal Member
Posts: 8
Joined: Thu May 27, 2021 2:59 pm

Re: Some help modding X-Com: Enforcer

Post by Orbis_Tertius »

Leo T_C_K wrote: Mon Jun 07, 2021 9:37 am I just wonder why he didn't post "EnforcerPlayer" instead of the PlayerPawn class still, but w/e.
I did that on my previous post.
As for inferior editor version, I don't know what he means either. I suppose he doesn't know anything below version 2.0?
Here. See any differences?

UT vs XCom

Image Image
[]KAOS[]Casey wrote: Sat Jun 05, 2021 4:25 pm playercalcview changes behavior on whether or not you're in ghost (bCollideWorld = false), so all you should need to do is override it.
Casey, playercalcview is part of the EnforcerPlayer subclass. I can't override those values because the problem begins with EnforcerPlayer, which is subclassed from PlayerPawn, and EnforcerPlayer is not editable.

The subclass EnforcerPLayer is set up in a way that it cannot be changed from within the editor (right-clicking and choosing "Edit Script" from the Actor Class browser prompts up the warning it has no script to edit), and when choosing to export all scripts, no script from Enforcer.u is extracted. It's the only package that can't be extracted. The code I left up there was seen through UTPT; what's more, the code of the subclass itself has instructions (such as "JL", which I assume are akin to "Jump to Line") that the Enforcer version of UnrealED cannot process and as such, cannot compile.

Further, the playercalcview function is also hardcoded in a DLL.

For all intents and purposes, it's locked. Or it's out of my inexperienced hands, at least. I thought about writing a new PlayerPawn subclass and hex editing the DLL, and some *very minor* tweaks in that direction showed promise, but I'm not returning to Enforcer. It's too much of a hassle. I'm off to play around with UT99 instead :)
User avatar
Leo T_C_K
OldUnreal Member
Posts: 3660
Joined: Sat Aug 27, 2005 6:24 pm

Re: Some help modding X-Com: Enforcer

Post by Leo T_C_K »

Interesting, but in that case the values should be able to change. So Enforcer does use editor 2.0 or some version of it then. That makes it a little different story.

playercalcview, does it appear in the default properties by default? If not, in the actual game it should if its not a () bool that makes it visible normally. Under None or whatever you should be able to see it.

You need to do editactor class=enforcerplayer in the actual game to try it. Without going fullscreen though as that's preferable, otherwise in most cases it ends up behind the window.

EDIT: Disregard what I said I thought playercalcview was a var, while it is an event. I wish it was tied to a var though.

One thing you could do is subclass enforcerplayer, use that player from then on in your user.ini and override the function in the new subclass.

But I see your point, after all its clear this was hasbro crap and you can see that on the moddability of the game that's nonexistant. Hiding the code? Very few games did that, I remember tactical ops or something doing that and that was bs. UC2 (pc beta) had hidden code too but it came with the full source code outside of the packages and it makes sense given it was supposed to be xbox game and all that would save space when compiling packages for xbox too...

EDIT2: In the end its just garbage, its raw...its FUCKIN RAW *changes face to Gordon Ramsey*
User avatar
[]KAOS[]Casey
OldUnreal Member
Posts: 4497
Joined: Sun Aug 07, 2011 4:22 am
Location: over there

Re: Some help modding X-Com: Enforcer

Post by []KAOS[]Casey »

try using ChocoPackageEdit to edit the if condition in Enforcer.u to something that always evaluates to false. Make sure to back up your files.
Post Reply

Return to “X-COM: Enforcer”