Classes

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
MarsovV
New User
Posts: 3
Joined: Wed Dec 01, 2010 5:45 pm

Classes

Post by MarsovV »

Posted here is a include file:

Code: Select all

use uo;

include ":attributes:attributes";
include ":attributes:attributes_ex";


const MAGE                 := "IsMage";                  
const WARRIOR           := "IsWarrior";         
const HUNTER              := "IsHunter";           


function GetClasseName( classe_id )
case( classe_id )
MAGE = return("mage");
WARRIOR = return("warrior");
HUNTER = return("hunter");
endcase
endfunction

function Get_Mobile_Classe_Name( mobile )
if( GetObjProperty( mobile, MAGE ));
return MAGE;
elseif( GetObjProperty( mobile, WARRIOR ));
return WARRIOR;
elseif( GetObjProperty( mobile, HUNTER ));
return HUNTER;
endif
return 0;
endfunction

function GetName( classe_id )
case( lower( classe_id ))
"mage":            return MAGE;
break;
"warrior":            return WARRIOR;
break;
"hunter":            return HUNTER;
break;

default:            return 0;

endcase
return 1;
endfunction

function GetClasseIdForSkillName( skill_name ) 

foreach classe in GetClasseIds()
if( skill_name in GetClasseSkills( classe ))
return classe;
endif
SleepMS(5);
endforeach    
return 0;
endfunction

function GetClasseIds()

return { MAGE, WARRIOR, HUNTER };

endfunction

function GetClasseSkills( classe_id )
case( classe_id )

MAGE: return { ALCHEMY, MAGERY, MEDITATION, RESISTING_SPELLS, MACE_FIGHTING, WRESTLING };

WARRIOR: return { ANATOMY, HEALING, TACTICS, MACE_FIGHTING, RESISTING_SPELLS, MEDITATION, DETECTING_HIDDEN, WRESTLING, SWORDSMANSHIP, FENCING };

HUNTER: return { ANATOMY, HEALING, TACTICS, ARCHERY, RESISTING_SPELLS, MEDITATION, DETECTING_HIDDEN, WRESTLING, FENCING, STEALTH, HIDING };
 
endcase 
return 1;
endfunction

function GetMaxValueForClasseSkill( classe_id )
case( classe_id )

MAGE: return { 150, 150, 150, 150, 150, 150 }; // Max Skill Value

WARRIOR: return { 150, 150, 150, 150, 150, 150, 150, 150, 150, 150 };

HUNTER: return { 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150 };

endcase 
return 1;
endfunction


How to bind to the name of the skill maximum value?
phao
Grandmaster Poster
Posts: 129
Joined: Fri Aug 31, 2007 2:25 pm
Location: Brazil

Re: Classes

Post by phao »

If you wanna get the maximum possible value for a skill, having its id, you can write that maximum value in the attributes.cfg file. Then, you could read it back using cfgfile.em functions.

You don't need to actually use attributes.cfg. You could make your own cfg file, but I think that'd strange.

The basic idea is: store it somewhere, and make a function to access it whenever needed. If you don't know how to do that, you should read the eScript guide (recalac's) on the documentation page for your pol version.

You may even hardcode it (you seem to like hardcoding values), as a dictionary, mapping skill ids to their maximum values.

By the way, comparing strings is often slower than comparing integers. And you seem to be using strings as ids. That's not a problem if not done frequently, but if you make it a habit of making ids being strings, your scripts could get really slow. Try to make ids integers.
Post Reply