 |
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:17
|
|
code:
city_t tmpCity;
int_t tmpPlayer;
int_t tmpWonder;
void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
{
int_t i;
unit_t tmpUnit;
int_t tmpNum;
int_t numUnits;
int_t tmpPlayer2;
player[0] = tmpPlayer;
numUnits = player[0].units;
tmpPlayer2 = tmpPlayer;
if (IsPlayerAlive(tmpPlayer2)) {
// Make all Units non veteran, except Special Units
for (i = 0; i < numUnits; i = i + 1) {
GetUnitByIndex(tmpPlayer2, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 106 && tmpNum <= 112) {
ToggleVeteran(tmpUnit, 1);
} else {
ToggleVeteran(tmpUnit, 0);
}
}
}
// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
tmpNum = GetUnitsAtLocation(tmpLoc);
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
ToggleVeteran(tmpUnit, 1);
}
}
// Hammurabi
HandleEvent(CreateWonder) 'Hammurabi' post {
tmpWonder = value[0];
if(tmpWonder == WonderDB(WONDER_HANGING_GARDENS)) {
tmpCity = city[0];
tmpPlayer = tmpCity.owner;
CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
DisableTrigger('Hammurabi');
}
}
This is your Wonder Unit Code, IW. But could you make a small change. Instead of making the Wonder unit appear after finish building a Wonder could you make this unit appear after research an advance? Maybe appearing in the Capital City (or anywhere else if it became a problem)? And with a 20 % (1 out of 5) chance of happenning.
Last edited by Pedrunn on 14-01-2002 at 23:22
|
|
|  |
 |
|
Immortal Wombat
|
 |
in perpetuity
Dec 2000 time: 05:17
|
|
Fair enough 
The veteran function can remain the same. It deals with the unit, not the creation effect, so just leave that in. Then for every unit you want created, make one of these handlers (as in the wonder-unit code):
code:
HandleEvent(GrantAdvance) 'Hammurabi' post {
city_t tmpCity;
int_t tmpPlayer;
int_t tmpAdvance;
int_t randomnum;
tmpAdvance = value[0];
if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
randomnum = random(4);
if(randomnum > 3){
tmpPlayer = player[0];
int_t i;
i = 0;
while(i < player[0].cities){
GetCityByIndex(tmpPlayer, i, tmpCity);
city[0] = tmpCity;
if(UnitsAtLocation(city[0].location) != 12){
CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
}
else {
i = i + 1;
}
}
}
}
}
Just change two bits for each one. The name of the handler - in between the two ' s at the top, and then change the unit it refers to in the UnitDB( brackets.
Then in the veteran function you will need to change some things:
code:
if (tmpNum >= 106 && tmpNum <= 112) {
Make the numbers in there be the lower 'wonderunit' number, and upper 'wonderunit' number. So it only refers to the wonderunits you want.
It strikes me that the veteran function is never actually used in the code. I don't know how that got through...
Add these lines:
code:
HandleEvent(MoveUnits) 'MakeVeteran' pre {
location_t tmpLoc;
tmpLoc = unit[0].location;
tmpPlayer = unit[0].owner;
VeteranEffect(tmpLoc, tmpPlayer);
}
DISCLAIMER: untried, untested, bugs likely.
Last edited by Immortal Wombat on 14-01-2002 at 23:52
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:17
|
|
Is that correct?
OBS: I guess this definitions will be off:
city_t tmpCity;
int_t tmpWonder;
Or should i leave both there for no reason since they wont interfere?
Or are they needed?
code:
city_t tmpCity;
int_t tmpPlayer;
int_t tmpWonder;
void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
{
int_t i;
unit_t tmpUnit;
int_t tmpNum;
int_t numUnits;
int_t tmpPlayer2;
player[0] = tmpPlayer;
numUnits = player[0].units;
tmpPlayer2 = tmpPlayer;
if (IsPlayerAlive(tmpPlayer2)) {
// Make all Units non veteran, except Special Units
for (i = 0; i < numUnits; i = i + 1) {
GetUnitByIndex(tmpPlayer2, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 106 && tmpNum <= 112) {
ToggleVeteran(tmpUnit, 1);
} else {
ToggleVeteran(tmpUnit, 0);
}
}
}
// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
tmpNum = GetUnitsAtLocation(tmpLoc);
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
ToggleVeteran(tmpUnit, 1);
}
}
HandleEvent(GrantAdvance) 'Hammurabi' post {
city_t tmpCity;
int_t tmpPlayer;
int_t tmpAdvance;
int_t randomnum;
tmpAdvance = value[0];
if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
randomnum = random(4);
if(randomnum > 3){
tmpPlayer = player[0];
int_t i;
i = 0;
while(i < player[0].cities){
GetCityByIndex(tmpPlayer, i, tmpCity);
city[0] = tmpCity;
if(UnitsAtLocation(city[0].location) != 12){
CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
}
else {
i = i + 1;
}
}
}
}
}
HandleEvent(GrantAdvance) 'Alexander' post {
city_t tmpCity;
int_t tmpPlayer;
int_t tmpAdvance;
int_t randomnum;
tmpAdvance = value[0];
if(tmpAdvance == AdvanceDB(ADVANCE_INFANTRY_TACTICS)) {
randomnum = random(4);
if(randomnum > 3){
tmpPlayer = player[0];
int_t i;
i = 0;
while(i < player[0].cities){
GetCityByIndex(tmpPlayer, i, tmpCity);
city[0] = tmpCity;
if(UnitsAtLocation(city[0].location) != 12){
CreateUnit(tmpPlayer, UnitDB(UNIT_ALEXANDER), city[0].location, 0);
}
else {
i = i + 1;
}
}
}
}
}
Last edited by Pedrunn on 15-01-2002 at 00:45
|
|
|  |
 |
