Jump to content

Class mismatch


kagato1980

Recommended Posts

Not sure if this is the right place to post, but here goes.

 

I want to alter multiple functions, but to extends them all is a lot of copy pasting..thought I could just extend them but replace the contents with their parent counterpart, and then modifiy that value.

 

Example:

static function X2DataTemplate CreateSuperiorFreeFireUpgrade()
{
	local X2WeaponUpgradeTemplate Template;

	`CREATE_X2TEMPLATE(class'X2WeaponUpgradeTemplate', Template, 'FreeFireUpgrade_Sup');

	SetUpFreeFireBonusUpgrade(Template);
	SetUpTier3Upgrade(Template);

	Template.strImage = "img:///UILibrary_StrategyImages.X2InventoryIcons.MagSniper_TriggerB_inv";
	Template.FreeFireChance = default.FREE_FIRE_SUP;
	
	return Template;
}

becomes

static function X2DataTemplate CreateSuperiorFreeFireUpgrade()
{
	local X2DataTemplate Template;

	Template = super.CreateSuperiorFreeFireUpgrade();
	Template.FreeFireChance *= 2;
	
	return Template;
}

Oddly enough, this throws 'Error, Unrecognized member 'FreeFireChance' in class 'X2DataTemplate', which is the same type the original function is returning. Changing it to other types like X2WeaponUpgradeTemplate results in a type mismatch. Any ideas? Is my way of calling the parent function incorrect?

 

Edit: For what I'm trying to achieve here, it's probably easier to directly manipulate the .ini values, but for learning sake it would be nice to have this working

Edited by kagato1980
Link to comment
Share on other sites

Ok, I solved it myself with a other approach; just overriding the config values in the function that sets up the templates:

class DefaultUpgradesItem extends X2Item_DefaultUpgrades;

static function array<X2DataTemplate> CreateTemplates()
{
	local array<X2DataTemplate> Items;

	//Override config values
	default.CRIT_UPGRADE_BSC=10;
	default.CRIT_UPGRADE_ADV=20;
	default.CRIT_UPGRADE_SUP=30;

	default.FREE_FIRE_BSC = 10;
	default.FREE_FIRE_ADV = 20;
	default.FREE_FIRE_SUP = 30;

	default.FREE_KILL_BSC = 10;
	default.FREE_KILL_ADV = 20;
	default.FREE_KILL_SUP = 30;

	default.AIM_UPGRADE_BSC=10;
	default.AIM_UPGRADE_ADV=20;
	default.AIM_UPGRADE_SUP=30;

	Items.AddItem(CreateBasicCritUpgrade());
	Items.AddItem(CreateAdvancedCritUpgrade());
	Items.AddItem(CreateSuperiorCritUpgrade());
	
	Items.AddItem(CreateBasicAimUpgrade());
	Items.AddItem(CreateAdvancedAimUpgrade());
	Items.AddItem(CreateSuperiorAimUpgrade());
	
	Items.AddItem(CreateBasicClipSizeUpgrade());
	Items.AddItem(CreateAdvancedClipSizeUpgrade());
	Items.AddItem(CreateSuperiorClipSizeUpgrade());
	
	Items.AddItem(CreateBasicFreeFireUpgrade());
	Items.AddItem(CreateAdvancedFreeFireUpgrade());
	Items.AddItem(CreateSuperiorFreeFireUpgrade());
	
	Items.AddItem(CreateBasicReloadUpgrade());
	Items.AddItem(CreateAdvancedReloadUpgrade());
	Items.AddItem(CreateSuperiorReloadUpgrade());
	
	Items.AddItem(CreateBasicMissDamageUpgrade());
	Items.AddItem(CreateAdvancedMissDamageUpgrade());
	Items.AddItem(CreateSuperiorMissDamageUpgrade());

	Items.AddItem(CreateBasicFreeKillUpgrade());
	Items.AddItem(CreateAdvancedFreeKillUpgrade());
	Items.AddItem(CreateSuperiorFreeKillUpgrade());
	
	return Items;
}

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...