- Code: Select all
use uo;
use os;
use cfgfile;
include "include/client";
include "include/magic";
include "../pkg/magic/druid/druid";
var gump_layout := {};
var gump_data := {};
//load the cfg file that contains information used to display reagent information
var reagent_cfg := ReadConfigFile (":*:itemnames");
//load the cfg file that containd the druid spells
var spell_cfg_file := ReadConfigFile (":*:spells");
program display_druidbag (character, bag)
if (GetObjProperty (bag, "#druidbagopen"))
if (GetProcess (GetObjProperty (bag, "#druidbagopen")))
return;
endif
endif
SetObjProperty (bag, "#druidbagopen", GetPid());
var done := 0;
repeat
BuildGump (character, bag);
var gump_return := SendDialogGump (character, gump_layout, gump_data);
if (!gump_return or !gump_return[0])
done := 1;
//if the return value is in the range dedicated to spells, try to cast that spell
elseif (gump_return[0] < 100)
var castingdruidspell := GetObjProperty (character, "#castingdruidspell");
if (castingdruidspell and castingdruidspell > ReadGameClock())
SendSysMessage (character, "You're already casting another spell!");
else
//make sure the staff is equipped
var staff := FindEquippedStaff (character);
if (!staff)
SendSysMessage (character, "You must equip a druid staff to cast a spell.");
else
//display powerwords and cast the spell
PrintTextAbove (character, spell_cfg_file[gump_return[0]].PowerWords);
if (!castdruidspell (character, staff, gump_return[0] ))
EraseObjProperty (character, "#castingdruidspell");
Fizzle (character);
endif
endif
endif
//if the return value is 9999, try to add all the runes to the bag
elseif (gump_return[0] == 9999 and character.cmdlevel)
AddAllRunes (character, bag);
//if its between 100 and 200, take the rune out of the bag
elseif (gump_return[0] >= 100 and gump_return[0] < 200)
TakeRuneOutOfBag (bag, spell_cfg_file[gump_return[0]-100].rune_objtype);
CreateItemInBackpack (character, spell_cfg_file[gump_return[0]-100].rune_objtype, 1);
SendSysMessage (character, "You take the rune out of the bag.");
elseif (gump_return[0] >= 200 and gump_return[0] < 300)
DisplayReagentRequirements (character, gump_return[0]-200);
endif
until (done or !character);
EraseObjProperty (bag, "#druidbagopen");
endprogram
///////////////////
// reads the spells.cfg file, parses the data found there, and builds the gump_data and
// gump_data
///////////////////
function BuildGump (character, bag)
gump_layout := {
"page 0",
"nodispose",
"resizepic 130 60 3500 300 300",
"gumppic 20 20 61"
};
gump_data := array ( "filler" );
//initialize some variables
var string_counter := 1;
var string_location_y := 100;
var spells_added := 0;
//the add button that gives GM the ability to add all the runes at once
if (character.cmdlevel)
gump_layout.append ("button 250 310 2462 2461 1 0 9999");
endif
//start going through the spells
gump_layout.append ("page 1");
for i := 81 to 102
//check to see if we need to start a new page
if (spells_added == 8)
gump_layout.append ("button 380 310 5601 5605 0 2");
string_location_y := 100;
gump_layout.append ("page 2");
gump_layout.append ("button 160 310 5603 5607 0 1");
elseif (spells_added == 16)
gump_layout.append ("button 380 310 5601 5605 0 3");
string_location_y := 100;
gump_layout.append ("page 3");
gump_layout.append ("button 160 310 5603 5607 0 1");
endif
//check to see if they have the rune in the bag
if (CheckForRuneInBag (bag, spell_cfg_file[i].rune_objtype ))
gump_layout.append ("button 200 " + (string_location_y + 5) + " 2103 2104 1 0 " + i);
gump_layout.append ("text 220 " + string_location_y + " 94 " + string_counter);
gump_data.append (spell_cfg_file[i].name);
gump_layout.append ("button 370 " + (string_location_y + 3) + " 5401 5401 1 0 " + (100+i));
gump_layout.append ("button 390 " + (string_location_y + 3) + " 4033 4033 1 0 " + (200+i));
string_counter := string_counter + 1;
string_location_y := string_location_y + 25;
spells_added := spells_added + 1;
endif
endfor
endfunction
///////////////////
// checks to make sure that the character has a staff equipped in order to cast a spell
///////////////////
function FindEquippedStaff (character)
var weapon_one := GetEquipmentByLayer (character, LAYER_HAND1);
if (weapon_one and weapon_one.objtype == UOBJ_DRUID_STAFF)
return weapon_one;
endif
var weapon_two := GetEquipmentByLayer (character, LAYER_HAND2);
if (weapon_two and weapon_two.objtype == UOBJ_DRUID_STAFF)
return weapon_two;
endif
return 0;
endfunction
///////////////////
// this spell is used so that GMs can easily fill a rune bag
///////////////////
function AddAllRunes (character, bag)
var current_spell;
EraseObjProperty (bag, "runes");
for i := 81 to 103
current_spell := FindConfigelem (spell_cfg_file, i);
if (current_spell and current_spell.name)
PutRuneInBag (bag, current_spell.rune_objtype);
endif
endfor
SendSysMessage (character, "All runes added.");
endfunction
///////////////////
// Sends a new gump that shows the reagent requirements for the spell
///////////////////
function DisplayReagentRequirements (character, spell_number);
var string_counter := 4;
var current_spell := spell_cfg_file[spell_number];
//new gump layout
var reg_gump_layout := {
"page 0",
"resizepic 130 60 3500 300 300",
"gumppic 20 20 61",
"gumppic 220 105 41",
"text 220 80 94 0",
"text 220 120 0 1",
"text 240 140 32 2",
"text 220 160 0 3"
};
//new gump data
var reg_gump_data := {
current_spell.name,
"Power Words",
current_spell.PowerWords,
"Reagents:"
};
//load the reagent list from the current potion into an array
var temporary_string_position := 180;
foreach current_reagent in GetConfigStringArray (current_spell, "reagent");
reg_gump_data.append(DescribeReagent (current_reagent));
reg_gump_layout.append ("text 240 " + temporary_string_position + " 0 " + string_counter );
string_counter := string_counter + 1;
temporary_string_position := temporary_string_position + 15;
endforeach
//send the completed gump to the character
SendDialogGump( character, reg_gump_layout, reg_gump_data );
endfunction
///////////////////
// this function looks at the reagent that was passed to it, and returns a string that best describes
// that reagent
///////////////////
function DescribeReagent (reagent)
var return_string := "";
var temp_split_words := splitwords(reagent);
var reagent_objtype := cint(temp_split_words[1]);
var reagent_number := cint(temp_split_words[2]);
var reagent_cfg_elem := FindConfigElem (reagent_cfg, reagent_objtype);
if (!reagent_cfg_elem)
return "an unknown reagent";
endif
if (reagent_number == 1 or reagent_number == 0)
return_string := cstr ("1 " + reagent_cfg_elem.name);
else
return_string := cstr (reagent_number + " " + reagent_cfg_elem.plural);
endif
return return_string;
endfunction
Can anyone tell me how to make this list above spell # 99?