Modding Questions - Finding existing Heroes

A forum to discuss custom scenarios, campaigns and modding in general.

Moderator: Panzer Corps 2 Moderators

Post Reply
rubycando
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Tue Feb 09, 2021 3:55 pm

Modding Questions - Finding existing Heroes

Post by rubycando »

Straight to the point, I'm interested in a few things:

Q1: Where does the game store the heroes while playing?
Obs: It's lua so it's a table, but ... what's the name of it? To what "super structure" does it belong to (ex.: Player , world, etc)? Is there a difference between how this gets stored in scenarios and campaigns?

Q2: Is the hero storage structure addressable via any functions or methods?
Obs: Similar to GetUnit() or GetPlayer(). We know NewHero() exists and, vaguely, what it does but what is a full list of a hero entity properties? We know of .extra_traits, and .modifiers but is there more we could work with? Can i extend it (see next question)?

We know of theese:
.portrait
.name
.extra_traits
.unit_classes
.hero.modifiers
.attack_modifiers
.defense_modifiers

What else is there please?

Q3: If i choose to make hero assignment to a unit meaningful (popup announcing 1000 xp points later the hero gets UnitClass.X trait) do I have to rely on AssignHeroAction trigger?
Obs: Could I extend the "hero structure" with an additional property, a bool perhaps to enable or disable permanently this upgrade, but ... i need at the very least to be able to check the relationship hero - unit. Is it the hero's unit or the unit's hero? How are they linked ?

Am I even allowed to do this (hehe)?

Thank you for reading this, hopefully someone might have an answer.
Kerensky
Content Designer
Content Designer
Posts: 8624
Joined: Wed Jan 12, 2011 2:12 am

Re: Modding Questions - Finding existing Heroes

Post by Kerensky »

Upcoming 1941 DLC has some very complex scripts related to detecting an existing hero to run other scripts based on if Adolf Galland is present in your CORE.

It's far too complex for my understanding, but maybe when that script becomes available, it might be able to answer your questions?
dalfrede
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1493
Joined: Wed Mar 15, 2017 7:48 pm

Re: Modding Questions - Finding existing Heroes

Post by dalfrede »

Hero Traits

• AASupport
• AggressiveCounterattack, "Attack bonus when defending"
• Alpine, +4 attack and +4 defense in hills and mountains
• ArtySupport
• ATSupport
• Avenger, "Gets attack bonus for each point of lost strength"
• BlockSupply, "Adjacent enemy units cannot get supplies or replacements"
• BunkerKiller
• Butcher, "Attack bonus against infantry units"
• Camouflage, Can only be detected by recons or adjacent ground units
• CarpetBombing, Destroys supplies (fuel and ammo) when attacking
• CheapReplacements, "Replacements in battle cost as on deployment phase"
• CityFighter, "Combat bonus in city terrain"
• CombatLuck, "Combat results can never be worse than predicted"
• CounterBattery, Provides support fire against enemy artillery units in range
• DeepKnowledge, "+5 attack against units which were introduced X+ years ago"
• Distraction, "Enemy units next to this unit do not counterattack or provide support fire"
• DoubleAttack, "Unit gets 2 attack actions per turn."
• DoubleMassAttack, "When participating in Mass Attack, contributes double effect."
• DoubleMove, "Unit gets 2 move actions per turn, without increasing the number of movement points."
• DoubleSupport,
• EntKiller2
• EntKiller3
• EntKiller4
• Envelopment, "Prevents enemy units from retreating, so they surrender instead."
• Evasion, "Has a certain chance to completely avoid enemy attack"
• Famous, "Generates 10 prestige per turn"
• FastDeployment, "Can unmount from organic transport after movement"
• FastEntrenchment, "Gets 2x entrenchment speed"
• FastLearner, "2x faster experience growth"
• FearsomeReputation, "-1 initiative to all adjacent enemy units"
• FerociousDefense, "Entrenchment of this unit cannot be ignored"
• FierceFighter, "Attack bonus for each adjacent enemy unit"
• FighterSupport
• FlagKiller, "Combat bonus when attacking enemy flags"
• ForcedMarch, +1 move point, cool down 3 turns
• HitAndRun, "When attacked, enemy units with lower initiative do not shoot back"
• IgnoreMassAttack, "Immunity to mass attack"
• IgnoresEntrenchment
• IgnoresZOC
• IncMaxOverstrength, Adds 5 to max over strength.
• LastStand, "Ignores all penalties from encirclements"
• Leadership, "+1 initiative to all adjacent friendly units"
• Legendary, "Generates 20 prestige per turn"
• LethalAttack, "50% suppression caused by this unit is converted to kills"
• Liberator, "2x prestige for all flags captured by this unit"
• LightningAttack, "Immune to all types of support fire"
• MachineGun, "1.5x"
• NoRetaliation
• OnTheRoll, "Gets progressive combat bonus after each kill"
• OverwhelmingAttack, "Always forces enemy units to retreat."
• PhasedMovement
• Provocator, "Enemies attacking adjacent friendly unit will attack this unit instead."
• Prudent, "Gets defense bonus for each point of lost strength"
• QuadripleGun, "2x"
• Readiness, "Strikes first when defending"
• ReducedSlots, "Unit slot cost is reduced by 50%"
• Resilient, "Cannot lose more than half of max strength in one go"
• RiverAssault, "Ignores combat penalties from rivers"
• ShockTactics, "When attacking, pins enemy unit in place by destroying all its movement points."
• SixthSense, "Complete immunity to ambushes"
• SmartEntrenchment, "Gets 2x bonus from entrenchment"
• Splitter, "Unit can be split without spending an extra unit slot."
• Steamroller, "Any kill triggers an Overrun"
• StrikesFirst, "Unit always attacks first"
• Survivor, "As long as this unit has more than 1 strength, it will always survive enemy attack"
• TankKiller, "Attack bonus against tank units"
• TenaciousDefender, "Defense bonus for each adjacent enemy unit"
• ThoroughPreparation, "Initiative bonus at the beginning of a mission"
• Vigilant
• ZeroSlots, "Unit slot cost is reduced to zero"


