Page 29 of 34

Re: [Modding] Creating my first scenario

Posted: Sun Jul 15, 2018 9:51 pm
by gwgardner
Since you mentioned that historically they sold cowhides to the Romans, could you do what Pavel said, but get gold ONLY if the tribe is at peace with the Romans?

Also could have a much cheaper type of boat, costing less citizens to build, but also cowhides and a few wood. It would only carry the smaller fighting units, but if cheap enough a tribe might build lots of them and swarm the enemy at sea.

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 12:43 am
by Cablenexus
I'm thinking of letting the cows as is. They move and they are free to move, but within 3 tiles from a city they produce cowhide.

- There can be a cowhide factory that increase it, there can be a unit ability that can attract cows, instead of them running away.

- There can be a mechanism that cows produce cowhide, but cost food.

- Cowhide can be traded

- Cowhide is needed for at least one unit and one special ability.

- A cowhide factory can slowly turn cowhide into gold.

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 4:44 am
by Cablenexus
It was a night work, but watching the modding video here:

https://www.youtube.com/watch?v=OaGg_8YGGpM

and just experimenting, and failing a lot of times (with a value can't be 0 error) I made good progress on the Cowhide Farms mechanism. It's a complete new resource now with a resource farm that produce cowhide, but cost an amount of food.
It also is taken by the birthrate. I has a library entry, a description, an 11th resource added to the topbar and can be added from the editor as a mine with a unique ID and the mechanism work (mostly) I have to assign some more parameters.

The library text is placeholder.

cowhides.jpg
cowhides.jpg (543.44 KiB) Viewed 2554 times

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 5:00 am
by n0kn0k
Tried starting up the mod but the whole game crashed. Pavel is fixing it for the next version. :)

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 5:03 am
by Cablenexus
n0kn0k wrote: Mon Jul 16, 2018 5:00 am Tried starting up the mod but the whole game crashed. Pavel is fixing it for the next version. :)
Yes, I added it to the description, you have to restart Aggressors. Just loading the mod isn't enough.

The mod itself works fine. Pavel will fix so you can load it without restart.

Please try again to restart Aggressors, it will pick up the mod automatically and you can load a new game and choose hollandv0.090

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 5:22 am
by Cablenexus
With an extra resource added, in the statescreen the scrollbar covers the resource icons partly:
resstate.jpg
resstate.jpg (31.79 KiB) Viewed 2544 times

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 5:49 am
by pavelk
Cablenexus wrote: Mon Jul 16, 2018 4:44 amI made good progress on the Cowhide Farms mechanism. It's a complete new resource now with a resource farm that produce cowhide, but cost an amount of food.
Good work! It seems like you dont need me anymore at all!:)

Btw. all the things you initially thought about can be done externally (a.k.a. in the mod definition file or scripts) but some of them are basic and some are a bit advanced stuff (but not that much).

The biggest change I see in most of the suggestions is to turn the the ambient animals to the actual game mechanism. Although it is still pretty easy:

Cows behavior:
To forbid cows to runaway you need to set moveDuringTurnProbability to 0 and set conflictingObstacles to 372.
You also need to change the script by overriding their functionality to run away.
Create new class in your AmbientModels.cs file and paste there this

Code: Select all

public class CowAmbientModel : DeerAmbientModel
{
    public override AmbientModel Create()
    {
        return new CowAmbientModel();
    }  

    public override AmbientUnitChange UnitIsAboutToPerformMove(AmbientUnit ambientUnit, Unit unit, Position position, Player viewer, bool isFinalPosition)
    {
        return null;
    }
}
and to activate it, change scripting of your AmbientModelMemento to CowAmbientModel.

This will ensure that the cows will stay on the same tile no matter what. The only issue is that their 3D models might "conflict" with the models of the unit on that tile. Right now the animals always run away when there are conflicting obstacles (like units) but this changes it so they dont run away and this could cause the 3D conflicts.

The second thing is to actually start counting the animals as a resource source. This totally depends on the way you want to use it. For example if you want to count just those cows which are in range of 3 tiles from the city, you should:
  1. copy the city class to your own Units.cs mod file;
  2. add to the endturn method this code (I would tell you the exact line on chat);
  3. change the numbers (ID of your new resource, distance from the city and yield of each cow group). I already added comments to the code itself.

Code: Select all

