Skip to content

Posts from "Замена" startcombat

No ratings yet — be the first to rate!
User Avatar
#1
Auto-translated
For a long time, the neutral color of heroes when using StartCombat annoyed me; after experimenting, I found a way to give them player colors.
When using SiegeTown, the color was preserved there, but siege objects remained. I tried removing all objects from the siege arena and it worked.
This will be Heaven1.(AdvMapTownShared).xdb — this is our arena without siege objects.
<Interior href="/Arenas/Town/NewHaven/NewHaven.(ArenaDesc).xdb#xpointer(/ArenaDesc)"/> Changes the scene when you open a creature or hero; haven=grass, etc., you'll figure it out by the names.
Next will be Spes.xdb — this is our setup on the arena; in Shared we insert our empty arena (<Shared href="Heaven1.(AdvMapTownShared).xdb#xpointer(/AdvMapTownShared)"/>)
<PlayerID> is exactly what sets the desired enemy color. Example: <PlayerID>PLAYER_2</PlayerID>
<Specialization/> sets siege bonuses like -1 luck to all attackers for the necropolis castle, etc. But you can turn them off.
<armySlots> the enemy army. If there's no hero, there will be mobs without a hero but with color.
<GarrisonHero/> link to the enemy hero. Example <GarrisonHero href="Duncan.xdb#xpointer(/AdvMapHero)"/> 
<Script/> Combat scripts on the arena, example <Script href="CombatScript_duncan.xdb#xpointer(/Script)"/>
<LinkToPlayer>PLAYER_2</LinkToPlayer> I'd also recommend setting the desired enemy color there.
<AllowQuickCombat>true</AllowQuickCombat> well, that's obvious — quick combat on/off; though I haven't tested whether disabling works, but most likely yes.
Next will be the enemy hero file; in the archive it will be Duncan.xdb — this is exactly the file where you write stats, spells, and skills.
<Shared> link to the hero  <Shared href="Duncan1.(AdvMapHeroShared).xdb#xpointer(/AdvMapHeroShared)"/>
in Duncan.xdb <armySlots> — this is exactly where you write the hero's army.
The next file, Duncan1.(AdvMapHeroShared).xdb, is a blank copy of the enemy hero; we need it if you want to change, for example, the hero's specialty, its icon, etc.
Throw all these files into your created map and make the paths correct too.
Now, to trigger the battle, here's an example of code to write in your MapScript
Author
SiegeTown("Freyda", "/Maps/SingleMissions/test/Spes.xdb#xpointer(/AdvMapTown)",
'/Scenes/CombatArenas/Boss_c6m3_Dirt2.xdb#xpointer(/AdventureFlybyScene)')   
Freyda is the script name of your hero, then comes the path to the Spes setup, and third is the path to the arena where all this will take place. You can use paths to standard arenas or to your own custom maps. For arenas, you need exactly Scenes, not Maps. 
Well, that seems to be it. The pros of this method: you don't need to keep a hero in reserve, you can trigger a battle even if that hero is standing on the map, you can trigger a battle as many times as you want by changing setups/armies/stats, etc., and you can color mobs without a hero. The cons: if your hero has the Insight skill and you click on the enemy hero, the game crashes — most likely I accidentally deleted that scene where the enemy hero stands in the clearing, but not sure(I found a fix, now it doesn't crash). As for enemy heroes, if they have artifacts, they will always drop from them, and there's no way to forbid that — plus or minus, depending on preference.
You can also trigger a regular siege with objects if you replace the Shared in Spes.xdb with the standard Heaven.(AdvMapTownShared).xdb and give it the standard path of the original files.
Hope this info helps if someone was looking for such a method.
If someone doesn't understand or it doesn't work, I'll attach a test map where I did all this, so you can look at an example.
Attachments 4
4 files attached • Total size: 756.7 KB
User Avatar
#2
Auto-translated

There is a much simpler way if you don't want to use a reserve — the function MakeHeroInteractWithObject( heroName, objectName ). You enter the script names of your own and the desired enemy hero, and then your hero effectively "touches" the enemy one, thereby triggering combat. If the target enemy hero is stationed in a town, you need to specify the script name of the town they are in for objectName (or alternatively use SiegeTown(heroName, townName, arenaName = "")). If the town doesn't have a script name, then you'll need to "kick" the hero out of the town using SetObjectPosition(). Now, if you need a specific Combat Script to run during all of this, you should put the path to the script in the Shared properties of the main (your own) hero so that it runs during every skirmish; then, write conditions so that the script only executes its code if we encounter a specific hero, for example (I took this code from my own map, which handles encounters between required heroes, such as when my hero attacks/is attacked by certain heroes):

function CheckHero()
if (GetDefenderHero() and GetHeroName(GetDefenderHero()) == "Duncan") or (GetAttackerHero() and GetHeroName(GetAttackerHero()) == "Duncan") then
if (GetDefenderHero() and GetHeroName(GetDefenderHero()) == "Freyda") or (GetAttackerHero() and GetHeroName(GetAttackerHero()) == "Freyda") then
print("Рубль будет? Мне на яхту не хватает")
end
end

That's how it works :)

Всякое/карты:

Добавление недостающей музыки гномам

In reply to Азгалор
User Avatar
#3
Auto-translated
Azgalor

There is a much simpler way if you don't want to use the reserve - the function "MakeHeroInteractWithObject( heroName, objectName )". Enter the script names of your own and the desired enemy hero, and then your hero essentially touches the enemy one, thereby triggering combat. If the target enemy hero is in a town, then in objectName you need to specify the script name of the town they are in (or simply run SiegeTown(heroName, townName, arenaName = "")). If the town doesn't have a script name, then you need to "kick" the hero out of the town via SetObjectPosition(). Now, if you need a specific Combat Script to be triggered during all this, then in the Shared of the main (your) hero, specify the path to the script that will run at every one of their skirmishes, and write conditions so that the script only executes its code if we meet a certain hero, for example (I took this code from my own map, which handles the meeting of specific heroes, like when my hero attacks/is attacked by certain heroes):

function CheckHero()
if (GetDefenderHero() and GetHeroName(GetDefenderHero()) == "Duncan") or (GetAttackerHero() and GetHeroName(GetAttackerHero()) == "Duncan") then
if (GetDefenderHero() and GetHeroName(GetDefenderHero()) == "Freyda") or (GetAttackerHero() and GetHeroName(GetAttackerHero()) == "Freyda") then
print("Рубль будет? Мне на яхту не хватает")
end
end

That's how it is)

But then a "random arena" will be triggered instead of the one that is needed.