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.

Code Problem... Please Help

Discussion in 'Programming' started by Malakian, Jan 25, 2002.

  1. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    When I compile my code (Grappling hook from the tutorial) it says my grappling hook file has an error on line 175 (very last line) in which it says 'end of file at end of class' or something like this, and my last class is just defining default properties.... no idea what the problem is... please any help would be dearly appreciated.
     
  2. Brood_of_Evil

    Brood_of_Evil Selene's martyr

    Joined:
    Nov 3, 2001
    Messages:
    147
    Likes Received:
    0
    Could you please copy/paste the whole error message, that would help a lot.

    If it is what I think it is, it probably means that there's a missing bracket '}' somwhere in the code, try looking thru the code and check that all the blocks of code start with '{' and ends with '}'
     
  3. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    Well I did what you said, and I was missing a close bracket, but now im getting an error 'Unexpected defaultproperties' thats my last class and I typed it just like it says in grappling hook tutorial.
     
  4. RestInPieces

    RestInPieces New Member

    Joined:
    Sep 20, 2001
    Messages:
    65
    Likes Received:
    0
    It has to be something with the brackets, maybe you have a bracket after Defaultproperties?
     
  5. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    Well I tried compiling it with and without brackets, still same error.
     
  6. Raeled

    Raeled Feuer Frei!

    Joined:
    Jul 1, 2001
    Messages:
    161
    Likes Received:
    0
    maybe your defaultprop's is in a function, coz of wronglt places brackets
     
  7. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    I just checked, and its not... all my functions and what not are properly close with close brackets...
     
  8. RegularX

    RegularX Master of Dagoth Lies

    Joined:
    Feb 2, 2000
    Messages:
    1,215
    Likes Received:
    0
    Trust me,they're not. They just look like they are. Check also for code that isnt using brackets, because if you have mixed and matched any code at all (or the author of the tutorial did ), then some statements may use them, and some don't,which could cause additional confusion.


    But unexpected defaultproperties has essentially 1 problem - it's in a function, not by itself where it belongs, meaning it's encapsulated in a function's brackets.



    On a side rant, can anyone explain to me why people don't use brackets? I mean, I know it's optional syntax, and not using it is a short cut, etc., etc - but c'mon they're two lousy additional characters. It's not like they're hurting anybody and it makes the code not only more readable but portable too...


    /rant


    rgx
     
  9. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    I use my brackets! lol... but ill check my code again... I mean, I could post it for you guys, its not THAT long... maybe I just have that writer thing, were after you write something you dont notice errors, cause im stoopid like that. but ill post it...

    //=============================================================================
    // GrapplingHook.
    //=============================================================================
    class GrapplingHook expands TournamentWeapon;

    var bool bHooked;
    var vector HookLocation, Force;
    var float GrappleLength, Omega, CForce;
    var int Counter;
    var GChain Chain;

    replication
    {
    //Things the server tells the client.
    unreliable if(ROLE == ROLE_Authority)
    HookLocation, GrappleLength, bHooked;
    }

    simulated function Destroyed()
    {
    if(Chain != None)
    Chain.Destroy();

    Super.Destroyed();
    }

    simulated function Tick(float DeltaTime)
    {
    if(Owner == None) return;

    if(bHooked)
    {
    if(Owner.Physics != PHYS_Falling)
    {
    StopGrapple();
    return;
    }

    Counter++;
    //Update angular velocity every 3rd tick, gives a less spiralled path.
    if(Counter == 3)
    {
    //Angular Velocity
    GrappleLength = VSize(HookLocation - Owner.Location);

    if(GrappleLength > 2500)
    {
    StopGrapple();
    return;
    }
    Omega = VSize(Owner.Velocity / GrappleLength) * DeltaTime;
    Counter = 0;
    }
    //Centripetal Force
    CForce = Owner.Mass * GrappleLength * Omega ^ 2;
    //Centripetal force is towards center of circle
    Force = Normal(HookLocation - Owner.Location);
    Force *= CForce;
    Owner.Velocity += DeltaTime * Force;
    //Clamp maximum velocity
    if(VSize(Owner.Velocity) > 1100)
    {
    Owner.Velocity = Normal(Owner.Velocity) * 1100;
    }
    else if(VSize(Owner.Velocity) <-1100)
    {
    Owner.Velocity = - (Normal(Owner.Velocity) * 1100);
    }
    }
    }

    function StartGrapple()
    {
    local vector x,y,z, End, HitLocation, HitNormal;
    local Actor Other;

    //Dont start grappling if already grappling.
    if(bHooked)
    return;

    GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
    //End trace to stop people grappling stupidly long distances
    Other = Trace(HitLocation, HitNormal, Owner.Location + X * 2500.0, Owner.Location);
    if(Other == None)
    return;

    Other.TakeDamage(10.0, Pawn(Owner), HitLocation, 400.0 * X, 'grapple');

    if(!Other.IsA('Pawn') && !Other.IsA('Projectile') && !Other.IsA('Decoration'))
    {
    bHooked = True;
    HookLocation = Hitlocation;
    GrappleLength = VSize(Owner.Location - HitLocation);
    if(Chain == None)
    {
    Chain = Spawn(class'StarterChain', Owner,, Owner.Location);
    if(Chain.IsA('StarterChain'))
    StarterChain(Chain).HookLocation = HookLocation;
    }
    //Give the player a kick to get them moving
    Owner.Velocity += Normal(Owner.Velocity - HookLocation) * 200;

    }
    }
    function StopGrapple()
    {
    bHooked = False;

    if(Chain != None)
    {
    Chain.Destroy();
    Chain = None;
    }
    }

    //Fire to begin grappling
    function fire(float Value)
    {
    GotoState('NormalFire');
    StartGrapple();
    }

    //Alt-Fire to stop grappling
    function AltFire(float Value)
    {
    GotoState('AltFiring');
    StopGrapple;
    }

    state NormalFire
    {
    ignores Fire, AltFire;
    Begin:
    FinishAnim();
    LoopAnim('boltloop');
    Finish();
    }

    state AltFiring
    {
    ignores Fire, AltFire;
    Begin:
    FinishAnim();
    LoopAnim('idle');
    Finish();
    }

    //Putting down weapons in favor of a new one.

    state DownWeapon
    {
    ignores Fire, AltFire, AnimEnd;

    function BeginState()
    {
    Super.BeginState();
    bCanClientFire = false;
    //Destroy chain
    bHooked = false;
    if(Chain != None);
    {
    Chain.Destroy();
    Chain = None;
    }
    }
    }

    defaultproperties
    {
    Counter=0
    PickupMessage="You got the Grappling Hook."
    ItemName="Grappling Hook"
    Mesh=LodMesh'Botpack.PulsePickup'
    InventoryGroup=1
    PlayerViewOffset=(X=1.500000000, Z=-2.00000000000)
    PlayerViewMesh=LodMesh'Botpack.PulseGunR'
    PickupViewMesh=LodMesh'Botpack.PulsePickup'
    ThirdPersonMesh=LodMesh'Botpack.PulseGun3rd'
    ThirdPersonScale=0.4000000
    }
     
  10. RegularX

    RegularX Master of Dagoth Lies

    Joined:
    Feb 2, 2000
    Messages:
    1,215
    Likes Received:
    0
    I'm only guessing here - but try to put brackets around statements like:

    if(bHooked)
    return;

    GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
    //End trace to stop people grappling stupidly long distances
    Other = Trace(HitLocation, HitNormal, Owner.Location + X * 2500.0, Owner.Location);
    if(Other == None)
    return;




    and see if that does it.



    rgx
     
  11. RestInPieces

    RestInPieces New Member

    Joined:
    Sep 20, 2001
    Messages:
    65
    Likes Received:
    0
    I think the brackets are alright. At least they are in the piece of code you posted. Copy the code from the tread in a .uc file, I'm sure there won't be any problems with defaultproperties. There but there must be a wrong bracket somewhere in your code, wich you didn't post, maybe at the very end of your file, which is 50 lines after defaultpropterties for some reason (some people find it not-comfortable to write while there cursor is at the bottom of their screen...)
     
  12. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    Heres my code straight out of the .uc file, and the difference is at the bottom, but I cant change it no matter what I do in unrealed, its always there when I export it, but its not there in unreal ed...


    //=============================================================================
    // GrapplingHook.
    //=============================================================================
    class GrapplingHook expands TournamentWeapon;

    var bool bHooked;
    var vector HookLocation, Force;
    var float GrappleLength, Omega, CForce;
    var int Counter;
    var GChain Chain;

    replication
    {
    //Things the server tells the client.
    unreliable if(ROLE == ROLE_Authority)
    HookLocation, GrappleLength, bHooked;
    }

    simulated function Destroyed()
    {
    if(Chain != None)
    Chain.Destroy();

    Super.Destroyed();
    }

    simulated function Tick(float DeltaTime)
    {
    if(Owner == None) return;

    if(bHooked)
    {
    if(Owner.Physics != PHYS_Falling)
    {
    StopGrapple();
    return;
    }

    Counter++;
    //Update angular velocity every 3rd tick, gives a less spiralled path.
    if(Counter == 3)
    {
    //Angular Velocity
    GrappleLength = VSize(HookLocation - Owner.Location);

    if(GrappleLength > 2500)
    {
    StopGrapple();
    return;
    }
    Omega = VSize(Owner.Velocity / GrappleLength) * DeltaTime;
    Counter = 0;
    }
    //Centripetal Force
    CForce = Owner.Mass * GrappleLength * Omega ^ 2;
    //Centripetal force is towards center of circle
    Force = Normal(HookLocation - Owner.Location);
    Force *= CForce;
    Owner.Velocity += DeltaTime * Force;
    //Clamp maximum velocity
    if(VSize(Owner.Velocity) > 1100)
    {
    Owner.Velocity = Normal(Owner.Velocity) * 1100;
    }
    else if(VSize(Owner.Velocity) <-1100)
    {
    Owner.Velocity = - (Normal(Owner.Velocity) * 1100);
    }
    }
    }

    function StartGrapple()
    {
    local vector x,y,z, End, HitLocation, HitNormal;
    local Actor Other;

    //Dont start grappling if already grappling.
    if(bHooked)
    return;

    GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
    //End trace to stop people grappling stupidly long distances
    Other = Trace(HitLocation, HitNormal, Owner.Location + X * 2500.0, Owner.Location);
    if(Other == None)
    return;

    Other.TakeDamage(10.0, Pawn(Owner), HitLocation, 400.0 * X, 'grapple');

    if(!Other.IsA('Pawn') && !Other.IsA('Projectile') && !Other.IsA('Decoration'))
    {
    bHooked = True;
    HookLocation = Hitlocation;
    GrappleLength = VSize(Owner.Location - HitLocation);
    if(Chain == None)
    {
    Chain = Spawn(class'StarterChain', Owner,, Owner.Location);
    if(Chain.IsA('StarterChain'))
    StarterChain(Chain).HookLocation = HookLocation;
    }
    //Give the player a kick to get them moving
    Owner.Velocity += Normal(Owner.Velocity - HookLocation) * 200;

    }
    }
    function StopGrapple()
    {
    bHooked = False;

    if(Chain != None)
    {
    Chain.Destroy();
    Chain = None;
    }
    }

    //Fire to begin grappling
    function fire(float Value)
    {
    GotoState('NormalFire');
    StartGrapple();
    }

    //Alt-Fire to stop grappling
    function AltFire(float Value)
    {
    GotoState('AltFiring');
    StopGrapple;
    }

    state NormalFire
    {
    ignores Fire, AltFire;
    Begin:
    FinishAnim();
    LoopAnim('boltloop');
    Finish();
    }

    state AltFiring
    {
    ignores Fire, AltFire;
    Begin:
    FinishAnim();
    LoopAnim('idle');
    Finish();
    }

    //Putting down weapons in favor of a new one.

    state DownWeapon
    {
    ignores Fire, AltFire, AnimEnd;

    function BeginState()
    {
    Super.BeginState();
    bCanClientFire = false;
    //Destroy chain
    bHooked = false;
    if(Chain != None);
    {
    Chain.Destroy();
    Chain = None;
    }
    }
    }

    defaultproperties
    {
    Counter=0
    PickupMessage="You got the Grappling Hook."
    ItemName="Grappling Hook"
    Mesh=LodMesh'Botpack.PulsePickup'
    InventoryGroup=1
    PlayerViewOffset=(X=1.500000000, Z=-2.00000000000)
    PlayerViewMesh=LodMesh'Botpack.PulseGunR'
    PickupViewMesh=LodMesh'Botpack.PulsePickup'
    ThirdPersonMesh=LodMesh'Botpack.PulseGun3rd'
    ThirdPersonScale=0.4000000
    }

    defaultproperties
    {
    }
    That has to be the problem, but it doesnt show up in UnrealED and I cant scroll down past the first default properties in UnrealED.
     
  13. Bytekeeper

    Bytekeeper Last of the Brunnen G

    Joined:
    Jul 15, 2001
    Messages:
    181
    Likes Received:
    0
    But you're not coding inside of UED or what ?
    Because then you can't make a defaultproperties statement in UED. And if that's the case ( you're using UED ), just stop using it or don't setup defaultproperties via code ;)
     
  14. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    how can I do default properties in UED, I have that VUC program... can I do it in that?
     
  15. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    Right-click the class in the actor browser and select "Default Properties." But in the first place, don't use UnrealEd for coding. :)
     
  16. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    What should I use for coding then?
     
  17. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
  18. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    Well im using UCC now, but im still getting default properties erros... Its saying stuff like 'Unkown propert in defaults: RemoteRole = ROLE_SimulatedProxy' basically im getting errors with every one of my default properties lines.... such frustration, argh! and i'm also getting this '{' bad file or command, error in my main grappling hook file when I compile it... Any help would be greatly appreciated!
     
  19. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    Don't add any extra spaces before or after the "=" in the defaultproperties section. (Is there any UnrealScript coder out there who didn't stumble over this UnrealScript pecularity sometime?)
     
  20. Malakian

    Malakian New Member

    Joined:
    Jan 25, 2002
    Messages:
    25
    Likes Received:
    0
    Well I fixed all the errors and got it compiled. I downloaded Arena Match to test it out, but I dont know what to type in to get the grapple hook as the main weapon in the arena... please help!
     

Share This Page