if (hasOwner)
{
	PositionCollection positionsWithCows = State.AmbientUnits.GetAmbientUnitByModelId(5).GetAmbientUnitsPositions().GetPositionsNotFurtherThan(unit.Position, 3, false);//3 here is the max distance from the city
	if (positionsWithCows.Count > 0)
	{
		int numberOfMyCowsAround = State.Chart.GetSquares(positionsWithCows).GetSquaresWithOwner(unit.OwnedBy).Count;

		if (numberOfMyCowsAround > 0)
		{
			GameResource cowHideResource = State.Resources.GetGameResourceById(6);//replace 6 by ID of your new resource
			if (cowHideResource != null)
			{
				PlayerResource cowHidesToAdd = cowHideResource.CreatePlayerResource(2 * numberOfMyCowsAround);//2 is the actual "yield" out of every cow group
				unit.OwnedBy.AddResources(new PlayerResourcesCollection(cowHidesToAdd), stateChanged);
			}
		}
	}
}
This will ensure that it counts all the cows in max range of 3 from the city which are on player's own tiles. The problem is that it can be counted more times (for each city having cows in the allowed distance). This can be also mitigated but I dont have any more time for that now, it is a bit more complicated.

But this way we turned the eye candy animals to the actual source of your new resource.

Now you can do any of those things you mentioned:
Cablenexus wrote: Mon Jul 16, 2018 12:43 amThere can be a cowhide factory that increase it
Similarly like the city, you can create a brand new building which will work with the nearby cows. It might be even better to have a different building than adding this functionality for the city.
Cablenexus wrote: Mon Jul 16, 2018 12:43 amthere can be a unit ability that can attract cows, instead of them running away.
Can also be done, but this is a bit more complicated. You would need to calculate the movement of cows (scripted in the ambientModels.cs file).
Cablenexus wrote: Mon Jul 16, 2018 12:43 amThere can be a mechanism that cows produce cowhide, but cost food.
This would be added to the script I just created (very similarly to production a consumption can be implemented - just add "-").
Cablenexus wrote: Mon Jul 16, 2018 12:43 amCowhide can be traded
This is automatic. Just leave therer the attributes for GameResourceMemento set to 15 (it is almost for all resources already).
Cablenexus wrote: Mon Jul 16, 2018 12:43 amCowhide is needed for at least one unit and one special ability.
Simply configurable in mod file (in costs).
Cablenexus wrote: Mon Jul 16, 2018 12:43 amA cowhide factory can slowly turn cowhide into gold.
This can be done even without scripting. Create new UnitModelMemento and specify <production and <consumption (look for example in city). Once player doesnt have enough consumption resources it doesnt produce the production resources.

Good luck!

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 5:51 am
by pavelk
Cablenexus wrote: Mon Jul 16, 2018 5:22 am With an extra resource added, in the statescreen the scrollbar covers the resource icons partly:
Well I am aware of that but I will not have time for fixing it now. Hopefully till the release is out it will be fixed. Anyway I logged it to the system;)

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 9:53 am
by n0kn0k
Cablenexus wrote: Mon Jul 16, 2018 5:03 am
n0kn0k wrote: Mon Jul 16, 2018 5:00 am Tried starting up the mod but the whole game crashed. Pavel is fixing it for the next version. :)
Yes, I added it to the description, you have to restart Aggressors. Just loading the mod isn't enough.

The mod itself works fine. Pavel will fix so you can load it without restart.

Please try again to restart Aggressors, it will pick up the mod automatically and you can load a new game and choose hollandv0.090
It crashed everytime for me untill I deleted the mod again.
But i'll try next patch. :)

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 9:56 am
by n0kn0k
Cablenexus wrote: Mon Jul 16, 2018 4:44 am It was a night work, but watching the modding video here:

https://www.youtube.com/watch?v=OaGg_8YGGpM

