Restricting class from using types of armour

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Faceless_Soldier
New User
Posts: 15
Joined: Mon Jun 30, 2008 9:07 pm

Restricting class from using types of armour

Post by Faceless_Soldier »

Code: Select all

function IsRestrictedArmour(who, item)
	var restricted_armour_type := CheckRestrictedArmour(who);
	if (item.graphic in restricted_armour_type)
		return 1; //Item cannot be equipped
	else
		return 0; //Item can be equipped
	endif
endfunction
The part I'm not sure about is the element highlighted in red. I've taken part of this from the Zulu scripts as the basis for my own and it appears to me that its a little outdated. I'm guessing the older configuration files had a graphic value for everything. How can I refer to the item ID (?) highlighted also in red below in a way like above?

Would it be easier to just go through and add in a graphic element to each configuration entry? As far as I can tell (through the use of SendSysMessage) it receives the graphic hex for which ever item groups are restricted to certain classes so I'm focusing on this at the moment. Ive had it tell me which graphics are restricted and however it doesn't apply it. I think it has something to do with how I'm comparing the values in the if statement. Ive also tried item.type - anyone know the correct reference?

if (item.graphic in restricted_armour_type)

//*--=[ LEATHER ARMOR ]=-----------
Armor 0x13C7
{
//Main Stuff
Name LeatherGorget
Desc leather gorget
VendorBuysFor 37
VendorSellsFor 74

//Equipment Info
MaxHP 35
StrRequired 10

//Armor Info
AR 13
Coverage Neck

//Scripts
DestroyScript onDestroy

//Custom Values
MedLoss 100
}

Any suggestions? I'm beginning to think I should just chuck in a "ArmourType" element into each of the armours and have it check against that...
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Re: Restricting class from using types of armour

Post by Austin »

The elem ID in an itemdesc.cfg is actually the objecttype property.
If it is less than 0xFFFF it uses the same object type as the graphic.

If it is not working, then the item's graphic is not in the restricted_armour_type array - the program lies in the function you are calling to get that info.

You need to show what is happening in CheckRestrictedArmour(mobile) and give an idea of what type of data it is returning.
You can do SysLog(restricted_armor_type); to output to the console and pol.log to paste.
Faceless_Soldier
New User
Posts: 15
Joined: Mon Jun 30, 2008 9:07 pm

Re: Restricting class from using types of armour

Post by Faceless_Soldier »

Here is the SysLog:

Code: Select all

[02/19 07:04:27] [scripts/misc/equiptest.ecl]: { { 5061, 5062, 5063, 5064, 5065, 5066, 5067, 5068, 5069, 5070, 5071, 5072, 5073, 5074, 5075, 7168, 7174, 7176, 7178 }, { 5076, 5077, 5078, 5079, 5080, 5081, 5082, 5083, 5084, 5085, 5086, 5087, 5088, 5089, 5090, 7170, 7180 }, { 5093, 5094, 5095, 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106 }, { 5051, 5052, 5053, 5054, 5055, 5056, 5057, 5058, 5059, 5060 }, { 5198, 5199, 5200, 5201, 5202, 5203, 5204, 5205, 5206, 5207 }, { 5128, 5129, 5130, 5131, 5132, 5133, 5134, 5135, 5136, 5137, 5138, 5139, 5140, 5141, 5142, 5143, 5144, 5145, 5146, 7172 }, { 7026, 7027, 7028, 7029, 7030, 7031, 7032, 7033, 7034, 7035 } }
This is the array thas is being returned. It looks as though there are arrays in an array. Could this cause issues with "in" ? If it would help, I'll work on it getting it to return a single value for each element in the array.

I'll post a sample of the function so you can see how it's done. I'm completely open to rewriting the function if you can see a better approach.

f

Code: Select all

unction CheckRestrictedArmour(who)
	var Class := GetObjProperty(who, "Class");
	var RestrictedArmour := array{};
	case(Class)
		CLASS_MAGE: //other classes removed to reduce size
			RestrictedArmour.append(GetArmourGraphics("Leather"));
			RestrictedArmour.append(GetArmourGraphics("Studded Leather"));
			RestrictedArmour.append(GetArmourGraphics("Ringmail"));
			RestrictedArmour.append(GetArmourGraphics("Chainmail"));
			RestrictedArmour.append(GetArmourGraphics("Bone"));
			RestrictedArmour.append(GetArmourGraphics("Platemail"));
			RestrictedArmour.append(GetArmourGraphics("Shields"));
		default:
			break;
	endcase
	return RestrictedArmour;
endfunction

Code: Select all

function GetArmourGraphics(armour)
	case(armour)
		"Leather":
			return array{5061, 0x13c5, 0x13c6, 0x13c7, 0x13c8, 0x13c9, 0x13ca, 0x13cb, 0x13cc, 0x13cd, 0x13ce, 0x13cf, 0x13d0, 0x13d1, 0x13d2, 0x13d3, 0x1c00, 0x1c06, 0x1c08, 0x1c0a};
		"Studded Leather":
			return array{0x13d4, 0x13d5, 0x13d6, 0x13d7, 0x13d8, 0x13d9, 0x13da, 0x13db, 0x13dc, 0x13dd, 0x13de, 0x13df, 0x13e0, 0x13e1, 0x13e2, 0x1c02, 0x1c0c};
		"Ringmail":
			return array{0x13e5, 0x13e6, 0x13e7, 0x13e8, 0x13e9, 0x13ea, 0x13eb, 0x13ec, 0x13ed, 0x13ee, 0x13ef, 0x13f0, 0x13f1, 0x13f2};
		"Chainmail":
			return array{0x13bb, 0x13bc, 0x13bd, 0x13be, 0x13bf, 0x13c0, 0x13c1, 0x13c2, 0x13c3, 0x13c4};
		"Bone":
			return array{0x144e, 0x144f, 0x1450, 0x1451, 0x1452, 0x1453, 0x1454, 0x1455, 0x1456, 0x1457}; 
		"Platemail":
			return array{0x1408, 0x1409, 0x140a, 0x140b, 0x140c, 0x140d, 0x140e, 0x140f, 0x1410, 0x1411, 0x1412, 0x1413, 0x1414, 0x1415, 0x1416, 0x1417, 0x1418, 0x1419, 0x141a, 0x1c04};
		"Shields":
			return array{0x1b72, 0x1b73, 0x1b74, 0x1b75, 0x1b76, 0x1b77, 0x1b78, 0x1b79, 0x1b7a, 0x1b7b};
		default:
			break;
	endcase
endfunction
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Restricting class from using types of armour

Post by Turley »

Jep I think your problem is with arrays in arrays and "in".
Replace
RestrictedArmour.append(GetArmourGraphics(blubb));
with
RestrictedArmour+=GetArmourGraphics(blubb);
then it should work
Faceless_Soldier
New User
Posts: 15
Joined: Mon Jun 30, 2008 9:07 pm

Re: Restricting class from using types of armour

Post by Faceless_Soldier »

Code: Select all

[scripts/misc/equiptest.ecl]: { 5061, 5062, 5063, 5064, 5065, 5066, 5067, 5068, 5069, 5070, 5071, 5072, 5073, 5074, 5075, 7168, 7174, 7176, 7178, 5076, 5077, 5078, 5079, 5080, 5081, 5082, 5083, 5084, 5085, 5086, 5087, 5088, 5089, 5090, 7170, 7180, 5093, 5094, 5095, 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106, 5051, 5052, 5053, 5054, 5055, 5056, 5057, 5058, 5059, 5060, 5198, 5199, 5200, 5201, 5202, 5203, 5204, 5205, 5206, 5207, 5128, 5129, 5130, 5131, 5132, 5133, 5134, 5135, 5136, 5137, 5138, 5139, 5140, 5141, 5142, 5143, 5144, 5145, 5146, 7172, 7026, 7027, 7028, 7029, 7030, 7031, 7032, 7033, 7034, 7035 }
So that fixed the "arrays in array" problem. I found the problem to be that I changed to item.objecttype which when I used SendSysMessage returned an error. I also added in item.graphic who returned the right value but didn't trigger it because it wasn't being checked. I changed to item.graphic and it works perfectly now.

Thanks for your guidance. I can use this concept in some of my other scripts now. :cheesy:
Post Reply