Larian Studios
I tried with a new ability spawning a new summon, but nothing drops. This is going to a bit long but bear with it for a while.
Be warned that i don't have the editor (i'm using linux and it doesn't work in wine, and i'm using the linux version of DOS EE besides).


I added this new entity (with a new map key) to one of the mod i'm altering (xc_encounters with the samaritan patch) roottemplates files:
Code
				<node id="GameObjects">
					<attribute id="Alignment" value="Good NPC" type="22" />
					<attribute id="BloodSurfaceType" value="1" type="1" />
					<attribute id="DisplayName" value="Undead Source Hunter" type="28" handle="" />
					<attribute id="Equipment" value="Summon_Source_GreaterUndead" type="22" />
					<attribute id="ExplodedResourceID" value="cd1918b9-f5fe-41f8-be10-7a5285d0e001" type="22" />
					<attribute id="ExplosionFX" value="FX_GP_CorpseExplosion_Skeleton_A" type="22" />
					<attribute id="Flag" value="0" type="4" />
					<attribute id="GroupID" value="0" type="5" />
					<attribute id="HitFX" value="FX_GP_Hit_Bone_A_Medium" type="22" />
					<attribute id="Icon" value="Portrait_Undead_Skeleton_Grunt_A" type="22" />
					<attribute id="LevelName" value="" type="22" />
					<attribute id="MapKey" value="12c5957b-4e9c-4482-a1c4-bf20aae39d43" type="22" />
					<attribute id="Name" value="Summon_UndeadSourceHunter" type="23" />
					<attribute id="PhysicsTemplate" value="78b438db-e742-4301-aa71-79508187c581" type="22" />
					<attribute id="Random" value="9223372036854788929" type="24" />
					<attribute id="RunSpeed" value="3.3" type="6" />
					<attribute id="Scale" value="1" type="6" />
					<attribute id="SkillSet" value="Summon_GreaterUndead" type="22" />
					<attribute id="SoundSwitch" value="Skel_Grunt" type="22" />
					<attribute id="Speaker" value="CYS_Undead_AggroSkeleton_Undead_M" type="22" />
					<attribute id="Stats" value="Summon_Source_GreaterUndead" type="22" />
					<attribute id="Type" value="character" type="22" />
					<attribute id="VisualTemplate" value="680fc263-8144-4eb7-82c5-1ef11a8a689e" type="22" />
					<attribute id="WalkSpeed" value="1.5" type="6" />
					<children>
						<node id="AIBounds">
							<attribute id="AIType" value="2" type="1" />
							<attribute id="Height" value="2" type="6" />
							<attribute id="Radius" value="0.5" type="6" />
						</node>
						<node id="Arms">
							<attribute id="Object" value="1c6ce0db-5ce1-4280-91af-8a58901e5858" type="22" />
						</node>
						<node id="Arms">
							<attribute id="Object" value="dca9b86e-499d-4622-bcbf-92fb412a5677" type="22" />
						</node>
						<node id="Arms">
							<attribute id="Object" value="24a201fe-8eab-40bf-9493-fcb153af9c62" type="22" />
						</node>
						<node id="Arms">
							<attribute id="Object" value="906a8859-008c-4f6e-8e94-b57aaa1f9b30" type="22" />
						</node>
						<node id="Arms">
							<attribute id="Object" value="e06c069b-9e30-4601-ac82-1561d0be0662" type="22" />
						</node>
						<node id="Arms">
							<attribute id="Object" value="a49a3a1b-acb0-414a-858f-bf0fe9287112" type="22" />
						</node>
						<node id="Bodies">
							<attribute id="Object" value="a8674e5e-a3a2-4e0f-a99b-614754462a16" type="22" />
						</node>
						<node id="Bodies">
							<attribute id="Object" value="53d25c2b-b1d0-43a3-a25b-e353891dd48d" type="22" />
						</node>
						<node id="Bodies">
							<attribute id="Object" value="58442bde-4efd-4eb2-b7ab-ae91158ff478" type="22" />
						</node>
						<node id="Bodies">
							<attribute id="Object" value="716f959a-3834-4e58-b135-26239d8356aa" type="22" />
						</node>
						<node id="Bodies">
							<attribute id="Object" value="09ff47b2-bae4-4b8e-afef-dfe89dcd2ca5" type="22" />
						</node>
						<node id="Heads">
							<attribute id="Object" value="c3af157f-f902-41bb-a4ec-e2013f9727c8" type="22" />
						</node>
						<node id="Heads">
							<attribute id="Object" value="a379d764-c03a-49ba-aff5-631adf93fda0" type="22" />
						</node>
						<node id="Legs">
							<attribute id="Object" value="c5f0fb4c-12ed-4c9d-9bd7-bcf9dfa3168e" type="22" />
						</node>
						<node id="Legs">
							<attribute id="Object" value="194eb12e-2d68-4475-85aa-49183998109e" type="22" />
						</node>
						<node id="Legs">
							<attribute id="Object" value="40d705df-b460-42f3-b3de-e0c5da762cd1" type="22" />
						</node>
						<node id="Legs">
							<attribute id="Object" value="a5f50696-9072-4d39-8627-1926973730fb" type="22" />
						</node>
						<node id="Legs">
							<attribute id="Object" value="2fe2d152-5b9d-4963-a6eb-3033700b44d0" type="22" />
						</node>
						<node id="OnDeathActions">
							<children>
								<node id="Action">
									<attribute id="ActionType" value="5" type="4" />
									<children>
										<node id="Attributes">
											<attribute id="templateAfterDestruction" value="" type="22" />
											<attribute id="visualDestruction" value="d77a175e-1c38-4fcc-8744-b40fc08341dd" type="22" />
										</node>
									</children>
								</node>
							</children>
						</node>
						<node id="Scripts">
							<children>
								<node id="Script">
									<attribute id="UUID" value="5bc80992-a7f6-4da6-83e2-3d276384d8f7" type="22" />
									<children>
										<node id="Parameters">
											<children>
												<node id="Parameter">
													<attribute id="MapKey" value="HardcoreOnly" type="22" />
													<attribute id="Type" value="1" type="4" />
													<attribute id="Value" value="0" type="23" />
												</node>
												<node id="Parameter">
													<attribute id="MapKey" value="SayBlindedText" type="22" />
													<attribute id="Type" value="1" type="4" />
													<attribute id="Value" value="1" type="23" />
												</node>
											</children>
										</node>
									</children>
								</node>
								<node id="Script">
									<attribute id="UUID" value="5f6440b3-51dd-42ab-9432-f9a94e4af403" type="22" />
									<children>
										<node id="Parameters">
											<children>
												<node id="Parameter">
													<attribute id="MapKey" value="HardcoreOnly" type="22" />
													<attribute id="Type" value="1" type="4" />
													<attribute id="Value" value="0" type="23" />
												</node>
											</children>
										</node>
									</children>
								</node>
							</children>
						</node>
						<node id="Treasures">
							<attribute id="TreasureItem" value="Magic_Loot" type="22" />
						</node>
					</children>
				</node>

