It would be an improvement if we could choose the type of spawned mage without having to stop playing (or waiting for an unknown amount of time and hoping).
One way of handling that is to make alt activate iterate through modes while making activate try finding suitable soul for the mode and spawning mage if it succeeds.
Example implementation:
7 soul selection modes:
- First soul- pick weakest soul (first on list)
- Random element- pick a soul with max amount of possible results, ask for confirmation if less than 5 possible elements, fail if only 1 element
- 5 elements(resis)- pick a soul with given element, ask for confirmation if more than 1 possible element or in last quarter of the soul list (might not want to use luci for mage :p), fail on lack of given element or presence of all elements
- No argument- next mode, search for soul and show the pick to player or ask for confirmation if needed (shows the pick + possible elements, asks to activate within n seconds to spawn)
- Element/Mode- set mode, activate
- Monster name- same as was
Code: Select all
class ArtifactSillySummonSkeletalMage extends ArtifactSummonSkeletalMage
Config(MonsterAssaultRPG);
var enum EMode
{
M_Random,
M_First,
M_Physical,
M_Ice,
M_Fire,
M_Poison,
M_Lightning
} Mode;
var int MaxPressDelay;
var int LastCancelledPressTime;
var bool bSpawnAnyways;
var bool bLastCancelled;
function Activate()
{
bSpawnAnyways = false;
if(bLastCancelled && Level.TimeSeconds - LastCancelledPressTime <= MaxPressDelay)
bSpawnAnyways = true;
bLastCancelled = false;
Super.Activate();
}
function AltActivate(optional string Param)
{
local int i;
local int iSoul;
if (InvSoul == None || Instigator == None)
{
Destroy();
return;
}
//Next mode
if (Mode < EMode.EnumCount - 1)
Mode = EMode(Mode+1);
else
Mode = EMode(0);
Instigator.ClientMessage(GetEnum(Enum'EMode', Mode));
if (Param != "")
{
//attempt to summon a monster with a soul matching this name
for (i = 0; i < InvSoul.SoulClasses.length; i++)
{
if (strcmp(InvSoul.SoulClasses[i].Default.FriendlyName, Param) != 0)
continue;
//found a soul...summon this monster using this soul
SoulIndex = i;
Activate();
SoulIndex = Default.SoulIndex; //bring back to default settings
return;
}
//check for mode param
if ( (strcmp("rand", Param) == 0) || (strcmp("random", Param) == 0) )
{Mode = M_Random; Activate(); return;}
if ( (strcmp("min", Param) == 0) || (strcmp("first", Param) == 0) )
{Mode = M_First; Activate(); return;}
if ( (strcmp("phys", Param) == 0) || (strcmp("physical", Param) == 0) )
{Mode = M_Physical; Activate(); return;}
if ( (strcmp("ice", Param) == 0) )
{Mode = M_Ice; Activate(); return;}
if ( (strcmp("fire", Param) == 0) )
{Mode = M_Fire; Activate(); return;}
if ( (strcmp("poi", Param) == 0) || (strcmp("poison", Param) == 0) )
{Mode = M_Poison; Activate(); return;}
if ( (strcmp("ene", Param) == 0) || (strcmp("lightning", Param) == 0) )
{Mode = M_Lightning; Activate(); return;}
//we did not find a matching soul or mode
Instigator.ClientMessage("Wrong param or monster: " $ Param);
return;
}
iSoul = GetSoulIndex();
if( iSoul >= 0 )
Instigator.ClientMessage("Using the " $ Default.ItemName $ " will consume the " $ InvSoul.SoulClasses[iSoul].Default.FriendlyName $ " soul.");
}
function int GetSoulIndex()
{
local int i,j;
local float BestResistance;
local array<int> BestElements;
local class<DWScriptedMonster> SelectedMonster;
local array<int> StoredBestElements;
local int iStored;
local bool bHasNeededElement;
if (Mode == M_First)
return 0;
for (i=0; i <= InvSoul.SoulClasses.length -1; i++)
{
SelectedMonster = InvSoul.SoulClasses[i];
bHasNeededElement = false;
BestElements.length = 0;
BestResistance = SelectedMonster.default.PhysicalResistance;
BestElements[0] = 0;
if (SelectedMonster.default.FireResistance == BestResistance)
BestElements[BestElements.length] = 1;
else if (SelectedMonster.default.FireResistance > BestResistance)
{
BestResistance = SelectedMonster.default.FireResistance;
BestElements.length = 0;
BestElements[0] = 1;
}
if (SelectedMonster.default.ColdResistance == BestResistance)
BestElements[BestElements.length] = 2;
else if (SelectedMonster.default.ColdResistance > BestResistance)
{
BestResistance = SelectedMonster.default.ColdResistance;
BestElements.length = 0;
BestElements[0] = 2;
}
if (SelectedMonster.default.LightningResistance == BestResistance)
BestElements[BestElements.length] = 3;
else if (SelectedMonster.default.LightningResistance > BestResistance)
{
BestResistance = SelectedMonster.default.LightningResistance;
BestElements.length = 0;
BestElements[0] = 3;
}
if (SelectedMonster.default.PoisonResistance == BestResistance)
BestElements[BestElements.length] = 4;
else if (SelectedMonster.default.PoisonResistance > BestResistance)
{
BestResistance = SelectedMonster.default.PoisonResistance;
BestElements.length = 0;
BestElements[0] = 4;
}
Switch(Mode)
{
case M_Random:
if (BestElements.length == 5)
{
return i;
}
if ( (BestElements.length > 1) && (BestElements.length > StoredBestElements.length) )
{
iStored = i;
StoredBestElements.length = 0;
for(j = 0; j < BestElements.length; j++)
{
StoredBestElements[StoredBestElements.length] = BestElements[j];
}
}
if ( (i >= int(round((InvSoul.SoulClasses.length - 1)*0.75))) && (StoredBestElements.length > 1) )
{
if(bSpawnAnyways)
return iStored;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[iStored].Default.FriendlyName$" With these elements: "$GetFriendlyElements(StoredBestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
break;
case M_Physical:
if (BestElements.length == 1 && BestElements[0] == 0)
{
if(i >= int(round((InvSoul.SoulClasses.length - 1)*0.75)))
{
if(bSpawnAnyways)
return i;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[i].Default.FriendlyName$" With these elements: "$GetFriendlyElements(BestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
return i;
}
if ( (BestElements.length < 5) &&((BestElements.length < StoredBestElements.length) || (StoredBestElements.length == 0)) )
{
for(j = 0; j < BestElements.length; j++)
{
if (BestElements[j] == 0)
bHasNeededElement = true;
}
if (bHasNeededElement)
{
iStored = i;
StoredBestElements.length = 0;
for(j = 0; j < BestElements.length; j++)
{
StoredBestElements[StoredBestElements.length] = BestElements[j];
}
}
}
if ( (i == (InvSoul.SoulClasses.length - 1)) && (StoredBestElements.length < 5) && (StoredBestElements.length > 0) )
{
if(bSpawnAnyways)
return iStored;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[iStored].Default.FriendlyName$" With these elements: "$GetFriendlyElements(StoredBestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
break;
case M_Ice:
if (BestElements.length == 1 && BestElements[0] == 2)
{
if(i >= int(round((InvSoul.SoulClasses.length - 1)*0.75)))
{
if(bSpawnAnyways)
return i;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[i].Default.FriendlyName$" With these elements: "$GetFriendlyElements(BestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
return i;
}
if ( (BestElements.length < 5) &&((BestElements.length < StoredBestElements.length) || (StoredBestElements.length == 0)) )
{
for(j = 0; j < BestElements.length; j++)
{
if (BestElements[j] == 2)
bHasNeededElement = true;
}
if (bHasNeededElement)
{
iStored = i;
StoredBestElements.length = 0;
for(j = 0; j < BestElements.length; j++)
{
StoredBestElements[StoredBestElements.length] = BestElements[j];
}
}
}
if ( (i == (InvSoul.SoulClasses.length - 1)) && (StoredBestElements.length < 5) && (StoredBestElements.length > 0) )
{
if(bSpawnAnyways)
return iStored;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[iStored].Default.FriendlyName$" With these elements: "$GetFriendlyElements(StoredBestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
break;
case M_Fire:
if (BestElements.length == 1 && BestElements[0] == 1)
{
if(i >= int(round((InvSoul.SoulClasses.length - 1)*0.75)))
{
if(bSpawnAnyways)
return i;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[i].Default.FriendlyName$" With these elements: "$GetFriendlyElements(BestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
return i;
}
if ( (BestElements.length < 5) &&((BestElements.length < StoredBestElements.length) || (StoredBestElements.length == 0)) )
{
for(j = 0; j < BestElements.length; j++)
{
if (BestElements[j] == 1)
bHasNeededElement = true;
}
if (bHasNeededElement)
{
iStored = i;
StoredBestElements.length = 0;
for(j = 0; j < BestElements.length; j++)
{
StoredBestElements[StoredBestElements.length] = BestElements[j];
}
}
}
if ( (i == (InvSoul.SoulClasses.length - 1)) && (StoredBestElements.length < 5) && (StoredBestElements.length > 0) )
{
if(bSpawnAnyways)
return iStored;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[iStored].Default.FriendlyName$" With these elements: "$GetFriendlyElements(StoredBestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
break;
case M_Poison:
if (BestElements.length == 1 && BestElements[0] == 4)
{
if(i >= int(round((InvSoul.SoulClasses.length - 1)*0.75)))
{
if(bSpawnAnyways)
return i;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[i].Default.FriendlyName$" With these elements: "$GetFriendlyElements(BestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
return i;
}
if ( (BestElements.length < 5) &&((BestElements.length < StoredBestElements.length) || (StoredBestElements.length == 0)) )
{
for(j = 0; j < BestElements.length; j++)
{
if (BestElements[j] == 4)
bHasNeededElement = true;
}
if (bHasNeededElement)
{
iStored = i;
StoredBestElements.length = 0;
for(j = 0; j < BestElements.length; j++)
{
StoredBestElements[StoredBestElements.length] = BestElements[j];
}
}
}
if ( (i == (InvSoul.SoulClasses.length - 1)) && (StoredBestElements.length < 5) && (StoredBestElements.length > 0) )
{
if(bSpawnAnyways)
return iStored;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[iStored].Default.FriendlyName$" With these elements: "$GetFriendlyElements(StoredBestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
break;
case M_Lightning:
if (BestElements.length == 1 && BestElements[0] == 3)
{
if(i >= int(round((InvSoul.SoulClasses.length - 1)*0.75)))
{
if(bSpawnAnyways)
return i;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[i].Default.FriendlyName$" With these elements: "$GetFriendlyElements(BestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
return i;
}
if ( (BestElements.length < 5) &&((BestElements.length < StoredBestElements.length) || (StoredBestElements.length == 0)) )
{
for(j = 0; j < BestElements.length; j++)
{
if (BestElements[j] == 3)
bHasNeededElement = true;
}
if (bHasNeededElement)
{
iStored = i;
StoredBestElements.length = 0;
for(j = 0; j < BestElements.length; j++)
{
StoredBestElements[StoredBestElements.length] = BestElements[j];
}
}
}
if ( (i == (InvSoul.SoulClasses.length - 1)) && (StoredBestElements.length < 5) && (StoredBestElements.length > 0) )
{
if(bSpawnAnyways)
return iStored;
Instigator.ClientMessage("Best soul found: "$InvSoul.SoulClasses[iStored].Default.FriendlyName$" With these elements: "$GetFriendlyElements(StoredBestElements));
Instigator.ClientMessage("Activate within "$MaxPressDelay$" seconds to spawn anyways.");
LastUseTime = -1;
bLastCancelled = true;
LastCancelledPressTime = Level.TimeSeconds;
return -1;
}
break;
}
}
//fail
Instigator.ClientMessage("No proper soul found or error");
return -1;
}
function string GetFriendlyElements(array<int> Elements)
{
local string ToReturn;
local int i;
ToReturn = "";
for (i=0; i < Elements.length; i++)
{
Switch(Elements[i])
{
case 0: ToReturn @= "Physical"; break;
case 1: ToReturn @= "Fire"; break;
case 2: ToReturn @= "Ice"; break;
case 3: ToReturn @= "Lightning"; break;
case 4: ToReturn @= "Poison"; break;
}
}
return ToReturn;
}
function class<DWScriptedMonster> GetMonsterclass(int MonsterIndex)
{
if(MonsterIndex < 0)
return None;
return Super.GetMonsterclass(MonsterIndex);
}
defaultproperties
{
ItemName="Silly Summon Skeletal Mage"
MaxPressDelay=2
Mode = M_First
}