Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WeaponBasePlacerPickupsManager extends Info
- placeable;
- struct PickupsRotationStruct
- {
- var() class<Weapon> WeaponClass;
- var() int Requirement;
- var() int StoredResources;
- };
- var() array< PickupsRotationStruct > PickupsRotation;
- var() array< int > Max_ISetupUses;
- var() bool bRandom;
- var array< int > SetupUsedCount;
- var int iCurrent;
- var PickupsRotationStruct NullRotationStruct;
- function PickupsRotationStruct GetRotationStruct()
- {
- local int i,j,CT,R,F,CS,MaxC; // CT = Chance Total; F = Final Random Value; CS = Current Sum;
- if (PickupsRotation.length <= 0)
- {
- log (self $ " Empty");
- return NullRotationStruct;
- }
- if (SetupUsedCount.length < PickupsRotation.length)
- SetupUsedCount.length = PickupsRotation.length;
- if (!bRandom)
- {
- i = iCurrent;
- for( j=0; j < PickupsRotation.length; i++ )
- {
- if (i >= PickupsRotation.length)
- i = 0;
- if (Max_ISetupUses.length <= i || Max_ISetupUses[i] <= 0 || Max_ISetupUses[i] > SetupUsedCount[i])
- {
- iCurrent = i + 1;
- (SetupUsedCount[i]) ++ ;
- return PickupsRotation[i];
- }
- j++;
- }
- return NullRotationStruct;
- }
- for( i=0; i < Max_ISetupUses.length; i++ )
- if (MaxC < Max_ISetupUses[i])
- MaxC = Max_ISetupUses[i];
- if (MaxC <= 0)
- MaxC = 1;
- for( i=0; i < PickupsRotation.length; i++ )
- if (Max_ISetupUses.length <= i || Max_ISetupUses[i] <= 0)
- CT += MaxC;
- else
- CT += (Max_ISetupUses[i] - SetupUsedCount[i]);
- if( CT <= 0 )
- {
- log (self $ " Chance total <= 0 ");
- return NullRotationStruct;
- }
- R = Rand(CT);
- F = CT - R;
- //log (self $ " Chance Total= " $ CT $ " Final Value= " $ F);
- for( i=0; i < PickupsRotation.length; i++ )
- {
- if (Max_ISetupUses.length <= i || Max_ISetupUses[i] <= 0)
- CS += MaxC;
- else
- CS += (Max_ISetupUses[i] - SetupUsedCount[i]);
- if(F <= CS)
- {
- (SetupUsedCount[i]) ++ ;
- return PickupsRotation[i];
- }
- }
- return NullRotationStruct;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement