• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Discussion Improved for shooting from pistols

Myth

Freebooter
Good afternoon. Today I want to share the improvements for shooting from the pistol. First, we fix the bug. The hero is not fully loaded with a pistol, enough bullets. Just waiting for the recharge. But it's worth to move from the location to the location as the gun is immediately charged. I'm talking about the original game. No one has fixed it.

Find "void SetEquipedItemToCharacter" in "\Program\characters\characterUtilite.c"

We make a duplicate of this function and rename it.

My new function call "SetEquipedItemToCharacterNew"

In the duplicate, we remove the lines

if(CheckAttribute(arItm,"chargeQ"))
{ LAi_GunSetChargeQuant(chref,sti(arItm.chargeQ));
} else
{ LAi_GunSetChargeQuant(chref,0);
}

Then we look for the function and "ExecuteCharacterEquip" replace it with the analogue below.

void ExecuteCharacterEquip(ref chref)
{
string stmp;
stmp = GetCharacterEquipByGroup(chref,BLADE_ITEM_TYPE);
if(stmp!="")
{
if(chref.id == pchar.id || IsOfficer(chref))
{
SetEquipedItemToCharacterNew(chref, BLADE_ITEM_TYPE, stmp);
}
else
{
SetEquipedItemToCharacter(chref, BLADE_ITEM_TYPE, stmp);
}
}
stmp = GetCharacterEquipByGroup(chref,GUN_ITEM_TYPE);
if(stmp!="")
{
if(chref.id == pchar.id || IsOfficer(chref))
{
SetEquipedItemToCharacterNew(chref, GUN_ITEM_TYPE, stmp);
}
else
{
SetEquipedItemToCharacter(chref, GUN_ITEM_TYPE, stmp);
}
}
}

Now the gun of the hero and his officers will not be charged when we move from the location to the location. It will be necessary to wait for it to be charged.
 
For convenience, I am writing a second improvement separately. The second improvement is that we will improve the algorithm for target selection. The result is that if there are no hostile or neutral characters nearby, then the player can not shoot the pistol.

New "LAi_CharacterCanFrie" for "Program\Loc_ai\LAi_utils.c"

bool LAi_CharacterCanFrie(aref chr)
{
if(!CheckAttribute(chr, "chr_ai.chargeprc"))
{
chr.chr_ai.chargeprc = "1";
chr.chr_ai.charge = 0;
return false;
}
if(chr.id == pchar.id && chr.chr_ai.type == LAI_TYPE_PLAYER)
{
int ichr = LAi_type_Player_FindNearEnemy(chr, 20);
if(ichr == -1)
{
return false;
}
}
if(stf(chr.chr_ai.charge) >= 1.0) return true;

return false;
}

From "Program\Loc_ai\types\LAi_player.c"

int LAi_type_Player_FindNearEnemy(aref chr, int radius)
{
int num, i, idx, cnt;
if(CheckAttribute(loadedlocation,"townsack") || CheckAttribute(loadedlocation,"parent_colony") || bEncInlocation) // for city location & Jungle with random events
{
num = FindNearCharacters(chr, radius, -1.0, -1.0, 0.01, false, true);
if(num < 0) return -1;
for (i =0; i<num; i++)
{
if (!IsOfficer(&characters[sti(chrFindNearCharacters.index)]))
{
idx = sti(chrFindNearCharacters.index);
return idx;
}
}
}
else //All other locations where there can be a battle.
{
num = FindNearCharacters(chr, 5.0, -1.0, -1.0, 0.001, false, true);
if(num <= 0)
{
chrFindNearCharacters[0].index = "-1";
return -1;
}
cnt = 0;
for(i = 0; i < num; i++)
{
idx = sti(chrFindNearCharacters.index);
if(LAi_group_IsEnemy(chr, &Characters[idx])) return idx;
}
}
}

The number 20 can be replaced by a new parameter for pistols with a range. I have no time for this yet.

About bEncInlocation - I added this flag to the file "Program\Loc_ai\LAi_monsters.c".
An example of an appendix below.

case 3:
if (rand(10) > 3) return false;
bEncInlocation = true;
num = GetAttributesNum(grp);
if (num <= 0) num = 1;
if (sti(pchar.rank) > 14) iRank = sti(pchar.rank) + sti(MOD_SKILL_ENEMY_RATE*2.5/num);
else iRank = sti(pchar.rank) + sti(MOD_SKILL_ENEMY_RATE*1.6/num);
str = "Patrol"+ location.index + "_";
string sGroup = "PatrolGroup_" + location.indeхж
for(i = 0; i < num; i++)
{
if (i == 0)
{
chr = GetCharacter(NPC_GenerateCharacter(str + i, "off_"+NationShortName(iNation)+"_"+(rand(1)+1), "man", "man", iRank+2, iNation, 1, true));
SetFantomParamFromRank(chr, iRank+2, true);
}
else
{
if (i == 3)
{
chr = GetCharacter(NPC_GenerateCharacter(str + i, NationShortName(iNation)+"_mush_"+(rand(2)+1), "man", "mushketer", iRank, iNation, 1, false));
//SetFantomParamFromRank(chr, iRank, true);
}
else
{
chr = GetCharacter(NPC_GenerateCharacter(str + i, "sold_"+NationShortName(iNation)+"_"+(rand(7)+1), "man", "man", iRank, iNation, 1, true));
SetFantomParamFromRank(chr, iRank, true);
}
}
chr.City = sCity;
chr.CityType = "soldier";
chr.greeting = "soldier_arest";
chr.dialog.filename = "Enc_Patrol.c";
chr.EncQty = num;
LAi_SetStayType(chr);
LAi_SetCheckMinHP(chr, LAi_GetCharacterHP(chr)-1, false, "LandEnc_PatrolBeforeDialog");
LAi_group_MoveCharacter(chr, sGroup);
locator = GetAttributeName(GetAttributeN(grp, i));
ChangeCharacterAddressGroup(chr, location.id, encGroup, locator);
}
LAi_group_SetLookRadius(sGroup, 100);
LAi_group_SetHearRadius(sGroup, 100);

str = "EncPatrol_" + location.index;
pchar.quest.(str).win_condition.l1 = "locator";
pchar.quest.(str).win_condition.l1.location = location.id;
pchar.quest.(str).win_condition.l1.locator_group = "encdetector";
pchar.quest.(str).win_condition.l1.locator = encGroup;
pchar.quest.(str).win_condition = "LandEnc_PatrolBegin";
pchar.quest.(str).EncQty = num; //кол-во патрульных
pchar.quest.(str).LocIdx = location.index;
str = "TimePatrol_" + location.index;
pchar.quest.(str).win_condition.l1 = "Timer";
pchar.quest.(str).win_condition.l1.date.day = GetAddingDataDay(0, 0, 1);
pchar.quest.(str).win_condition.l1.date.month = GetAddingDataMonth(0, 0, 1);
pchar.quest.(str).win_condition.l1.date.year = GetAddingDataYear(0, 0, 1);
pchar.quest.(str).win_condition = "LandEnc_PatrolOver";
pchar.quest.(str).LocIdx = location.index;
str = location.index;
pchar.GenQuest.(str).nation = iNation;
break;
 
Back
Top