Announcement

Collapse
No announcement yet.

Problem with multiple subclassed vehicles

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

    Problem with multiple subclassed vehicles

    OK I have run into a problem and am looking for a solution. I have created a custom vehicle that is subclassed from the ONSPRV class. I have also written a mutator that replaces all the Hellbenders on a map with my one. This is fine until I use a map with a custom hellbender of its own. This is understandable as my mutator works by iterating through all the VehicleFactorys on a map and if the VehicleFactory is set to spawn an Onslaught.ONSPRV it changes it to my vehicle class. I have a lot of user maps on my server that have there own hellbender versions.

    Some maps use custom hellbenders such as ones without the rear torrut. I want to be able to change these benders so that they will have all the features of my bender but still retain their features as the map designer intended like having no rear gun.

    I know I could do this by accually changing the Onslaught.ONSPRV class but I really want to avoid doing this.

    An example of this is a change I would like to implement in the Vehicle class. I have subclass of this which contains a moded version of the PlaceExitingDriver () function. On Assault racing maps which I play a lot if you are close to the side of the track and jump out of your vehicle a lot of the time you will be placed over the side and fall to your death. My version of the PlaceExitingDriver () function always places you in on the track.
    Is there a way to get all vechicles to extend my version of the vehicle class instead of the original one when the hellbender class or other is unknown.

    #2
    Sound like you want to try multiple inheritance or re-inheritance. Neither of those things is possible without some byte hacking, lol. There is a way, however, to replace all hellbender subclasses with your subclass. You can cast classes in uscript. It's as easy as class<MyClass>(class'SomeOtherClass'), and remember to check for none. Works the same with class variables, etc.

    Not the solution you desire, but its half way there, at least.

    Comment


      #3
      Im not sure how you mean to use casting to achieve my aim

      Code:
      class MwMVehicle extends Vehicle;
      
      function bool PlaceExitingDriver()
      {
          
      }
      Code:
      class MutMwMVehicles extends Mutator config(user);
      
      function PostBeginPlay()
      {
      	local SVehicleFactory Factory;
      	local MwMVehicle veh;
      	foreach AllActors( class 'SVehicleFactory', Factory )
      	{
      		veh = class<MwMVehicle>(Factory.VehicleClass);
      
      		//if (Factory.VehicleClass.isA('ONSPRV'))
      		//	
      		//	Factory.VehicleClass =  veh;
      		//}
      		
      	}
      	
          
          Super.PostBeginPlay();
      }
      The above code is wrong. Am I even on the right track here.

      thanks.

      Comment


        #4
        Maybe I was unclear before, let me show by example:

        Code:
        function PostBeginPlay()
        {
        	local SVehicleFactory Factory;
        	foreach AllActors( class 'SVehicleFactory', Factory )
        	{
        		if (class<ONSPRV>(Factory.VehicleClass) != None)
        		{
        			// VehicleClass is an ONSPRV or a subclass
        		}
        	}
        	
            
            Super.PostBeginPlay();
        }
        Essentially its just casting the class, not an object. Your example is trying to cast one class to another class and put the result into an object variable, which you cant do. Its like saying var Actor A = class'Actor';

        However, once youve casted the class (assuming it isnt none), you know that the factory is spawning a PRV, or a subclass of PRV, therefor you can replace it with your version. Its not exactly what you wanted to do, but its about the best solution, aside from leaving the custom vehicles alone (which is actually no solution).

        Comment


          #5
          Ah yes I get it now what your showing me. It would work but It would take away from the dept of the maps on my server. I have hellbenders and scorpions with every combinations of guns imaginable on them so to replace all of these with the default versions would certainly take away from what the authors intended. Although that could be a plus in some maps.

          [EDIT]
          I was just thinking there would it be possible to create a function in my custom hellbender class that recieves a ONSPRV as input. It would then setup it's guns based on the ONSPRV's guns that was passed to it.

          e.g. function setupWeapons(ONSPRV hb)

          and the mutator

          Code:
          function PostBeginPlay()
          {
          	local SVehicleFactory Factory;
          	local ONSPRV bender;
          	local MwMBender mwmBender;
          	foreach AllActors( class 'SVehicleFactory', Factory )
          	{
          		if (class<ONSPRV>(Factory.VehicleClass) != None)
          		{
          			bender = class<ONSPRV>(Factory.VehicleClass);
          			mwmBender.setupWeapons(bender)
          			Factory.VehicleClass = mwmBender;
          		}
          	}
          	
              
              Super.PostBeginPlay();
          }
          Thanks for the help.
          John

          Comment

          Working...
          X