Page 21 of 24

Re: New Dynamic Script Ideas

PostPosted: 01 Mar 2015, 09:46
by Krom
I guess you could give a player one special unit alike Barbarian and call him a "hero" ;-)

Re: New Dynamic Script Ideas

PostPosted: 01 Mar 2015, 09:51
by Esthlos
Krom wrote:I guess you could give a player one special unit alike Barbarian and call him a "hero" ;-)

In AED12 (or 11, depends on the version of the campaign) for example the player loses if his king gets killed.
The king is a Knight, as no other unit type would fit the role and as far as I remember a few TPR units are given as reinforcements, which fits the plot.

Having a way to differentiate him from the other Knights would be very handy in my opinion.

(P.S. It's been a while that you're no longer answering my PMs... did you receive them? (?) )

Re: New Dynamic Script Ideas

PostPosted: 11 Aug 2015, 17:06
by Strangelove
I'd like to have fallowing State in the next Release of the Remake:

  Code:
States.GroupAssignedToDefencePosition(GroupID, X, Y)

Returns true if target Group is assigned to the Defence Position on Coordinate X, Y.

Here an Example:

  Code:
var iAttackGroup: Integer;
var bAttack: Boolean;

procedure OnMissionStart();
begin
   Actions.AIDefencePositionAdd(1, 10, 20, 0, 0, 20, 1);
   iAttackGroup := 0;
end;

procedure OnWarriorEquipped(aUnitID, aGroupID: Integer);
begin
   if States.GroupOwner(aGroupID) = 1 and iAttackGroup = 0 then
   begin
      if States.GroupAssignedToDefencePosition(aGroupID, 10, 20) then
         aGroupID := iAttackGroup;
   if iAttackGroup <> 0 and States.GroupMemberCount(iAttackGroup) = 12 then
      bAttack := true;
end;

procedure OnTick()
begin
   if bAttack then
   begin
      Actions.GroupOrderAttackHouse(iAttackGroup, States.HouseAt(50, 50));
      bAttack := false;
   end;
end;

Re: New Dynamic Script Ideas

PostPosted: 11 Aug 2015, 20:37
by thibmo
Esthlos wrote:
RandomLyrics wrote:
Esthlos wrote:I find it strange that nobody asked this yet (but I can't remember where did you post the link with the proposed features, so I can't actually check this :$ ), but can we please have an Actions.HouseLock command, to do the opposite of Actions.HouseUnlock?

HouseAllow(false) it will do the job :P

Thank you.

I knew this (used it in Golden Cliffs - Bonus), but it disables wares' distribution for that building too, and if the unlock was supposed to be temporary then there needs to be dedicated scripting to re-enable it when the time comes in the construction tree... a HouseLock command would have none of these cons, and would in my opinion be a more elegant way of reverting HouseUnlock.

I'd try the following: HouseAllow(aPlayerIndex, aHouseType: Word; aAllowed: Boolean);
And as far as I know it didn't block wares?
Must give it a double check.

//Edit: Confirmed to work -->
1. Image
2. Image

Re: New Dynamic Script Ideas

PostPosted: 18 Aug 2015, 19:55
by Strangelove
Those 2 Actions would be a blessing!

  Code:
Actions.AddAIAttack(Player Index, Target, Soldier Amount, Initial delay, Melee Group Count, Antihorse Count, Ranged Count, Mounted Count: Integer; Random Groups, Repeating: Boolean);
Actions.RemoveAllAIAttacks(Player Index);

Re: New Dynamic Script Ideas

PostPosted: 28 Apr 2016, 22:41
by thunder
Hi,
Today Finaly I could figurate out how the Hello word is working on the overlay:D step by step forward:)

I would like to ask, is there any speciel command which could help to me count speciel type of citizens (unittype) and killing them?
For example I would like to kill only the butchers, or I would like to kill only miners with script. Kill them silent in the same time and I need to know how many citizens were killed by this script.
Should I register all citizens in an array? How could I identify them?
does every unit have speciel/uniqe ID? (or just the unit ID avaiable? like stoner has 10 or labourer have 9)
Thank you for the helps!
t