#• PathFinder, "When moving, treats any difficult terrain as clear"
#• AimedShot, "Gets 'aimed shot' ability. This ability trades movement action for +50% accuracy."
#• AllWeatherCombat, "Immunity to weather effects"
#• BridgeKiller
#• DefenderOfPeople, "Combat bonus when adjacent to friendly settlements"
#• Evacuation, "Unit can be quickly evacuated from the map at any point"
#• ExtendedSupport, "Support fire works within full unit's range"
#• FastUnmount
#• IgnoreGroundState, "Treats muddy, snowy and frozen ground as dry"
#• OrganizedLanding, "No suppression when disembarking"
#• Overwatch, "Attacks enemy units which enter this unit's ZOC"
#• TerrainExpert, "Assumes 'camouflage' in close terrain"

Unit traits

• Alpine, " +4 attack and +4 defense in hills and mountains
• Area damage (X), " Attacks all units within radius X from attack hex (can be used for A bomb and similar mass destruction weapons) (atomic bomb?)
• Attack penalty after move (X ), " -X to accuracy when attacking after movement. Could be used for heavy artillery only (light would not have this penalty)
• Bridge killer, " This unit can attack and destroy bridges.
• Camouflage, " Can only be detected by recons or adjacent ground units
• Carpet Bombing, "Destroys supplies (fuel and ammo) when attacking
• Counter Battery Fire, " Provides support fire against enemy artillery units in range
• Entrenchment Killer 2x, " Destroys 2 points of entrenchment
• Entrenchment Killer 3x, " Destroys 3 points of entrenchment
• Entrenchment Killer 4x, " Destroys 4 points of entrenchment
• Evade (X), " When attacked, the unit has X% chance to evade (cancel) the attack. The game displays an “Evades!” message, and no combat happens.
• Fast unmount, " This unit unmounts from its attached transport after first enemy attack
• Forced March, " +1 move point, cooldown 3 turns
• Fuel consumption (X), " This unit spends X% from normal fuel consumption (normal is 1 point of fuel per 1 movement point)
• Ignores Entrenchment, " Ignores enemy entrenchment when attacking
• Ignores Zone of Control, " Ignores ZOC projected by enemy units when moving
• Kamikaze, " Unit is destroyed after its first attack
• Low-altitude attack, " (TODO) AA units with this trait get +X to accuracy (gameplay parameter) against aircraft with the same trait. Aircraft with this trait get –Y to ground defense (gameplay parameter) when attacking a ground target (not when they are being attacked).
• Mine Killer, " Can attack minefields and damage them
• Mine Sweeper, " Destroys minefields with a single attack
• Minefield, " Minefields cannot be crossed until destroyed
• Move or fire, " Can move or fire, but not both, in a single turn
• No Attack After Move, " Cannot attack after spending its move action
• No Entrenchment, " Unit does not entrench
• No Move After Attack, " Cannot move after spending its attack action
• No Replace, " Unit cannot be given replacements
• No Retaliation, " When attacking, enemy units don't shoot back
• No Retreat, " Unit never retreats
• No Split, " Unit cannot be split
• No Surrender, " Unit never surrenders
• No Upgrade, " Unit cannot be upgraded
• No Zone of Control, " Does not project ZOC to adjacent hexes
• Open Top, " Open-topped vehicle, vulnerable to strafing fighters
• Overrun, " Can overrun crippled enemy units
• Phased Movement, " Can move in steps within its movement point limit
• Recon movement, " The unit can make several moves within its total movement points limit. Every movement consumes an additional movement point.
• Second move (X), " Active ability. Converts unused attack action to another X% of normal move points limit.
• Single Shot, " Unit disappears after its first attack
There comes a time on every project when it is time to shoot the engineer and ship the damn thing.
rubycando
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Tue Feb 09, 2021 3:55 pm