Notice the new TreasureItem loot table:


And i added this new ability to SkillData.txt - a aside, i'm also asking what is the purpose of the second entry there. I'm just copying the pattern from the XC_Encounters skeleton summon where it has that second entry with _13 suffix, but i don't know what it's for, is it some kind of level scaling?:
Code
new entry "Summon_UndeadSourceHunter"
type "SkillData"
data "SkillType" "Summon"
data "Ability" "Summon"
data "Element" "None"
data "ActionPoints" "6"
data "Cooldown" "8"
data "CooldownReduction" "30"
data "ChargeDuration" "0"
data "Lifetime" "-1"
data "SummonLevel" "-1"
data "Magic Cost" "1"
data "Template" "12c5957b-4e9c-4482-a1c4-bf20aae39d43"
data "TargetRadius" "12"
data "Icon" "Skill_Source_CreateUndeadGreater"
data "DisplayName" "Summon_UndeadSourceHunter_DisplayName"
data "DisplayNameRef" "Summon Undead Source Hunter"
data "Description" "Summon_UndeadSourceHunter_Description"
data "DescriptionRef" "Summon an skeletal source hunter that serves beyond death."
data "StatsDescription" "Summon_UndeadSourceHunter_StatsDescription"
data "StatsDescriptionRef" "<p align="left"><font color="ff9500" size=19 face="Copperplate Gothic Light">   RECOMMENDED</font><br><font color=cc7700" face="Copperplate Gothic Light">    •    Scales with level<br></font><br><br><font face="Copperplate Gothic Bold">Range: [2]</font><br><br>A ghoulish invention of a borderline heretic of the order, this spell allows the summoning of source hunters that agree to fight after death. The hunter may drop broken magic loot they wore in their ill fated last journey.<br><br>You can only have one summon at a time.</p>"
data "StatsDescriptionParams" "SummonLevel;TargetRadius;Lifetime"
data "FXScale" "100"
data "PrepareAnimationInit" "skill_summon_earth_start"
data "PrepareAnimationLoop" "skill_summon_earth_loop"
data "PrepareEffect" "FX_Skills_WitchCraft_Summon_Prepare_A;FX_Skills_WitchCraft_Generic_A_Prepare_Hands:Bip001 R Forearm:Bip001 L Forearm"
data "CastAnimation" "skill_summon_earth_cast"
data "CastTextEvent" "cast"
data "CastEffect" "FX_Skills_WitchCraft_Summon_Cast_A"
data "CastEffectTextEvent" "cast"
data "TargetCastEffect" "FX_Skills_WitchCraft_Summon_Summon_A"
data "TargetEffect" "FX_GP_Target_WitchCraft_A"

