Training dummy (working on one at this moment) where do i put the XP?

Hi all, we have recently discussed the craving for a training dummy and work is slow as -turnip- so in a moment of clarity ive put all the stuff i need (exept for a .qb editor) on my usb stick and brought it to work.

so far ive mad a potion that looks like a box, and im working on an entling that wont attack or move or agro and looks like a training dummy.

after that im going to figure out push button = spawn entling-thats-a-training-dummy

the only thing that so far i havent been able to grasp is: where are XP values defined? because all the monsters ive checked have

     },
     "exp_reward": {
        "type": "basic",
        "value": 0
     }

in their Json file. WHAT DO THE NUMBERS MEAN (M)(J)ASON!?!?
but on a serious note, XP, where? how to make sure you actually get xp after you slay a defenseless training dummy…

Yeah, unfortunately it won’t be as easy as attaching some XP values to a box.

For one, you will need to mark the the box as “hostile” of some sort. Not too hostile, though, otherwise your wipmpier hearthlings will start running away from the sight of it, thinking that it’s an actual enemy. Recall that you already can attack inanimate objects in Stonehearth; your soldiers destroy the camp of the Goblins when you send them all in. It would probably be a good idea to have a look at how Radiant made those attackable objects in their code, and adapt that code to your problem.

Assuming you got this first step to work, now, when the box gets destroyed, it might reward some experience. And at this point, you might say you have a full, complete mod. You can set up a dummy, as soon as it’s up, your soldiers will run up to it, swarm it, and reduce it to splinters, and get some XP. You will have a working, but extremely unrealistic mod.

In order to make an attackable dummy that isn’t destructible, you will need to take the following things into account: a) Hearthlings attack an enemy until either it dies, they die, or they take so much damage that they’re forced to run away. Your engagement time with the dummy must be on some sort of time limit, otherwise your soldiers will always keep hitting the dummy and never backing off, b) with the normal Combat Component, you only get XP when the enemy is killed. So you’ll either need to write a custom component for your box that sends out an “Oh no I’m dead” signal after a few hits, and your footman can relax, get his xp, and not attack the dummy anymore, which, although it sent that signal out, isn’t actually dead! Heehee, aren’t we such scamps, OR you will have to create your very own new action chain, not the usual attack_enemy or whatever they have, but train_on_dummy that will consider this, c) unless you manually break your soldiers apart into parties, all your combat hearthlings will travel and fight in a party. Attacking a dummy shouldn’t be a party action, it’s an individual action.

Considering all of these facts, I want to direct you to stonehearth/components/combat_state_component and stonehearth/components/party_component. You will almost certainly have to write your own component for the dummy, whether you do it the easy way or the hard way, so you might as well get comfortable with component composition.

Yeah im going for the box>hit deploy button >despawn and spawn an enemy > enemy is a training dummy with no agro so your soldiers DONT run at unless you tell them to (or at least i hope it works this way, experiments will need to be done) and after they smash it up they gain xp.-route.

seeing as hearthlings dont use training weapons and use actual, sharp weapons and literal lumps of rock, the dummy getting destroyed isnt -that- far fetched to me (this is basicly the same system as the game “a game of dwarves” used for training dummies, where resources and crafting time limited dummy-production. (unless you go dummy mad, but thats self inflicted game breaking)

simpler to do in my oppinion, this way i dont have to write complicated code (well, maybe for the push button to go from a packed up-box-dummy to a deployed immobile dummy)

all i have to find out is why hearthlings gain xp if they kill an enemy.

The actual exp reward is defined in the tuning files inside stonehearth\data\monster_tuning.
These files are then referenced in campaign encounters that spawn enemies.

1 Like

As you said, experiments will need to be done, but I don’t believe the game can function this way as of now. If there’s any scent of anything hostile, your soldiers will rush it.

Yeah, that’s another good way of approaching this problem. As you’ve said, though, you will need a special button that actually spawns the attackable dummy. This is something I’ve done before, and I can give you a bird’s eye overview of the things you’ll need to do to add a new button to an item. Spawning an enemy itself isn’t too hard, either, you can check out on my Personal Thread, I had an experiment where I spawned a Giant Enemy Skeleton in a microworld test. I guess at this point, the hardest bit would be making a selectively-hostile monster, so that your h’lings don’t run away from it, and your soldiers don’t auto-kill it immediately.

1 Like

am i assuming correctly, because those files do have an XP component, that i could actually ignore the tuning files, not write one at all, and put the xp in the monster file itsself, that the xp would be the same across all difficulties, this would also stop the game from spawning a deployed training dummy as a monster unintentionally?

edit:
because the monster file has:
},
“exp_reward”: {
“type”: “basic”,
“value”: 0
}