Re: Modding Questions - Finding existing Heroes

Post by rubycando »

@Kerensky

Thank you for your reply it sounds like the DLC code could be useful to some degree.

@dalfrede

While I already knew those from another forum post it's still useful to have them like this. Thank you for that list.

Clarification:

When I spoke about properties and the ones I know, I ment this:
function CreatePanzerAce(unit_id)
local hero = NewHero()
hero.portrait = "/Game/Gui/Common/Heroes/de_af_baer.de_af_baer"
hero.name = NSLOCTEXT("scenario_PolandNorth1", "Johannes_Bolter", "Johannes Bolter")
hero.extra_traits = {UnitTrait.PhasedMovement, UnitTrait.OnTheRoll, UnitTrait.Survivor}
hero.unit_classes = {UnitClass.Tank, UnitClass.AntiTank}
hero.modifiers = {{type = Fuel, mod = 100}, {type = Speed, mod = 20}}
hero.defense_modifiers = {{type = DefenseType.Close, mod = 5}}
local action = world:MakeNewHeroAction(0, hero)
world:Exec(action)
end
In the above code hero is a variable and you assign a new object created via NewHero() function call to it. However the object created, "a hero", has some properties like .portrait for portrait or .unit_classes to determine what unit types can he be assigned to, Tanks and Antitanks in this case.
I was looking for information on what other properties "a hero" table has not what values are possible for them as those are partially known (like the traits you listed or the abysmal documentation).
The traits themselves are values of a property in this case.
Patrick Ward
Slitherine
Slitherine
Posts: 1214
Joined: Thu Sep 04, 2014 2:49 pm
Location: A small island in the Outer Hebrides.

Re: Modding Questions - Finding existing Heroes

Post by Patrick Ward »

Depending on where Dalfrede got his list it might not be up to date.
A long time back I posted the original list I'd been provided with to create the icons but since then they've gone through a lot of changes after feedback from beta, updates, DLC etc.. Not being involved in game design I was rarely privy to those changes.

So if thats that original list, its a good starting point, but don't be surprised to find issues. For example, some of the ones with figures .. 50%, +4 etc. had these numbers removed so that they could be used more dynamically.

Pat
............................

Pat a Pixel Pusher

............................
rubycando
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 4
Joined: Tue Feb 09, 2021 3:55 pm

Re: Modding Questions - Finding existing Heroes

Post by rubycando »

There's a few things I was trying to do where I discovered the guessed way does not work.

Creating a hero with {type = Fuel, mod = 100} and {type = Speed, mod = 20} works as expected but {type = Range, mod = 2} does not.
Neither do negative numbers.
Funny enough if you mod the units.csv to have range 1 instead of 0 for your units and use {type = Range, mod = 1} does work and you get a unit with 2 range ... and a crash when you remove hero form that unit.
I'm in the process of finding out if the problem is addressing Unit properties via key (Fuel, etc) versus full syntax (Unit.Fuel, etc) but alas no luck so far.