and just experimenting, and failing a lot of times (with a value can't be 0 error) I made good progress on the Cowhide Farms mechanism. It's a complete new resource now with a resource farm that produce cowhide, but cost an amount of food.
It also is taken by the birthrate. I has a library entry, a description, an 11th resource added to the topbar and can be added from the editor as a mine with a unique ID and the mechanism work (mostly) I have to assign some more parameters.

The library text is placeholder.


cowhides.jpg
This reminds me of Lords of the Realm.
If you remake this game into Lords of the Realm 1 you will be my hero. :mrgreen:

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 11:33 am
by Cablenexus
n0kn0k wrote: It crashed everytime for me untill I deleted the mod again.
But i'll try next patch. :)
It should not crash, also not in v5g.

In the .zip file there are two folders. Did you copy/pasted the complete folders to the game and user directories?

The holland mod folder to the bin directory (the name of the folder is ancient_rome-holland) and the hollandv0.90 folder to the scenario directory in the user folder (not the game scenario folder)?

Did you get an error log?

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 11:49 am
by Cablenexus
n0kn0k wrote: Mon Jul 16, 2018 9:56 am
Cablenexus wrote: Mon Jul 16, 2018 4:44 am It was a night work, but watching the modding video here:

https://www.youtube.com/watch?v=OaGg_8YGGpM

and just experimenting, and failing a lot of times (with a value can't be 0 error) I made good progress on the Cowhide Farms mechanism. It's a complete new resource now with a resource farm that produce cowhide, but cost an amount of food.
It also is taken by the birthrate. I has a library entry, a description, an 11th resource added to the topbar and can be added from the editor as a mine with a unique ID and the mechanism work (mostly) I have to assign some more parameters.

The library text is placeholder.


cowhides.jpg
This reminds me of Lords of the Realm.
If you remake this game into Lords of the Realm 1 you will be my hero. :mrgreen:
Yes, after I start a modern Warlords III Darklords Rising remake and a Defenders of the Crown remake ;-)))))

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 12:04 pm
by n0kn0k
Cablenexus wrote: Mon Jul 16, 2018 11:33 am
n0kn0k wrote: It crashed everytime for me untill I deleted the mod again.
But i'll try next patch. :)
It should not crash, also not in v5g.

In the .zip file there are two folders. Did you copy/pasted the complete folders to the game and user directories?

The holland mod folder to the bin directory (the name of the folder is ancient_rome-holland) and the hollandv0.90 folder to the scenario directory in the user folder (not the game scenario folder)?

Did you get an error log?
Got it. That's where I messed up. I'll give it a spin as Rome. :)

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 12:50 pm
by Cablenexus
@n0kn0k,

Thanks! Really interested in your feedback.

I think it should be even easier to install the mod as harryvdk already mentioned. Just a one click install (Steam workshop does this automatically) should be really nice.

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 1:09 pm
by n0kn0k
Cablenexus wrote: Mon Jul 16, 2018 12:50 pm @n0kn0k,

Thanks! Really interested in your feedback.

I think it should be even easier to install the mod as harryvdk already mentioned. Just a one click install (Steam workshop does this automatically) should be really nice.
Just played 25 or so turns. Fun gameplay on the southern wall. Imho move the units onto the walls at the start. Now they are too late.
Building up a road network fast now because the map is sooooooooooooooooooo big. ;)
Most of the tribes offered peace now.

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 2:05 pm
by Cablenexus
n0kn0k wrote: Mon Jul 16, 2018 1:09 pm
Cablenexus wrote: Mon Jul 16, 2018 12:50 pm @n0kn0k,

Thanks! Really interested in your feedback.

I think it should be even easier to install the mod as harryvdk already mentioned. Just a one click install (Steam workshop does this automatically) should be really nice.
Just played 25 or so turns. Fun gameplay on the southern wall. Imho move the units onto the walls at the start. Now they are too late.
Building up a road network fast now because the map is sooooooooooooooooooo big. ;)
Most of the tribes offered peace now.
The units from the Roman Empire or the Tencteri and/or Usipetes units?

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 10:51 pm
by Cablenexus
The Holland mod is not yet compatible with version v6.

I hope tomorrow morning to have the mod updated. Thank you.

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 11:41 pm
by Cablenexus
Cablenexus wrote: Mon Jul 16, 2018 5:22 am With an extra resource added, in the statescreen the scrollbar covers the resource icons partly:

resstate.jpg
The same scrollbar problem with >10 resources happens in the goverment compare screen:
scroll.jpg
scroll.jpg (146.41 KiB) Viewed 2494 times

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 11:46 pm
by Cablenexus
The mod is working again in v6

It's always a little complex to keep the mod up to date in a beta since there are a lot of major changes constantly. So I had to change lines in the script and copy/pasted parts of the new version to my own mod.
It's sometimes very frustrating when you think all your "advanced" files are good to go and still you get a crash.

This time it was because I forget to change the line Lasymachus in Macedonia.
The program returns the following error to me:

inner exception Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index


So it's always a puzzle where it is related to ;-)
No critism here and I'm fully aware that it's my own repsonsibility, but I just wanted to share this :roll:

Like before, since I'm not allowed to share a download link yet, send me a private message (PM) here in the forums or let me know in the comments that you want to play the mod.
I still have to repack and upload the mod so it will me tomorrow before I can send it.
(I also want to test myself a bit if no errors occur in v6).

Re: [Modding] Creating my first scenario

Posted: Mon Jul 16, 2018 11:57 pm
by gwgardner
I'm guessing that even after release of the game to the public, you will have to update the mod everytime, or sometimes, when the game is revised.