and the tuning file also has
“attributes”: {
“max_health”: 60,
“muscle”: 0,
“menace”: 20,
“courage”: 40,
“speed”: 80,
“additive_armor_modifier”: 0,
“exp_reward”: 3 <<<<<this one.

Yes, of course. :slightly_smiling_face:

1 Like

yeah this would be the tricky bit but it would be a good place to start at least.

i saw that one, fully intended checking that one out, yes :smiley: (thanks for the documentation on that)

1 Like

BTW I think your idea of a potion that is equippable and auto-consumes itself should be doable.
Though I would try to make it auto-unequip and destroy itself once that happens, for the first attempt.
Otherwise, you’ll really have to write custom code for a belt that can store potions and create AI actions to deal with it (since it’s an equipped item, not sure if restocking with the current code would work, but you can always try - actually, you could define a special storage filter and have that belt only have that filter, so that no other items get restocked to it).

For the dummy, could we cheat even more? Like, you know you can add exp while talking with a hearthling with the professor trait. You could have a custom AI action that does something like: search for dummy / “attack dummy” (just an animation) / reduce some counter on the dummies attributes when this animation loops / when it reaches 0, add exp to footman, and destroy the dummy if you want, too. You could try have an engineer repairing it, though that could require more code. This could be considered a different AI group than combat, so that real combat always has priority for the footman.

Doesn’t really have to be actual combat. That way you skip the hostile checks.
There’s a hearth that spawns undead, you could check that too if you want.

1 Like

this is indeed my plan, but i’d thought i’d cut my teeth on the training dummy first, as an excersize. so far it seems to be going quite well :slight_smile: thanks for all the feedback btw!

this sounds cleaner…but harder to do, ill concider this plan B (the less i have to fiddle with animations and AI, the better for me, at least to start with i dont mind slightly more files for my jack-in-the-box style training plan)

EDIT:
what does a “ghost form” for a potion do btw? i just fully took over the structure of a potion so far but i dont get that bit yet.

1 Like

The ghost represents the semi-transparent item that we see when we order to place an item in the ground. Some tonics have it and some others don’t.

If your item isn’t going to be placeable, you don’t need the ghost.

If you’re gonna make it equippable, copy an existing gear and add the missing components from the potion to it.
(never tried a command on an equipped item, mainly because it’s tricky to select it once equipped, but feel free to experiment).

ah, the “its going to be put HERE” ghost. what you also get for beds and chairs and things before you heartling puts it down somewhere, and recently, when you are going to plant trees, got it!

seeing as my box that deploys the training dummy will be placable: its going to need a ghost form :slight_smile:

this thread is going to be an excelent Q&A source for someone down the line, lol.

1 Like

right, ive got a box with a button (potion style) ive removed the buff from it, so there wont be an icon in the left bottom corner for four hours saying that there is a potion.
ive made a new lua with

local DeployDummy = class()

function function MicroWorld:place_enemy(x, z)
– Item despawns self, spawns attackable dummy that gives XP on destruction
local pop = stonehearth.population:get_population(LOCAL_ENEMY)
local foe = pop:create_new_citizen(‘Training dummy’)

local town = stonehearth.town:get_town(‘player_1’)

radiant.terrain.place_entity(foe, Point3(x, 1, z))
return foe
end

return DeployDummy

in it, based around @Moai 's giant skeleton spawn code, removed this bits of it that would make it REALLY BIG and the stuff that gives it a weapon (its a dummy, it doesnt have to fight back)

now for the coordinate system… how does that work?

X and Z are the flat planes, going forward/backward, left/right. Y is the vertical plane, up/down. You’ll need to experiment to figure out the rest, my work with the coordinate system is limited to making cubemitters so far.

1 Like

good to know (used to X/Y being horizontal and Z vertical…)
i was more thinking in the terms of are coordinates relative to the source calling the code, or is it an absolute thing, that kinda stuff :confused:

Check out my personal thread for more info, I did write a bit about it. Point 0,0,0 is the exact central voxel of where you clicked the the map when disembarking, the exact center of your map. 0,1,0 is 1 voxel above the center. 0,-1,0 is 1 voxel below the center, and possibly, depending on the map and generation type, below the ground. If you use Microworld, then -1 on the Y axis corresponds to 1 block below the ground.

e: Allow me to link you some resources that I know and have used around this site. Reading through them should give you a very broad overview of some of the game’s systems.

Stonehearth official modding guide
In-depth look at AI
RepeatFeed

And you are familiar with my thread.

e2: Now that I’ve re-read it, my thread is pretty barren when it comes to usable content. :\ I’ll need to post more often to that.

1 Like

@Moai thanks for the links, that repeat feed one is bloody insane, the man made a train? What the hell XD.

I think the coords thing will indeed be a trail and error. Got a free day tomorrow, then, its testing time :smile:

1 Like

I am honored and slightly upset at the same time.

2 Likes

Concider it maximum respect, you indeed are a wizzard. With an extra z, for extra magic

quick suggestion/question (unless you have this part already sorted)

About how to stop/keep attacking etc -

Why not make the dummy togable in the sense of force attack/attack move command? That way you can toggle/untogle at leasiure?

Please note - i have no mod background and might be talking out of my -cottage pie- also could not stand to read past the first few posts (all the code hurts my eyes :stuck_out_tongue: )

  • just thought i would suggest regardless because in early post you said you also had this issue on how to stop attacking/read as training etc???