Announcement

Collapse
No announcement yet.

Coin Counter Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Coin Counter Help

    Ok so i am making a mutator that every time you touch a coin model that i will place in a map, it disapears and you get +1 to a counter. This is what a have so far.




    //===========================================
    //Coin Counter
    ///==========================================

    class CoinCounter extends Actor;
    // model info i know how to find out

    function Touch( actor Other )
    {
    // stumped Coins = Coiins +1?
    }

    defaultproperties
    {
    Mesh=CoinMesh
    DrawType=DT_Mesh
    b_static=False
    bCollideActors=True
    collisionheight= 56
    }

    I do not know what to do from here, and would love all the help i can get. I know i have to add to a value, but do not know where to declare the Coin value.

    #2
    Well if all the coins are the same value then 'coin++;' would work

    Comment


      #3
      Why not use a pickup instead of an actor? Then your mutator could replace adrenaline, for example, with your coins.

      Comment


        #4
        ok, i took Bonehed316's advice and extened from TournamentHealth class. Looks like the only function i have to rewrite would be the Touch,and extend another script from Xpawn called CoinHolder that would hold the value of Coins? Aslo, where would i define what model the pickup uses?


        Class CoinHolder extends Xpawn;

        int Coins







        Class Coin extends TournamentHealth

        auto state Pickup
        {
        function Touch( actor Other )
        {
        local Pawn P;

        if ( ValidTouch(Other) )
        {
        P = Pawn(Other);
        CoinHolder(p)Coins = coins++
        AnnouncePickup(P);
        SetRespawn();

        }
        }

        Comment


          #5
          Ok I changed some things around.
          I have made a coin folder in the ut2004 directory, adn under that made 3 folders, classes, textures, and Models.

          In the models i have my model(health.psk)

          in the textures i have my texture(coinskin.bmp)

          In my classes folder i have 3 files
          Coin.uc
          //======================
          //Coin
          //======================


          Class Coin extends TournamentHealth

          auto state Pickup
          {
          function Touch( actor Other )
          {
          local Pawn P;

          if ( ValidTouch(Other) )
          {
          P = Pawn(Other);
          CoinHolder(p)Coins = coins++
          AnnouncePickup(P);
          SetRespawn();

          }
          }
          }

          CoinModel.uc

          //================================================== =============================
          // [CoinModel]
          //================================================== =============================

          class CoinModel extends Actor;
          #exec MESH MODELIMPORT MESH=CoinModelMesh MODELFILE=models\Health.PSK LODSTYLE=10
          #exec MESH ORIGIN MESH=CoinModelMesh X=0 Y=0 Z=0 YAW=0 PITCH=0 ROLL=0

          #exec MESHMAP SCALE MESHMAP=CoinModelMesh X=1.0 Y=1.0 Z=1.0


          // Digest and compress the animation data. Must come after the sequence declarations.
          // 'VERBOSE' gives more debugging info in UCC.log


          #EXEC TEXTURE IMPORT NAME=CoinModelTex0 FILE=TEXTURES\coinskin.bmp GROUP=Skins

          #EXEC MESHMAP SETTEXTURE MESHMAP=CoinModelMesh NUM=0 TEXTURE=CoinModelTex0

          // Original material [0] is [01 - Default] SkinIndex: 0 Bitmap: coinskin.bmp Path: C:\Documents and Settings\Dan911\Desktop


          defaultproperties
          {
          Mesh=CoinModelMesh
          DrawType=DT_Mesh
          bStatic=False
          bCollideActors=True
          collisionheight= 56
          }


          and finally CoinValue.uc

          /================================================
          //Coin Value
          //================================================




          Class CoinValue extends Xpawn; //define the coin value

          int Coins

          Coins = "1"


          I am curous if i would have to make a map using this mutator, or can i spawn a coin with a console command. Also, will this script work?

          Comment


            #6
            Ok i have completed my mod, at least for now. I would like to know how to make a coin spawn every time a hit a key or make them spawn randomly on a level, and have a hud meter that says how many you have. Anyway, here is th ecode that works. Type summon coin.coin to make one.

            //================================================== ===========================
            // Coin
            //================================================== ===========================
            class Coin extends TournamentHealth;

            #exec MESH MODELIMPORT MESH=CoinMesh MODELFILE=models\Coin.PSK LODSTYLE=10
            #exec MESH ORIGIN MESH=CoinMesh X=0 Y=0 Z=0 YAW=0 PITCH=0 ROLL=0
            #exec MESHMAP SCALE MESHMAP=CoinMesh X=1.0 Y=1.0 Z=1.0
            #EXEC TEXTURE IMPORT NAME=CoinTex0 FILE=TEXTURES\coinskin.bmp GROUP=Skins
            #EXEC MESHMAP SETTEXTURE MESHMAP=CoinMesh NUM=0 TEXTURE=CoinTex0

            //var() int CoinCounter;
            var() int CoinAmount;


            auto state Pickup
            {
            function Touch( actor Other )
            {
            local CoinVar P;
            P.CoinCounter=P.CoinCounter+1;
            log("Coins="$P.CoinCounter);

            if ( ValidTouch(Other) )
            {
            P = CoinVar(Other);
            if (P.CoinCounter<100)
            {
            AnnouncePickup(P);
            SetRespawn();
            }
            }
            }
            }


            //function outputcoinamount(actor Other)
            //{
            // log("coin="$CoinCounter);
            //}

            defaultproperties
            {
            HealingAmount=0
            bStatic=False
            MaxDesireability=0.3
            PickupMessage="You got a coin *****"
            //bSuperHeal=true
            Physics=PHYS_Rotating
            RotationRate=(Yaw=24000)
            DrawScale=1.0
            PickupSound=sound'PickupSounds.HealthPack'
            PickupForce="HealthPack" // jdf
            DrawType=DT_Mesh
            Mesh=CoinMesh
            //StaticMesh=StaticMesh'XPickups_rc.MiniHealthPack'
            CollisionRadius=24.0
            CoinAmount=1
            //HealingAmount=5
            //Style=STY_AlphaZ
            //ScaleGlow=0.6
            //CullDistance=+4500.0
            }


            //================================================== ===========================
            // CoinVar
            //================================================== ===========================
            class CoinVar extends xPawn;

            var() int CoinCounter;

            defaultproperties
            {
            CoinCounter=0
            }

            Comment


              #7
              Changing Player class

              I know for this to work i have to make the player class CoinVar. How do i do this?

              edit

              i was informed on how to do this, here is my code

              //================================================== ===========================
              // Gametype.
              //================================================== ===========================

              class Gametype extends xDeathMatch;
              defaultproperties

              {
              DefaultPlayerClassName="XGame.xPawn"
              MapListType="XInterface.MapListDeathMatch"
              HUDType="XInterface.HudCDeathMatch"
              DeathMessageClass=class'XGame.xDeathMessage'

              ScreenShotName="UT2004Thumbnails.DMShots"
              DecoTextName="XGame.Deathmatch"

              Acronym="DM"
              MapPrefix="DM"
              GameName="Coin Collector"
              DefaultEnemyRosterClass="XGame.xDMRoster"
              Description="Collect the coins dude"
              }

              Comment

              Working...
              X