Jump to content
SirPope

Would this be possible? Unit to resource supply

Recommended Posts

Would it be possible to have a unit become a resource supply as/when it dies?

Basically a wood sprite or something that when above say 10% health it is just a normal unit. When it gets below that (or more likely just dies), it becomes a resource supply for wood.

Cruel... yes but is it possible to make something with this feature? Something like a promotion when damaged maybe? An aura that triggers on death and turns it into a non-moving 'tree-sheep'? It'd be a Gaia unit like the naked fanatic spawns on some maps. I have no plans to make this I'm just curious as to how and if it is even possible. It might be possible with a map trigger idk.

Share this post


Link to post
Share on other sites

See Health's SpawnEntityOnDeath as documented in the entity XML documentation. You will most likely also have to change the death type (to vanish).

Depending on what you spawn you might want to prefix the template name with resource|. To find out what that does read the special/filter/resource.xml file in addition to the CParamNode documentation. Or in case you don't want to read that much on how it works behind the scenes just look at the resource filter template listed above, and eg the sheep template, and compare that to a tree template.

Depending on what you want you should pick either something similar to the sheep template, or something like a tree template.

  • Like 3

Share this post


Link to post
Share on other sites

I might have to give this a try. It seems simple enough. Plus, it will give me an ideal on how to mod.

I mainly just want to mess around with the AI - nothing really usable or big just something to do when I'm bored. My own little civ with techs and stuff would be neat to test the code I make. Thanks for the links. I didn't even know those kinds of pages existed. I've got annoying fantasy themed ideas in my head. Glad to hear I'm not quite delusional. Of course the models will just be what's provided in A22. I probably don't need to copy them. I should just be able to place them in the template and 0ad should grab them from public.

Thanks again.

  • Like 1

Share this post


Link to post
Share on other sites

Another question:

Is it possible to give a unit a tech?

For my hero, I want to give him a tech upgrade that will increase the attack of all units of a certain type. I want it to be a pair tech, increase attack or decrease train time.

The other hero will be increase building hp or decrease build time. I don't think I've seen this done before so I figured I'd ask.

Share this post


Link to post
Share on other sites

Yes, look at some buildings for how this is done. For the most part (unless it is about moving, or anything tied to UnitAI) there is no difference between units and buildings.

  • Thanks 2

Share this post


Link to post
Share on other sites

Oh okay I figured it out. Thank you. I can even reduce the price of the tech (and increase the time) when you get it from the unit instead of the building. That's pretty neat.

I've got a spawn entity on death problem atm. I think the idea isn't going to work.

Basically, I've got ruins that you can build, they also work as stone mines. Thing is I want them to decay over time (I've got that one working), when it dies it spawns a solider that you can only get from these stones (unless you unlock the tech to train them from the barracks). My problem is if you set the foundation and walk away, a soldier spawns automatically. The soldier doesn't spawn when the resource is depleted (which is good). It just spawns automatically from just setting the foundation and waiting a few seconds. :/

Would a degen aura work instead or is there a way to add the entity on death part when the building is build? I'm kinda liking the degen aura as placing several near each other should stack right?

Edited by SirPope
Clarification

Share this post


Link to post
Share on other sites

So the ruins are to be gathered while under construction? Or only when fully constructed? And they should decay while under construction, or only once fully constructed?

For just removing the spawning while that thing is a foundation is to modify the special/filter/formation template to disable SpawnEntityOnDeath.

Add the following to the <Health> tag: <SpawnEntityOnDeath disable=""/>. That way no foundation (so this is not limited to this specific template, but to all) will spawn an entity on death. If that is what you want I cannot tell.

Auras stack if you make them stackable.

  • Thanks 1

Share this post


Link to post
Share on other sites

I only want it to be gathered (and to decay) when it's completely built. The gathering part is working fine. I figured when a resource was used up, it's considered dead. That's not what happens and that is perfect.

 

I got the foundations to stop committing suicide by adding that to the special filter and setting it's regenrate to 0.0 as well. Thank you very much. :)

 

I couldn't block the aura from affecting the foundation but I'll just leave the decay increase to a tech.

Share this post


Link to post
Share on other sites

You could probably use the special filter to add a class (Foundation) to the foundation, then change the aura to not apply to entities that have the Foundation class (+!Foundation for each entry or something).

  • Thanks 2

Share this post


Link to post
Share on other sites

I didn't know the not symbol worked. Thank you very much. The 'call of the briar' aura is working perfectly now. I kinda lost hope when I couldn't get it to work how I wanted. I'm liking what I got. A hawk scout trainable from an outpost and stones that turn into champion pikemen after about a minute or so... that's about it at the moment but progress.

Share this post


Link to post
Share on other sites

Wow, I notice the inconsistency part of the hybrids.

