Classes problem

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Feeh
New User
Posts: 1
Joined: Fri Aug 09, 2013 2:49 pm

Classes problem

Post by Feeh »

I'm using Core 099 and I'm having some problem with classes
The system is designed to work with 8-skill classes and the max level is achieved when every skill in the class has a value of 150

I want to change the system to achieve the max level when every skill has a value of 100 but following the same-adjusted rules

Original
level 1 - 75 in each skill
level 2 - 90 in each skill...

New
level 1 - 50 in each skill
level 2 - 60 in each skill...

It seems to follow a 1.5 ratio but here goes the problem
I've added another class which does have 12 skills instead of 8 and the system fails saying my level is never higher than 1, even with 100 in every skill

Here is the code I'm using (original) for quick reference

Code: Select all

Elem Settings
{
	BonusLevel             0.20
        EachMustRepresent      5.0 //7.5
        RepresentLevelMod      1
        AverageSkill           50 //75
        AverageLevelMod        10 //15
        AveragePPSkills        90
        AveragePPMod           20
}

function IsFromThatClasse( mobile, classe_skills )

        var classe := 0,
	    total := 0,
	    number := len( classe_skills ),
	    level := 0;

	foreach i in AP_ListAttributesByType( "skill" ) //foreach skill

		var amount := AP_GetSkill( mobile, i ); //get 'i' skill from 'mobile', same as RunUO's mobile.Skills[i].Base
		total += amount;
		if( i in classe_skills ) //if the skill is present on the class definition
			classe += amount;
		endif
                SleepMS(5); //Why should we wait? POL thing...
	endforeach

    //if else statments does not have braces, they end with else-endif, the same for foreach-endforeach
	if( classe < settings.AverageSkill * number ) //anything that start with settings.* refer to the table above
		return 0;
	elseif( classe_skills == GetClasseSkills( PP ) ) //GetClasseSkills(x) return the skill array, better check if the specified class is PowerPlayer
		var average := classe / SKILLID__HIGHEST, // SKILLID__HIGHEST 48(Remove trap) or 49(Necromancy) ?
		    raise_average := 0;

		while( average >= ( settings.AveragePPSkills + raise_average ))
			level += 1;
			raise_average += settings.AveragePPMod;
                        SleepMS(5);
		endwhile
		return level;
	elseif( classe < CInt( total * number * settings.EachMustRepresent * 0.01 )) //CInt(x) convert x to int
		return 0;
	else
		level := 1;

		var represent := settings.EachMustRepresent + settings.RepresentLevelMod,
		    percent   := CDbl( total * number * represent * 0.01 ),
		    average_t := CDbl(( settings.AverageSkill + settings.AverageLevelMod ) * number );

		while(( classe >= average_t ) && ( classe >= percent ))
			level     += 1;
			represent := CDbl( represent + settings.RepresentLevelMod ); //CDbl(x) >> convert x to double
			percent   := CDbl( total * number * represent * 0.01 );
			average_t := CDbl( average_t + settings.AverageLevelMod * number );
                        SleepMS(5);
		endwhile

		return level;
	endif
endFunction
thanks for any help
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Classes problem

Post by CWO »

I would start by putting debug messages within your script. A simple SendSysMessage(mobile, CStr(variable)); maybe after the foreach, sending the total and classe to make sure it's counting the total correctly, and whenever you grab a value or change a variable (preferably outside of loops) to give yourself an idea what the script is seeing. SendSysMessage(mobile, "classe=" + CStr(classe) + " total=" + CStr(total)); Also something I see (may just be when you put it in the forum post), the line

Code: Select all

var average := classe / SKILLID__HIGHEST, // SKILLID__HIGHEST 48(Remove trap) or 49(Necromancy) ?


looks like it has a comma instead of a semicolon?

But sending debug SysMessages are the best way to work on the script and show what your variables are doing. Just make sure you CStr() the message so you don't run into errors with variable types.
Post Reply