Camaro'
2010-11-05 10:51:49
Rawr
The idea of fighting.simba is
The idea is that once the actual functions are done, all that would need to be added is an object record for whatever monster you want to fight. Once it's added as an object, you would set it up in DeclarePlayers, and it would fight it.
New Feature: Bone Burying!
Fighting:
[INDENT]Completed[/INDENT]
[INDENT]Checks to see if the monster is in fight before fighting: [/INDENT]
[INDENT][INDENT]-Works[/INDENT][/INDENT]
Bone Burying:
[INDENT]Completed and tested.[/INDENT]
Bugs:
[INDENT]Not known.[/INDENT]
Monsters:
[INDENT]White Chicken(MONSTER_CHICKEN_WHITE)[/INDENT]
[INDENT]Brown Chicken(MONSTER_CHICKEN_BROWN)[/INDENT]
[INDENT]Giant Rat(MONSTER_RAT_GIANT)[/INDENT]
[INDENT]Every Cow(MONSTER_COW_SPOT, MONSTER_COW_DARK, MONSTER_COW_LIGHT, MONSTER_COW_LIGHT_CALF)[/INDENT]
Loot system:
[INDENT]Completed[/INDENT]
[INDENT][INDENT]-Tested and it works :)[/INDENT][/INDENT]
[INDENT]Chicken : Bones[/INDENT]
[INDENT]Rat: Bones[/INDENT]
[INDENT]Cows: Bones, Raw Beef, and Cow hide[/INDENT]
Progress Report:
[INDENT]Incomplete, I have no clue of how it works[/INDENT]
Eating:
[INDENT]Completed[/INDENT]
[INDENT][INDENT]-Not Tested[/INDENT][/INDENT]
Equipment:
[INDENT]Nothing started regarding equipment.[/INDENT]
Skills Const:
[INDENT]Only set to use attack right now[/INDENT]
[INDENT]I have some ideas I will work on later on.[/INDENT]
Setup Fighting:
[INDENT]Completed[/INDENT]
[INDENT][INDENT]Loads Monsters[/INDENT][/INDENT]
Rawr
Fighting.simba
{******************************************************************************}
{ Procedure MSI_EatFood(); }
{ By: Camaro' }
{ Date: January 26th, 2011 }
{ Description: Eats food, will run away if no food. }
{******************************************************************************}
function MSI_EatFood(): Boolean;
var
Slots: TIntegerArray;
I: Integer;
begin
if (HPPercent > 60) then
begin
Result := True;
Exit;
end;
MSI_Debug('Eating food!');
for I := FISH_COOKED_SHRIMP to FISH_COOKED_SWORDFISH do
begin
Slots := MSI_FindItemSlots(i);
if (Length(Slots) <= 0) then
Continue;
MSI_ClickItemSlot(Slots[I], ['Eat']);
Wait(500 + Random(500));
if (HPPercent > 60) then
begin
Result := True;
Exit;
end;
end;
SetRun(True);
with MSI_Players[CurrentPlayer] do
case Lowercase(Scripts[CurrentScript].RunDirection) of
'north':
begin
Mouse(MMCX, MMCY - 35, 10, 10, true); //North
MSI_Flag(0);
end;
'south':
begin
Mouse(MMCX, MMCY + 35, 10, 10, true); //South
MSI_Flag(0);
end;
'west':
begin
Mouse(MMCX + 35, MMCY, 10, 10, true); //West
MSI_Flag(0);
end;
'east':
begin
Mouse(MMCX - 35, MMCY, 10, 10, true); //East
MSI_Flag(0);
end;
end;
MSI_Debug('We are out of food!');
end;
{******************************************************************************}
{ Procedure MSI_InFight; }
{ By: Camaro' }
{ Date: 15 December 2010 }
{ Description: Returns true if you are in a fight }
{******************************************************************************}
function MSI_InFight: Boolean;
var
TP : TPoint;
begin
MSI_AddHeader('MSI_InFight');
Result := SRL_InFight;
MSI_CloseHeader('MSI_InFight: '+BoolToStr(Result));
end;
{******************************************************************************}
{ function MSI_WaitWhileFighting : Boolean; }
{ By: Camaro' }
{ Date: 11 December 2010 }
{ Description: Wait's until the monster is killed. }
{******************************************************************************}
function MSI_WaitWhileFighting : Boolean;
var
cts, t, MonColorCount: Integer;
Arr, tpArr: array of TPoint;
SearchBox: TBox;
begin
MSI_AddHeader('MSI_WaitWhileFighting');
MSI_AddHeader('Entering loop');
MSI_Flag(0);
MarkTime(T);
repeat
if not (MSI_EatFood) then
Break;
MSI_FindRandoms;
if (not(MSI_InFight)) then
begin
MSI_Debug('No more monster, exiting loop');
Break;
end;
Result := True;
MSI_AntiBan(RandomRange(0, 3000), ANTI_BAN_CHANCE);
Wait(20 + Random(20));
if (TimeFromMark(T) > 35000) then
begin
MSI_Debug('Took over 25 seconds while fighting, exiting loop');
Break;
end;
until(False);
MSI_CloseHeader('Out of loop');
MSI_CloseHeader('MSI_WaitWhileFighting : Exit');
end;
{******************************************************************************}
{ function MSI_MakeLootArray(monsterLoot: TIntegerArray): TIntegerArray; }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: Checks and verifys the users loot options. }
{******************************************************************************}
function MSI_MakeLootArray(monsterLoot: TIntegerArray): TIntegerArray;
var
I, J : Integer;
playerLoots : TIntegerArray;
begin
playerLoots := MSI_Players[CurrentPlayer].Scripts[CurrentScript].Loot;
for i := 0 to High(playerLoots) do // User Specified
for j := 0 to High(monsterLoot) do // Global Monster Loots
if (playerLoots[I] = monsterLoot[J]) then
begin
SetLength(Result, Length(Result) + 1);
Result[High(Result)] := playerLoots[J];
MSI_SubDebug('Player Loots['+Inttostr(i)+'] = '+IntToStr(playerLoots[i])+'');
Break;
end;
end;
{******************************************************************************}
{ Procedure MSI_PickLoot(Loots: TIntegerArray); }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: Picks loot from the ground. }
{******************************************************************************}
procedure MSI_PickLoot(Loots: TIntegerArray);
var
LootIndex : Integer;
TS : TStringArray;
//Loots : TIntegerArray;
begin
if (Length(Loots) < 1) then
Exit;
MSI_AddHeader('MSI_PickLoot');
if (MSI_FindObjects(Loots, LootIndex, ClickRight)) then
if (WaitOption(MSI_Objects[Loots[LootIndex]].Option, 100)) then
MSI_Flag(0)
else
begin
if (Random(5) = 2) then
MakeCompass(random(360));
end;
MSI_CloseHeader('MSI_PickLoot' + MSI_Objects[Loots[LootIndex]].Name);
end;
{******************************************************************************}
{ function MSI_LoadMonster(which : Integer): TMonster; }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: Loads the monster based on 'which'. }
{******************************************************************************}
function MSI_LoadMonster(which : Integer): TMonster;
begin
case which of
MONSTER_COW_SPOT, MONSTER_COW_DARK, MONSTER_COW_LIGHT, MONSTER_COW_LIGHT_CALF:
with Result do
begin
Name := 'Cow';
LootObjs := [BONES_NORMAL, RAW_BEEF, COWHIDE]; //objects
LootItems := [];// items
Constant := which;
ColorInfo := MSI_Objects[Constant];
end;
MONSTER_RAT_GIANT:
with Result do
begin
Name := 'Giant Rat';
LootObjs := [BONES_NORMAL]; //objects
LootItems := [];// items
Constant := which;
ColorInfo := MSI_Objects[Constant];
end;
MONSTER_CHICKEN_BROWN:
with Result do
begin
Name := 'Brown Chicken';
LootObjs := [BONES_NORMAL]; //objects
LootItems := [];// items
Constant := which;
ColorInfo := MSI_Objects[Constant];
end;
MONSTER_CHICKEN_WHITE:
with Result do
begin
Name := 'White Chicken';
LootObjs := [BONES_NORMAL]; //objects
LootItems := [];// items
Constant := which;
ColorInfo := MSI_Objects[Constant];
end;
end;
end;
{******************************************************************************}
{ function MSI_LoadAllMonsters(Start, Finish : Integer): Boolean; }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: Loads all monsters. }
{******************************************************************************}
function MSI_LoadAllMonsters(Start, Finish : Integer) : Boolean;
var
I : Integer;
begin
for I := Start to Finish do
MSI_Monsters[I] := MSI_LoadMonster(I);
Result := True;
end;
{******************************************************************************}
{ function MSI_SetupFighting: Boolean; }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: Sets up the fighting script. }
{******************************************************************************}
function MSI_SetupFighting: Boolean;
var
I: Integer;
begin
MSI_LoadAllMonsters(MONSTER_CHICKEN_WHITE, MONSTER_COW_LIGHT_CALF);
with MSI_Players[CurrentPlayer] do
for I := 0 to High(Scripts[CurrentScript].Monsters) do
MSI_Monsters[Scripts[CurrentScript].Monsters[I]].PossibleLoot := MSI_MakeLootArray(MSI_Monsters[Scripts[CurrentScript].Monsters[I]].LootObjs);
Result := True;
end;
{ //checks if ur kill count is over the amountToKill
function MSI_CheckKills(MonsterIndex: Integer) : Boolean;
var
maxKill : TIntegerArray;
begin
maxKill := MSI_Players[CurrentPlayer].Scripts[CurrentScript].MaxKills;
if (MSI_Players[CurrentPlayer].Scripts[CurrentScript].TotalKills > maxKill[MonsterIndex]) then
Result := True;
end;
}
{******************************************************************************}
{ function MSI_Fight: Boolean; }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: Fights the monster, returns true when it clicks 'attack'. }
{******************************************************************************}
function MSI_Fight: Boolean;
var
I, MonsterIndex, FS, TX, TY: Integer;
NMonsters : TIntegerArray;
TP : TPoint;
begin
if (MSI_InFight) then
begin
Result := True;
Exit;
end;
nMonsters := MSI_Players[CurrentPlayer].Scripts[CurrentScript].Monsters;
with MSI_Players[CurrentPlayer] do
if (not MSI_Scripts[Scripts[CurrentScript].Name].ClickClosest) then
nMonsters := MSI_RearrangeArray(nMonsters, Scripts[CurrentScript].Priority);
MSI_AddHeader('MSI_Fighting');
if (MSI_FindObjects(nMonsters, MonsterIndex, Nothing)) then
begin
TP := Point(MSI_Objects[nMonsters[MonsterIndex]].X, MSI_Objects[nMonsters[MonsterIndex]].Y);
if (not(IsFightAt(TP.X, TP.Y))) then
begin
if (TP.X > 0) and (TP.Y > 0) then
begin
MMouse(TP.X, TP.Y, 5, 5);
if (WaitUpText(MSI_Objects[nMonsters[MonsterIndex]].UpText, 100)) then
begin
GetMousePos(TX, TY);
Mouse(TX, TY, 0, 0, False);
if (WaitOption(MSI_Objects[nMonsters[MonsterIndex]].Option, 100)) then
begin
Result := True;
MSI_Flag(0);
end;
end;
end;
end;
end;
if (Random(8) = 2) then
MakeCompass(random(360));
Wait(500 + Random(500));
MSI_CloseHeader('Fighting'+MSI_Monsters[nMonsters[MonsterIndex]].Name);
end;
{******************************************************************************}
{ procedure MSI_BuryBones; }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: Burys bones. }
{******************************************************************************}
procedure MSI_BuryBones;
var
slots : TIntegerArray;
j : Integer;
begin
slots := MSI_FindItemSlots(LOOT_BONES_NORMAL);
for j := 0 to High(slots) do
begin
MSI_ClickItemSlot(slots[j], ['ury']);
Wait(RandomRange(1000, 1700));
MSI_FindRandoms;
end;
end;
{******************************************************************************}
{ function MSI_FightLoop: Boolean; }
{ By: Camaro' }
{ Date: 25 January 2011 }
{ Description: The loop which picks up loot, and fights until out of food. }
{******************************************************************************}
function MSI_FightLoop: Boolean;
var
I, MonsterIndex: Integer;
nMonsters : TIntegerArray;
begin
nMonsters := MSI_Players[CurrentPlayer].Scripts[CurrentScript].Monsters;
while (MSI_EatFood) do
begin
MSI_FindRandoms;
if (InvFull) then
begin
if (MSI_InFight) then
MSI_WaitWhileFighting;
if (MSI_Players[CurrentPlayer].Scripts[CurrentScript].Bury) then
MSI_BuryBones();
end;
MSI_Fight;
Wait(255 + Random(255));
if (MSI_WaitWhileFighting) then
begin
for I := 0 to High(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Monsters) do
begin
if (not(InvFull)) then
MSI_PickLoot(MSI_Monsters[nMonsters[i]].PossibleLoot);
end;
end;
Wait(500 + Random(500));
end;
end;
Objects.simba
{ NPCs ======================================= ]
[============================================= }
MONSTER_COW_LIGHT://Lighter cow (light brownish). Full grown, has spots
with MSI_Objects[whichObject] do
begin
Name := 'Cow';
UpText := 'ack Cow';
Option := 'ttac';
Colors := [5860225];
Tol := 15;
Hue := 0.06;
Sat := 0.75;
FindAllColors := False;
W := 25;
H := 25;
Accuracy := 40;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
MONSTER_COW_LIGHT_CALF://Lighter cow (light brownish). Calf
with MSI_Objects[whichObject] do
begin
Name := 'Cow';
UpText := 'ack Cow';
Option := 'ttac';
Colors := [5994394];
Tol := 14;
Hue := 0.03;
Sat := 0.96;
FindAllColors := False;
W := 18;
H := 18;
Accuracy := 25;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
MONSTER_COW_DARK://Darker cow with no spots
with MSI_Objects[whichObject] do
begin
Name := 'Cow';
UpText := 'ack Cow';
Option := 'ttac';
Colors := [4541788];
Tol := 11;
Hue := 0.07;
Sat := 0.72;
FindAllColors := False;
W := 25;
H := 25;
Accuracy := 50;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
MONSTER_COW_SPOT://Dark cow with spots
with MSI_Objects[whichObject] do
begin
Name := 'Cow';
UpText := 'ack Cow';
Option := 'ttac';
Colors := [2440517];
Tol := 11;
Hue := 0.06;
Sat := 1.05;
FindAllColors := False;
W := 25;
H := 25;
Accuracy := 35;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
MONSTER_CHICKEN_BROWN://Brown
with MSI_Objects[whichObject] do
begin
Name := 'Chicken';
UpText := 'ack Chic';
Option := 'ttac';
Colors := [2444389];
Tol := 8;
Hue := 0.13;
Sat := 0.94;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 25;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
MONSTER_CHICKEN_WHITE:
with MSI_Objects[whichObject] do
begin
Name := 'Chicken';
UpText := 'ack Chic';
Option := 'ttac';
Colors := [7975366 ];
Tol := 20;
Hue := 0.03;
Sat := 1.57;
FindAllColors := False;
W := 15;
H := 15;
Accuracy := 15;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
MONSTER_RAT_GIANT:
with MSI_Objects[whichObject] do
begin
Name := 'Giant Rat';
UpText := 'ack Gian';
Option := 'ttac';
Colors := [4474440];
Tol := 25;
Hue := 0.00;
Sat := 0.00;
FindAllColors := False;
W := 13;
H := 13;
Accuracy := 7;
ExcludeSelf := True;
RightClickOnly := False;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
NPC_STILES:
with MSI_Objects[whichObject] do
begin
Name := 'Stiles';
UpText := 'tiles';
Option := 'chan';
Colors := [3092273];
Tol := 7;
Hue := 0.08;
Sat := 0.17;
FindAllColors := False;
W := 25;
H := 40;
Accuracy := 10;
ExcludeSelf := False;
RightClickOnly := True;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
{ Ground Items =============================== ]
[============================================= }
COWHIDE:
with MSI_Objects[whichObject] do
begin
Name := 'Cowhide';
UpText := 'ake';
Option := 'ake Co';
Colors := [14408937];
Tol := 8;
Hue := 0.20;
Sat := 2.09;
FindAllColors := False;
W := 11;
H := 11;
Accuracy := 15;
ExcludeSelf := False;
RightClickOnly := True;
Tries := 1;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
RAW_BEEF:
with MSI_Objects[whichObject] do
begin
Name := 'Raw beef';
UpText := 'ake';
Option := 'ake Raw be';
Colors := [1714112];
Tol := 8;
Hue := 0.00;
Sat := 0.00;
FindAllColors := False;
W := 6;
H := 6;
Accuracy := 8;
ExcludeSelf := False;
RightClickOnly := True;
Tries := 3;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
BONES_NORMAL:
with MSI_Objects[whichObject] do
begin
Name := 'Bones';
UpText := 'ake';
Option := 'ake Bon';
Colors := [13027286];
Tol := 11;
Hue := 0.09;
Sat := 0.94;
FindAllColors := False;
W := 10;
H := 10;
Accuracy := 22;
ExcludeSelf := False;
RightClickOnly := True;
Tries := 1;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
AssociatedItems := [];
end;
Globals.simba
// Fighting
SCRIPT_FIGHTER = 81;
SCRIPT_ARRAY_LENGTH = 81; // Change to the highest script constant
////////
LOC_FIGHT = 124;
LOC_ARRAY_LENGTH = 124; // Change to the highest location constant
/////
LOOT_BONES_NORMAL = 174;
ITEM_ARRAY_LENGTH = 174; // Change to the highest item constant
/////
BONES_NORMAL = 101;
COWHIDE = 102;
RAW_BEEF = 103;
OBJ_ARRAY_LENGTH = 103; // Change to the highest object constant
/////
(**
* Constants representing all the different MSI NPCS
*)
const
// NPCs
NPC_STILES = 0;
MONSTER_CHICKEN_WHITE = 1;
MONSTER_CHICKEN_BROWN = 2;
MONSTER_RAT_GIANT = 3;
MONSTER_COW_SPOT = 4;
MONSTER_COW_DARK = 5;
MONSTER_COW_LIGHT = 6;
MONSTER_COW_LIGHT_CALF= 7;
NPC_ARRAY_LENGTH = 7; // Change to the highest NPC constant
/////
(**
* TMonster, used for fighting
*)
type
TMonster = record
Name : String;
Constant : Integer;
ColorInfo : TMSObject; // Would be set like ColorInfo := MSI_Objects[Constant];
LootObjs : TIntegerArray; // Mainscreen Objects
LootItems : TIntegerArray; // Inventory Items
WhileFighting : procedure; // Any EXTRA fighting procedure to call (CheckPoison, checkArrows)
PossibleLoot : TIntegerArray; // Not SPECIFIED BY USER! Holds all possible loot from monster
end;
/////
// Fighting
Monsters : TIntegerArray;
Loot : TIntegerArray;
RunDirection : String;
MaxKills : TIntegerArray;//not used yet
Bury : Boolean;
TotalKills : Integer; //NOT SPECIFIED BY USER //Not used yet.....
/////
MSI_Monsters : array[MONSTER_CHICKEN_WHITE..MONSTER_COW_LIGHT_CALF] of TMonster;
Scripts.simba
{ FIGHTER ================================ ]
[============================================= }
SCRIPT_FIGHTER:
with MSI_Scripts[whichScript] do
begin
Name := 'Combat Fighter';
Constant := SCRIPT_FIGHTER;
SkillName := 'Attack';
SkillConst := SKILL_ATTACK;
BankType := NoBank;
AutoObjects := @MSI_FightLoop;
PlayerSetup := @MSI_SetupFighting;
with Defaults do
begin
Monsters := [];
Loot := [];
RunDirection := 'north';
end;
end;
Setup.simba
{$include_once MSI/Skills/Fighting.simba} Items.simba
//GetItemColor
LOOT_BONES_NORMAL: Result := 11579576;
//GetDTMPoints
//Monster Loot
LOOT_BONES_NORMAL:
Result := [
Point(14, 11),
Point(21, 6),
Point(11, 21),
Point(2, 9),
Point(25, 15)
];
//LoadItem
{ Monster Loot =============================== ]
[ ============================================ }
LOOT_BONES_NORMAL:
with MSI_Items[whichItem] do
begin
Name := 'Bones';
UpText := ['ury Bo'];
Colors := [11579576];
Tol := 4;
Stackable := False;
end;
RunME.simba
//Location = LOC_FIGHT;
//This kills cows in falador (next to chickens) and collects bones, raw beef, and cowhide. It burys the bones.
Name := SCRIPT_FIGHTER; // The script constant
MONSTERS := [MONSTER_COW_SPOT, MONSTER_COW_DARK, MONSTER_COW_LIGHT, MONSTER_COW_LIGHT_CALF]; // Trees to cut
Loot := [BONES_NORMAL, RAW_BEEF, COWHIDE];
Bury := True; //Bury Bones
News: January 26th: Fixed up fighting, made it 1337, and added bone burying :D
This part is entirely optional, as there aren't many people who run out there and go idle as far as I can tell.
2) Mages/Ranges - they will probably realize you're being a sneaky thing if you keep running back into that area near spawn. Not a major problem unless a TON of people use this method.