Daxter_06
New member
- Joined
- May 9, 2006
- Messages
- 458
New Ways of Scripting
Hey everyone. I will be using this thread to show you new pieces of code that
will allow you to further improve your scripting and give you the ability
to use these new pieces to make scripting easier.
An example of this is new variable scripting methods. The first method
allows you to make a variable equal to more than one thing without using
another line.
Variable = expression + expression
e.g.
oTown = get town with id 0
nPlayer = get oTown player
MeleePlatoons = variable constant from ARMY_UNIT_TYPE_MELEE_1 to ARMY_UNIT_TYPE_MELEE_10
Gatehouse = get building ABODE_NUMBER_GATEHOUSE in oTown min built 1.0
oPlatoon = get platoon of player nPlayer nearest {Gatehouse} radius 50.0 + get platoon of type constant MeleePlatoons nearest {Gatehouse} radius 50.0
This method of looking for a platoon will check to see if any platoons of the specific player of
any level from Melee 1 to Melee 10 (in this case but you can do the same for ranged platoons) are near the gatehouse. "MeleePlatoons" declares that any platoon of level 1-10 can be any platoon and if that platoon is of the specified player then it exists and is near the gatehouse. In this case the gate will open.
The line equal to oPlatoon which says "get platoon of type constant MeleePlatoons nearest {Gatehouse} radius 50.0" looks for any platoons between Melee levels 1-10 by saying that the variable "MeleePlatoons" holds the value of constants Melee type 1 to Melee type 10 and therefore platoons of any of those levels is a valid platoon.
In simplified terms of the above variable;
oPlatoon = look for a platoon of any player of any level between the min and max set
e.g.
oPlatoon = player 0 + Melee level 2 which therefore is a valid platoon.
Use of this variable declaration method is used in my AI script(s).
Hey everyone. I will be using this thread to show you new pieces of code that
will allow you to further improve your scripting and give you the ability
to use these new pieces to make scripting easier.
An example of this is new variable scripting methods. The first method
allows you to make a variable equal to more than one thing without using
another line.
Variable = expression + expression
e.g.
oTown = get town with id 0
nPlayer = get oTown player
MeleePlatoons = variable constant from ARMY_UNIT_TYPE_MELEE_1 to ARMY_UNIT_TYPE_MELEE_10
Gatehouse = get building ABODE_NUMBER_GATEHOUSE in oTown min built 1.0
oPlatoon = get platoon of player nPlayer nearest {Gatehouse} radius 50.0 + get platoon of type constant MeleePlatoons nearest {Gatehouse} radius 50.0
This method of looking for a platoon will check to see if any platoons of the specific player of
any level from Melee 1 to Melee 10 (in this case but you can do the same for ranged platoons) are near the gatehouse. "MeleePlatoons" declares that any platoon of level 1-10 can be any platoon and if that platoon is of the specified player then it exists and is near the gatehouse. In this case the gate will open.
The line equal to oPlatoon which says "get platoon of type constant MeleePlatoons nearest {Gatehouse} radius 50.0" looks for any platoons between Melee levels 1-10 by saying that the variable "MeleePlatoons" holds the value of constants Melee type 1 to Melee type 10 and therefore platoons of any of those levels is a valid platoon.
In simplified terms of the above variable;
oPlatoon = look for a platoon of any player of any level between the min and max set
e.g.
oPlatoon = player 0 + Melee level 2 which therefore is a valid platoon.
Use of this variable declaration method is used in my AI script(s).