KF2-Server-Extension/ServerExt/Classes/Ext_TraitZED_Summon.uc

186 lines
5.3 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class Ext_TraitZED_Summon extends Ext_TraitZEDBase
abstract;
struct FZEDTypes
{
var() array< class<KFPawn_Monster> > Zeds;
};
var() array<FZEDTypes> DefZedTypes;
var config array<string> ZedTypes;
var config float ZedRespawnTime;
var config int FinalLevelPrestige;
static function string GetPerkDescription()
{
local string S;
S = Super.GetPerkDescription();
2020-11-28 20:12:58 +00:00
if (Default.FinalLevelPrestige>0)
2017-10-20 02:00:49 +00:00
S $= "|Level 6 requires prestige level: #{FF4000}"$Default.FinalLevelPrestige;
return S;
}
static function CheckConfig()
{
local byte i,j;
2020-11-28 20:12:58 +00:00
if (Default.ZedTypes.Length==0)
2017-10-20 02:00:49 +00:00
{
Default.ZedTypes.Length = Default.DefZedTypes.Length;
2020-11-28 20:12:58 +00:00
for (i=0; i<Default.ZedTypes.Length; ++i)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
for (j=0; j<Default.DefZedTypes[i].Zeds.Length; ++j)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (j==0)
2017-10-20 02:00:49 +00:00
Default.ZedTypes[i] = PathName(Default.DefZedTypes[i].Zeds[j]);
else Default.ZedTypes[i] $= ","$PathName(Default.DefZedTypes[i].Zeds[j]);
}
}
Default.ZedRespawnTime = 60.f;
Default.FinalLevelPrestige = 3;
StaticSaveConfig();
}
2020-11-28 20:12:58 +00:00
else if (Default.ZedTypes.Length==5) // Upgrade config from old version.
2017-10-20 02:00:49 +00:00
{
Default.ZedTypes.Length = Default.DefZedTypes.Length;
2020-11-28 20:12:58 +00:00
for (i=5; i<Default.ZedTypes.Length; ++i)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
for (j=0; j<Default.DefZedTypes[i].Zeds.Length; ++j)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (j==0)
2017-10-20 02:00:49 +00:00
Default.ZedTypes[i] = PathName(Default.DefZedTypes[i].Zeds[j]);
else Default.ZedTypes[i] $= ","$PathName(Default.DefZedTypes[i].Zeds[j]);
}
}
2020-11-28 20:12:58 +00:00
if (Default.LevelCosts.Length==5)
2017-10-20 02:00:49 +00:00
Default.LevelCosts.AddItem(Default.DefLevelCosts[5]);
Default.FinalLevelPrestige = 3;
StaticSaveConfig();
}
2020-11-28 20:12:58 +00:00
if (Default.ZedRespawnTime==0)
2017-10-20 02:00:49 +00:00
{
Default.ZedRespawnTime = 60.f;
StaticSaveConfig();
}
Super.CheckConfig();
class'Ext_T_ZEDHelper'.Static.LoadMonsterList();
}
2020-11-28 20:04:55 +00:00
static function bool MeetsRequirements(byte Lvl, Ext_PerkBase Perk)
2017-10-20 02:00:49 +00:00
{
local int i;
// First check level.
2020-11-28 20:12:58 +00:00
if (Perk.CurrentLevel<Default.MinLevel || (Lvl>=5 && Perk.CurrentPrestige<Default.FinalLevelPrestige))
2017-10-20 02:00:49 +00:00
return false;
// Then check base trait.
2020-11-28 20:12:58 +00:00
if (Lvl==0 && Default.BaseTrait!=None)
2017-10-20 02:00:49 +00:00
{
i = Perk.PerkStats.Find('StatType','Damage');
2020-11-28 20:12:58 +00:00
if (i>=0)
2017-10-20 02:00:49 +00:00
return (Perk.PerkStats[i].CurrentValue>=30);
}
return true;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
static function ApplyEffectOn(KFPawn_Human Player, Ext_PerkBase Perk, byte Level, optional Ext_TraitDataStore Data)
2017-10-20 02:00:49 +00:00
{
local Ext_T_ZEDHelper H;
local int i;
H = Player.Spawn(class'Ext_T_ZEDHelper',Player);
2020-11-28 20:12:58 +00:00
if (H!=None)
2017-10-20 02:00:49 +00:00
H.CurLevel = Level-1;
// Make other traits refresh (apply HP/damage scalers).
2020-11-28 20:12:58 +00:00
for (i=0; i<Perk.PerkTraits.Length; ++i)
if (Perk.PerkTraits[i].CurrentLevel>0 && Class<Ext_TraitZEDBase>(Perk.PerkTraits[i].TraitType)!=None && !Class<Ext_TraitZEDBase>(Perk.PerkTraits[i].TraitType).Default.bIsSummoner)
2017-10-20 02:00:49 +00:00
Perk.PerkTraits[i].TraitType.Static.ApplyEffectOn(Player,Perk,Level,Data);
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
static function CancelEffectOn(KFPawn_Human Player, Ext_PerkBase Perk, byte Level, optional Ext_TraitDataStore Data)
2017-10-20 02:00:49 +00:00
{
local Ext_T_ZEDHelper H;
foreach Player.ChildActors(class'Ext_T_ZEDHelper',H)
2020-11-28 20:12:58 +00:00
if (!H.bIsExtra)
2017-10-20 02:00:49 +00:00
H.Destroy();
}
// Replication for final level prestige.
static function string GetRepData()
{
local string S;
S = Super.GetRepData();
S $= IntToStr(Default.FinalLevelPrestige);
return S;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
static function string ClientSetRepData(string S)
2017-10-20 02:00:49 +00:00
{
S = Super.ClientSetRepData(S);
Default.FinalLevelPrestige = StrToInt(S);
return S;
}
2020-11-28 20:04:55 +00:00
static function string GetValue(name PropName, int ElementIndex)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
switch (PropName)
2017-10-20 02:00:49 +00:00
{
case 'ZedTypes':
return (ElementIndex==-1 ? string(Default.ZedTypes.Length) : Default.ZedTypes[ElementIndex]);
case 'ZedRespawnTime':
return string(Default.ZedRespawnTime);
case 'FinalLevelPrestige':
return string(Default.FinalLevelPrestige);
default:
return Super.GetValue(PropName,ElementIndex);
}
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
static function ApplyValue(name PropName, int ElementIndex, string Value)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
switch (PropName)
2017-10-20 02:00:49 +00:00
{
case 'ZedTypes':
2020-11-28 20:12:58 +00:00
if (Value!="#DELETE" && ElementIndex<Default.ZedTypes.Length)
2017-10-20 02:00:49 +00:00
Default.ZedTypes[ElementIndex] = Value;
break;
case 'ZedRespawnTime':
Default.ZedRespawnTime = float(Value);
break;
case 'FinalLevelPrestige':
Default.FinalLevelPrestige = int(Value);
break;
default:
Super.ApplyValue(PropName,ElementIndex,Value);
return;
}
StaticSaveConfig();
}
defaultproperties
{
bIsSummoner=true
NumLevels=6
DefLevelCosts(0)=20
DefLevelCosts(1)=10
DefLevelCosts(2)=10
DefLevelCosts(3)=20
DefLevelCosts(4)=30
DefLevelCosts(5)=100
DefMinLevel=20
DefZedTypes.Add((Zeds=(Class'KFPawn_ZedClot_Alpha',Class'KFPawn_ZedClot_Slasher',Class'KFPawn_ZedClot_Cyst',Class'KFPawn_ZedCrawler')))
DefZedTypes.Add((Zeds=(Class'KFPawn_ZedClot_Slasher',Class'KFPawn_ZedGorefast',Class'KFPawn_ZedStalker')))
DefZedTypes.Add((Zeds=(Class'KFPawn_ZedBloat',Class'KFPawn_ZedStalker',Class'KFPawn_ZedGorefast')))
DefZedTypes.Add((Zeds=(Class'KFPawn_ZedHusk',Class'KFPawn_ZedSirenX',Class'KFPawn_ZedScrake')))
DefZedTypes.Add((Zeds=(Class'KFPawn_ZedSirenX',Class'KFPawn_ZedFleshpound',Class'KFPawn_ZedScrake')))
DefZedTypes.Add((Zeds=(Class'ExtPawn_ZedHans_Pet')))
2017-10-20 02:00:49 +00:00
WebConfigs.Add((PropType=2,PropName="ZedTypes",UIName="Zed Types",UIDesc="Type of zeds each level can spawn (separate types with a comma)",NumElements=-1))
WebConfigs.Add((PropType=0,PropName="ZedRespawnTime",UIName="Zed RespawnTime",UIDesc="Time in seconds it takes for zeds to respawn"))
WebConfigs.Add((PropType=0,PropName="FinalLevelPrestige",UIName="Final Level Prestige",UIDesc="Prestige level required for this perks final level"))
}