new entry "Summon_UndeadSourceHunter_13"
type "SkillData"
using "Summon_UndeadSourceHunter"
data "Level" "13"

I added a loot to TreasureTable.txt at the end of the file:
Code
new treasuretable "Magic_Loot"
IgnoreLevelDiff 1
new subtable "-1"
object category "I_LOOT_Paw_A_Rabbit_A_Lucky",100,100,0,0,0,0,0,0
object category "I_LOOT_Claw_A_Sharp",100,100,0,0,0,0,0,0
object category "I_LOOT_Antler_A_Adult",100,100,0,0,0,0,0,0
object category "I_LOOT_Tusk_A_Large",100,100,0,0,0,0,0,0
object category "I_LOOT_Tail_A_Rat_A_Long",100,100,0,0,0,0,0,0
object category "I_LOOT_Foot_Chicken_A_Big",100,100,0,0,0,0,0,0
object category "I_LOOT_Eye_A_Creepy",100,100,0,0,0,0,0,0
object category "I_LOOT_Tooth_A_Sharp",100,100,0,0,0,0,0,0
object category "I_LOOT_Skull_Human_A_Ancient",100,100,0,0,0,0,0,0
object category "I_LOOT_Scraps_Metal_A",100,100,0,0,0,0,0,0
object category "I_LOOT_Scraps_Plate_A",100,100,0,0,0,0,0,0
object category "I_LOOT_Scraps_Scale_A",100,100,0,0,0,0,0,0

