Let's start with a few images for visual reference:
[img=http://img4.imageshack.us/img4/5453/uo0002bn.th.jpg]
[img=http://img7.imageshack.us/img7/9370/uo0003o.th.jpg]
[img=http://img4.imageshack.us/img4/7133/uo0001t.th.jpg]
Features:
- Visual gump display
- Gump is transeparent and movable so player can view behind
- Tracked mobiles listed on a radar type display in a button format
- Radar buttons are interactive, and change colour based on successfuly obtained info
- On successful skill check mobile details will be displayed
Todo:
- The gump displays an icon for mobiles tracked, the function that calls the appropriate images is not complete
Code: Select all
////////////////////////////////////////////////////////////////////////////////
// Package: Tacking
// Scripts: Tacking
// Version: 3.21
//
// Design Date: Sept 01 2009
//
// Designed by Damien White
// Designed for The Shores of Babylon
////////////////////////////////////////////////////////////////////////////////
// Info:
// MobileInfo[0] = Unused
// MobileInfo[1] = Tracked Mobile Ref
// MobileInfo[2] = Name - Skill Check Success or Fail [1/0]
// MobileInfo[3] = Speed - Skill Check Success or Fail [1/0]
// MobileInfo[4] = Hidden - Skill Check Success or Fail [1/0]
// MobileInfo[5] = Image - Shown if name is known
//
// TotalInfo = [2] + [3] + [4] -> Tracks # of peices of info success for button colour
//
// Picture = function tileimage(tile)
//
// Colours -> Red = 37 Blue = 98 Green = 371
////////////////////////////////////////////////////////////////////////////////
// Details:
// - Skill check vs Dexterity done for each trackable added to Visual Array (MobileInfo)
// - Skill check vs Dexterity for each peice of info (Name, Speed, Hidden)
// - Picture is given if name is successful
// - Skill Checks are made against the tracked mobiles Dexterity
// - Skill gain is based on difficulty, which is based on mobiles dexterity
// - range = (skill% / 2) + 5 (Max range = 55 paces)
// - mobiles removed from radar when out of range
//
////////////////////////////////////////////////////////////////////////////////
// Things to do:
// - add sfx check for all races
//
////////////////////////////////////////////////////////////////////////////////
// Modules
use uo;
use os;
use polsys;
use attributes;
// Includes
include ":attributes:advanceCheck";
// Program Body
program tracking(who)
// How far is tracking range? (Skill / 2 = # of paces) + 5
var TrackingRange := (GetAttributeBaseValue( who, "Tracking" ) / 20)+5;
// List of Mobiles in that range (Including tracker)
var Trackables := ListMobilesNearLocation( who.x, who.y, who.z, TrackingRange, realm := _DEFAULT_REALM );
// Set up variables used
var HowSuccessful; // Used in skill check
var MobileInfo := array; // Array of information on each mobile (See top)
var SingleMobileInfo := {0,0,0,0,0,0}; // Temp array used for setting MobileInfo
var NumberOfTrackables := 0; // Used to count Mobiles in area
var TrackDifficulty; //Difficulty Level (Check against itself)
var award_diff;
// Add all trackables, except tracker to array, and data
for a := 1 to len(Trackables)
TrackDifficulty := GetAttribute( Trackables[a], "Dexterity" );
award_diff := TrackDifficulty;
// General skill check to find mobile
HowSuccessful := SkillCheck(who, "Tracking", TrackDifficulty, award_diff, advance_flags:=ADV_ALL);
// Fill Mobile Info array for each trackable on successful skill check
If ( HowSuccessful > 0) // Skill Check here if the mobile button should be added
if ((Trackables[a].serial != who.serial) || (GetCmdLevelNumber(Trackables[a]) > 1) || (Trackables[a].connected != 1)) // Only add tracked mobiles not tracker or admin team
// Action and sound effect -> Hands on hips -> "Ahha!"
// Check human female and male
// **** Add check for all races
PerformAction(who,6);
if (who.graphic == 0x190)
PlaySoundEffect (who, 0x41b);
elseif (who.graphic == 0x191)
PlaySoundEffect (who, 0x30c);
endif
sleepms(1200);
// Add Mobile Ref to Mobile Info
SingleMobileInfo[1] := Trackables[a];
// Skill Check for name
HowSuccessful := SkillCheck(who, "Tracking", TrackDifficulty, award_diff, advance_flags:=ADV_ALL);
// Fill Mobile Info with -> Name data
If ( HowSuccessful > 0)
SingleMobileInfo[2] := 1;
endif
// Fill Mobile Info with -> Speed data
HowSuccessful := SkillCheck(who, "Tracking", TrackDifficulty, award_diff, advance_flags:=ADV_ALL);
If ( HowSuccessful > 0)
SingleMobileInfo[3] := 1;
endif
// Fill Mobile Info with -> hidden data
HowSuccessful := SkillCheck(who, "Tracking", TrackDifficulty, award_diff, advance_flags:=ADV_ALL);
If ( HowSuccessful > 0)
SingleMobileInfo[4] := 1;
endif
// Add Single Mobile Info to Mobile Info Array
MobileInfo.append(SingleMobileInfo);
// Set Single Mobile Info to default
SingleMobileInfo := {0,0,0,0,0,0};
// Track number of mobile currently refferenced
NumberOfTrackables := NumberOfTrackables + 1;
endif
endif
endfor
// Preset variables used to track mobile clicked in gump
var ButtonReturned := 1;
var ButtonSelected := 0;
// Gump Display Loop -> Only exit if quit button is pressed
while(ButtonReturned != 0)
ButtonReturned := CInt(DisplayGump(who, MobileInfo, NumberOfTrackables, ButtonSelected, TrackingRange));
ButtonSelected := ButtonReturned;
endwhile
endprogram
// Making it a function makes it easier to loop
function DisplayGump(who, MobileInfo, NumberOfTrackables, ButtonSelected, TrackingRange)
var gump := array {
"page 0",
"noclose",
"resizepic 8 27 2620 265 449",
"checkertrans 13 32 255 439",
"text 93 31 147 0",
"gumppic 0 32 9006",
"resizepic 158 327 2620 91 94",
"tilepic 168 339 8459",
"text 22 448 996 1",
"text 32 296 147 2",
"gumppic 88 296 2440",
"gumppic 135 159 1210",
"text 96 296 37 3",
"text 32 328 147 4",
"gumppic 88 328 2444",
"text 96 328 37 5",
"text 32 360 147 6",
"gumppic 88 360 2444",
"text 96 360 37 7",
"gumppic 17 427 2360",
"text 32 424 37 8",
"gumppic 94 427 2362",
"text 112 424 98 9",
"gumppic 177 428 2361",
"text 192 424 371 10",
"button 57 392 1027 1027 1 0 0"
};
// Define Button Image for each mobile and add to gump DisplayGump
var MobileDistanceX;
var MobileDistanceY;
var ButtonImage;
var TotalInfo;
var DistanceToMobile;
//Add buttons to gump
for a := 1 to NumberOfTrackables
MobileDistanceX := ((MobileInfo[a,1].x - who.x) + 135);
MobileDistanceY := ((MobileInfo[a,1].y - who.y) + 159);
TotalInfo := cint(MobileInfo[a,2]) + cint(MobileInfo[a,3]) + cint(MobileInfo[a,4]);
Case(TotalInfo)
1: // Red
ButtonImage := 2360;
2: // Blue
ButtonImage := 2362;
3: // Green
ButtonImage := 2361;
Default: // Red
ButtonImage := 2360;
endcase
DistanceToMobile := Distance( MobileInfo[a,1], who );
If (DistanceToMobile <= TrackingRange) // Continue to list mobile if still within range
gump[Len(gump) + a] := "button " + MobileDistanceX + " " + MobileDistanceY + " " + ButtonImage + " " + ButtonImage + " 1 0 " + cstr(a);
endif
endfor
// Add Mobile Info to gump
var Species;
var SpeciesColour;
var Speed;
var SpeedColour;
var Hidden;
var HiddenColour;
// On 1st load of gump, no button is pressed, so set defaults
if (ButtonSelected == 0)
Species := "unknown";
SpeciesColour := 37;
Speed := "unknown";
SpeedColour := 37;
Hidden := "unknown";
HiddenColour := 37;
gump[8] := "tilepic 168 339 " + tileimage(0);
else
// Species
if(MobileInfo[ButtonSelected,2] == 1)
Species := MobileInfo[ButtonSelected,1].name;
SpeciesColour := 371;
gump[8] := "tilepic 168 339 " + tileimage(MobileInfo[ButtonSelected,1].graphic);
else
Species := "unknown";
SpeciesColour := 37;
gump[8] := "tilepic 168 339 " + tileimage(0);
endif
// Speed
if(MobileInfo[ButtonSelected,3] == 1)
//Text Info
If (MobileInfo[ButtonSelected,1].run_speed == 0)
Speed := "no move";
elseif (MobileInfo[ButtonSelected,1].run_speed > 30)
Speed := "fast";
elseif (MobileInfo[ButtonSelected,1].run_speed > 20)
Speed := "medium";
elseif (MobileInfo[ButtonSelected,1].run_speed > 10)
Speed := "slow";
endif
SpeedColour := 371;
else
Speed := "unknown";
SpeedColour := 37;
endif
// Hidden
if(MobileInfo[ButtonSelected,4] == 1)
if(MobileInfo[ButtonSelected,1].hidden == 1)
Hidden := "yes";
HiddenColour := 371;
else
Hidden := "no";
HiddenColour := 371;
endif
else
Hidden := "unknown";
HiddenColour := 37;
endif
endif
// Adjust colour of text for Species, Speed and HiddenColour
gump[13] := "text 96 296 " + SpeciesColour + " 3";
gump[16] := "text 96 328 " + SpeedColour + " 5";
gump[19] := "text 96 360 " + HiddenColour + " 7";
var data := array {
"- - Tracking - -",
"The Shores of Babylon © 2009 - 2010",
"Species:",
Species,
"Speed:",
Speed,
"Hidden:",
Hidden,
"Unknown",
"Not Sure",
"Successful"
};
var trapcancelbutton := 0;
var SelectedMobile := SendDialogGump(who, gump, data);
foreach key in ( SelectedMobile.keys )
ButtonSelected := key;
trapcancelbutton := 1;
endforeach
if (trapcancelbutton == 0)
ButtonSelected := 0;
endif
return ButtonSelected;
endfunction
// I could not find an easy way to do this
function tileimage(tile)
case(tile)
0x1: // Ogre
return 0x20df;
0x2: // Ettin
return 0x20de;
0x3: // Zombie
return 0x20ec;
0x4: // Gargoyle
return 0x20d9;
0x5: // Bird - Eagle
return 0x20f2;
0x6: // Bird - Generic
return 0x20ee;
0x7: // Orc - Captain
return 0x25af;
0x8: // Corpser
return 0x20d2;
0x9: // Daemon
return 0x20d3;
0xa: // Daemon 2
return 0x20d3;
0xb: // Spider - Dread
return 0x25c4;
0xc: // Dragon
return 0x20d6;
0xd: // Elemental - Air
return 0x20ed;
0xe: // Elemental - Earth
return 0x20d7;
0xf: // Elemental - Water
return 0x20f3;
0x10: // Elemental - Water
return 0x210b;
0x11: // Orc
return 0x20e0;
0x12: // Ettin 2
return 0x20de;
0x13: // Spider - Dread 2
return 0x25c4;
0x14: // Spider - Frost
return 0x25c5;
0x15: // Snake - Giant
return 0x25bf;
0x16: // Gazer
return 0x20f4;
0x17: // Wolf - Dire
return 0x25d0;
0x18: // Liche - Retro
return 0x25a4;
0x19: // Wolf - Grey
return 0x25d1;
0x1a: // Ghost
return 0x25c7;
0x1b: // Wolf - Grey 2
return 0x25d1;
0x1c: // Spider - Giant
return 0x25c6;
0xcf: // Sheep
return 0x20eb;
0xd8: // Cow Spotted (Brown?)
return 0x2103;
0xe7: // Cow Brown (Spotted?)
return 0x2103;
0xea: // Deer - Stag
return 0x20d4;
0xed: // Deer - Doe
return 0x20d4;
0x190: // Human Male
return 0x20cd;
0x191: // Human Female
return 0x20ce;
default: // No Draw
return 0x1;
endcase
endfunction