|  |
 |
|  |
 |
|  |
 |
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:17
|
|
IW, could you check if the code is right now?
code:
void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
HandleEvent(MoveUnits) 'MakeVeteran' pre {
location_t tmpLoc;
tmpLoc = unit[0].location;
tmpPlayer = unit[0].owner;
VeteranEffect(tmpLoc, tmpPlayer);
}
{
int_t i;
unit_t tmpUnit;
int_t tmpNum;
int_t numUnits;
int_t tmpPlayer2;
player[0] = tmpPlayer;
numUnits = player[0].units;
tmpPlayer2 = tmpPlayer;
if (IsPlayerAlive(tmpPlayer2)) {
// Make all Units non veteran, except Special Units
for (i = 0; i < numUnits; i = i + 1) {
GetUnitByIndex(tmpPlayer2, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 106 && tmpNum <= 112) {
ToggleVeteran(tmpUnit, 1);
} else {
ToggleVeteran(tmpUnit, 0);
}
}
}
// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
tmpNum = GetUnitsAtLocation(tmpLoc);
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
ToggleVeteran(tmpUnit, 1);
}
}
HandleEvent(GrantAdvance) 'Hammurabi' post {
city_t tmpCity;
int_t tmpPlayer;
int_t tmpAdvance;
int_t randomnum;
tmpAdvance = value[0];
if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
randomnum = random(4);
if(randomnum > 3){
tmpPlayer = player[0];
int_t i;
i = 0;
while(i < player[0].cities){
GetCityByIndex(tmpPlayer, i, tmpCity);
city[0] = tmpCity;
if(UnitsAtLocation(city[0].location) != 12){
CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
}
else {
i = i + 1;
}
}
}
}
}
I want to know if only one civ can get this unit or every civ that research the advance can have it (this mean every civ can have a hammurabi in the same game).
|
|
|  |
 |
|
Immortal Wombat
|
 |
