Announcement

Collapse
No announcement yet.

Avoiding actor replacement in custom scripts

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

  • Avoiding actor replacement in custom scripts

    In 1.5 I'd like to see at least ThieveryGameSettings equipped with one of these:

    [code:1:deeb772e1d]var MyActor SActors[14]; // Stores subclasses that want to add functions
    var MyActor Executer; // Executer is for reference to this actor in subclass(es)
    var(AddFunctions) bool bAddFunctions; // Must be set to true in subclass if functions in the subclass are suposed to be added

    function PostBeginPlay()
    {
    SetTimer(1.0, false); // My primitive way of making sure all other things are in place
    }

    function Timer()
    {
    AddSubFunctions;
    }

    function bool AddSubFunctions
    {
    local MyActor A;
    local int I;

    ForEach AllActors(class'MyClass', A)
    {
    If ((A.class != class) && A.bAddFunctions && (I < 14))
    {
    SActors[I] = A; //
    A.Executer = self;
    I++; // Roll over
    }
    }
    }

    function MyFunction()
    {
    local int I;

    // Executes subclass function(s):
    while ((SActors[I] != None) && (I < 14)) // Goes through subactor list
    {
    SActors[I].MyFunction();
    I++;
    }

    // Original MyFunction code goes here
    }

    function MyFunction2()
    {
    local int I;

    // Executes subclass function(s):
    while ((SActors[I] != None) && (I < 14)) // Goes through subactor list
    {
    SActors[I].MyFunction2();
    I++;
    }

    // Original MyFunction2 code goes here
    }[/code:1:deeb772e1d]

    Sample subclass actor:

    [code:1:deeb772e1d]function MyFunction()
    {
    Spawn(class'SomeClass',, Executer.Location, Executer.Rotation);
    }

    defaultproperties
    {
    bAddFunctions = true;
    }[/code:1:deeb772e1d]


    Basically this actor finds actors that are subclasses of itself in the map and adds them to SActors, and at the start of each of its own functions it runs the same functions of the actors listed in SActors.
    ]V[]V[

  • #2
    YES!!!

    Comment


    • #3
      ??? :? ???

      o well,
      This is my cool sig.

      Comment


      • #4
        Originally posted by daniel
        ??? :? ???

        o well,
        Basically, MM is saying:

        -Only one instance of ThieveryGameSettings (TGS) can be used at any one time, in a level

        -TGS contains two rather important functions (assigning the default inventory, & custom events when a Pawn is splashed by a water arrow), and so only those for the chosen Thieverygamesettings will get activated

        -This is fine for standard Thievery gametypes, with most mutators

        -However, should a mutator/gametype require a new TGS actor to be created, to allow a specific effect be achieved, then the functions of the other actor actor will be discarded

        -This is gonna cause some nasty problems for certain maps,
        eg. In SoulsHarbour, the damage from water arrows is processed in TGS, so when some mutators overwrite the TGS, the water warrow damage will stop working.

        To be honest, I think that the current method of dealing with PawnSplashed could be better dealt with. Maybe cause them to look for a specific PawnSplashed actor, which could handle this function, or maybe you could damage all splashed pawns with 'waterdamage' of 0, and a map-embedded mutator could deal with increasing the damage where necessary. Or you could just modify the TBot code to take X damage from being splashed, being transferred onto players where necessary.

        Comment


        • #5
          Also, we could make the changing of gamerules mid-game pretty easy if we added these two simple functions:

          [code:1:804ed30c7b]function bool AddSingleSub( MyClass Sub )
          {
          local int I;
          local bool bFoundSlot;

          while ((I < 14) && !bFoundSlot) // Find free slot
          {
          if (SActors[I] == None)
          {
          SActors[I] = Sub; //
          bFoundSlot = true;
          }
          I++;
          }
          Return bFoundSlot;
          }

          function bool RemoveSingleSub( MyClass Sub )
          {
          local int I;
          local bool bFoundSlot;

          while ((I < 14) && !bFoundSlot) // Find slot with actor Sub
          {
          if (SActors[I] == Sub)
          {
          SActors[I] = None;
          bFoundSlot = true;
          }
          I++;
          }
          Return bFoundSlot;
          }[/code:1:804ed30c7b]

          Aditionally, this might be usefull:
          [code:1:804ed30c7b]function bool FindSub (MyClass Sub)
          {
          local int I;
          local bool bFoundSlot;

          while ((I < 14) && !bFoundSlot) // Find slot with actor Sub
          {
          if (SActors[I] == Sub)
          {
          bFoundSlot = true;
          }
          I++;
          }
          Return bFoundSlot;
          }
          [/code:1:804ed30c7b]

          The code for all three above is very similar, so this might be used instead of them:
          [code:1:804ed30c7b]function bool ProcessSingleSub( MyClass Sub, MyClass SubB )
          {
          local int I;
          local bool bFoundSlot;

          while ((I < 14) && !bFoundSlot)
          {
          if (SActors[I] == Sub)
          {
          SActors[I] = SubB;
          bFoundSlot = true;
          }
          I++;
          }
          Return bFoundSlot;
          }[/code:1:804ed30c7b]
          Now if you want to check A, you'd use ProcessSingleSub( A, A );.
          If you want to add A to a free slot, you'd use ProcessSingleSub( None, A );.
          If you want to remove A to create a free slot, you'd use ProcessSingleSub( A, None );
          And if you want to replace A with B, you'd simply use ProcessSingleSub( A, B );

          Also you might want to remove any SubB actors that are already there:
          [code:1:804ed30c7b]function bool ProcessSingleSub( MyClass Sub, MyClass SubB )
          {
          local int I;
          local bool bFoundSlot;

          for (I = 0; I < 14; I++)
          {
          if (!bFoundSlot && (SActors[I] == Sub))
          {
          SActors[I] = SubB;
          bFoundSlot = true;
          }
          else if (SActors[I] == SubB) // Check for & remove duplicates
          {
          SActors[I] = None;
          }
          }
          Return bFoundSlot;
          }[/code:1:804ed30c7b]

          And now we just need to fix the AddSubFunctions function:
          [code:1:804ed30c7b]function AddSubFunctions
          {
          local MyActor A;
          local int I;
          local bool bFoundSlot;

          ForEach AllActors(class'MyClass', A)
          {
          if ((A.class != class) && A.bAddFunctions)
          {
          for (I = 0; I < 14; I++)
          {
          if (!bFoundSlot && (SActors[I] == None)
          {
          SActors[I] = A;
          A.Executer = self;
          bFoundSlot = true;
          }
          else if (SActors[I] == A) // Check for & remove A's already there
          SActors = None;
          }
          }
          }
          }[/code:1:804ed30c7b]

          There. Now it's about as good as it gets.

          Lastly we should probably rename AddSubFunctions to something like AddAllSubs. And maybe we'll make a RemoveAllSubs later as well.
          ]V[]V[

          Comment


          • #6
            I forgot, the MyFunctions need a bit of changing as well:

            [code:1:7a5bad8331]function MyFunction()
            {
            local int I;

            // Executes subclass function(s):
            for (I = 0; I < 14; I++;) // Goes through subactor list
            {
            if (SActors[I] != None)
            SActors[I].MyFunction();
            }

            // Original MyFunction code goes here
            }[/code:1:7a5bad8331]
            ]V[]V[

            Comment

            Working...
            X