Jump to content

lamaros

Members
  • Posts

    28
  • Joined

  • Last visited

Nexus Mods Profile

About lamaros

lamaros's Achievements

Apprentice

Apprentice (3/14)

  • First Post
  • Collaborator
  • Conversation Starter
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. So, under the X2Character Template we have, function XComGameState_Unit CreateInstanceFromTemplate(XComGameState NewGameState) { local XComGameState_Unit Unit; Unit = XComGameState_Unit(NewGameState.CreateStateObject(class'XComGameState_Unit')); Unit.OnCreation(self); return Unit; } Is this of any relevance? I wish I knew what I was doing... And this this tracks back to XComAISpawnManager? private event XComGameState_Unit CreateUnitInternal( Vector Position, X2CharacterTemplate CharacterTemplate, ETeam Team, XComGameState NewGameState, bool bRollForLoot, bool PerformAIUpdate, XComGameState_Unit ReanimatedFromUnit, optional string CharacerPoolName ) { local XComGameStateHistory History; local XComGameState_Unit UnitState; local XComGameState_Player PlayerState; local bool bUsingStartState, bFoundExistingPlayerState; local TTile UnitTile; History = `XCOMHISTORY; bUsingStartState = (NewGameState == History.GetStartState()); // find the player matching the requested team ID... foreach History.IterateByClassType(class'XComGameState_Player', PlayerState) { if( PlayerState.GetTeam() == Team ) { bFoundExistingPlayerState = true; break; } } // ... or create one if it does not yet exist if( !bFoundExistingPlayerState ) { PlayerState = class'XComGameState_Player'.static.CreatePlayer(NewGameState, Team); NewGameState.AddStateObject(PlayerState); } // create the unit UnitTile = `XWORLD.GetTileCoordinatesFromPosition(Position); UnitState = CharacterTemplate.CreateInstanceFromTemplate(NewGameState); UnitState.PostCreateInit(NewGameState, CharacterTemplate, PlayerState.ObjectID, UnitTile, Team == eTeam_Alien, bUsingStartState, PerformAIUpdate, ReanimatedFromUnit, CharacerPoolName); // Auto loot UnitState.bAutoLootEnabled = bRollForLoot; //// Timed Loot //if( bRollForTimedLoot ) //{ // UnitState.RollForTimedLoot(); //} if( !CharacterTemplate.bIsCosmetic && `PRES.m_kUnitFlagManager != none ) { `PRES.m_kUnitFlagManager.AddFlag(UnitState.GetReference()); } return UnitState; } Not sure what X2StrategyGame_SimCombat does, but doesn't seem as relevant?
  2. Ok, so I've hit a wall with this. My current understanding is not up to solving, so I'll have to learn more and return to it in the future. For others who might be interested here is what we (almost all EladDv's code) have at the moment, stripped back to try and debug. Here is XComGameState_NCE.uc class XComGameState_NCE extends Object Config(NCE); //-----NCE Vars----- var int vfiLength; var int points; //-----Config Vars Enemy----- var config bool bIs_EnemyNCE_Activated; var config int EnemyHP_randNCE; var config int EnemyHP_cost; var config int EnemyArmorMitigation_randNCE; var config int EnemyArmorMitigation_cost; var config int EnemyTotalPoints; var config int EnemyTolerance; //-----NCE Enemy Units----- function RandomEnemyStats(XComGameState_Unit Unit) { local array<ECharStatType> statGroup; local int Costs[2]; local int ValuesFromINI[2]; local int BaseEnemyValues[2]; local int vfiLength; local int points; local bool PointCheck; local int j,Count; local int currentStat; local array<int> RandomStats; local int testing; local int testing2; local int testing3; testing = Unit.GetMyTemplate().CharacterBaseStats[eStat_HP]; testing2 = Unit.getCurrentStat(eStat_HP); testing3 = Unit.getBaseStat(eStat_HP); statGroup.AddItem(eStat_HP); statGroup.AddItem(eStat_ArmorMitigation); `log("Has Vanilla Stats? " @HasVanillaStats(Unit)); if(bIs_EnemyNCE_Activated&&HasVanillaStats(Unit)) { `log("NCE Enemy Activated"); `log("HP template at start " @testing); `log("HP current stat at start " @testing2); `log("HP base stat at start " @testing3); Costs[0]=EnemyHP_cost; Costs[1]=EnemyArmorMitigation_cost; ValuesFromINI[0]=EnemyHP_randNCE; ValuesFromINI[1]=EnemyArmorMitigation_randNCE; BaseEnemyValues[0]=Unit.getCurrentStat(eStat_HP)-(ValuesFromINI[0]/2); BaseEnemyValues[1]=Unit.getCurrentStat(eStat_ArmorMitigation); vfiLength=2; do { points=EnemyTotalPoints; PointCheck=true; for(j=0;j<vfiLength;j=j+1) { currentStat=(Rand((ABS(ValuesFromINI[j]))+1)); points-=(currentStat*Costs[j]); RandomStats.addItem(BaseEnemyValues[j]+currentStat); } if(ABS(points)>=EnemyTolerance&&Count<75) { RandomStats.remove(0,RandomStats.Length); PointCheck=false; Count++; } else if(Count>75) { `log("too much counting"); } } Until(PointCheck==true); for (j=0;j<vfiLength;j=j+1) { Unit.setBaseMaxStat(statGroup[j],RandomStats[j]); Unit.setCurrentStat(statGroup[j],RandomStats[j]); } Unit.setBaseMaxStat(eStat_ArmorChance,100.00f); Unit.setCurrentStat(eStat_ArmorChance,100.00f); testing = Unit.GetMyTemplate().CharacterBaseStats[eStat_HP]; testing2 = Unit.getCurrentStat(eStat_HP); testing3 = Unit.getBaseStat(eStat_HP); `log("HP template stat at end " @testing); `log("HP current stat at end " @testing2); `log("HP base stat at end " @testing3); `log("Enemy Stats Reported"); } else if (!(bIs_EnemyNCE_Activated&&HasVanillaStats(Unit))) { `log("NCE Enemy Not Active"); `log("HP template stat not active at " @testing); `log("HP current stat not active at " @testing2); `log("HP base stat not active at " @testing3); } } //-----Support Functions----- function array<ECharStatType>GetStats() { local array<ECharStatType> ToRet; ToRet.AddItem(eStat_HP); ToRet.AddItem(eStat_ArmorMitigation); return ToRet; } function bool HasVanillaStats(XComGameState_Unit Unit) { local int tempStat; local int baseStat; local int i; local int count; local array<ECharStatType> Stats; count = 0; Stats = GetStats(); tempStat = Unit.GetMyTemplate().CharacterBaseStats[Stats[i]]; baseStat = Unit.getBaseStat(Stats[i]); for(i=0;i<Stats.length;i++) { if(tempStat==baseStat) { count++; } } if (count>1) return true; else return false; } Here is XComNCE.ini ;Not Created Equal Configuration ;--------------------------------------- [ExtendedFights.XComGameState_NCE] ;-----Enemy Configuration----- bIs_EnemyNCE_Activated=True; Is Not Created Equally Active? ;Randomise Negative and Positive, values are the total range EnemyHP_randNCE=2 EnemyHP_cost=10 ;Randomise Positive Only, values are the total range EnemyArmorMitigation_randNCE=1 EnemyArmorMitigation_cost=20 EnemyTotalPoints=20 ; Total Points allocated to stats. EnemyTolerance=0 And here is where it's trying to hook in with UIAvengerHUD_Listener_NCE.uc class UIAvengerHUD_Listener_NCE extends UIScreenListener Config(NCE); // Set this value in the defaultproperties to filter UI signals based on class var class<UIScreen> ScreenClass; event OnInit(UIScreen Screen) { local Object ThisObj; ThisObj=self; `XEVENTMGR.RegisterForEvent(ThisObj, 'OnUnitBeginPlay', Epigenetics); } function EventListenerReturn Epigenetics(Object EventData, Object EventSource, XComGameState GameState, Name EventID) { local XComGameState_NCE Randomiser; Randomiser= new class 'XComGameState_NCE'; `log("NCE Enemy Start"); if(XComGameState_Unit(EventSource).GetTeam() == eTeam_Alien) { `log("Trying to randomise enemy unit"); Randomiser.RandomEnemyStats(XComGameState_Unit(EventSource)); } return ELR_NoInterrupt; } defaultproperties { // Leaving this assigned to none will cause every screen to trigger its signals on this class ScreenClass = UIAvengerHUD; } And here is what the debug log is saying: http://imgur.com/a/YegYx (that the base stats and current stats have been changed) Yet despite this all enemy units have default stats.
  3. Worked out the issue, nothing to see here.
  4. I've been poking about your code ElaDdv. Have you used a different way to get the random stats for enemies function to run than you did for the soldier stats? Under the Downloadablecontent info you're still only going with: foreach `XCOMHISTORY.IterateByClassType(class'XComGameState_Unit', Unit ) { `log("Mod Foreach"); SecondWaveObject.RandomStats(Unit); } It's just brought in by the UIAvengerHUD_Listener? function EventListenerReturn Epigenetics(Object EventData, Object EventSource, XComGameState GameState, Name EventID) { local XComGameState_SecondWave Randomiser; Randomiser= new class 'XComGameState_SecondWave'; if(XComGameState_Unit(EventSource).GetTeam() == eTeam_Alien) { `log("An Enemy Unit was NCEd"); Randomiser.RandomEnemyStats(XComGameState_Unit(EventSource)); } return ELR_NoInterrupt; }
  5. Good work, I think I mostly follow. I'm stuck on working out how to ask XComGameState_Unit what the unit type/name is for if i wanted to alter this to modify different ones in custom ways, though. Going to run myself through some java lessons so I get a better understanding of how the OOP bit work.
  6. Hi all, Just a thread where people can share general ideas they've had for mods for the interest of others. Please share your ideas here if you're happy with others using them or whatever! ----- I had an idea of a way of handling fatigue in the game the other day which is far beyond my ability at the moment (heopfully I'll get better quick enough), but which I'd love to someone explore if they care to. Mission Fatigue Clock My altered concept of this Long War feature. There's a fatigue counter alongside the injured/fit counter. Every mission a unit goes on grants them a fatigue tick, and every mission they don't go on clears two ticks. if it is ever 3(?) or above the soldier is forced to sit out/treated as injured. Ie: Goes on Mission - Clock goes up one, to 'Tired(1)'Goes on Mission - Clock goes up one, still 'Tired(2)'Goes on Mission - Clock goes up one, to 'Exhausted'Forced to Skip Mission - Clock drops two, to 'Tired(1)'Goes on Mission - Clock goes up one, still 'Tired(2)'Skips Mission (either optional or because injured) - Clock drops two, to normal. Military Assassination - New Council Mission Type Only allowed to take reduced troops (2-3ish). Target is an enemy unit with extra health/armor that just has to be killed. Evac is same as point you drop in. Can buy intel boosts ala second last story mission - ideas being to remove timer, grant cover, grant extra unit, blah blah.
  7. Back in a different direction, on structs. If I understand this correctly you use this to create a single array, with each entry in the array having three variables. How do I populate this array though? By making these variables arrays, in effect just using the struct to bring them together into a single array? Is there any good guide to unreal script anywhere? I feel like I'm missing so many basic concepts that I'm hitting the wall too often... struct RandomChange { var array<UnitName> Target; var array<UnitStat> StatType; var array<UnitRandAmount> Amount; } var array<RandomChange> RandomChanges;
  8. Hmm, so I'm obviously missing something. Soldiers are not units in the same way Advent Troopers are? How come, function RandomStats(XComGameState_Unit Soldier) {Soldier.setBaseMaxStat(eStat_HP,randomVariable)} seems to work, but function RandomStats(XComGameState_Unit AdvTrooperM1) {AdvTrooperM1.setBaseMaxStat(eStat_HP,randomVariable)} doesn't? I'm know I'm missing something here, but struggling to parse everything. Also, going back to an earlier point, class SomethingThatGetsStats extends object; string function getBaseMaxStat(string something) { return "here you go"; } local SomethingThatGetsStats getEnemyRandomNCE; This gives the string SomethingThatGetsStats the function getBaseMaxStat, for with the string variable something? So I want to use the function setBaseMaxStat to set the eStat_HP for Solder. Writing this out it works to say, Soldier.setBaseMaxStat(eStat_HP,8)} From my experience it seems that if I have this code, function RandomStats(XComGameState_Unit Soldier) {Soldier.setBaseMaxStat(eStat_HP,8)} It will set soldier health to 8. But, if I want to break that down in to variables, local string UnitRandomType local string UnitRandomStatType local int UnitRandomStatValue and then vary the setBaseMaxStat function based on those variables, I'd go somewhere like? string function getBaseMaxStat(UnitRandomStatType,UnitRandomStatValue) { return "here you go"; } Hmm that doesn't seem right. I've lost myself here..
  9. Can I do something like: function RandomEnemyStats(XComGameState_Unit Unit) { if( (CharTemplate.CharacterGroupName == 'AdvTrooperM1') && (CharTemplate.CharacterStats.Type == 'eStat_HP') { Unit.SetBaseMaxStat( eStat_HP, blah blah) } } Nevermind! :blush:
  10. So, logically speaking, I have to: a) check the unit being created, and the stat being set b) check that against my config arrays to see if that combination is included there c) if so then if check how much to modify the template base stat by when setting it d) then set the stats, and move onwards. Does that seem correct?
  11. I do have a long way to go, that's true :), but a lot further along that yesterday when I was literally clueless. Thanks for the pointers. The variable names were just thrown in there for five seconds to see if it did anything, not a naming convention i'm going for.Yeah, didn't want to do that either, was just seeing if it did anything.I'm not entirely sure what you mean by 'type'. Ok, so what I'm looking at is... function OnCreation(X2CharacterTemplate CharTemplate) { local int i; local ECharStatType StatType; m_CharTemplate = CharTemplate; m_TemplateName = CharTemplate.DataName; UnitSize = CharTemplate.UnitSize; UnitHeight = CharTemplate.UnitHeight; for (i = 0; i < eStat_MAX; ++i) { StatType = ECharStatType(i); CharacterStats[i].Type = StatType; SetBaseMaxStat( StatType, CharTemplate.CharacterBaseStats[i] ); SetCurrentStat( StatType, GetMaxStat(StatType) ); }Which seems more the right track?
  12. EladDv's method might be better in the end, but I'm going to see where i get with this. My current knowledge problem is how to use the entries in the array to get the units estats. How do I take two values like follows: EnemyRandomNCE[0]=AdvTrooperM1 EnemyStatRandom[0]=eStat_HP And convert that to code that will effectively ask AdvTrooperM1.getBaseMaxStat(eStat_HP) I've tried a few ways, converting to strings and whatnot, but I'm a bit too beginner for it it seems. My awful code, to see where I'm going wrong.: INI EnemyRandomNCE[0]=AdvTrooperM1 EnemyRandomStatNCE[0]=eStat_HP StatRandomAmountNCE[0]=1 Class var config array<int> EnemyRandomNCE; var config array<int> EnemyRandomStatNCE; var config array<int> StatRandomAmountNCE; //random enemy test function RandomEnemyStats(XComGameState_Unit Unit) { local array<int> RandomStats; local int n; local int currentStat; local bool endThis; local string getEnemyRandomNCE; local string getEnemyRandomStatNCE; do { endThis=false; getEnemyRandomNCE=string(EnemyRandomNCE[n]); getEnemyRandomStatNCE=string(EnemyRandomStatNCE[n]); for(n=0;n<10;n=n++) { currentStat=(Rand((ABS(StatRandomAmountNCE[n]))+1)); RandomStats.addItem((getEnemyRandomNCE.getBaseMaxStat(getEnemyRandomStatNCE))+currentStat); } getEnemyRandomNCE.setBaseMaxStat(getEnemyRandomStatNCE,RandomStats[n]); endThis=false; } Until(endThis==true); }
  13. My thinking now on the best way to do this is to have the enemy you want modified, the stat you want modified, and how you want it modified, in three arrays. EnemyRandom[0]=AdvTrooperM1 EnemyStatRandom[0]=eStat_HP StatRandomAmount[0]=1 EnemyRandom[1]=AdvTrooperM2 EnemyStatRandom[1]=eStat_HP StatRandomAmount[1]=2 ... 2. Then update those values in the XComGameState_Unit? So your final output is currentStat=(Rand(StatRandomAmount[n]+1)); RandomStats.addItem(EnemyRandom[n].getBaseMaxStat(EnemyStatRandom[n])+currentStat) EnemyRandom[n].setBaseMaxStat(EnemyStatRandom[n],RandomStats[n]); EnemyRandom[n].setCurrentMaxStat(EnemyStatRandom[n],RandomStats[n]); until the end of the array? Does that make sense logically? Obviosuly the code itself would be.. not this.
  14. Anyone know anything more about eStat_CombatSims?
×
×
  • Create New...