Requires Craft Spider Mines because that's what Craft Auto Turret extends.
Have a download and code below:
SillyRPG.u
http://www3.zippyshare.com/v/47398011/file.html
AbilityCraftAutoTurret.uc:
Code: Select all
class AbilityCraftAutoTurret extends AbilityCraftSpiderMines
	abstract;
static simulated function int Cost(RPGPlayerDataObject Data, int CurrentLevel)
{
    local int i;	
    if (Data.Abilities.length > 0 && class<AbilityClassMechanic>(Data.Abilities[0]) != None)
	{
	for (i = 1; i < Data.Abilities.length; i++) //[0] class
    		if (class<AbilityCraftSpiderMines>(Data.Abilities[i]) != None)
    			break;
    	if (i >= Data.Abilities.length)
    		return 0;
    	return Super(RPGAbility).Cost(Data, CurrentLevel);
	}
   Return 0;
}
static function ModifyPawn(Pawn Other, int AbilityLevel)
{
	local ArtifactCraftAutoTurret Artifact;
	local RPGStatsInv	StatsInv;
	local InvScrapMetal InvMetal;
	
	if (Other.Role < ROLE_Authority)
		return;
	if(Monster(Other) != None)
		return;
		
	InvMetal = InvScrapMetal(Other.FindInventoryType(class'InvScrapMetal'));
	
	if (InvMetal == None)
		return;  //this should not happen if you are a mechanic
		
	StatsInv = RPGStatsInv(Other.FindInventoryType(class'RPGStatsInv'));
	Artifact = ArtifactCraftAutoTurret(Other.FindInventoryType(class'ArtifactCraftAutoTurret'));
	if (Artifact != None)
	{
		if (Artifact.AbilityLevel == AbilityLevel)
			return;
	}
	else
	{
		Artifact = Other.spawn(class'ArtifactCraftAutoTurret', Other,,, rot(0,0,0));
        if (Artifact != None)
        {
    		Artifact.giveTo(Other);
    		Other.NextItem();
        }
	}
	if (Artifact != None)
	{
		Artifact.AbilityLevel = AbilityLevel;
		Artifact.InvMetal = InvMetal;
		if (StatsInv != None)
			Artifact.AmmoBonus = StatsInv.DataObject.AmmoMax;
	}
}
defaultproperties
{
     AbilityName="Craft Auto Turret"
     Description="Using spare parts of any metal, the mechanic is able to generate auto turret.|Mana cost (per level):  40, 30, 20, 10|Turrets generated: 1|Metal cost:  1|Max level:  4"
     StartingCost=4
     CostAddPerLevel=-1
     BotChance=0
     MaxLevel=4
     PackageName="SillyRPG"
     ClassFilterName="Mechanic Class"
     RequiredRanking(0)=1
     RequiredRanking(1)=1
     RequiredRanking(2)=2
     RequiredRanking(3)=2
     bGivesArtifact=True
}Code: Select all
class ArtifactCraftAutoTurret extends ArtifactCraftSpiderMines;
var class<Weapon> WeaponClass;
//// v  Yeah, I don't know how to let timer() acces those without making some additional var-s.
var xWeaponBaseSilly A;
var string TempParam;
function int GetCost()
{
	return Max(0, 50 - (10 * AbilityLevel));
}
//// It's actually unused as it is :p
function int GetAmmo()
{
	return 1;
}
function Activate()
{
	AltActivate();
}
function AltActivate(optional string Param)
{
	local float TimeDelta;
	local Vector StartTrace, EndTrace, SpawnLocation, HitNormal;
	////local xWeaponBaseSilly A;	
	////local int i;
	if (Instigator == None || InvMetal == None)
	{
		Destroy();
		return;
	}
    //Can't use this if you don't have enough adrenaline...
    if (Instigator.Controller.Adrenaline < GetCost())
    {
        Instigator.ReceiveLocalizedMessage(MessageClass, GetCost(), None, None, Class);
        bActive = false;
        GotoState('');
        return;
    }
    //Can't use this if we don't have scrap metal
    if (Param != "")
    {
		if (int(Param) > 5 || int(Param) <= 0)
		{
			Instigator.ReceiveLocalizedMessage(MessageClass, 4000, None, None, Class);
            bActive = false;
            GotoState('');
            return;
		}
		
		if (InvMetal.ScrapMetal[int(Param) - 1] <= 0)
		{
			Instigator.ReceiveLocalizedMessage(MessageClass, 1000 + int(Param), None, None, Class);
            bActive = false;
            GotoState('');
            return;
		}
	}
	else if (InvMetal.ScrapMetal[0] <= 0 && InvMetal.ScrapMetal[1] <= 0 && InvMetal.ScrapMetal[2] <= 0 && InvMetal.ScrapMetal[3] <= 0 && InvMetal.ScrapMetal[4] <= 0)
    {
        Instigator.ReceiveLocalizedMessage(MessageClass, 1000, None, None, Class);
        bActive = false;
        GotoState('');
        return;
    }
    //Check to see if we are allowed to use this again by time.
    TimeDelta = Level.TimeSeconds - LastUseTime;
    if (Level.TimeSeconds - LastUseTime < UseDelay)
    {
        Instigator.ReceiveLocalizedMessage(MessageClass, 5000 + UseDelay - TimeDelta, None, None, Class);
        bActive = false;
        GotoState('');
        return;
    }
    LastUseTime = Level.TimeSeconds;
	StartTrace = Instigator.Location;
	EndTrace = Instigator.Location + vector(Instigator.Rotation) * Instigator.GroundSpeed;
    if (Instigator.Trace(SpawnLocation, HitNormal, EndTrace, Instigator.Location) != None)
	{
		SpawnLocation -= vector(Instigator.Rotation) * 40;
//// That's where 'warzone' begins XD . Basically RPG system was stealing mah turret without me knowing about it :/
		A = spawn(Class'SillyRPG.xWeaponBaseSilly',,, SpawnLocation, Instigator.Rotation);
	}
	else
		A = spawn(Class'SillyRPG.xWeaponBaseSilly',,, EndTrace, Instigator.Rotation);
//// However our evil RPG system has no desire for WeaponBase but engine won't let me spawn it without edit (bNoDelete = false; bStatic = false;)
		
   if (A != None)
   {	
	A.WeaponType=WeaponClass;
	A.PostBeginPlay();
	////A.Destroy();
//// Turns out RPGWeaponPickup gives Pickup back to its PickupBase (here: my WeaponBase) after a lil bit, so I decided to delay accesing it, to get around that.
	TempParam=Param;
        SetTimer(1,false);
	////if (A.bSucces == true)
	/*if (A.myPickUp != None)
	{	
	  A.myPickUp.RespawnTime = 0;
	  A.myPickUp.bDropped = true;
	  A.myPickUp.RespawnEffect();
	  ////A.AmmoAmount = GetAmmo();
	  A.myPickUp.SetTimer(120, false);
	
	  //cost
          Instigator.Controller.Adrenaline -= GetCost();
          if (Instigator.Controller.Adrenaline < 0)
    	   Instigator.Controller.Adrenaline = 0;
    	
          //Remove scrap metal
          if (Param != "")
	 	  InvMetal.RemoveMetal(int(Param) - 1);
	  else
	  {
		  i = 4;
          while (InvMetal.ScrapMetal[i] <= 0 && i >= 0)
        	  i--;
    	  InvMetal.RemoveMetal(i);
	  }
	}*/
      ////A.Destroy();
     
   }
}
function Timer()
{
	local int i;
	if (A.myPickUp != None)
	{	
	  A.myPickUp.RespawnTime = 0;
	  A.myPickUp.bDropped = true;
	  A.myPickUp.RespawnEffect();
	  ////A.AmmoAmount = GetAmmo();
	  A.myPickUp.SetTimer(120, false);
	
	  //cost
          Instigator.Controller.Adrenaline -= GetCost();
          if (Instigator.Controller.Adrenaline < 0)
    	   Instigator.Controller.Adrenaline = 0;
    	
          //Remove scrap metal
          if (TempParam != "")
	 	  InvMetal.RemoveMetal(int(TempParam) - 1);
	  else
	  {
		  i = 4;
          while (InvMetal.ScrapMetal[i] <= 0 && i >= 0)
        	  i--;
    	  InvMetal.RemoveMetal(i);
	  }
	}
     
      A.Destroy();
//// Oops :|  //// Well: kill(), no reset, auto kill wherever I put them don't do the job, eh, don't care abot it anyway.    ////A.myEmitter.Destroy();
}
defaultproperties
{
     AbilityLevel=1
     UseDelay=2
     WeaponClass=Class'DWU2Weapons.AutoTurretDeploy'
     MinActivationTime=0.000001
     ActivateSound=Sound'WeaponSounds.BaseGunTech.BReload2'
     IconMaterial=Texture'ME_RPGExpansion.Icons.CraftSpiderMines'
     ItemName="Craft Auto Turret"
}Code: Select all
class xWeaponBaseSilly extends xWeaponBase;
//var bool bSucces;
// Tried to access pickup earlier here, but as I have found out later- it got 'stolen' earlier.
/*function SpawnPickup()
{
	Super(xPickUpBase).SpawnPickup();
	if (myPickUp != None)
	{	
	  myPickUp.RespawnTime = 0;
	  myPickUp.bDropped = true;
	  myPickUp.RespawnEffect();
	  //A.AmmoAmount = GetAmmo();
	  myPickUp.SetTimer(120, false);
	  bSucces = true;
	}
}*/
defaultproperties
{
	bNoDelete = false;
	bStatic = false;
	//bSucces = false;
}[/color]
