Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Spawn with shieldbelt

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

  • Spawn with shieldbelt

    I am using this code to let people spawn with all weapons, but I want to add a shieldbelt to it. And it gives an error when doing so.

    Code:
    function PostBeginPlay()
    {
      // Perform a check if the config is there and if not, write a default config.
      if (CfgCheck!="ConfigCheck_001") {
        CfgCheck="ConfigCheck_001";
        bUseInfiniteAmmo=false;
        EnforcerAmmo=60;
        BioAmmo=30;
        ShockAmmo=20;
        LinkAmmo=100;
        StingerAmmo=75;
        FlakAmmo=15;
        RocketAmmo=12;
        SniperAmmo=9;
        bNoArrows=true;
        }
      SaveConfig();
    
    Super.PostBeginPlay();
      // Give everybody a default weapon if the Ammo is set higher than 0.
    
    //    DefaultInventory[DefaultInventory.Length] = class'UTGame.UTArmorPickup_Helmet';     // <= Doesnt work, type mismatch in '='
      if(BioAmmo>0)
        DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
      if(ShockAmmo>0)
        DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
      if(LinkAmmo>0)
        DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
      if(StingerAmmo>0)
        DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
      if(FlakAmmo>0)
        DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
      if(RocketAmmo>0)
        DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
      if(SniperAmmo>0)
        DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
    }
    
    function SetPlayerDefaults(Pawn PlayerPawn)
    {
      // bInfiniteAmmo is a recognized variable. If the config states bUseInfiniteAmmo=true this will trigger the bInfiniteAmmo.
     if(bUseInfiniteAmmo)
     {
    	UTInventoryManager(PlayerPawn.InvManager).bInfiniteAmmo=true;
     }
      // If bUseInfiniteAmmo=false than add ammo to every weapon.
     else
     {
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(EnforcerAmmo-50,class'UTGame.UTWeap_Enforcer');
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(BioAmmo-25,class'UTGameContent.UTWeap_BioRifle_Content');
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(ShockAmmo-20,class'UTGame.UTWeap_ShockRifle');
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(LinkAmmo-50,class'UTGame.UTWeap_Linkgun');
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(StingerAmmo-100,class'UTGame.UTWeap_Stinger');
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(FlakAmmo-10,class'UTGame.UTWeap_FlakCannon');
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(RocketAmmo-9,class'UTGame.UTWeap_RocketLauncher');
            UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(SniperAmmo-10,class'UTGame.UTWeap_SniperRifle');
     }
    	Super.SetPlayerDefaults(PlayerPawn);
    }
    BTW this is in a gametype not a mutator.
    "Type mismatch in '=' " - what to do?
    Help is appreciated.

  • #2
    "Type mismatch in '=' " obviously points out a type mismatch in an assignment on the specified line. I suggest you look up the types of the variable you try to assign to and of the expression you are assigning to the variable.

    Comment


    • #3
      Originally posted by Wormbo View Post
      "Type mismatch in '=' " obviously points out a type mismatch in an assignment on the specified line. I suggest you look up the types of the variable you try to assign to and of the expression you are assigning to the variable.
      I'm guessing you mean the DefaultInventory.Length part. What do I change Length to?

      I searched for what to fill in there but I don't know where to find that.
      Searched through UTWeapon.uc Weapon.uc ...

      Comment


      • #4
        Again, compare the data types of both sides of the assignment and check whether the left side type matches (or at least is a super class of) the right side type.

        For your information: the left side is not "Length", it's "DefaultInventory[DefaultInventory.Length]", so you need to find out the type of the DefaultInventory array.

        Comment


        • #5
          Originally posted by Wormbo View Post
          Again, compare the data types of both sides of the assignment and check whether the left side type matches (or at least is a super class of) the right side type.

          For your information: the left side is not "Length", it's "DefaultInventory[DefaultInventory.Length]", so you need to find out the type of the DefaultInventory array.
          Hmm, I searched for DefaultInventory in every parent of UTCTFGame and it gave no results..

          Comment


          • #6
            Take a look at this, to give a Pawn a weapon, I can do this

            Code:
            function GivePawnWeapon(class<Weapon> WeaponClass, Pawn P)
            {
                local UTWeapon Weap;
            
                Weap = UTWeapon(P.FindInventoryType(WeaponClass));
                if (Weap == None)
                {
                    Weap = UTWeapon(P.CreateInventory(WeaponClass));
                }
                Weap.AmmoCount = Weap.MaxAmmoCount;
            }
            And to give a Pawn armor, I can do this:

            Code:
            UTPawn(P).ShieldBeltArmor = 100;
            Are you sure you need to use the inventoryManager to add the shieldbelt?

            Comment


            • #7
              Using 'UTPawn(P).ShieldBeltArmor = 100;' worked!

              Code:
              function PostBeginPlay()
              {
                // Perform a check if the config is there and if not, write a default config.
                if (CfgCheck!="ConfigCheck_001") {
                  CfgCheck="ConfigCheck_001";
                  bUseInfiniteAmmo=false;
                  EnforcerAmmo=60;
                  BioAmmo=30;
                  ShockAmmo=20;
                  LinkAmmo=100;
                  StingerAmmo=75;
                  FlakAmmo=15;
                  RocketAmmo=12;
                  SniperAmmo=9;
                  bNoArrows=true;
                  LogInternal("Rewrote config");
                  }
                SaveConfig();
              
              Super.PostBeginPlay();
                // Give everybody a default weapon if the Ammo is set higher than 0.
              
                if(BioAmmo>0)
                  DefaultInventory[DefaultInventory.Length] = class'UTGameContent.UTWeap_BioRifle_Content';
                if(ShockAmmo>0)
                  DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_ShockRifle';
                if(LinkAmmo>0)
                  DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_LinkGun';
                if(StingerAmmo>0)
                  DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_Stinger';
                if(FlakAmmo>0)
                  DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_FlakCannon';
                if(RocketAmmo>0)
                  DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_RocketLauncher';
                if(SniperAmmo>0)
                  DefaultInventory[DefaultInventory.Length] = class'UTGame.UTWeap_SniperRifle';
              }
              
              function SetPlayerDefaults(Pawn PlayerPawn)
              {
                UTPawn(PlayerPawn).ShieldBeltArmor = 100;
               if(bUseInfiniteAmmo)
               {
              	UTInventoryManager(PlayerPawn.InvManager).bInfiniteAmmo=true;
              	LogInternal("Infinite ammo");
               }
                // If bUseInfiniteAmmo=false than add ammo to every weapon.
               else
               {
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(EnforcerAmmo-50,class'UTGame.UTWeap_Enforcer');
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(BioAmmo-25,class'UTGameContent.UTWeap_BioRifle_Content');
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(ShockAmmo-20,class'UTGame.UTWeap_ShockRifle');
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(LinkAmmo-50,class'UTGame.UTWeap_Linkgun');
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(StingerAmmo-100,class'UTGame.UTWeap_Stinger');
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(FlakAmmo-10,class'UTGame.UTWeap_FlakCannon');
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(RocketAmmo-9,class'UTGame.UTWeap_RocketLauncher');
                      UTInventoryManager(PlayerPawn.InvManager).AddAmmoToWeapon(SniperAmmo-10,class'UTGame.UTWeap_SniperRifle');
                      LogInternal("No infinite ammo");
               }
              	Super.SetPlayerDefaults(PlayerPawn);
              }
              As you can see, I put it in function SetPlayerDefaults and that was enough.

              I think I can even make the armor amount configurable by changing it to UTPawn(P).ShieldBeltArmor = ArmorAmount; with adding a configurable int ArmorAmount.

              Thanks!

              Comment


              • #8
                Originally posted by Taboen View Post
                I think I can even make the armor amount configurable by changing it to UTPawn(P).ShieldBeltArmor = ArmorAmount; with adding a configurable int ArmorAmount.

                Thanks!
                No problem So many help me, I try to help when I can.

                P.S. you may want to edit your first post to change the topic from shieltbelt to shieldbelt.

                Comment


                • #9
                  Originally posted by bushbomb View Post
                  No problem So many help me, I try to help when I can.

                  P.S. you may want to edit your first post to change the topic from shieltbelt to shieldbelt.
                  Lol, changed

                  Comment


                  • #10
                    For the record, I suspect that Wormbo wasn't being intentionally obtuse - he was being didactic. Part of what's nice about this community is that they'll help you get answers, but what's even nicer is that some folks (like Wormbo) will even go out of their way to teach you how to get your own answers.

                    Give a man some code, and you help him for a day
                    Teach a man to code, and you help him for a lifetime
                    ... or something like that.

                    Comment

                    Working...
                    X