1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

3rd person and other things

Discussion in 'Programming' started by Wannabeemapper, Feb 22, 2002.

  1. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    Firstly I want to say I'm very new (3 days and counting) to UScript and I must say, it's a rather steep learning curve.

    These are the things I would like..
    - Player spawns in 3rd person view every time.
    - A better vie perspective for 3rd person view.
    - Character/Weapons in 3rd person translucent.
    - A crosshair in 3rd person view.
    - For all of the above to work online.

    So far I have made a subclass of TFemale2 and I have got the player in 3rd person with a nicer view perspective and translucent mesh. The player only spawns in 3rd person view the first spawn, after that the player spawns in 1st person view. This has taken me 3 days to get working and I'm still a bit stumped how to get my weapons to be translucent.

    From what I understand I will have to subclass a HUD to paint my crosshair. Is there any way to get everything I want into a mutator? That would be the best solution.

    The worst headache I can forsee is getting it to work online. I have tried my char class but the server keeps making me into a default male soldier, grrr. Since some aimbots and skinhacks work online it must be possible. I'm only needing code that allows me to see the game how I want (ClientSide). I don't want to be translucent to other players on the server, that would be far too dodgy.

    So can anybody give me some hints or assistance with what I'm trying to accomplish? any help would be very much appreciated, especially some hints about drawing my crosshair on the HUD. the tutorials at CHiMERiC aren't really much help. :)
     
  2. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    Well another day is nearly gone and I don't have much to show for it.

    I found that there's a PostRender function inside the actor I'm subclassing so I don't need to subclass a HUD hopefully. I have currently got a dot printed on the HUD at a fixed location to represent my crosshair. I have no idea how I'm going to actually draw the dot in the correct position but I guess I'll figure it out in a week or 2 :rolleyes:

    I was wondering. For my crosshair, is it more efficient to print a dot? or to plop a tile down instead?

    I'm also wondering about these damn weapons that I cannot make translucent. How the hell do I modify the .Style and .ScaleGlow of weapons when they are activated/switched? There are 2 exec functions in the class PrevWeapon() and NextWeapon() but so far I have had no luck trying to modify those. There's also a function ChangedWeapon() which I am trying to coorce some cooperation from. Currently it's resting all my efforts to actually do anything but eat up bytes in my script :(

    I also finally found that there's some defaultproperties that can be set at the bottom of the classes .uc file. UEd has a major humphy when I try to add a defaultproperties section in my class? UEd tells me there is an "unexpected defaultproperties" in my script. Howcome?

    And regarding the defaultproperties, are those properties applied each time the player respawns? If I can ever get to use them and they are then it would solve at least my problem of the player only spawning translucent the first time. :)
     
  3. aspie

    aspie It's all good baby.

    Joined:
    Feb 24, 2001
    Messages:
    315
    Likes Received:
    0
    To get the exact centre of the screen use ClipX and ClipY (the lengths of the screen) then halve them.

    SetPos(Canvas.ClipX/2,Canvas.ClipY/2);

    But if your using a tile (texture) for your crosshair you need to account for the dimensions of the texture. If the texture was 32 pixels by 32 pixels you would use:

    SetPos(Canvas.ClipX/2-16, Canvas.ClipY/2-16);

    For the defaultproperties error the problem is ued. Most experienced scripters use external editors and export the source code. In Ued open the actor browser and select 'export all packages' from the menu. This will dump all the code for each class in to individual text files (extension .uc). These are contained in folders in your UT directory. For example anything from Botpack will go into UnrealTournament\Botpack\Classes.

    For your own packages create a new folder in your UT one. The name of this folder will be the name of the .u package. Inside this folder create another folder called 'Classes'. You should now have:

    UnrealTournament\<package name\Classes

    Inside the classes folder is where you should store all your .uc files (ie classes). To make UT compile your classes you need to open up UnrealTournament.ini (in system folder) and scroll down to the 'EditPackages=*******' line. Then add you package to the list after all the other.

    EditPackage=<package name>

    Now when ever you want to compile your code just hit ucc.exe (in system folder) and it will compile, just make sure you delete your existing .u package as ucc doesn't overwrite.
     
  4. mr.s-d

    mr.s-d CHiMERiC Moderator

    Joined:
    Aug 30, 2001
    Messages:
    65
    Likes Received:
    0
    In Pawn.uc:
    Code:
    var travel Weapon       Weapon;        // The pawn's current weapon.
    
    So from within a PlayerPawn class, to change the current weapon's draw style:
    Code:
    Weapon.Style = STY_Translucent;
    
    Obviously you'll need to hook into the function that change the player's weapon to ensure that whatever weapon they're using is set to translucent.
     
  5. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    Hey wow! Thanks a heap bud :)

    I now got EditPlus on the job and I got a user tool to run UCC.exe :)

    I'll save some bucks and register EditPlus as long as it don;t misbehave whilst I'm savin me pennies :D

    I finally got my weapons translucent by modifying the NextWeapon() and PrevWeapon() exec functions. I used some pretty nasty script to do it but hey, it's working. For some reason I cannot get the weapon to be translucent when the player spawns. Does anybody know of like a function that get's called to initialize the player and setup his inventory? Or is that function hidden somewhere inside the GameType?

    For the rest of the evening I'll wrestle with the crosshair :p

    Cheers aspie, at least I will be able to have a crosshair in the middle of my screen now :D

    mr.s-d.. I'll check that in a bit. I have the translucency working at the moment but your simple line of code looks far more efficient than my behemouth line of gobledegook :p
     
  6. RestInPieces

    RestInPieces New Member

    Joined:
    Sep 20, 2001
    Messages:
    65
    Likes Received:
    0
    Hehe, I just finished the 3rd Person Cam for Ultima Unreal :)
    What exactly do you want to do with the crosshair? I mean, while viewing from a cam, you can't just use a normal crosshair, of course, since Cam.Roation and the Player.ViewRotation are the same , and when you are aiming at an enemy with your cam's crosshair, your Player will in most cases shoot somewhere completely else (look at the pic :) ) .
    A soulution to the problem would be to make a trace form the cam whenever a weapon is fired, and them set Player.ViewRotation to that the player looks at the Hitlocation.
     
  7. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    Heheheh, nice bmp that one. Really demonstrates the point :)

    Ok well I see what you mean. It must be possible to get a nice crosshair in 3rd person working though.

    from how your suggestion reads to me the player not really have much aiming ability, or maybe I just don;t understand. I'm only a hapless n00bi3 afterall :(

    I simply want to play UT in 3rd person view with a darn crosshair. Nothing more, nothing less. I know it's a FPS game but after several years I feel like a change :p

    I thought using some sort of trace (like traceweapon) information could be converted into a Z?? (up/down) offset to draw the crosshair dot, since in 3rd person the crosshair always stays vertically centered. I currently have very few ideas how I would accomplish this though :rolleyes:

    Hmmmm, Ultima Unreal sounds quite nice :cool:
     
  8. RestInPieces

    RestInPieces New Member

    Joined:
    Sep 20, 2001
    Messages:
    65
    Likes Received:
    0
    Hm, just read my post again, didnt express myself too clearly :/
    Okay, lets have a look at the picutre again, there is a line from the camera to the enemy. Imagine you're looking through the cam, then the line starts at the middle of the screen (where you see the crosshair). So if you're aiming at the Robot's head (you move your mouse so that the crosshair is on the Robot's head), then the line is pointing to the enemy's head, right? And this is where you want the player to shoot. So all you have to do is:
    Whenever a weapon is fired, make a trace from your cam, pointing to the direction you cam is looking at:
    And then rotate your player's ViewRotation, so that he is aiming to that point:
    And that's all there is to it. Well, of course, now you may no longer have Cam.Rotation == PlayerPawn.ViewRotation.
    Therefore, when you change PlayerPawn.ViewRotation, save the new rotation to a var, and use this var to calculate how much you have to rotate the cam.
    I hope this helps you :)
     
  9. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    Hmmm well thanks for that. I am currently wondering if it would be better to have a laser sight of some sort that eminates from the weapon.

    I'll look about the place for some laser sight script and see if it's possible to kludge it in with the script I already have.

    Thx again dude, you have enlightened me :cool:
     
  10. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    BAH, it seems it's not possible to have a lasersight type crosshair in 3rd person view from within a subclass of TFemale2. Dang.

    Oh well I think I will shelve this for a while and think it through a bit more.

    At least I've got a darn better 3rd person view perspective, even if it's only useful for testing maps and offline playing.
     
  11. AV_ACE

    AV_ACE New Member

    Joined:
    Jan 30, 2002
    Messages:
    14
    Likes Received:
    0
    Umm... can I ask what command did you use to move the camera? I have tried cam.Z and pawn.cam.Z, except they are just errors. Thankyou
     
  12. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    Ok well I'm just a newbie so I just subclasses TFemale2. I have no idea how to get this sort of thing into a mutator, if it's even possible.

    To change the 3rd person view perspective I just kludged in some new values by trial and error. I modified the CalcBehindView function. Here is the script from my subclass..

    ---

    function CalcBehindView(out vector CameraLocation, out rotator CameraRotation, float Dist)
    {
    local vector View,HitLocation,HitNormal;
    local float ViewDist;
    CameraRotation = ViewRotation;
    View = vect(1,0,0) >> CameraRotation;
    CameraRotation.Pitch -= 4096; // added by me
    if( Trace( HitLocation, HitNormal, CameraLocation - (Dist + 30) * vector(CameraRotation), CameraLocation ) != None )
    ViewDist = FMin( (CameraLocation - HitLocation) Dot View, Dist );
    else
    ViewDist = Dist;
    CameraLocation -= (ViewDist - 30) * View; //30
    CameraLocation.Z +=50; // added by me
    }

    ---

    I found this to be quite a nice view perspective. I am still thinking of how to implement a damn lasersight type crosshair into the class but I'm thinking that it's impossible.

    When you are looking directly up or down the view get's a little wonky but that's not such an issue since not many people use those views.

    I hope this little bit helps you with your own scripting dilema :cool:
     
  13. AV_ACE

    AV_ACE New Member

    Joined:
    Jan 30, 2002
    Messages:
    14
    Likes Received:
    0
    Yes, it does help. Thankyou.
     
  14. AV_ACE

    AV_ACE New Member

    Joined:
    Jan 30, 2002
    Messages:
    14
    Likes Received:
    0
    Yes, it does help. Thankyou.
     
  15. AV_ACE

    AV_ACE New Member

    Joined:
    Jan 30, 2002
    Messages:
    14
    Likes Received:
    0
    I found out how to get it into a mutator by 'borrowing' the following code from the matrix moves mutator...



    function ModifyLogin(out class<playerpawn> SpawnClass, out string Portal, out string Options)
    {
    local class <playerpawn> NewPlrClass;

    NewPlrClass = GetPClass(SpawnClass);

    if(NewPlrClass != none)
    SpawnClass = NewPlrClass;

    if ( NextMutator != None )
    NextMutator.ModifyLogin(SpawnClass, Portal, Options);
    }

    function class<PlayerPawn> GetPClass(class<Actor> myPlrClass)
    {

    if(myPlrClass == class'BotPack.Commander')
    return class'person.PCommander';
    else if(myPlrClass == class'BotPack.TBoss')
    return class'person.PTBoss';
    else if(myPlrClass == class'BotPack.TMale1')
    return class'person.PTMale1';
    else if(myPlrClass == class'BotPack.TMale2')
    return class'person.PTMale2';
    else if(myPlrClass == class'BotPack.TFemale1')
    return class'person.PTFemale1';
    else if(myPlrClass == class'BotPack.TFemale2')
    return class'person.PTFemale2';
    else
    return none;
    }


    with the code you gave earlier in Pbasemale, Pbasefemale and Pcommander.

    I then put bBehindview = true into the modify player function, but this only puts the player into third person view at the start of the game; after the player respawns the player is back in first person view... and I dont know how to solve this.

    Hope this helps
     
  16. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    WOW

    This helps a lot. Very nice work dude. Well I haven't been doing any uscripting for a while, I have been mapping :)

    To get the player spawning in 3rd persin there's a mutator called "ExternalView" which can be found here. This mutator causes a lot of access nones and you have to fart about and go to the guys homepage to actually download it. It does have the info you need, though I couldn't figure out what was causing the access nones.
     
  17. AV_ACE

    AV_ACE New Member

    Joined:
    Jan 30, 2002
    Messages:
    14
    Likes Received:
    0
    Ah... they have taken this mutator off fileplanet. Please could you put the code here...thankyou!
     
  18. Wannabeemapper

    Wannabeemapper Wannabee Mapper

    Joined:
    Feb 19, 2002
    Messages:
    34
    Likes Received:
    0
    Oh dear. Unfortunatly I no longer have the mutator.

    I did some trawling and came up with this link for you. It will download the ExternalView mutator. The guy had updated his webpage and for some strange reason he put the mutator into his utilities section :p

    Good luck dude :cool:
     
  19. AV_ACE

    AV_ACE New Member

    Joined:
    Jan 30, 2002
    Messages:
    14
    Likes Received:
    0
    Thankyou, that does work.

    I have been thinking about your laser sight. I presume by this you mean a red line coming out of the barrel of the players gun in the same direction he is pointing.

    My suggestion is that you give the player an item which works basically like a pulse gun on 2ndary fire which has no ammo and does not damage (with different skins).

    giving the player this item would be easy, add this to you mutator class:


    function bool AlwaysKeep(Actor Other)
    {
    if ( Other.IsA('lasersight') )
    return true;

    if ( NextMutator != None )
    return ( NextMutator.AlwaysKeep(Other) );
    return false;
    }

    function ModifyPlayer(Pawn Other)
    {
    local Inventory Inventory;

    Inventory = Other.FindInventoryType(class'lasersight');
    if ( Inv == None )
    {
    inv = Spawn(class'lasersight');
    if( inv != None )
    {
    inv.bHeldItem = true;
    inv.GiveTo(Other);
    inv.Activate();
    }
    }
    else
    return;

    //put rest of code here

    if ( NextMutator != None )
    NextMutator.ModifyPlayer(Other);
    }


    this would give the player the item. I have looked at the secondary fire of the pulse rifle and it seems to create a small parent beam which replicates itself and orients itself constantly until it hits a wall.

    The item could look like this **NOTE I HAVE NOT TRIED THIS: IT WILL NEED DEBUGGING, ETC**


    class lasersight extends Pickup;

    var laserBolt LB;

    state Activated
    {
    function endstate()
    {
    if ( LB!=None)
    LB.Destroy();
    bActive = false;
    }

    function Tick( float DeltaTime )
    {
    if (LB == None)
    LB = Spawn(class'laserBolt',Owner,,Pawn(owner).location,Pawn(Owner).viewrotation);

    if ( Pawn(Owner) == None )
    {
    LB.Destroy();
    return;
    }

    LB.updatebeam(self,Pawn(Owner).viewrotation);
    }

    function BeginState()
    {
    LB = Spawn(class'laserBolt',Owner,,Pawn(owner).location,Pawn(Owner).viewrotation);
    }

    Begin:
    }


    state DeActivated
    {
    Begin:
    LB.Destroy();
    }

    defaultproperties
    {
    bActivatable=True
    RemoteRole=ROLE_DumbProxy //...?
    }


    Like I said, Its only a rough idea and I cut a few corners and have probably made v. obvious errors :). Here is the projectile based on the beam from the pulsegun, which continually self replicates and self oritentates itself into a line:


    class LBolt extends projectile;

    var LBolt LaserBeam;
    var float BeamSize;

    simulated function Destroyed()
    {
    Super.Destroyed();
    if ( LaserBeam != None )
    LaserBeam.Destroy();
    }

    simulated function CheckBeam(vector X, float DeltaTime)
    {
    local actor HitActor;
    local vector HitLocation, HitNormal;

    // check to see if hits something, else spawn or orient child

    HitActor = Trace(HitLocation, HitNormal, Location + BeamSize * X, Location, true);
    if ( (HitActor != None) && (HitActor != Instigator)
    && (HitActor.bProjTarget || (HitActor == Level) || (HitActor.bBlockActors && HitActor.bBlockPlayers))
    && ((Pawn(HitActor) == None) || Pawn(HitActor).AdjustHitLocation(HitLocation, Velocity)) )
    {
    if (LaserBeam != None )
    {
    LaserBeam.Destroy();
    LaserBeam = None;
    }

    return;
    }

    if ( LaserBeam == None )
    {
    LaserBeam = Spawn(class'LBolt',,, Location + BeamSize * X);
    }
    else
    LaserBeam.UpdateBeam(self, X, DeltaTime);
    }

    simulated function UpdateBeam(LBolt ParentBolt, vector Dir, float DeltaTime)
    {
    local actor HitActor; //don't know why these are here - from Pbolt code
    local vector HitLocation, HitNormal;

    SetLocation(ParentBolt.Location + BeamSize * Dir);
    SetRotation(ParentBolt.Rotation);
    CheckBeam(Dir, DeltaTime);
    }

    defaultproperties
    {
    BeamSize=81.000000
    MaxSpeed=0.000000
    Damage=0.000000
    MomentumTransfer=0
    bNetTemporary=False
    Physics=PHYS_None
    RemoteRole=ROLE_None
    LifeSpan=60.000000
    Style=STY_Translucent
    Texture=Texture'Botpack.Skins.pbolt0' //change this
    Skin=Texture'Botpack.Skins.pbolt0'
    Mesh=LodMesh'Botpack.PBolt'
    bUnlit=True
    SoundRadius=0
    bCollideActors=False
    bCollideWorld=False
    }



    hope this gives you a few new ideas to work with...
     
  20. AV_ACE

    AV_ACE New Member

    Joined:
    Jan 30, 2002
    Messages:
    14
    Likes Received:
    0
    P.S. the external view mut keeps churning out access nones becuase in externalviewticker.uc the author left a space between function tick and (float deltatime).
     

Share This Page