Hi guys, could someone of the coders explain me this part of the <b>AICannon.c</b> in deep, please?
// calculate recharge time for cannon
float Cannon_GetRechargeTime()
{
aref aCharacter = GetEventData();
ref rCannon = GetCannonByType(sti(aCharacter.Ship.Cannons.Type));
float fCannonSkill = stf(aCharacter.TmpSkill.Cannons); // 0.1 to 1.0
if (!CheckAttribute(rCannon, "ReloadTime"))
{
string CannonType = GetCannonName(sti(aCharacter.Ship.Cannons.Type));
if (CannonType != "No Cannons") trace("Cannon " + CannonType + " has no reloadTime!"); // LDH - don't need trace if no cannons
return 20.0; // LDH - changed from 1.0 so a real cannon will have a reasonable reload time, just in case
} // NK 05-07-18 fix for "No Cannons"
float fReloadTime = sti(rCannon.ReloadTime); // reload time in seconds
float fMultiply = AIShip_isPerksUse(aCharacter.TmpPerks.FastReload, 1.0, 0.<img src="style_emoticons/<#EMO_DIR#>/cool.gif" style="vertical-align:middle" emoid="8)" border="0" alt="cool.gif" />;
fMultiply = AIShip_isPerksUse(aCharacter.TmpPerks.ImmediateReload, fMultiply, 0.5);
// boal ReloadTime for cannons is influenced by Ship Crew -->
//fMultiply = fMultiply * Bring2RangeNoCheck(4.0, 1.0, 0.0, 1.0, stf(aCharacter.Ship.Crew.MinRatio));
// Ship.Crew.Quantity - ñêîêà Ãà ðîäó ñåé÷à ñ
// Ship.Crew.Morale - òåêóùà ÿ ìîðà ëü 0..99 45 - ñðåäÃÿÿ
// Ship.maxcrew
// Ship.MinCrew
// aCharacter.skill.Leadership - ñòðîêà ñ ÷èñëîì
float cQ = GetCrewQuantity(aCharacter);
//float cMC = GetMaxCrewQuantity(aCharacter);
float cCM = 70;
if(CheckAttribute(aCharacter,"Ship.Crew.Morale")) cCM = sti(aCharacter.Ship.Crew.Morale);
// unneeded due to damage scaling based on crew qty NK 04-09-15
/*if(cMC)
{
fReloadTime = fReloadTime * (1 + (1 - cQ / cMC) * 4);
}*/
// NK can qty 05-04-18 -->
// now do crew qty scaling for above MIN_CREW_FOR_ALL_GUNS
int mcq = GetMinCrewQuantity(aCharacter);
if(mcq)
{
int canqty = GetCannonQuantity(&aCharacter);
if(canqty)
{
float crewratio = makefloat(cQ) / makefloat(mcq*5); //yes can be >1!
ref rship = GetShipByType(GetCharacterShipType(&aCharacter));
aref arship; makearef(arship, aCharacter.ship);
int fullqty = GetLocalShipAttrib(&arship, rship, "MaxCanQty");
crewratio = crewratio * makefloat(fullqty) / makefloat(canqty); // so if can qty decreases, not as much crew needed.
if(crewratio > MIN_CREW_FOR_ALL_GUNS)
{
fReloadTime *= Bring2Range(1.0, 1/(1.5*BEST_RATE_FOR_ALL_CREW), MIN_CREW_FOR_ALL_GUNS, 1.5, crewratio);
}
}
else { fReloadTime *= 10; }
}
//else { trace("char " + aCharacter.id + " name " + aCharacter.lastname + " has 0 mincq!"); }
// NK <--
fReloadTime = fReloadTime * (1 + (1 - cCM / 70) / 10);
//Log_SetStringToLog(aCharacter.id);
// debug info
//if( aCharacter.id == "Blaze")
//{
//Log_SetStringToLog("RTime "+fReloadTime+" Multiply "+ fMultiply +" CannonSkill " + fCannonSkill +" q "+aCharacter.Ship.Crew.Quantity+" m "+sti(refBaseShip.MaxCrew) + " ml "+aCharacter.Ship.Crew.Morale);
//}
// boal ReloadTime for cannons is influenced by Ship Crew <--
return fMultiply * (fReloadTime - fCannonSkill * (fReloadTime / 4.0));
}
i would like to know what at all influence the reloadtime of the ships cannons!
did the AICannon.c only influence the AI or even the Players ship?
especially this two lines of the code i don´t understand:
1)
fReloadTime *= Bring2Range(1.0, 1/(1.5*BEST_RATE_FOR_ALL_CREW), MIN_CREW_FOR_ALL_GUNS, 1.5, crewratio);
2)
Log_SetStringToLog("RTime "+fReloadTime+" Multiply "+ fMultiply +" CannonSkill " + fCannonSkill +" q "+aCharacter.Ship.Crew.Quantity+" m "+sti(refBaseShip.MaxCrew) + " ml "+aCharacter.Ship.Crew.Morale);
Thanks a million!
CU THOMAS
// calculate recharge time for cannon
float Cannon_GetRechargeTime()
{
aref aCharacter = GetEventData();
ref rCannon = GetCannonByType(sti(aCharacter.Ship.Cannons.Type));
float fCannonSkill = stf(aCharacter.TmpSkill.Cannons); // 0.1 to 1.0
if (!CheckAttribute(rCannon, "ReloadTime"))
{
string CannonType = GetCannonName(sti(aCharacter.Ship.Cannons.Type));
if (CannonType != "No Cannons") trace("Cannon " + CannonType + " has no reloadTime!"); // LDH - don't need trace if no cannons
return 20.0; // LDH - changed from 1.0 so a real cannon will have a reasonable reload time, just in case
} // NK 05-07-18 fix for "No Cannons"
float fReloadTime = sti(rCannon.ReloadTime); // reload time in seconds
float fMultiply = AIShip_isPerksUse(aCharacter.TmpPerks.FastReload, 1.0, 0.<img src="style_emoticons/<#EMO_DIR#>/cool.gif" style="vertical-align:middle" emoid="8)" border="0" alt="cool.gif" />;
fMultiply = AIShip_isPerksUse(aCharacter.TmpPerks.ImmediateReload, fMultiply, 0.5);
// boal ReloadTime for cannons is influenced by Ship Crew -->
//fMultiply = fMultiply * Bring2RangeNoCheck(4.0, 1.0, 0.0, 1.0, stf(aCharacter.Ship.Crew.MinRatio));
// Ship.Crew.Quantity - ñêîêà Ãà ðîäó ñåé÷à ñ
// Ship.Crew.Morale - òåêóùà ÿ ìîðà ëü 0..99 45 - ñðåäÃÿÿ
// Ship.maxcrew
// Ship.MinCrew
// aCharacter.skill.Leadership - ñòðîêà ñ ÷èñëîì
float cQ = GetCrewQuantity(aCharacter);
//float cMC = GetMaxCrewQuantity(aCharacter);
float cCM = 70;
if(CheckAttribute(aCharacter,"Ship.Crew.Morale")) cCM = sti(aCharacter.Ship.Crew.Morale);
// unneeded due to damage scaling based on crew qty NK 04-09-15
/*if(cMC)
{
fReloadTime = fReloadTime * (1 + (1 - cQ / cMC) * 4);
}*/
// NK can qty 05-04-18 -->
// now do crew qty scaling for above MIN_CREW_FOR_ALL_GUNS
int mcq = GetMinCrewQuantity(aCharacter);
if(mcq)
{
int canqty = GetCannonQuantity(&aCharacter);
if(canqty)
{
float crewratio = makefloat(cQ) / makefloat(mcq*5); //yes can be >1!
ref rship = GetShipByType(GetCharacterShipType(&aCharacter));
aref arship; makearef(arship, aCharacter.ship);
int fullqty = GetLocalShipAttrib(&arship, rship, "MaxCanQty");
crewratio = crewratio * makefloat(fullqty) / makefloat(canqty); // so if can qty decreases, not as much crew needed.
if(crewratio > MIN_CREW_FOR_ALL_GUNS)
{
fReloadTime *= Bring2Range(1.0, 1/(1.5*BEST_RATE_FOR_ALL_CREW), MIN_CREW_FOR_ALL_GUNS, 1.5, crewratio);
}
}
else { fReloadTime *= 10; }
}
//else { trace("char " + aCharacter.id + " name " + aCharacter.lastname + " has 0 mincq!"); }
// NK <--
fReloadTime = fReloadTime * (1 + (1 - cCM / 70) / 10);
//Log_SetStringToLog(aCharacter.id);
// debug info
//if( aCharacter.id == "Blaze")
//{
//Log_SetStringToLog("RTime "+fReloadTime+" Multiply "+ fMultiply +" CannonSkill " + fCannonSkill +" q "+aCharacter.Ship.Crew.Quantity+" m "+sti(refBaseShip.MaxCrew) + " ml "+aCharacter.Ship.Crew.Morale);
//}
// boal ReloadTime for cannons is influenced by Ship Crew <--
return fMultiply * (fReloadTime - fCannonSkill * (fReloadTime / 4.0));
}
i would like to know what at all influence the reloadtime of the ships cannons!
did the AICannon.c only influence the AI or even the Players ship?
especially this two lines of the code i don´t understand:
1)
fReloadTime *= Bring2Range(1.0, 1/(1.5*BEST_RATE_FOR_ALL_CREW), MIN_CREW_FOR_ALL_GUNS, 1.5, crewratio);
2)
Log_SetStringToLog("RTime "+fReloadTime+" Multiply "+ fMultiply +" CannonSkill " + fCannonSkill +" q "+aCharacter.Ship.Crew.Quantity+" m "+sti(refBaseShip.MaxCrew) + " ml "+aCharacter.Ship.Crew.Morale);
Thanks a million!
CU THOMAS