"!Foundation+BriarRuin" works the same as ["!Foundation BriarRuin"] (I was using that one). The logic gets flipped upside down.

I've switch to the one below. Thank you for linking me that post and file. I've bookmarked D977 to use as a reference for future techs/auras.

"affects": [["!Foundation","BriarRuin"]],

 

Share this post


Link to post
Share on other sites

Are citizen soldiers class 'Citizen' and class 'Soldiers' or just: "CitizenSoldier'?

I'm seeing this separation of the two in a few json files. Female inspiration for the SVN. Yet the template unit infantry file has CitizenSoldier as the class.

#Edit nevermind. Indexof just looks for an occurrence in the whole string.

Edited by SirPope
Noticed the use of indexOf in the matchclass list. NVM

Share this post


Link to post
Share on other sites

Maybe all of them. The classes the actual templates have might be somewhat inconsistent, check the files if you want more detailed information. I don't expect a lot of unification to happen there since number of devs caring about that decreased recently.

  • Like 1

Share this post


Link to post
Share on other sites

From what I can tell, in the svn, it is just CitizenSoldier in the Classes tag and separated in the VisibleClasses tag.

The AI looks at the <Classes> tag. It does say classes in the wiki's tech&aura pages but every mod I've seen (not many really) seems to get it confused with visibleclasses. The 'if I see it; the game sees it' or 'beauty before usability'... kinda mentally.<Looks at both.

 

Anyway, point of post:

Anyone familiar with entity collection?

I can't for the life of me figure out how to get all the entities around a specific position.

Array = getEntitiesAround( pos, maxRange );

Edited by SirPope
Fixed Declaration

Share this post


Link to post
Share on other sites
2 hours ago, SirPope said:

Anyway, point of post:

Anyone familiar with entity collection?

I can't for the life of me figure out how to get all the entities around a specific position.

Array = getEntitiesAround( pos, maxRange );

More details of what you want to do and where would help: All entities including gaia ones as trees? and inside petra? If yes,  you can simply do something like

for (let ent of gameState.getEntities().values())
{
	if (!ent.position())
		continue;
	let distSquare = API3.SquareVectorDistance(yourPosition, ent.position());
	if (distSquare > yourDistance*yourDistance)
		continue;
    ... do what your need with this entity ...
}

You can even create your function  getEntitiesAround using this loop.

But note that there are a lot of such examples inside petra, with such a loop used with all kind of entity collections (if you are not interested in trees, you'd better use another much smaller collection).

  • Thanks 1

Share this post


Link to post
Share on other sites

That might be a limitation of the AI as for everyone but the GUI (which should just display the visible classes) there is no distinction between Classes and VisibleClasses.

  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, mimo said:

API3.SquareVectorDistance

Looking for that function found me plenty of examples, thank you.

 

57 minutes ago, leper said:

there is no distinction between Classes and VisibleClasses.

Looking into that, it seems you're right... Great now, I'm curious how I fixed hyrule and delenda.

Update: Oh I remember, I had to add the <Classes> tag with the proper class so petra would use it. Market to BarterMarket, ect...

Edited by SirPope
Figured out how.
  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, SirPope said:

Looking for that function found me plenty of examples, thank you.

 

Looking into that, it seems you're right... Great now, I'm curious how I fixed hyrule and delenda.

Update: Oh I remember, I had to add the <Classes> tag with the proper class so petra would use it. Market to BarterMarket, ect...

Why delenda?

Share this post


Link to post
Share on other sites

In delenda? I think I had to add some tags to the statue template (DropsiteGlory, Resource). I think that was just to get my edited version of petra to build them though.

I think the support_slave template was missing the worker tag in the moddb version of delenda. I think it was using Gatherer but petra doesn't seem to check for that specific class, just Worker.

The support_female_citizen file I have has an indent in it so it looks like I added worker there as well? I doubt that.

I'm pretty sure I had to add some tags to get some aura's and tech's working properly.

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, SirPope said:

From what I can tell, in the svn, it is just CitizenSoldier in the Classes tag and separated in the VisibleClasses tag.

The AI looks at the <Classes> tag. It does say classes in the wiki's tech&aura pages but every mod I've seen (not many really) seems to get it confused with visibleclasses. The 'if I see it; the game sees it' or 'beauty before usability'... kinda mentally.

Can you be more explicit? The AI uses GetIdentityClasses from globalscript/Templates.js which is a concatenation of Classes and VisibleClasses (which it calls internally Classes). If you have examples where this is not the case, it's certainly a bug and you should report it either here or on trac.

Share this post


Link to post
Share on other sites

I updated that post to get rid of the declaration. If I find something I'll report it. Only thing in A22, that I've noticed was that the minus symbol doesn't remove it from both of the class tags. Which kinda works as intended but if aura and techs look at both. I'm not sure about the svn.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×