in perpetuity
Dec 2000 time: 05:17
|
|
quote: Originally posted by Pedrunn
IW, could you check if the code is right now?
|
Not quite 
code:
void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
{
int_t i;
unit_t tmpUnit;
int_t tmpNum;
int_t numUnits;
int_t tmpPlayer2;
player[0] = tmpPlayer;
numUnits = player[0].units;
tmpPlayer2 = tmpPlayer;
if (IsPlayerAlive(tmpPlayer2)) {
// Make all Units non veteran, except Special Units
for (i = 0; i < numUnits; i = i + 1) {
GetUnitByIndex(tmpPlayer2, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 106 && tmpNum <= 112) {
ToggleVeteran(tmpUnit, 1);
} else {
ToggleVeteran(tmpUnit, 0);
}
}
}
// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
tmpNum = GetUnitsAtLocation(tmpLoc);
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
ToggleVeteran(tmpUnit, 1);
}
}
HandleEvent(MoveUnits) 'MakeVeteran' pre {
location_t tmpLoc;
tmpLoc = unit[0].location;
tmpPlayer = unit[0].owner;
VeteranEffect(tmpLoc, tmpPlayer);
}
HandleEvent(GrantAdvance) 'Hammurabi' post {
city_t tmpCity;
int_t tmpPlayer;
int_t tmpAdvance;
int_t randomnum;
tmpAdvance = value[0];
if(tmpAdvance == AdvanceDB(ADVANCE_IRON_WORKING)) {
randomnum = random(4);
if(randomnum >= 3){
tmpPlayer = player[0];
int_t i;
i = 0;
while(i < player[0].cities){
GetCityByIndex(tmpPlayer, i, tmpCity);
city[0] = tmpCity;
if(UnitsAtLocation(city[0].location) != 12){
CreateUnit(tmpPlayer, UnitDB(UNIT_HAMMURABI), city[0].location, 0);
}
else {
i = i + 1;
}
}
}
}
}
[/quote]
That is now right.
quote:
I want to know if only one civ can get this unit or every civ that research the advance can have it (this mean every civ can have a hammurabi in the same game). |
Every civ can get one. Is this right?
If not, add the line
code:
DisableTrigger('Hammurabi');
below the CreateUnit line. This will mean it only fires once in the game. First person to get there gets the chance of getting it. If you want everyone to have the chance of getting it, leave it as it is.
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:17
|
|
quote:
below the CreateUnit line. This will mean it only fires once in the game. First person to get there gets the chance of getting it. If you want everyone to have the chance of getting it, leave it as it is.
|
Actually i rather have every civ with a chance of the unit in the same game. so i will leave the way it is.
Last edited by Pedrunn on 19-01-2002 at 18:01
|
|
|  |
 |
|
Pedrunn
|
 |
of Natal, Brazil
Jul 2001 time: 02:17
|
|
Oh Oh!
code:
No fuction named UnitsAtLocation
I'm getting a message like that for each unit i add.
So i changed this fuction by
code:
GetUnitsAtLocation
and the errors messages disappeared. What i did was right?
I'm going to test it now anyway.
Last edited by Pedrunn on 19-01-2002 at 22:17
|
|
|  |
 |
|
Immortal Wombat
|
 |
in perpetuity
Dec 2000 time: 05:17
|
|
Just use this:
code:
void_f VeteranEffect (location_t tmpLoc, int_t tmpPlayer)
{
int_t i;
unit_t tmpUnit;
int_t tmpNum;
int_t numUnits;
int_t tmpPlayer2;
player[0] = tmpPlayer;
numUnits = player[0].units;
tmpPlayer2 = tmpPlayer;
if (IsPlayerAlive(tmpPlayer2)) {
// Make all Units non veteran, except Special Units
for (i = 0; i < numUnits; i = i + 1) {
GetUnitByIndex(tmpPlayer2, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 106 && tmpNum <= 112) {
ToggleVeteran(tmpUnit, 1);
} else {
ToggleVeteran(tmpUnit, 0);
}
}
}
// Make all Units veterans who share the location Alexander, Robin Hood and Richard The Lion Heart
tmpNum = GetUnitsAtLocation(tmpLoc);
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
ToggleVeteran(tmpUnit, 1);
}
}
HandleEvent(MoveUnits) 'MakeVeteran' pre {
location_t tmpLoc;
tmpLoc = unit[0].location;
tmpPlayer = unit[0].owner;
VeteranEffect(tmpLoc, tmpPlayer);
}
Make sure the tmpNum in the first function has the right boundaries (includes only the wonder units) and that you have not got CannotBuild lines in their units.txt entries.
Ben
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:17. Apolyton Time is 00:17. |
top of page
|
| archivepost |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|