Re: New Dynamic Script Ideas

PostPosted: 26 Feb 2017, 13:34
by Toxic
When you want to create a map via script (actions: MapTileSet, MapTileHeightSet, MapTileObjectSet for each tile) in Events.OnMissionStart the map will be loading for at least 10 second at my High-end Pc (loading with same script without those actions takes less than 1 sec). I expect that those commands have to do much more than just to change textures. In result this means repeated process which requires to calculate 256*256 tiles.
Is there a way how to make loading of maps generated via script faster? Maybe something like Events.OnMissionLoad which will allow me to change tiles using actions in this function at once before game start analizing map tiles.

Second idea - to set random number generator using seed (for example if script generates a nice map and you want play it again).
  Code:
States.GetSeed() - return you seed of random number generator
Actions.SetSeed() - to set seed of random number generator

And third - to set parameters (constants) of your script in game. For example from chat menu in multiplayer, there could be this option (I have scripts which limit number of towers, send resources to teammates with specific ratio, change difficulty). So you do not have to create new map with specifics script parameters over and over again.

Re: New Dynamic Script Ideas

PostPosted: 26 Feb 2017, 14:13
by Krom
"When you want to create a map via script" - why would you want to create it every time when you can create it once in MapEd?

"to set random number generator using seed" - maybe it's better to use your own seed and RNG in the script?

Re: New Dynamic Script Ideas

PostPosted: 26 Feb 2017, 14:48
by Toxic
Krom wrote:"When you want to create a map via script" - why would you want to create it every time when you can create it once in MapEd?

Because when you create map in map editor it will be always same. I am talking about completely randomly generated map (I already made it).

Krom wrote:"to set random number generator using seed" - maybe it's better to use your own seed and RNG in the script?

Ok. :'(

Is there any chance to set parameters (seed) of script from game?

Re: New Dynamic Script Ideas

PostPosted: 26 Feb 2017, 17:48
by Krom
Dynamic scripts were never intended to be used in such a way. They are inherently "slow".

A better approach would be to add random-map-generation code into KaM Remake itself (or another standalone tool).

Re: New Dynamic Script Ideas

PostPosted: 26 Feb 2017, 17:52
by Ben
Toxic, with the exception of the slow creation speed, is this script of your working? I would be interested in seeing it.

Re: New Dynamic Script Ideas

PostPosted: 26 Feb 2017, 18:17
by Krom
I'd like to see some examples of its work too

Re: New Dynamic Script Ideas

PostPosted: 27 Feb 2017, 19:06
by Toxic
Ben wrote:... is this script of your working?

Sure. I made new topic:

viewtopic.php?f=32&t=3231

Re: New Dynamic Script Ideas

PostPosted: 02 Mar 2017, 11:20
by Esthlos
For campaigns: Actions.SetNextMission(MissionNumber: Integer);

This would allow for interactive campaigns... for example: in mission 3, you have an allied town.
If you save it, you go to mission 4, where you help them and gain their support for later.
If you don't save it, you obviously need to skip mission 4, so you go straight to mission 5 using Actions.SetNextMission(5).

Another example: mission 2 is an "homebase" mission, so OnMissionStart of every mission you say Actions.SetNextMission(2), and you save and restore the homebase's state in the campaign-wide variables; this way, you can effectively visit your main town after every mission, and even treat all the other maps as expeditions.

Pwease?

Re: New Dynamic Script Ideas

PostPosted: 02 Mar 2017, 12:04
by thibmo
Esthlos wrote:For campaigns: Actions.SetNextMission(MissionNumber: Integer);

I think this might bring a challenge.

How will you be able to complete the campaign, then?
Maybe a command like Actions.LoadMap(aMapName: string); // Must be in the same directory
Would be better. Then you could load a new map file whilst keeping the script values.
Then you keep one single mission that you can present as a campaign-like mission.

For the question 'how about loading a save-game?' : This might require a change in the save file. ( Which is a good thing, as that's the requirement for a new release IIRC :P )