UE2 - UT2kX multiweaponbase trouble with state creation

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Lord_Farin

New Member
Apr 18, 2009
5
0
0
Hello there. I am currently working on my first real mod thing, namely a MultiWeaponBase, which is capable of having multiple weapons to show (eg. Flak cannon for 5 secs, then Link Gun for 10 secs, and finally Shock Rifle for 5 secs, and then repeat).

I am struggling with defining states for every weapon, because some states will not be called (if there are only two diff. weapons selected, instead of 3, 4 or more). If this is solved, then every state can just modify the WeaponType variable from xPickupBase class, and hence hopefully display a different weapon. After doing that, they will call Sleep with the specified time and move on to the next state.

Should I just create some state check which sends it to the next state if no weapon and/or time is specified?
And, will just changing the variable WeaponType result in the desired effect, or is there some other action needed in xPickupBase as well?

Google and UnrealWiki do not really give results for this kind of problem, maybe because it is very trivial (and I am just a newb)

Thanks in advance anyway,
Lord_Farin
 
Last edited:

Kyllian

if (Driver == Bot.Pawn); bGTFO=True;
Aug 24, 2002
3,575
0
36
45.64.294
kyllian.deviantart.com
Sounds like what you're trying to pull off is a weapon version of the xWildCardBase for shield/keg/dd
No idea if it'd work but you could poke around that and see if you can change out weapons for pickups
 

Lord_Farin

New Member
Apr 18, 2009
5
0
0
Whilst searching for xWildCardBase, I found that it uses the following function:

Pickup Transmogrify( class<Pickup> NewClass )
Changes the nature of the Pickup, used in with the WildCardBase which varies the Pickup. (from http://wiki.beyondunreal.com/Legacy:Pickup#States)

Code:
// Turns the pickup into a different type of pickup - specificly used by the WildcardCharger
function Pickup Transmogrify(class<Pickup> NewClass) // de
{
    local Pickup NewPickup;

    NewPickup = Spawn(NewClass);
    NewPickup.PickupBase = PickupBase;
    NewPickup.RespawnTime = RespawnTime;

    if (MyMarker != None )
    {
        MyMarker.markedItem = NewPickup;
        NewPickup.MyMarker = MyMarker;
        MyMarker = None;
    }
    Destroy();

    return NewPickup;
}
(from http://ericdives.com/UT2004-UnCodex/Source_engine/pickup.html#101)

Could someone please post some more information on that particular function, like what arguments it specifically takes, and how to use it, but most important, how it does what it does? It seems to me that if I use it in some state function, together with Sleep, I should be able to pull it off...

At least, thanks for the help so far. It has been useful ;)
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Could someone please post some more information on that particular function, like what arguments it specifically takes, and how to use it, but most important, how it does what it does? It seems to me that if I use it in some state function, together with Sleep, I should be able to pull it off...

At least, thanks for the help so far. It has been useful ;)
How about just looking up where and how it's called by the wildcard base?
I once made a multi-pickup base for Chaos UT 2, maybe you can get some inspiration there.
I really recommend doing that.
 

Lord_Farin

New Member
Apr 18, 2009
5
0
0
I have checked all the references, and now I have come up with this compilable bunch of code:

Code:
//UT2004 multi weapon base with new staticmesh
//to automatically convert all xWeaponBases in a level to have this mesh, 
//use the editor console command "NewPickupBases"
class MultiWeaponBase extends xWeaponBase
    placeable;

var() class<Weapon> PickupClasses[8];
var() float         PickupTimes[8];
var int NumClasses;
var int CurrentClass;
var int override;

simulated function PostBeginPlay()
{
	if ( Role == ROLE_Authority )
	{
		NumClasses = 0;
		while (NumClasses < ArrayCount(PickupClasses) 
		&& PickupClasses[NumClasses] != none
                && PickupTimes[NumClasses] != 0.0 )
			NumClasses++;
		CurrentClass = 0;
		WeaponType = PickupClasses[CurrentClass];
	}
	if (WeaponType != None)
		PowerUp = WeaponType.default.PickupClass;

	Super.PostBeginPlay();
    override = 0;
    Timer();
	SetLocation(Location + vect(0,0,-1)); 
}

function Timer()
{
Begin:
    if (override != 999)
    {
        CurrentClass = override%NumClasses;
        override = 999;
    }
    else
        CurrentClass = (CurrentClass+1)%NumClasses;

    if (PickupClasses[CurrentClass] != none && PickupTimes[CurrentClass] != 0.0)
	   PowerUp = PickupClasses[CurrentClass].default.PickupClass;
	else
        goto 'Begin';

    SetTimer( PickupTimes[CurrentClass], false );

	if( myPickup != none )
		myPickup = myPickup.Transmogrify(PowerUp);
}

defaultproperties
{
	bDelayedSpawn=false
    SpiralEmitter=class'XEffects.Spiral'

    DrawScale=0.8
    DrawType=DT_StaticMesh
    StaticMesh=XGame_rc.AmmoChargerMesh
    Texture=None

    CollisionRadius=60.000000
    CollisionHeight=6.000000
}

This is my multibase atm. It is loadable, but if I put it in a map, and test that, I am spawnkilled all the time (left a small crater)... Any explanations to that? Also, still, the base does not seem to do its actual job (change)
 

Lord_Farin

New Member
Apr 18, 2009
5
0
0
Thanks for all help. By explicitly defining bStatic=false as a default, (and hitting Rebuild All) the whole MultiWeaponBase now functions correctly, and supports up to 8 different weapons. It is also possible to define the base to have no weapon for some time. Enjoy!

The package is located in the attachment, have fun!

Thanks again with the help for my first real useful UT2k4 mod, especially to Wormbo! Now that I sort of got the hang, I think I will stick around ;p
 

Attachments

  • MyEdits.rar
    1 KB · Views: 3
Last edited: