I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

Legacy:Dma/Developer Journal

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

During school assignments, I have been working on several projects.

  • dma/JetPack - This will someday be a jet pack that works flawlessly in network play.
  • dma/MutMultiJump - This lets the server admin set the number of multijumps to allow.
  • More to come if I get the time.

If you want to find the superclass of a class at runtime, you can try this:

static final function class FindSuperClass(class C) {
    local State obj;
    local Class X;
    local array< class > SuperClasses;
    local Class BestClass< SEMI >
    local int i;
 
    foreach C.AllObjects(class'State', obj) {
        X = Class(obj);
        if ((X != None) && (X != C) && ClassIsChildOf(C, X)) {
            SuperClasses[SuperClasses.Length] = X;
        }
    }
    BestClass = class'Object';
 
    for (i=0; i<SuperClasses.Length; i++) {
        if (ClassIsChildOf(SuperClasses[i], BestClass)) {
            BestClass = SuperClasses[i];
        }
    }
 
    return BestClass< SEMI >
}

Foxpaw: I'm curious, why does the first loop only look for things that are subclasses of "state?"

Dma: Because class'Class' results in a compiler error and Class is derived from State. This speeds it up a bit. The compiler does some special junk on the second argument of AllObjects which doesn't like class'Class' as a first argument. It does NOT use Object like the prototype says.

Foxpaw: Hmm, that's interesting. Where is the class file for class? Or for state? And then why does the engine report class variables as a "classproperty" (a primitive) instead of an "objectproperty," (a reference/pointer) if Class is indeed a class itself? I'm interested to learn more about this arrangement.

Dma: In Unrealed, you'll find it in the class browser if you turn off "actor classes only", etc. There is NO script source for these. You might be able to learn more by using the EDITOBJ console command in the game or editor.