Announcement

Collapse
No announcement yet.

UT2004RPG with Druid, iteration help

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

    UT2004RPG with Druid, iteration help

    UT2004 with UT2004RPG v2 and DruidsRPG155

    To summarize my question, how can I iterate through the inventory of a particular Pawn to (1) destroy all weapons and (2) destroy all artifacts.

    More details:
    Artifacts like "ArtifactFlight" under Inventory.Powerups.RPGArtifact are what I would like to be able to get a hold of and delete. I setup a function that does this:
    PHP Code:
    function whatever (PlayerController Sender) {
    local RPGArtifact artifact;
    artifact Sender.Pawn.Spawn(class'UT2004RPG.ArtifactFlight',sender.pawn);
    artifact.giveto(sender.pawn);

    Problem is, if I run it twice or 3 times, then I get 2 or 3 copies of the "boots of flight" artifact. I only want to allow one copy of them at any time in someone's inventory. The weapon issue is very similar, but for a simple specific example, I'll stick with this one artifact. A couple ways I've tried with no success is:

    PHP Code:
     for (Inv Sender.Pawn.InventoryInv != NoneInv Inv.Inventory) {
    if (
    Inv.IsA('ArtifactFlight')) { Inv.Destroy();}
    }

    and

    if (
    Sender.Pawn.FindInventoryType(class'ArtifactFlight') != none) {
    artifact sender.pawn.FindInventoryType(class'ArtifactFlight');
    artifact.Destroy();

    Thanks for any help you can give. Keep in mind that there are about 9 artifacts, so I need to code it for each of them.

    #2
    ah, nevermind, I figured it out.

    Comment


      #3
      How did you do it, I was looking at this the other night, but i guess I was too drunk to figure it out...

      Comment


        #4
        Here's the main part of the code, x and i are simply integers.

        PHP Code:
                if (command ~= "uncharmme") {
                      
        0;
                    for (
        Inv Sender.Pawn.InventoryInv != NoneInv Inv.Inventory) {
                        
        i++;
                    }
                    for (
        0<= ix++) {
                       for (
        Inv Sender.Pawn.InventoryInv != NoneInv Inv.Inventory) {
                            if (
        string(inv.Class) ~= "UT2004RPG.ArtifactFlight") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "UT2004RPG.ArtifactInvulnerability") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "UT2004RPG.ArtifactLightningRod") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "DruidsRPG155.DruidArtifactMonsterSummon") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "DruidsRPG155.DruidEnhancedArtifactMonsterSummon") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "UT2004RPG.ArtifactTeleport") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "UT2004RPG.ArtifactTripleDamage") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "DruidsRPG155.DruidArtifactMakeMagicWeapon") {inv.Destroy();}
                            else if (
        string(inv.Class) ~= "DruidsRPG155.DruidArtifactSpider") {inv.Destroy();}
                        }
                    }
                   } 
        I'm sure there's a way with less lines of code, but if it works, why fix it? If someone knows a way with out having to type in the class names for each artifact, please let me know. Thanks.

        Comment


          #5
          ok, for short you can say instead of:

          else if (string(inv.Class) ~= "UT2004RPG.ArtifactInvulnerability") {inv.Destroy();}

          say

          else if (inv.IsA('ArtifactInvulnerability') {inv.Destroy();}


          so if the packages upgrade, like DruidsRPG155 to 156, etc...you don't need to redo any code.

          Comment

          Working...
          X