Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Vague UnrealScript Problem

Unwanted

CyberP

Unwanted
Joined
Aug 2, 2013
Messages
1,711
Can I request some help? DeusEx modding communities are dead so here will have to do.

Unrealscript (unreal Engine 1, so no functions present in later versions or Kismet stuff).
Deus Ex's game code.
Player class (DeusExPlayer.u)

What I need to do: Make Multitools able to hack keypads and such at range.

Why: Lockpick & multitools cost the same, there are the same number of these tools across the game on average, and roughly the same number of hack/pickable devices too. However, multitools are slightly less worthy of investment due to the fact that by the time you are in reach of a camera, turret, alarm unit etc, you have usually overcome the threat they present (you are out of the turret or cameras FOV, you've cleaned out the place before reaching the alarm unit etc) so by making multitools a ranged tool balance will be achieved and infiltration would be more interesting, plus multitools are already wireless anyhow.

Code:
// ----------------------------------------------------------------------
// HighlightCenterObject()
//
// checks to see if an object can be frobbed, if so, then highlight it
// ----------------------------------------------------------------------

function HighlightCenterObject()
{
    local Actor target, smallestTarget;
    local Vector HitLoc, HitNormal, StartTrace, EndTrace;
    local DeusExRootWindow root;
    local float minSize;
    local bool bFirstTarget;

    if (IsInState('Dying'))
        return;

    root = DeusExRootWindow(rootWindow);

    // only do the trace every tenth of a second
    if (FrobTime >= 0.1)
    {
        // figure out how far ahead we should trace
        StartTrace = Location;
        EndTrace = Location + (Vector(ViewRotation) * MaxFrobDistance);

        // adjust for the eye height
        StartTrace.Z += BaseEyeHeight;
        EndTrace.Z += BaseEyeHeight;

        smallestTarget = None;
        minSize = 99999;
        bFirstTarget = True;

        // find the object that we are looking at
        // make sure we don't select the object that we're carrying
        // use the last traced object as the target...this will handle
        // smaller items under larger items for example
        // ScriptedPawns always have precedence, though
        foreach TraceActors(class'Actor', target, HitLoc, HitNormal, EndTrace, StartTrace)
        {
            if (IsFrobbable(target) && (target != CarriedDecoration))
            {
                if (target.IsA('ScriptedPawn'))
                {
                    smallestTarget = target;
                    break;
                }
                else if (target.IsA('Mover') && bFirstTarget)
                {
                    smallestTarget = target;
                    break;
                }
                else if (target.CollisionRadius < minSize)
                {
                    minSize = target.CollisionRadius;
                    smallestTarget = target;
                    bFirstTarget = False;
                }
            }
        }
        FrobTarget = smallestTarget;

        // reset our frob timer
        FrobTime = 0;
    }
}

What I want to do is if (inHand.IsA('Multitool')) Then Increase maxFrobDistance, but only for hackabledevices.

I've made a number of attempts but am struggling to solve this problem.

It may be a bit of vague problem, but I am hoping someone can help. The code has a few comments so it should be easy enough to understand. Follow-up questions will be answered swiftly. This function is needed so we can Frob targets at a distance and also so the object highlight is displayed, so we can see how many multitools are needed to hack the objects.
I haven't been coding too long so please use laymans terms if necessary.
 
Unwanted

CyberP

Unwanted
Joined
Aug 2, 2013
Messages
1,711
What I want to do is if (inHand.IsA('Multitool')) Then Increase maxFrobDistance, but only for hackabledevices.


It is problematic because the object trace applies to all objects: weapons, pickups, decoration, movers etc, and it is constantly being updated. I make a special case to increase MaxFrobDistance for HackableDevices only if mutlitool is inhand, but it only works if already targeting a hackable device first and then walking back whilst keeping the hackabledevice in the crosshairs, but if we look away then look at the hackable device again no highlight, maxfrobdistance is default again. I don't understand why this would be happening if it is constantly refreshing every tenth of a second. I guess you need to see the code I wrote (then deleted) first to understand what I am going on about more clearly, which I can write again if need be.
 
Unwanted

CyberP

Unwanted
Joined
Aug 2, 2013
Messages
1,711
Yes fuckers! Problem solved. Logical progression.
 
Unwanted

CyberP

Unwanted
Joined
Aug 2, 2013
Messages
1,711
It's difficult to explain. I wasn't that complex of a problem though, a veteran would have handled it in no time & maybe with a simpler, cleaner solution, but it was a nice challenge to overcome that I spent a fair amount of time on.
 

Ninjerk

Arcane
Joined
Jul 10, 2013
Messages
14,323
I gave it a look, but I don't recognize the language. I could kind of tell what's going on, but whatever logic issue there was, wasn't clear to me.
 

J1M

Arcane
Joined
May 14, 2008
Messages
14,661
It's difficult to explain. I wasn't that complex of a problem though, a veteran would have handled it in no time & maybe with a simpler, cleaner solution, but it was a nice challenge to overcome that I spent a fair amount of time on.
Did you open the multitool's weapon script and increase the maximum range constant?
 
Unwanted

CyberP

Unwanted
Joined
Aug 2, 2013
Messages
1,711
Ha, is that an insult?

There's no such thing:

Code:
//=============================================================================
// Multitool.
//=============================================================================
class Multitool extends SkilledTool;

// ----------------------------------------------------------------------
// TestMPBeltSpot()
// Returns true if the suggested belt location is ok for the object in mp.
// ----------------------------------------------------------------------

simulated function bool TestMPBeltSpot(int BeltSpot)
{
   return (BeltSpot == 8);
}

function texture GetWeaponHandTex()
{
    local deusexplayer p;
    local texture tex;

    tex = texture'weaponhandstex';

    p = deusexplayer(owner);
    if(p != none)
    {
        switch(p.PlayerSkin)
        {
            //default, black, latino, ginger, albino, respectively
            case 0: tex = texture'weaponhandstex'; break;
            case 1: tex = texture'HDTPItems.skins.weaponhandstexblack'; break;
            case 2: tex = texture'HDTPItems.skins.weaponhandstexlatino'; break;
            case 3: tex = texture'HDTPItems.skins.weaponhandstexginger'; break;
            case 4: tex = texture'HDTPItems.skins.weaponhandstexalbino'; break;
        }
    }

    return tex;
}

simulated function renderoverlays(Canvas canvas)
{
    multiskins[1] = Getweaponhandtex();

    super.renderoverlays(canvas);

    multiskins[1] = none; 
}

simulated function PreBeginPlay()
{
    Super.PreBeginPlay();

    // If this is a netgame, then override defaults
    if ( Level.NetMode != NM_StandAlone )
        MaxCopies = 5;
   
}

defaultproperties
{
     UseSound=Sound'DeusExSounds.Generic.MultitoolUse'
     maxCopies=20
     bCanHaveMultipleCopies=True
     ItemName="Multitool"
     PlayerViewOffset=(X=20.000000,Y=10.000000,Z=-16.000000)
     PlayerViewMesh=LodMesh'DeusExItems.MultitoolPOV'
     PickupViewMesh=LodMesh'DeusExItems.Multitool'
     ThirdPersonMesh=LodMesh'DeusExItems.Multitool3rd'
     LandSound=Sound'DeusExSounds.Generic.PlasticHit2'
     Icon=Texture'DeusExUI.Icons.BeltIconMultitool'
     largeIcon=Texture'DeusExUI.Icons.LargeIconMultitool'
     largeIconWidth=28
     largeIconHeight=46
     Description="A disposable electronics tool. By using electromagnetic resonance detection and frequency modulation to dynamically alter the flow of current through a circuit, skilled agents can use the multitool to manipulate code locks, cameras, autogun turrets, alarms, or other security systems."
     beltDescription="MULTITOOL"
     Mesh=LodMesh'DeusExItems.Multitool'
     CollisionRadius=4.800000
     CollisionHeight=0.860000
     Mass=20.000000
     Buoyancy=10.000000
}
 

J1M

Arcane
Joined
May 14, 2008
Messages
14,661

Sorry, this is the Codex so I expected the worst.
Of course I looked for the simplest solution first.

Do you know UnrealScript fairly well?
I worked on a mod for UT2003 that won some money in the first "Make Something Unreal" contest. Haven't used it in a long time.
 
Unwanted

CyberP

Unwanted
Joined
Aug 2, 2013
Messages
1,711
Oh. My old programming/modding partner was a UT2004 modder.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom