forums | blogs | polls | tutorials | downloads | rules | help

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in remember_me_form_alter() (line 78 of /var/www/siegetheday.org/sites/all/modules/contrib/remember_me/remember_me.module).

Show me string to int script

Here is my last failed attempt to retrieve the string for 'Min Damage' and convert it to a useable integer for simple math stuff.

ShowDPS$()

{

UIText uiText$ = QueryDerivedText( UIShell.FindUIWindow( "text_min_damage_value", "character_main_tab" ) );
sText$ = GetText( uiText$ );
int MinDam$ = GetInt( sText$ );

string tmp1$ = "oops"; //defining the variable type before use
StringTool.Assignf( tmp1$, "%i", MinDam$ );
SetUITextText$( "character_main_tab", "text_DPS_value", tmp1$ );

}

whomisold wrote:
Here is my last failed attempt to retrieve the string for 'Min Damage' and convert it to a useable integer for simple math stuff.

ShowDPS$()

{

UIText uiText$ = QueryDerivedText( UIShell.FindUIWindow( "text_min_damage_value", "character_main_tab" ) );
sText$ = GetText( uiText$ );
int MinDam$ = GetInt( sText$ );

string tmp1$ = "oops"; //defining the variable type before use
StringTool.Assignf( tmp1$, "%i", MinDam$ );
SetUITextText$( "character_main_tab", "text_DPS_value", tmp1$ );

}


__________________________

This code doesn't look so illogical but it's not really convenient for skrit.
Get/check once fubi.log for the available functions and the classes they belong too.

 
To get a number from an UI text field you can try this:

string text_num$;
UIText uiText$ = Query...
uiText$.GetText( text_num$ ); 	// this will copy the text into text_num$
int num$ = Stringtool.GetDelimitedInt(text_num$,0);

 
But there's another way to find out the damage since you will need the actor anyway to find out his attack speed:

float dps$;
goid char$ = UIPartyManager.GetSelectedCharacter();
if ( char$.IsValid )
{
	go weapon_go$ = char$.Go.Inventory.SelectedOffensiveWeaponOrSpell;
	if ( weapon_go$ != NULL )
	{
		float interval$ = CalcTotalWeaponSpeed$( char$.Go, weapon_go$ );
		if ( interval$ > 0.0 )
		{
			my range damage$;
			Rules.GetDamageRange( char$, weapon_go$.Goid, damage$ );
			dps$ = ( damage$.min + damage$.max ) * 0.5 / interval$;
		}
	}
}
k_inc_damage_utils.skrit form v2.3/addon will provide CalcTotalWeaponSpeed$(), you have to include it but you also could copy the function/code not to depend on the game version.

Nonetheless I hope nobody is going to trust this DPS value blindly. Finally combative abilities are co-determined too by criticals, areas of damage, number of (spell) projectiles, chances to bleed/ignite/stun/freeze, etc. - unfortunately to express such things with a number could turn out to be rather difficult... :o

The number I want displayed is just for quick comparison. I am running low on junk mail scraps from penciling the calc. Cheer

Again, my thanks for exceeding my request. Got some more thinking to do with your suggestions.

As you can see, I blended KG's ideas.
I wanted to check the mages too, but the 'offensive' version of ?getselectedweaponorspell seems to be broken in that it only returns for ranged and melee weapon. Perhaps it has an internal use but not one instance is it used for scripted skrit.

The function is called via a small defined rollover window over the 'DPS' text display block.
Not perfect but functionally satisfying for my purposes. Just got to play thru till I get a dualist for final testing.

ShowDPS$()
{
float dps$;
string tmp$;
float interval$;
goid char$ = UIPartyManager.GetSelectedCharacter();
if ( char$.IsValid )
{
go weapon_go$ = char$.Go.Inventory.SelectedWeaponOrSpell;
if ( weapon_go$ != NULL )
{
if ( weapon_go$.IsSpell )
{
interval$ = weapon_go$.Magic.CastReloadDelay;
}
else
{
interval$ = CalcTotalWeaponSpeed$( char$.Go, weapon_go$ );
}
if ( interval$ > 0.0 )
{
UIText uiText$ = QueryDerivedText( UIShell.FindUIWindow( "text_min_damage_value", "character_main_tab" ) );
uiText$.GetText( tmp$ ); // this will copy the text into text_num$
int min$ = Stringtool.GetDelimitedInt(tmp$,0);
UIText uiText$ = QueryDerivedText( UIShell.FindUIWindow( "text_max_damage_value", "character_main_tab" ) );
uiText$.GetText( tmp$ ); // this will copy the text into text_num$
int max$ = Stringtool.GetDelimitedInt(tmp$,0);
dps$ = ( min$ + max$ ) * 0.5 / interval$;
StringTool.Assignf( tmp$, "%f", dps$ );
SetUITextText$( "character_main_tab", "text_DPS_value", tmp$ );
}
}
}
}