And i added new localization for the name of the summon and ability on the localization folder of the mod (which is how i know i'm summoning the right npc). I also used the samaritan mod on new game event to add the ability like it adds a bunch of others so that works.


Anyway, what doesn't work is the new loot table. In fact any loot table i add doesn't work. Is this normal? Does the game hardcode summons to erase their loot table before creating them?

Is there a workaround using the 'ondeath' triggers to spawn items? (Ideally making it so that only deaths created by enemies not pcs or henchmen create the item?=
Hey,

sorry for the rather late reply, I hope you're still around:

I did a quick test in the Editor, added a treasure to Summons_Earth_Spider, summoned it with a scroll and killed it. The engine indeed doesn't seem to generate treasure for skill-summoned characters, nothing was dropped.

I can think of two solutions (the first being the viable one, the second only for 'theory'):

1. We spawn a container from a script when the summon dies. For this, an item template for this container must be created and the appropriate 'inventory' (= treasure table name) must be added to this template. A pouch-like item, as used in the script example below, might be a good base for such a treasure container template. We need a container to generate the treasure (and can't spawn the treasure directly), because scripts aren't able to level-scale items and apply modifiers to it.

The script code could look like this:

Code
EVENT Spawn_Summon_Treasure
VARS
	CHARACTER:_char
        CHARACTER:_killer
	CHARACTERTEMPLATE:_temp
	FLOAT3:_pos
	ITEM:_item
ON
	OnDie(_char,_,_killer,_)
ACTIONS
	IF "c1&c2&c3&c4&!c5&!c6"
		IsEqual(__Me, Player1_dac1443f-a866-4ab3-b240-e705c0b20ec5) //Player 1 will be our secret treasure spawner
		CharacterGetTemplate(_char,_temp)
		IsEqual(_temp,12c5957b-4e9c-4482-a1c4-bf20aae39d43) //the summon's template GUID, taken from the template you posted
		GetPosition(_char,_pos)
                CharacterIsPlayer(_killer) //only kills by npcs will spawn the treasure, as you requested
                IsEqual(_killer,null) //only when the summon dies an unnatural death (by a character) the item will spawn
	THEN		
		Add(_pos,{1;0;1}) //a small offset for the spawn position to avoid clipping with the corpse
		IF "c1"
			FindValidPosition(_pos,5,_char)
		THEN
			SpawnItem(LOOT_Pouch_A_244deb74-a42b-44b3-94b1-a7fe3620b98e,_pos,_item) //the template must be replaced with your custom treasure container template
			PlayEffectAt(_item,"FX_Env_Sparkles_A")
		ENDIF
	ENDIF

The code must be added to the EVENTS section of a player script. The 'Player.charScript', the Samaritan 'Player_AI.charScript' or any other player script of XC_Encounters can be used for this. Our spawn mechanic will be handled by Player 1, he's the character to observe the summon's death and to spawn the treasure.


2. Creating a pseudo-skill instead of a proper summon skill and summon the character from a player script instead (this skill is for player characters only, I suppose?), something like:

Code
EVENT Fake_Summon
VARS
    FLOAT:_stat
    INT:_level
ON
     OnSkillCast(__Me,[Skill Name]) //side note: first parameter can only be __Me, although the API suggests otherwise
ACTIONS
    IF "c1"
		CharacterGetStat(_stat,__Me,Level) //get summoner level
	THEN
		Cast(_level,_stat) //cast float to integer
		SpawnCharacter(_,12c5957b-4e9c-4482-a1c4-bf20aae39d43,__Me,1,1,__Me,_level)
	ENDIF

//Param 1: character variable to store the resulting character (here left empty with an underscore)
//Param 2: Character Template of the character to spawn
//Param 3: Position to summon the character at (here it's just the position of the summoner)
//Param 4: 1 = Play spawn animation, 0 = do not play spawn animation
//Param 5: 1 = is summon, 0 = is not summon
//Param 6: Owner of the Summon
//Param 7: Level of the spawned character (here the same level as the summoner)

Script-summoned characters generate treasure, so this should work.

Cons of solution 2:
- the summon exists until it's killed
- the summon isn't displayed next to the summoner's character portrait
- the summon destination cannot be taken from the skill itself but must be chosen by the script (here it's just the position of the summoner, i. e. __Me)


Tell me if this works for you and if you need further help. smile
© Larian Studios forums