Figuring out all these things without proper documentation is not fun and is honestly wearing me down.
Ill wait for the DLC but if still no docs ...
dalfrede
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1493
Joined: Wed Mar 15, 2017 7:48 pm

Re: Modding Questions - Finding existing Heroes

Post by dalfrede »

My list is modified from Pat's earlier list.
All 'Hero Traits' tested as of V1.01.15
Traits that did not create Hero given '#'.
Alphabetized list.

Unit traits given because most unit traits can be 'Heroes', but many make no sense as a user Hero. "No Split" anyone.

Whether a given Hero actually does anything has not be tested.
List may be incomplete.
There comes a time on every project when it is time to shoot the engineer and ship the damn thing.
NoBenNotAgain
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 17
Joined: Thu Dec 03, 2020 6:13 pm

Re: Modding Questions - Finding existing Heroes

Post by NoBenNotAgain »

Just a comment, apropos of nothing: I'd love it if the "AllWeatherCombat" trait could be resurrected in the future. I loved my rainy day fighters in original PzC.
“We’ll start the war from right here.”
—Gen. Theodore Roosevelt Jr
KaiP
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 9
Joined: Sat Mar 06, 2021 9:45 am

Re: Modding Questions - Finding existing Heroes

Post by KaiP »

Its also possible with Lua to replace an Core unit hero with another one ?
Its possible to set an Hero also to an spawned unit ?
And give this spawned unit a name ?
Grondel
Brigadier-General - 15 cm Nblwf 41
Brigadier-General - 15 cm Nblwf 41
Posts: 1960
Joined: Mon Aug 04, 2014 10:07 pm

Re: Modding Questions - Finding existing Heroes

Post by Grondel »

KaiP wrote: Sun Mar 14, 2021 9:19 pm Its also possible with Lua to replace an Core unit hero with another one ?
yes.
KaiP wrote: Sun Mar 14, 2021 9:19 pm Its possible to set an Hero also to an spawned unit ?
sadly spawned units have no id, or i´m not able to get that id. if u find a way to grab the id of a spawned unit u can asign a hero to it.
KaiP wrote: Sun Mar 14, 2021 9:19 pm And give this spawned unit a name ?
same here, no unit id no naming it.
KaiP
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 9
Joined: Sat Mar 06, 2021 9:45 am

Re: Modding Questions - Finding existing Heroes

Post by KaiP »

sadly spawned units have no id, or i´m not able to get that id. if u find a way to grab the id of a spawned unit u can asign a hero to it.
I think - the unit IDs count from the last count of IDs staying on the map - you can see the next coming ID if you set an addional unit on the map - so you have to count the row of spawned units and set the Hero one round after deployment time in the Lua script. I tested and it runs. But I dont know, how to set an unit name row - in the original DLCs there is nothing - but possible Kerency or others here can help with Lua in this point of problem.

Lua Example:
---------------------------------------------------------------------------------------------
function Reinforcements1() -- Bedingung im Editor: Trigger Rundenende
return world.round == 8
end

function CreateAndAssignNewHero(unit_id)
local hero = NewHero()
local unit = world:GetUnit(unit_id)
hero.portrait = "/Game/Gui/Common/Heroes/DE/********.********"
hero.name = NSLOCTEXT("scenario_********", "********", "********")
hero.extra_traits = {UnitTrait.********, UnitTrait.********}
-- hero.modifiers = {{type = Initiative, mod = 10}, {type = Spotting, mod = 1}}
-- hero.attack_modifiers = {{type = TargetType.Soft, mod = 10}}
-- hero.defense_modifiers = {{type = Ground, mod = 10}}
hero.unit_classes = {UnitClass.********"}
local action = world:MakeNewHeroAction(unit.owner_id, hero)
world:Exec(action)

local assign_hero_action = world:MakeAssignHeroAction(unit, hero.id)
world:Exec(assign_hero_action)

end

function PlayerHero1()
CreateAndAssignNewHero(20) -- specify id of the unit which will get this hero inf

end
---------------------------------------------------------------------------------------------
I have 19 IDs on the map and No 20 is the new spawned unit - so the Hero comes to this unit in round 8 - spawning of the unit is round 7 !
********" - Your own names and data files
Post Reply

Return to “Panzer Corps 2 Scenario Design”