Stratagus function expanded

francot514
Posts: 87
Joined: Wed May 21, 2014 6:26 am

Stratagus function expanded

Postby francot514 » Sat Dec 05, 2015 8:21 am

Hi i want to ask if is possible to expand lua functions, like for set ChangeUnit to different player, or create teams of players, where there will be alliances, any help regards this??
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Stratagus function expanded

Postby Andrettin » Sat Dec 05, 2015 9:04 am

francot514 wrote:Hi i want to ask if is possible to expand lua functions, like for set ChangeUnit to different player, or create teams of players, where there will be alliances, any help regards this??
All of this is already possible :)

To change a unit's owner to a different player, use the following function:
ChangeUnitOwner(unit, old_player, new_player)

"unit" is the slot used by the unit
"old_player" is the index of the unit's current player
"new_player" is the index of the player you want to become the unit's owner

To create alliances between players, use the following function:
SetDiplomacy(player, "allied", other_player)

"player" is the index of the player you are changing the diplomatic stance of
"'allied'" - leave this as is (other values this argument can take are "enemy" and "neutral)
"other_player" is the index of the player object of the diplomatic stance change

You also need to do this for the other player, so you also need to add:
SetDiplomacy(other_player, "allied", player)

Remember to set shared vision for the players:
SetSharedVision(player, true, other_player)
SetSharedVision(other_player, true, player)
francot514
Posts: 87
Joined: Wed May 21, 2014 6:26 am

Re: Stratagus function expanded

Postby francot514 » Thu Dec 10, 2015 6:46 am

Ok, good to know all this is currently possible, i will need to allow my maps have it by default, there is a way to configure this ingame, or can only be added by modyfying map script??
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Stratagus function expanded

Postby Andrettin » Thu Dec 10, 2015 7:23 am

francot514 wrote:Ok, good to know all this is currently possible, i will need to allow my maps have it by default, there is a way to configure this ingame, or can only be added by modyfying map script??
It is possible to have your maps do those things by default (with triggers which appear on all maps, for instance).
francot514
Posts: 87
Joined: Wed May 21, 2014 6:26 am

Re: Stratagus function expanded

Postby francot514 » Thu Dec 10, 2015 7:36 am

What you mean triggers that appear on all maps??, a common lua file that contains all triggers?

Who is online

Users browsing this forum: No registered users and 0 guests