Results 1 to 5 of 5
  1. #1
    MSgt. Shooter Person
    Join Date
    May 2010
    Posts
    32

    Default [SOLVED]Help - XP System Not Working with Melee Weapon

    So I've been following this XP tutorial: http://udkc.info/index.php?title=Tut...g_an_XP_system It's working great except that when I kill something with my melee weapons the HUD doesn't update properly. I've put logs in my script to see what is going on and based on what I'm seeing in the log all my variables update when I make a kill with my melee weapon but the HUD doesn't update. Then if I kill something with say my bow the variables update and the HUD updates but the variables in the log and what is displayed in the HUD don't match. I'm still learning unrealscript and I can't for the life of me figure out why it is doing this. Any help in this would be very much appreciated.

    GameInfo Class:
    Code:
    class SwordGame extends UTGame;
    
    // Function that is executed after each kill
    function ScoreKill(Controller Killer, Controller Other)
    {
        local SwordTestPlayerController PC;
     
        super.ScoreKill(Killer, Other);
        `log("KILLER:"$Killer);
        // Cast to the custom MyPlayerController class
        PC = SwordTestPlayerController(Killer);
        `log("PC:"$PC);
        // Give XP through our custom function to our PlayerController, change 100 to whatever amount you want
        PC.GiveXP(100);
    }
    
    defaultproperties
    {
        PlayerControllerClass=class'SwordTestPlayerController'
        HUDType=class'SwordHUD'
        DefaultPawnClass=Class'SwordPawn'
    
        bUseClassicHUD = true
    }
    PlayerController Class:
    Code:
    class SwordTestPlayerController extends UTPlayerController;
    
    // Mouse event enum
    enum EMouseEvent
    {
        LeftMouseButton,
        RightMouseButton,
        MiddleMouseButton,
        ScrollWheelUp,
        ScrollWheelDown,
    };
    var bool bSprint;
    
    const MAX_LEVEL = 50;
    const XP_INCREMENT = 500; // Amount of XP that is added to the amount of XP required for a level, after each level progression
     
    var int XP; // Total amount of gathered XP
    var int Level; // Current level
    var int XPGatheredForNextLevel; // Amount of XP gathered for the next level
    var int XPRequiredForNextLevel; // Amount of XP required for the next level
    
    simulated function PostBeginPlay()
    {
        super.PostBeginPlay();
     
        // Calculate XP-related properties at the start of the game
        CalculateLevelProgress();
    }
    
    public function GiveXP(int amount)
    {
        `log("XP GIVEN"$amount);
        XP += amount;
        `log("XP NOW:"$XP);
        CalculateLevelProgress();
     
        while (XPGatheredForNextLevel >= XPRequiredForNextLevel && Level < MAX_LEVEL)
        {
            Level++;
     
            // Recalculate level progress after leveling up
            CalculateLevelProgress();
        }
    }
    
    private function CalculateLevelProgress()
    {
        local int xpToCurrentLevel; // Total amount of XP gathered with current and previous levels
     
        xpToCurrentLevel = 0.5*Level*(Level-1)*XP_INCREMENT;
        `log("XPTOCURRENTLEVEL:"$xpToCurrentLevel);
        XPGatheredForNextLevel = XP - xpToCurrentLevel;
        `log("XPGATHEREDFORNEXTLEVEL:"$XPGatheredForNextLevel);
        XPRequiredForNextLevel = Level * XP_INCREMENT;
        `log("XPREQUIREDFORNEXTLEVEL:"$XPRequiredForNextLevel);
    }
    
    
    
    exec function Sprint()
    {
     Pawn.GroundSpeed *= 3;
    }
    exec function NotSprint()
    {
     Pawn.GroundSpeed /= 3;
    }
    exec function ToggleSprint()
    {
        if(bSprint == true)
        {
            NotSprint();
            bSprint = false;
        }
        else
        {
            Sprint();
            bSprint = true;
        }    
    }
    
    exec function StartFire( optional byte FireModeNum )
    {
        HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Pressed);
        Super.StartFire(FireModeNum);
    }
    
    exec function StopFire( optional byte FireModeNum )
    {
        HandleMouseInput((FireModeNum == 0) ? LeftMouseButton : RightMouseButton, IE_Released);
        Super.StopFire(FireModeNum);
    }
    
    // Handle mouse inputs
    function HandleMouseInput(EMouseEvent MouseEvent, EInputEvent InputEvent)
    {
        local SwordTestPlayerInput SwordTestPlayerInput;
    
        SwordTestPlayerInput = SwordTestPlayerInput(PlayerInput);
    
        if (SwordTestPlayerInput != None)
        {
            // Detect what kind of input this is
            if (InputEvent == IE_Pressed)
            {
                // Handle pressed event
                switch (MouseEvent)
                {
                    case LeftMouseButton:
                        SwordTestPlayerInput.MouseLeftPressed();
                        break;
    
                    case RightMouseButton:
                        SwordTestPlayerInput.MouseRightPressed();
                        break;
    
                    case MiddleMouseButton:
                        SwordTestPlayerInput.MouseMiddlePressed();
                        break;
    
                    case ScrollWheelUp:
                        SwordTestPlayerInput.MouseScrollUp();
                        break;
    
                    case ScrollWheelDown:
                        SwordTestPlayerInput.MouseScrollDown();
                        break;
    
                    default:
                        break;
                }
            }
            else if (InputEvent == IE_Released)
            {
                // Handle released event
                switch (MouseEvent)
                {
                    case LeftMouseButton:
                        SwordTestPlayerInput.MouseLeftReleased();
                        break;
    
                    case RightMouseButton:
                        SwordTestPlayerInput.MouseRightReleased();
                        break;
    
                    case MiddleMouseButton:
                        SwordTestPlayerInput.MouseMiddleReleased();
                        break;
    
                    default:
                        break;
                }
            }
        }
    }
    
    exec function MiddleMousePressed()
    {
        HandleMouseInput(MiddleMouseButton, IE_Pressed);
    }
    
    exec function MiddleMouseReleased()
    {
        HandleMouseInput(MiddleMouseButton, IE_Released);
    }
    
    exec function MiddleMouseScrollUp()
    {
        HandleMouseInput(ScrollWheelUp, IE_Pressed);
    }
    
    exec function MiddleMouseScrollDown()
    {
        HandleMouseInput(ScrollWheelDown, IE_Pressed);
    }
    
    // Override this state because StartFire isn't called globally when in this function
    auto state PlayerWaiting
    {
        exec function StartFire(optional byte FireModeNum)
        {
            Global.StartFire(FireModeNum);
        }
    }
    
    defaultproperties
    {
        bSprint = false;
        InputClass=class'SwordTestPlayerInput'
    
        Level = 1;
        XP = 0;
    }
    MeleeWeapon Class:
    Code:
    class BroadSwordNew extends UTWeapon;
    
    var int osmeleedamage; // Damage done by the weapon
    var ParticleSystem pawnhiteffect; //Particle effect to spawn when hitting a pawn
    var array<Actor> SwingHurtList;//Array of pawns that have been hit
    var SoundCue SwordClank;
    var int t;
    
    simulated function StartFire(byte FireModeNum)
      {
        //Clear hurtlist
        SwingHurtList.Remove(0,SwingHurtList.Length);
        //Primary attack
        if(FireModeNum==0)
            {
                t=0;
                PlayWeaponAnimation('Slice_01',0.1);
                GoToState('Swinging');
            }
       }
        
    state Swinging
    {
        function Tick(float DeltaTime)
            {
                super.Tick(DeltaTime);
                //`log("TICK");
                TraceSwing();
                t++;
                if (t==6)
                {
                    EndFire(0);
                }
            }
    
    
        function TraceSwing()
        {
            local actor traced;
            local vector hitlocation, hitnormal, traceEnd, traceStart;
            local pawn hitpawn;
            
            //Get location of sockets in world.
            SkeletalMeshComponent(Mesh).GetSocketWorldLocationAndRotation ('EndControl', traceStart);
            SkeletalMeshComponent(Mesh).GetSocketWorldLocationAndRotation('StartControl', traceEnd);
            //`log("TRACE");
            //trace from weaponpoint to meleesocket
            Foreach TraceActors(class'actor', traced, hitlocation, hitnormal, traceEnd, traceStart)
            {
                //If traced actor isn't you, is a pawn, check if pawn isn't in the hurtlist.
                if(traced != Owner && Pawn(traced) != none && Addtoswinghurtlist(traced))
                {
                    hitpawn = Pawn(traced);
                    // Do damage to the traced pawn
                    hitpawn.TakeDamage(osmeleedamage, Pawn(traced).Controller, hitlocation, Normal((Traced.Location - Owner.Location))*75000, class'DmgType_Crushed');
                    //spawn particle effect at hitlocation.
                    WorldInfo.MyEmitterPool.SpawnEmitter(pawnhiteffect,Hitlocation,, Traced);
                    PlaySound(SwordClank);
                    EndFire(0);
                }
            }
        }
        
        function bool AddToSwingHurtList(Actor newEntry)
        {
            local int i;
            for(i=0; i < SwingHurtList.Length;i++)
            {
                if(SwingHurtList[i] == newEntry) // if pawn is in array
                return false;
            }
            SwingHurtList.AddItem(newEntry); // add pawn to array
            //`log("HIT");
            return true;
        }
        simulated function EndFire(byte FireModeNum)
        {
            //`log("EXIT STATE");
            super.EndFire(0);
            SetTimer(0.2,false,'ExitState');
        }
        function ExitState(name NextStateName)
        {
            //`log("EXIT");
            //super.EndFire(0);
            GoToState('Active');
        }
    }
    defaultproperties
      {
        Begin Object class=AnimNodeSequence Name=MeshSequenceA
        End Object
    
        Begin Object Name=FirstPersonMesh
            SkeletalMesh=SkeletalMesh'GDC_Materials.Meshes.SK_ExportSword2'
            AnimSets(0)=AnimSet'GDC_Materials.Meshes.SwordAnimsetTest'
            Animations=MeshSequenceA
            Translation=(z=-1)
            Scale=.15
        End Object    
    
        AttachmentClass=class'BroadSwordAttachmentNew'
        
        Begin Object Name=PickupMesh
            SkeletalMesh=SkeletalMesh'GDC_Materials.Meshes.SK_ExportSword2'
            Scale=.5
        End Object
    
        ShotCost(0)=0
    
        AmmoCount=1
    
        MaxAmmoCount=1
        
        MuzzleFlashSocket=EndControl
    
        osmeleedamage=30
    
        SwordClank=A_Vehicle_Scorpion.SoundCues.A_Vehicle_Scorpion_BladeExtend
    
        pawnhiteffect=T_FX.Effects.P_FX_Bloodhit_Corrupt_Near
    
        PickupSound=SoundCue'A_Vehicle_Scorpion.SoundCues.A_Vehicle_Scorpion_BladeRetract'
      }
    HUD Class:
    Code:
    class SwordHUD extends UTHUD;
    
    //var SidePawn Jump;
    //var int jumptest;
    
    function DrawHealthBar(float percentFull)
    {
        local int currentBarWidth;
        local int maxBarWidth; 
        local int barHeight;
        local int barPositionX;
        local int barPositionY;
        local int healthPct;
    
        maxBarWidth = 300;
        barHeight = 20;
        barPositionX = 20;
        barPositionY = 20;
        healthPct = percentFull * 100;
    
        currentBarWidth = maxBarWidth * percentFull;
    
            // Draw the "filled" part of the bar
        Canvas.SetPos(barPositionX, barPositionY);        // X, Y position
        Canvas.SetDrawColor(0, 200, 0, 200);    // R, G, B, A for bar rectangle
        Canvas.DrawRect(currentBarWidth, barHeight);
    
            // Draw the empty part of the bar
        Canvas.SetPos(barPositionX + currentBarWidth, barPositionY);
        Canvas.SetDrawColor(200, 255, 200, 110);
        Canvas.DrawRect(maxBarWidth - currentBarWidth, barHeight);
    
            // Draw some text next to the bar
        Canvas.SetPos(barPositionX + maxBarWidth + 10, barPositionY);
        Canvas.SetDrawColor(0, 200, 0, 200);
        Canvas.Font = class'Engine'.static.GetMediumFont();
        Canvas.DrawText("Health: "$healthPct$"%");
    }
    
    function DrawManaBar(float percentFull)
    {
        local int currentBarWidth;
        local int maxBarWidth; 
        local int barHeight;
        local int barPositionX;
        local int barPositionY;
        local int manaPct;
    
        maxBarWidth = 300;
        barHeight = 20;
        barPositionX = 20;
        barPositionY = 60;
        manaPct = percentFull * 100;
    
        currentBarWidth = maxBarWidth * percentFull;
    
            // Draw the "filled" part of the bar
        Canvas.SetPos(barPositionX, barPositionY);        // X, Y position
        Canvas.SetDrawColor(0, 0, 200, 200);    // R, G, B, A for bar rectangle
        Canvas.DrawRect(currentBarWidth, barHeight);
    
            // Draw the empty part of the bar
        Canvas.SetPos(barPositionX + currentBarWidth, barPositionY);
        Canvas.SetDrawColor(200, 200, 255, 110);
        Canvas.DrawRect(maxBarWidth - currentBarWidth, barHeight);
    
            // Draw some text next to the bar
        Canvas.SetPos(barPositionX + maxBarWidth + 10, barPositionY);
        Canvas.SetDrawColor(0, 0, 200, 200);
        Canvas.Font = class'Engine'.static.GetMediumFont();
        Canvas.DrawText("Mana: "$manaPct$"%");
    }
    
    function DrawAmmoBar(float percentFull)
    {
        local int currentBarWidth;
        local int maxBarWidth; 
        local int barHeight;
        local int barPositionX;
        local int barPositionY;
        local int AmmoPct;
    
        maxBarWidth = 300;
        barHeight = 20;
        barPositionX = 20;
        barPositionY = 40;
        if (PawnOwner.Weapon!=None)
        {
        if(UTWeapon(PawnOwner.Weapon).MaxAmmoCount==1)
        {
        AmmoPct = percentFull;
        }
        else
        {
        AmmoPct = percentFull * 100;
        }
        }
        currentBarWidth = maxBarWidth * percentFull;
    
            // Draw the "filled" part of the bar
        Canvas.SetPos(barPositionX, barPositionY);        // X, Y position
        Canvas.SetDrawColor(200, 0, 200, 200);    // R, G, B, A for bar rectangle
        Canvas.DrawRect(currentBarWidth, barHeight);
    
            // Draw the empty part of the bar
        Canvas.SetPos(barPositionX + currentBarWidth, barPositionY);
        Canvas.SetDrawColor(255, 200, 255, 110);
        Canvas.DrawRect(maxBarWidth - currentBarWidth, barHeight);
    
            // Draw some text next to the bar
        Canvas.SetPos(barPositionX + maxBarWidth + 10, barPositionY);
        Canvas.SetDrawColor(200, 0, 200, 200);
        Canvas.Font = class'Engine'.static.GetMediumFont();
        Canvas.DrawText("Ammo: "$AmmoPct);
    }
    
    function DrawBar(String  Title, float Value, float MaxValue,int X, int Y, int R, int G, int B) // Create our function used to draw bars
    {
    local int PosX; //Declare our variable representing our postition on the X-axis
    local int BarSizeX; //Declare our variable representing the size of our bar
     
    PosX = X; //Where we should draw the rectangle
    BarSizeX = 300 * FMin(Value / MaxValue, 1); // size of active rectangle (change 300 to however big you want your bar to be)
     
    //Displays active rectangle
    Canvas.SetPos(PosX,Y);
    Canvas.SetDrawColor(R, G, B, 200);
    Canvas.DrawRect(BarSizeX, 12);
     
    //Displays empty rectangle
    Canvas.SetPos(BarSizeX+X,Y);
    Canvas.SetDrawColor(255, 255, 255, 80);
    Canvas.DrawRect(300 - BarSizeX, 12); //Change 300 to however big you want your bar to be
     
    //Draw our title
    Canvas.SetPos(PosX+300+5, Y); //Change 300 to however big your bar is
    Canvas.SetDrawColor(R, G, B, 200);
    Canvas.Font = class'Engine'.static.GetSmallFont();
    Canvas.DrawText(Title);
     
    } 
    
    //function DrawLevelBar(float percentFull)
    //{
    //    local int currentBarWidth;
    //    local int maxBarWidth; 
    //    local int barHeight;
    //    local int barPositionX;
    //    local int barPositionY;
    //    local SwordTestPlayerController PC;
    //
    //    maxBarWidth = 300;
    //    barHeight = 20;
    //    barPositionX = 20;
    //    barPositionY = 80;
    //    
    //    PC = SwordTestPlayerController(PlayerOwner);
    //
    //    currentBarWidth = maxBarWidth * percentFull;
    //
    //        // Draw the "filled" part of the bar
    //    Canvas.SetPos(barPositionX, barPositionY);        // X, Y position
    //    Canvas.SetDrawColor(200, 0, 0, 200);    // R, G, B, A for bar rectangle
    //    Canvas.DrawRect(currentBarWidth, barHeight);
    //
    //        // Draw the empty part of the bar
    //    Canvas.SetPos(barPositionX + currentBarWidth, barPositionY);
    //    Canvas.SetDrawColor(255, 200, 200, 110);
    //    Canvas.DrawRect(maxBarWidth - currentBarWidth, barHeight);
    //
    //        // Draw some text next to the bar
    //    Canvas.SetPos(barPositionX + maxBarWidth + 10, barPositionY);
    //    Canvas.SetDrawColor(200, 0, 0, 200);
    //    Canvas.Font = class'Engine'.static.GetMediumFont();
    //    Canvas.DrawText("Level: "@PC.Level);
    //}
    
    //function DrawXPBar(float percentFull)
    //{
    //    local int currentBarWidth;
    //    local int maxBarWidth; 
    //    local int barHeight;
    //    local int barPositionX;
    //    local int barPositionY;
    //    local SwordTestPlayerController PC;
    //
    //    maxBarWidth = 300;
    //    barHeight = 20;
    //    barPositionX = 20;
    //    barPositionY = 100;
    //    
    //    PC = SwordTestPlayerController(PlayerOwner);
    //
    //    currentBarWidth = maxBarWidth * percentFull;
    //
    //        // Draw the "filled" part of the bar
    //    Canvas.SetPos(barPositionX, barPositionY);        // X, Y position
    //    Canvas.SetDrawColor(200, 200, 0, 200);    // R, G, B, A for bar rectangle
    //    Canvas.DrawRect(currentBarWidth, barHeight);
    //
    //        // Draw the empty part of the bar
    //    Canvas.SetPos(barPositionX + currentBarWidth, barPositionY);
    //    Canvas.SetDrawColor(255, 255, 200, 110);
    //    Canvas.DrawRect(maxBarWidth - currentBarWidth, barHeight);
    //
    //        // Draw some text next to the bar
    //    Canvas.SetPos(barPositionX + maxBarWidth + 10, barPositionY);
    //    Canvas.SetDrawColor(200, 200, 0, 200);
    //    Canvas.Font = class'Engine'.static.GetMediumFont();
    //    Canvas.DrawText("XP:"@PC.XP$"/"$PC.XPRequiredForNextLevel);
    //}
    
    //function DrawArmorBar(float percentFull)
    //{
    //    local int currentBarWidth;
    //    local int maxBarWidth; 
    //    local int barHeight;
    //    local int barPositionX;
    //    local int barPositionY;
    //    local int ArmorPct;
    //
    //    maxBarWidth = 300;
    //    barHeight = 20;
    //    barPositionX = 20;
    //    barPositionY = 60;
    //    ArmorPct = percentFull;
    //
    //    currentBarWidth = percentFull * 3;
    //
    //        // Draw the "filled" part of the bar
    //    Canvas.SetPos(barPositionX, barPositionY);        // X, Y position
    //    Canvas.SetDrawColor(200, 200, 0, 200);    // R, G, B, A for bar rectangle
    //    Canvas.DrawRect(currentBarWidth, barHeight);
    //
    //        // Draw the empty part of the bar
    //    Canvas.SetPos(barPositionX + currentBarWidth, barPositionY);
    //    Canvas.SetDrawColor(200, 255, 0, 110);
    //    Canvas.DrawRect(maxBarWidth - currentBarWidth, barHeight);
    //
    //        // Draw some text next to the bar
    //    Canvas.SetPos(barPositionX + maxBarWidth + 10, barPositionY);
    //    Canvas.SetDrawColor(200, 200, 0, 200);
    //    Canvas.Font = class'Engine'.static.GetMediumFont();
    //    Canvas.DrawText("Armor: "$ArmorPct$"%");
    //}
    
    function DrawString(string text, int X, int Y, int R, int G, int B, int A)
    {
        Canvas.SetPos(X, Y);
        Canvas.SetDrawColor(R, G, B, A);
        Canvas.Font = class'Engine'.static.GetMediumFont();
        Canvas.DrawText(text);
    }
    
    function DrawGameHud()
    {
        local SwordTestPlayerController PC;
        local string CurEqWeap;
    
        // Type cast the PlayerOwner property of the HUD to SidePlayerController
        PC = SwordTestPlayerController(PlayerOwner);
    
        if (!PlayerOwner.IsDead())
        {
            // Display health bar only when the player hasn't died
            if(PlayerOwner.Pawn.HealthMax > 0)
            {
                DrawHealthBar(float(PlayerOwner.Pawn.Health) / float(PlayerOwner.Pawn.HealthMax));
            }
        
        
        DrawManaBar(float(SwordPawn(PawnOwner).CurrentMana) / float(SwordPawn(PawnOwner).MaxMana));
        if (PawnOwner.Weapon!=None)
        {
        DrawAmmoBar(float(UTWeapon(PawnOwner.Weapon).AmmoCount) / float(UTWeapon(PawnOwner.Weapon).MaxAmmoCount));
        }
        else
        {
        DrawAmmoBar(0);
        }
    
    DrawBar("Level:"@PC.Level, PC.Level, PC.MAX_LEVEL ,20,80,200,200,200); //...and our level-bar
    if ( PC.Level != PC.MAX_LEVEL ) //If our player hasn't reached the highest level...
    {
        DrawBar("XP:"@PC.XPGatheredForNextLevel$"/"$PC.XPRequiredForNextLevel, PC.XPGatheredForNextLevel, PC.XPRequiredForNextLevel, 20, 100, 80, 255, 80); //...draw our XP-bar
    }
    
        //DrawLevelBar(float(PC.Level) / float(PC.MAX_LEVEL)); //...and our level-bar
        //if ( PC.Level != PC.MAX_LEVEL ) //If our player hasn't reached the highest level...
        //{
        //    DrawXPBar(float(PC.XP) / float(PC.XPRequiredForNextLevel)); //...draw our XP-bar
        //    `log("HUD XPGATHEREDFORNEXTLEVEL:"$PC.XP);
        //    `log("HUD XPREQUIREDFORNEXTLEVEL:"$PC.XPRequiredForNextLevel);
        //}
    
    //    DrawArmorBar(float(UTPawnOwner.GetShieldStrength())); 
            // Always display other information
        CurEqWeap=String(PawnOwner.Weapon);
        //`log("WEAPON:"$CurEqWeap);
        If (CurEqWeap=="Poisonball_0")
        {
        DrawString("Weapon: POISONBALL",20,120,140,80,0,200);
        }
        If (CurEqWeap=="Fireball_0")
        {
        DrawString("Weapon: FIREBALL",20,120,140,80,0,200);
        }
        If (CurEqWeap=="Frostball_0")
        {
        DrawString("Weapon: FROSTBALL",20,120,140,80,0,200);
        }
        If (CurEqWeap=="Lightning_0")
        {
        DrawString("Weapon: LIGHTNING",20,120,140,80,0,200);
        }
        If (CurEqWeap=="BroadSwordNew_0")
        {
        DrawString("Weapon: SWORD",20,120,140,80,0,200);
        }
        If (CurEqWeap=="UTWeap_Bow_0")
        {
        DrawString("Weapon: BOW",20,120,140,80,0,200);
        }
        If (CurEqWeap=="crossbow_0")
        {
        DrawString("Weapon: CROSSBOW",20,120,140,80,0,200);
        }
        If (CurEqWeap=="ForcePush_0")
        {
        DrawString("Weapon: FORCE PUSH",20,120,140,80,0,200);
        }
        If (CurEqWeap=="SwordNew_0")
        {
            DrawString("Weapon: SWORD",20,120,140,80,0,200);
        }
        If (CurEqWeap=="HammerNew_0")
        {
            DrawString("Weapon: HAMMER",20,120,140,80,0,200);
        }
        If (CurEqWeap=="AxeNew_0")
        {
            DrawString("Weapon: AXE",20,120,140,80,0,200);
        }
        If (CurEqWeap=="None")
        {
        DrawString("Weapon: NONE",20,120,140,80,0,200);
        }
    //    DrawString("Score: "$PC.SidePoints,20,100,0,80,160,200);
    //    DrawString("Lives: "$PC.Lives,140,80,80,80,80,200);
        }
    //    if ((PlayerOwner != none) && PlayerOwner.Pawn != none)
    //    {
    //        Jump = SidePawn(PlayerOwner.Pawn);
    //        jumptest = Jump.MaxMultiJump;
    //        if (jumptest == 0)
    //        {
    //            DrawString("Double Jump Not Available",140,100,255,255,255,255);
    //        }
    //        if (jumptest == 1)
    //        {
    //            DrawString("Double Jump Available",140,100,255,255,255,255);
    //        }
    //    }
    }
    
    defaultproperties
    {
    //    bCrosshairShow=false
    }
    I know this is probably ugly code but it works for the most part. Anyone have any ideas why it doesn't work for my melee weapon?
    Last edited by Xandrax; 04-28-2012 at 09:03 PM.

  2. #2
    MSgt. Shooter Person
    Join Date
    May 2010
    Posts
    32

    Default

    Could it be because I overwrite the startfire, stopfire, and endfire functions and something in the normal version of those calls the right thing needed to update the HUD properly?

  3. #3
    MSgt. Shooter Person
    Join Date
    May 2010
    Posts
    32

    Default

    Well my bad. I guess my melee class is not calling the scorekill function and what I was seeing in the log was my player dieing at the end when I hit ESC out of the editor. I've put some code in the area where my mele weapon does damage and I'm trying to reference the scorkill function in my swordgame info class but I keep getting none returned so it never calls the function. Any ideas on how I can call the scorekill function in SwordGame from my BroadSwordNew class?

  4. #4
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    484

    Default

    Xandrax
    Maybe:
    WorldInfo.Game.ScoreKill(Owner.Controller, traced.Controller);

  5. #5
    MSgt. Shooter Person
    Join Date
    May 2010
    Posts
    32

    Default

    Figured it out. Thanks for the help rquester.

    Melee Weapon Class:
    Code:
    class BroadSwordNew extends UTWeapon;
    
    var int osmeleedamage; // Damage done by the weapon
    var ParticleSystem pawnhiteffect; //Particle effect to spawn when hitting a pawn
    var array<Actor> SwingHurtList;//Array of pawns that have been hit
    var SoundCue SwordClank;
    var int t;
    
    simulated function StartFire(byte FireModeNum)
      {
        //Clear hurtlist
        SwingHurtList.Remove(0,SwingHurtList.Length);
        //Primary attack
        if(FireModeNum==0)
            {
                t=0;
                PlayWeaponAnimation('Slice_01',0.1);
                GoToState('Swinging');
            }
       }
        
    state Swinging
    {
        function Tick(float DeltaTime)
            {
                super.Tick(DeltaTime);
                //`log("TICK");
                TraceSwing();
                t++;
                if (t==6)
                {
                    EndFire(0);
                }
            }
    
    
        function TraceSwing()
        {
            local actor traced;
            local vector hitlocation, hitnormal, traceEnd, traceStart;
            local pawn hitpawn;
            
            //Get location of sockets in world.
            SkeletalMeshComponent(Mesh).GetSocketWorldLocationAndRotation ('EndControl', traceStart);
            SkeletalMeshComponent(Mesh).GetSocketWorldLocationAndRotation('StartControl', traceEnd);
            //`log("TRACE");
            //trace from weaponpoint to meleesocket
            Foreach TraceActors(class'actor', traced, hitlocation, hitnormal, traceEnd, traceStart)
            {
                //If traced actor isn't you, is a pawn, check if pawn isn't in the hurtlist.
                if(traced != Owner && Pawn(traced) != none && Addtoswinghurtlist(traced))
                {
                    hitpawn = Pawn(traced);
                    // Do damage to the traced pawn
                    hitpawn.TakeDamage(osmeleedamage, Pawn(traced).Controller, hitlocation, Normal((Traced.Location - Owner.Location))*75000, class'UTDmgType_LinkPlasma');
                    //spawn particle effect at hitlocation.
                    WorldInfo.MyEmitterPool.SpawnEmitter(pawnhiteffect,Hitlocation,, Traced);
                    PlaySound(SwordClank);
                    EndFire(0);
                    //`log("HITPAWN CONTROLLER:"$hitpawn.controller);
                    if (hitpawn.Controller==None)
                    {
                        //`log("BOT KILLED");
                        WorldInfo.Game.ScoreKill(Pawn(Owner).Controller,Pawn(traced).Controller);
                    }
                }
            }
        }
        
        function bool AddToSwingHurtList(Actor newEntry)
        {
            local int i;
            for(i=0; i < SwingHurtList.Length;i++)
            {
                if(SwingHurtList[i] == newEntry) // if pawn is in array
                return false;
            }
            SwingHurtList.AddItem(newEntry); // add pawn to array
            //`log("HIT");
            return true;
        }
        simulated function EndFire(byte FireModeNum)
        {
            //`log("EXIT STATE");
            super.EndFire(0);
            SetTimer(0.2,false,'ExitState');
        }
        function ExitState(name NextStateName)
        {
            //`log("EXIT");
            GoToState('Active');
        }
    }
    defaultproperties
      {
        Begin Object class=AnimNodeSequence Name=MeshSequenceA
        End Object
    
        Begin Object Name=FirstPersonMesh
            SkeletalMesh=SkeletalMesh'GDC_Materials.Meshes.SK_ExportSword2'
            AnimSets(0)=AnimSet'GDC_Materials.Meshes.SwordAnimsetTest'
            Animations=MeshSequenceA
            Translation=(z=-1)
            Scale=.15
        End Object    
    
        AttachmentClass=class'BroadSwordAttachmentNew'
        
        Begin Object Name=PickupMesh
            SkeletalMesh=SkeletalMesh'GDC_Materials.Meshes.SK_ExportSword2'
            Scale=.5
        End Object
    
        ShotCost(0)=0
    
        AmmoCount=1
    
        MaxAmmoCount=1
        
        MuzzleFlashSocket=EndControl
    
        osmeleedamage=30
    
        SwordClank=A_Vehicle_Scorpion.SoundCues.A_Vehicle_Scorpion_BladeExtend
    
        pawnhiteffect=T_FX.Effects.P_FX_Bloodhit_Corrupt_Near
    
        PickupSound=SoundCue'A_Vehicle_Scorpion.SoundCues.A_Vehicle_Scorpion_BladeRetract'
        CrossHairImage=None
      }


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.