Modding attempt to penalize cavalry vs elephants

Post Reply
welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Sat Sep 08, 2007 11:56 am

Modding attempt to penalize cavalry vs elephants

Post by welk »

I have began to explore scripts, and to see how to work

As exercice, I tried to set a heavy handicap for Cavalry when cavalry atacks elephants : I want to have a percent=0 in any case (horses are afreid by elephants = so, they can't attack them)

My "exercise" is that : I have included blue lines in a existant function, and it seems work perfect. I don't know if my "exercise" is very "orthodox" (because I have no knoledges in coding), but it's works in game :mrgreen:
(perhaps is it not necessary because the game has already that, but I wanted to learn how to work with scripts and to see if this sort of adding makes or do not make bugs)

In CombatTools.BSF (what I added is in blue)

FUNCTION GetShootingWeaponModifier(me, target, distance, volley, test, print)
{
int percent;
int POA;
int POA_adjustment;
int total_modifier;
int any_shooters;
int range;
int any_printed;
int shots;
int capability;
int effective_armour;

any_printed = 0;
total_modifier = 0;
any_shooters = 0;

if (print == 1)
{
PrintStringIndexedX(1, test, "IDS_TT_SHOOTVOLLEY", volley);
}

// Handgun
percent = GetAttrib(me, "Handgun");
if (percent > 0)
{
any_shooters = 1;
if (distance > 1)
{
percent = 0;
}
else
{
percent *= CloseRangeNonLightFootShootingModifier(me);
percent /= 100;
}

if (print == 1)
{
PrintStringLiteralX(1, test, "\n");
PrintStringIndexedX(1, test, "IDS_CAPABILITY", 4);
PrintEffectiveShots(test, me, percent, volley, 0);
any_printed = 1;
}

if (target == -1) // Used for calculating ShootingRating
{
POA = -50; // Average POA vs Mounted and Foot
}
else
{
POA = 0;
}

if (IsUnitSquadType(me, "Cavalry") == 1) // If Cavalry attacks elephants, the capabilities percent for this attack is always 0 => no effect)
{
any_shooters = 1;
if (IsUnitSquadType(target, "Elephants") == 1)
{
percent = 0;
}

}



One thing I have top say :
1/ This is very interessant to work in modding on this game
2/ But you, FOG2/Slitherine staff; should get us a way to rationalize our work efforts : it would be great to have a complete list :
* of usable functions
* of usable terms encountered in scripts (what is me, what is POA, etc
* of usable definition
sample : to found how "declare" elephants as attackant in my script work, I had to search in the script a place where elephants were used, to see how to "declare" my elephants
If I had had a list, it would have been very easy
Sample of list :

Target definitions : if (IsUnitSquadType(target, "elephants")
etc (for each type units)

Squads definitions : if (IsUnitSquadType(me, "Cavalry")
etc (for each type units)


Hubert Cater did that for Strategic command to help modders to realize scripts : complete lists of functions, declarations,definitions, etc and it hels the work. At this time, we work as blinds, we have to ask for each little step : what is what ? what is this ? etc etc : this process is not very logical and rationalized

A complete list of functions, target definitions, int values, squads definitions, etc would be great (as I did in others threads with the complete list of usable files and usable suqads data)

And a question, please : where is in vanilla scripts the lines concerning fighting Cavalry vs elephangts (defense or attack) ?
My two loved naval games :
Victory at sea
Mare Nostrum
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: Modding attempt to penalize cavalry vs elephants

Post by rbodleyscott »

welk wrote:One thing I have top say :
1/ This is very interessant to work in modding on this game
2/ But you, FOG2/Slitherine staff; should get us a way to rationalize our work efforts : it would be great to have a complete list :
* of usable functions
* of usable terms encountered in scripts (what is me, what is POA, etc
* of usable definition
sample : to found how "declare" elephants as attackant in my script work, I had to search in the script a place where elephants were used, to see how to "declare" my elephants
If I had had a list, it would have been very easy
Sample of list :

Target definitions : if (IsUnitSquadType(target, "elephants")
etc (for each type units)

Squads definitions : if (IsUnitSquadType(me, "Cavalry")
etc (for each type units)


Hubert Cater did that for Strategic command to help modders to realize scripts : complete lists of functions, declarations,definitions, etc and it hels the work. At this time, we work as blinds, we have to ask for each little step : what is what ? what is this ? etc etc : this process is not very logical and rationalized

A complete list of functions, target definitions, int values, squads definitions, etc would be great (as I did in others threads with the complete list of usable files and usable suqads data)
Fair enough. We would want to do that in time, but it isn't the highest priority we have at the moment because of pressure of developing the vanilla game further.
And a question, please : where is in vanilla scripts the lines concerning fighting Cavalry vs elephants (defense or attack) ?
The simple answer is there aren't any lines that specifically do that.

What there are is:

1) Code that disorders cavalry when close to elephants. The PercentDisordered() function in CombatTools.BSF
2) Effect of elephants on the various cavalry capabilities in GetImpactPOA() and GetMeleePOA() in CombatTools.BSF

If you want to disallow cavalry from ever charging elephants you would do it in ChargePermitted() function in CombatTool.BSF
Richard Bodley Scott

Image
welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding attempt to penalize cavalry vs elephants

Post by welk »

Ok, thanks. Hope you will have time to do later

Juste 2 questions :
I encouter very ofty "me" or (me) in the scripts. And also POA.

What means these, please ?
My two loved naval games :
Victory at sea
Mare Nostrum
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28261
Joined: Sun Dec 04, 2005 6:25 pm

Re: Modding attempt to penalize cavalry vs elephants

Post by rbodleyscott »

welk wrote:Ok, thanks. Hope you will have time to do later

Juste 2 questions :
I encouter very ofty "me" or (me) in the scripts. And also POA.

What means these, please ?
me is just an integer variable. It is usually used as the parameter representing the id of the unit to which the function primarily refers. It is a local variable and has no existence outside the function in which it is a parameter.

POA = points of advantage. What the combat system revolves around.
Richard Bodley Scott

Image
welk
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Sat Sep 08, 2007 11:56 am

Re: Modding attempt to penalize cavalry vs elephants

Post by welk »

Ok, thanks for infos :wink:
My two loved naval games :
Victory at sea
Mare Nostrum
Post Reply

Return to “Field of Glory II: Modding”