Aller au contenu

Photo

GUI Scripting Troubles


  • Veuillez vous connecter pour répondre
30 réponses à ce sujet

#1
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

Hello everyone, I'm a beginner mod who's trying to apply some changes to NWN2.

 

My biggest trouble so far seems to be interacting with the GUI.

For example, I have made this script:

// This scripts defines the maximum mana of a creature


void main()

{	
	int Levels = GetTotalLevels(OBJECT_SELF, 0);

	int Class_1 = GetClassByPosition(1, OBJECT_SELF);
	int Class_2 = GetClassByPosition(2, OBJECT_SELF);
	int Class_3 = GetClassByPosition(3, OBJECT_SELF);
	int Class_4 = GetClassByPosition(4, OBJECT_SELF);
	
	int CLVL_1 = GetLevelByClass(Class_1, OBJECT_SELF);
	int CLVL_2 = GetLevelByClass(Class_2, OBJECT_SELF);
	int CLVL_3 = GetLevelByClass(Class_3, OBJECT_SELF);
	int CLVL_4 = GetLevelByClass(Class_4, OBJECT_SELF);
	
	int C_HP_1 = StringToInt(Get2DAString("classes", "HitDie", Class_1));
	int C_HP_2 = StringToInt(Get2DAString("classes", "HitDie", Class_2));
	int C_HP_3 = StringToInt(Get2DAString("classes", "HitDie", Class_3));
	int C_HP_4 = StringToInt(Get2DAString("classes", "HitDie", Class_4));
	
	int C_SK_1 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_1));
	int C_SK_2 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_2));
	int C_SK_3 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_3));
	int C_SK_4 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_4));
	
	int C_MP_1 = 18 - C_HP_1 - C_SK_1;
	int C_MP_2 = 18 - C_HP_2 - C_SK_2;
	int C_MP_3 = 18 - C_HP_3 - C_SK_3;
	int C_MP_4 = 18 - C_HP_4 - C_SK_4;
	
	int MaxCls = CLVL_1 * C_MP_1 + CLVL_2 * C_MP_2 + CLVL_3 * C_MP_3 + CLVL_4 * C_MP_4;
	int MaxWis = Levels * GetAbilityModifier(4, OBJECT_SELF);
	int MaxTot = MaxCls + MaxWis;
	if (MaxTot < Levels)
	{
		MaxTot = Levels;
	}
	string MaxTot_String = IntToString(MaxTot);
	SetLocalInt(OBJECT_SELF, "Clangeddin_Maximum_Mana", MaxTot);
	
	//Current Mana
	
	int FirstCheck = GetLocalInt(OBJECT_SELF, "Clangeddin_Mana_First_Time");
	
	if (FirstCheck == 0)
	{
		SetLocalInt(OBJECT_SELF, "Clangeddin_Current_Mana", MaxTot);
		SetLocalInt(OBJECT_SELF, "Clangeddin_Mana_First_Time", 1);
	}
	
	object oRester = GetLastPCRested();
	
	if (oRester == OBJECT_SELF)
	{
		SetLocalInt(OBJECT_SELF, "Clangeddin_Current_Mana", MaxTot);
	}
	
	int Current_MP = GetLocalInt(OBJECT_SELF, "Clangeddin_Current_Mana");
	string CMP_String = IntToString(Current_MP);
	string Display_Message = CMP_String + "/" + MaxTot_String;
	
	float mp_ratio = IntToFloat(Current_MP) / IntToFloat(MaxTot);
	
	SetGUIObjectText(OBJECT_SELF, "SCREEN_PARTY_BAR", "MP_DISPLAY", -1, Display_Message);
	SetGUIProgressBarPosition(OBJECT_SELF, "SCREEN_PARTY_BAR", "MP_BAR", mp_ratio);
	
  	FloatingTextStringOnCreature(Display_Message, OBJECT_SELF, TRUE, 2.0);
	
	
}

It fires off a persistent feat that pretty much enables a Mana System (to replace Vancian Magic). It's just the part the calculates The maximum mana of the creature, that restores it to max when you rest and that -SHOULD- update the MP display on the party bar.

Here I will link the parts of the XML that it should link to:

<UIText name="MP_DISPLAY" x=99 y=31 width=100 height=18 align=center valign=middle fontfamily="Special_Font_2" style="2" />
<UIProgressBar name="MP_BAR" x=99 y=31 width=100 height=18 vertical=false img="party_mana_fill.tga" > </UIProgressBar>			
<UIIcon name="MP_BAR_BG" x=99 y=31 width=100 height=18 img="party_health_fill_bg.tga" />

The Script works perfectly until the GUI part. I know because the floating message that gives both current and maximum mana pops up regularly (as it should, since it's a persistent feat) displaying the correct values. However, the GUI party frame is empty, and no message is displayed.

It's not just the Party Bar UI. Even Character Screen and Inventory have the same problem.

But in general it seems I'm getting something wrong with the whole "from module to GUI" approach.
I've been trying to look online and I read even one beginner's tutorial, following it's instructions, but I didn't solve my issues.

Can anyone tell me if there's something wrong with my scripts? And if yes, would there be a way to adjust them?

Thanks very much in advance for all the helpful replies.


  • BartjeD aime ceci

#2
kevL

kevL
  • Members
  • 4 056 messages

about the ProgressBar. it's a bit screwy in my experience. I set a .2da so that resting takes 1sec / level, and when i rest the progressBar window appears, but no progress shows until there's only 5 seconds left (the default for resting) - when suddenly the bar fills up to the -5 second mark and then continues normally to completion. I tried nicking around with various functions trying to get it to register progress properly but never could,

it sounds like you're having more troubles than that, though; could you describe better what you want or expect to happen, and isn't



#3
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

Screenshots would be helpful. To start, does the empty bar appear in your UI? What you have looks very similar to what I did to make a stamina bar appear next to the HP bar, including the script parts.



#4
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

I have made this screenshot to illustrate the problem better:

 

NWN2_Screen_Test.jpg

 

As you can see the mana bar is empty with no text displayed. It should be partially filled with blue and have the display of 36/72 on it.



#5
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi Clangeddin86,

I have a number of Progress Bars in a number of GUIs all working well. (I'm guessing it was my tutorial you looked at? I don't go into too many details about that function, but it's easy enough to get working ... usually.)

It may be more useful if you post the entire XML script for me to look at.

In the meanwhile, try using some debug figures (on a switch) that send data to the GUI to see if the raw data is updating the GUI. Another thing to check is to see what your idlexpiretime is. Maybe it is not allowing the GUI to refresh quick enough?

Also, quickly looking over your script, I think you need to separate out the ON RESTED part to apply an update to the variables and recall the GUI after that when using OBJECT_SELF. i.e. It looks a little confusing to me where you are calling the GUI and last PC rested from one script. Then again, I may just be tired. ;)

Anyway, post the entire XML and I'll take a look if I get some time. I don't do any module work on Sundays though, so it will either be tonight (if you post it early enough) or Monday.

EDIT: Here is my own entire TIMER/BOSS BAR XML that I use for my Progress Bar (Maybe looking at these will help you):-
 
<?xml version="1.0" encoding="utf-8">

<!--
The updaterate has been reduced to avoid needless strain on the engine (as the UI executes a script each update).
-->

<UIScene name="SCREEN_BOSS" width=500 height=100 x="ALIGN_CENTER" y=100 draggable="false" idleexpiretime="0.1" scriptloadable="true"
capturemouseevents=false capturemouseclicks=false ignoreevents=true focusable=false priority="SCENE_INGAME" fadeout="0.5" update="true"
updaterate="0.1" OnUpdate="UIObject_Misc_ExecuteServerScript('gui_boss_update')" />


<!-- Title -->
<UIText name="BOSS_TEXT" fontfamily="Special_Font" style=4 x=ALIGN_CENTER y=0 width="PARENT_WIDTH" height="DYNAMIC" color="EEEEEE" align="center"
capturemouseevents=false capturemouseclicks=false ignoreevents=true focusable=false draggable=false text="Health" />

<!-- Bar -->
<!-- The background is 1.003% wider and 26.667% higher than the bar -->

<UIIcon name="BOSS_HEALTHBAR_BORDER" x=ALIGN_CENTER y=29 height=42 width=454 img="xpbar_bg.tga" hidden="false"
capturemouseevents=false capturemouseclicks=false ignoreevents=true focusable=false draggable=false />
<UIProgressBar name="BOSS_HEALTHBAR" x=ALIGN_CENTER y=30 height=40 width=450 img="xpbar_blue.tga" hidden="false"
capturemouseevents=false capturemouseclicks=false ignoreevents=true focusable=false draggable=false />
And here is the script it calls:-
 
// SCRIPT ADAPTED TO HANDLE A TIMER BAR (By Lance Botelle)

#include "INC_GUI_BOSSBAR"

void main()
{	
	float fPos = 0.0;	
	
	// CHECK FOR TIMER FIRST
	
	int TIMER = GetLocalInt(OBJECT_SELF, "TIMER");
	int TIMERFULL = GetLocalInt(OBJECT_SELF, "TIMERFULL");	
	fPos = IntToFloat(TIMER)/IntToFloat(TIMERFULL);	
		
	// ELSE ALLOW MONSER HIT POINT UPDATE
	
	if(TIMERFULL == 0)
	{
	object oObject = GetLocalObject(OBJECT_SELF, "SCREEN_BOSS_TARGET");	
	string sVariable = GetLocalString(OBJECT_SELF, GUI_BOSSBAR_VARNAME_FLOAT);
		
		if(sVariable != ""){fPos = GetLocalFloat(oObject, sVariable);}
		
		else
		{
			int nMaxHP = GetMaxHitPoints(oObject);
			if(GetIsObjectValid(oObject) && nMaxHP != 0)
			{
				fPos = IntToFloat(GetCurrentHitPoints(oObject)) / IntToFloat(nMaxHP);
			}
		}
		
	}
			
	// UPDATE THE BAR(S)
	SetGUIProgressBarPosition(OBJECT_SELF, "SCREEN_BOSS", "BOSS_HEALTHBAR", fPos);
	SetGUIObjectText(OBJECT_SELF, "SCREEN_BOSS", "BOSS_TEXT", -1, "TIME REMAINING: " + IntToString(TIMER));	
	
	// RUNE PUZZLE BAR
	SetGUIProgressBarPosition(OBJECT_SELF, "RUNES_IMAGE", "BOSS_HEALTHBAR", fPos);	
}
Cheers,
Lance.


EDIT: This link shows a TIMER progress bar in operation:-

http://worldofalthea...me-puzzles.html
  • BartjeD aime ceci

#6
Tchos

Tchos
  • Members
  • 5 042 messages

If you get that working, that can open some doors.  I'd like to see it.



#7
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

If you get that working, that can open some doors.  I'd like to see it.


Hi Tchos,

EDITED FOR CLARITY

I'm not aware of any problems doing this ... It sounds like there is a problem I may be missing?

EDIT: OK, you caught my curiosity ... I am looking at this more closely now, and will post a working version ... hopefully.

Cheers,
Lance.

#8
Tchos

Tchos
  • Members
  • 5 042 messages

I wasn't suggesting that there would be a problem, I was just expressing an interest in the implementation of a mana system like this with a bar, which I haven't yet seen.  I meant it as a little encouragement.  There are a lot of things that I'd like to see, which would pose no problem to create, but either no one has yet had the interest to do so, or has not yet taken the time.



#9
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi Again,

OK, this was a really quick test and I only edited a couple of things to make it display, and it looks OK on testing:-

MANBARTEST.jpg

Here are the two scripts I used:-

ON MODULE REST:-
 
// This scripts defines the maximum mana of a creature
 
 
void main()
{	
	// THE PC RESTING
	object oRester = GetLastPCRested();
	
	int Levels = GetTotalLevels(oRester, 0);
 
	int Class_1 = GetClassByPosition(1, oRester);
	int Class_2 = GetClassByPosition(2, oRester);
	int Class_3 = GetClassByPosition(3, oRester);
	int Class_4 = GetClassByPosition(4, oRester);
	
	int CLVL_1 = GetLevelByClass(Class_1, oRester);
	int CLVL_2 = GetLevelByClass(Class_2, oRester);
	int CLVL_3 = GetLevelByClass(Class_3, oRester);
	int CLVL_4 = GetLevelByClass(Class_4, oRester);
	
	int C_HP_1 = StringToInt(Get2DAString("classes", "HitDie", Class_1));
	int C_HP_2 = StringToInt(Get2DAString("classes", "HitDie", Class_2));
	int C_HP_3 = StringToInt(Get2DAString("classes", "HitDie", Class_3));
	int C_HP_4 = StringToInt(Get2DAString("classes", "HitDie", Class_4));
	
	int C_SK_1 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_1));
	int C_SK_2 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_2));
	int C_SK_3 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_3));
	int C_SK_4 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_4));
	
	int C_MP_1 = 18 - C_HP_1 - C_SK_1;
	int C_MP_2 = 18 - C_HP_2 - C_SK_2;
	int C_MP_3 = 18 - C_HP_3 - C_SK_3;
	int C_MP_4 = 18 - C_HP_4 - C_SK_4;
	
	int MaxCls = CLVL_1 * C_MP_1 + CLVL_2 * C_MP_2 + CLVL_3 * C_MP_3 + CLVL_4 * C_MP_4;
	int MaxWis = Levels * GetAbilityModifier(4, oRester);
	int MaxTot = MaxCls + MaxWis;
	if (MaxTot < Levels)
	{
		MaxTot = Levels;
	}
	string MaxTot_String = IntToString(MaxTot);
	SetLocalInt(oRester, "Clangeddin_Maximum_Mana", MaxTot);
	
	//Current Mana
	
	int FirstCheck = GetLocalInt(oRester, "Clangeddin_Mana_First_Time");
	
	if (FirstCheck == 0)
	{
		SetLocalInt(oRester, "Clangeddin_Current_Mana", MaxTot);
		SetLocalInt(oRester, "Clangeddin_Mana_First_Time", 1);
	}	
	
	if (oRester == oRester)
	{
		SetLocalInt(oRester, "Clangeddin_Current_Mana", MaxTot);
	}
	
	int Current_MP = GetLocalInt(oRester, "Clangeddin_Current_Mana");
	string CMP_String = IntToString(Current_MP);
	string Display_Message = CMP_String + "/" + MaxTot_String;
	
	float mp_ratio = IntToFloat(Current_MP) / IntToFloat(MaxTot);
	
	SetGUIObjectText(oRester, "SCREEN_PARTY_BAR", "MP_DISPLAY", -1, Display_Message);
	SetGUIProgressBarPosition(oRester, "SCREEN_PARTY_BAR", "MP_BAR", mp_ratio);
	
  	FloatingTextStringOnCreature(Display_Message, oRester, TRUE, 2.0);
	
}
PartyBar.XML
 
<?xml version="1.0" encoding="utf-8">

<UIScene name="SCREEN_PARTY_BAR" x=ALIGN_RIGHT y=ALIGN_TOP width=212 height=602 scriptloadable="true"
capturemouseclicks=false capturemouseevents=false priority="SCENE_INGAME"/>
	
	<UIListBox name="PARTY_LIST" x=0 y=0 width=212 height=PARENT_HEIGHT xPadding=0 yPadding=0 
		showpartialchild=true scrollbaronright=true unequalcontrols=true scrollsegmentsize=60 hidescrollbarwhennotneeded=true capturemouseclicks=false
		update=true OnUpdate=UIListBox_OnUpdate_UpdatePartyBar() 	>

		<UIPane name="CHAR_BOX" x=ALIGN_LEFT y=ALIGN_TOP width=197 height=86 prototype=true capturemouseclicks=false capturemouseevents=false >

			<!-- status effect grid -->
			<UIGrid name="STATUSEFFECT_GRID" columns=4 rows=3 x=0 y=5 xPadding=1 yPadding=1 capturemouseclicks=false capturemouseevents=false >
				<UIButton name="EFFECT_BUTTON_1" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,9) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_2" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,6) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_3" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,3) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_4" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,0) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_5" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,10) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_6" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,7) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_7" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,4) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_8" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,1) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_9" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,11) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_10" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,8) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_11" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,5) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_12" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,2) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
			</UIGrid>

			<UIText name="current_hp" x="125" y="15" width="58" height="30" align="left" valign="top" fontfamily="Special_Font" style="2" 
			update=true OnUpdate=UIText_OnUpdate_DisplayHealth("CURRENT_HEALTH") />

			<UIText name="max_hp" x="125" y="45" width="58" height="30" align="right" valign="bottom" fontfamily="Special_Font" style="2" 
			update=true OnUpdate=UIText_OnUpdate_DisplayHealth("MAX_HEALTH") />

			<!-- portrait -->
			<UIButton name="PM_PORTRAIT" x=119 y=0 width=78 height=86 handleactiontarget=true 
				OnLeftClick=UIButton_Input_PossessCompanion("PARTY_BAR_SLOT",-1)
				OnRightClick=UIButton_Input_TargetCompanion("PARTY_BAR_SLOT",-1)
				OnLeftDoubleClick=UIButton_Input_CameraCompanion("PARTY_BAR_SLOT",-1)
				OnMouseDropReceived=UIButton_OnDropReceived_PartyItemTransfer()
				OnRadialRequest=UIObject_OnRadial_DisplayActionTargetRadial()
				OnToolTip=UIObject_Tooltip_DisplayPartyBarData("FULLNAME",OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT)
				update=true OnUpdate=UIButton_OnUpdate_UpdatePlayerState(-1,"p_m_frame_selection","p_nc_frame") >
				<UIFrame state=base		fill="p_m_frame_noselect.tga" />
				<UIFrame state=up		fill="b_empty.tga" />
				<UIFrame state=down		fill="b_empty.tga" />
				<UIFrame state=focused	fill="b_empty.tga" />
				<UIFrame state=hilited	fill="b_empty.tga" />
				<UIFrame state=hifocus	fill="b_empty.tga" />
				<UIFrame state=disabled fill="b_empty.tga" />
			</UIButton>
			
			<!-- frame states -->
			<UIIcon name="PORTRAIT_FRAME_DEAD"		x=119 y=0 width=78 height=86 img="p_m_dead2.tga"			hidden=true ignoreevents=true 
				update=true OnUpdate=UIObject_OnUpdate_CheckCharacterHealth("DEAD") draggable=false />
			<UIIcon name="PORTRAIT_FRAME_DYING"		x=119 y=0 width=78 height=86 img="p_m_dying.tga"			hidden=true ignoreevents=true 
				update=true OnUpdate=UIObject_OnUpdate_CheckCharacterHealth("DYING") draggable=false />
			<UIIcon name="PORTRAIT_FRAME_LEVELUP"	x=119 y=0 width=78 height=86 img="p_m_level_up.tga"			hidden=true ignoreevents=true
				update=true OnUpdate=UIObject_OnUpdate_CheckForLevelUp() draggable=false />
			<UIIcon name="PORTRAIT_FRAME_PARTYLEADER" x=119 y=0 width=78 height=86 img="p_mp_party_leader.tga"	hidden=true ignoreevents=true
				update=true OnUpdate=UIObject_OnUpdate_CheckForPartyLeader() draggable=false />

			<!-- hp bar -->
			<UIIcon name="HP_BAR_FRAME"				x=100 y=0 width=19 height=86 img="p_m_health_frame.tga"
				OnToolTip=UIObject_Tooltip_DisplayPartyBarData("HP_RATIO",OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) />
			<UIProgressBar name="HP_BAR"			x=102 y=10 width=15 height=65 vertical=true img="p_m_health_fill.tga" 
				update=true OnUpdate=UIProgressBar_OnUpdate_DisplayPartyHPPercentage(-1) >
			</UIProgressBar>			
			<UIIcon name="HP_BAR_BG"				x=100 y=10 width=15 height=65 img="p_m_health_bg.tga" />
			<!-- Character Custom Portrait icon -->
			<UIIcon name="CUSTOM_PORTRAIT_ICON"  x=121 y=13 width=64 height=64 hidden=true />


			<UIText name="MP_DISPLAY" x=99 y=31 width=100 height=18 align=center valign=middle fontfamily="Special_Font_2" style="2" />
			<UIProgressBar name="MP_BAR" x=99 y=31 width=100 height=18 vertical=false img="p_m_health_fill.tga" > </UIProgressBar>			
			<UIIcon name="MP_BAR_BG" x=99 y=31 width=100 height=18 img="p_m_health_bg.tga" />
			

			<!-- character render             -->    	
			<UIPortrait name="PORTRAIT_BG" x=121 y=13 width=64 height=64 hidden=true prototype=true texture="p_m_bg_dark.tga"
				update=true OnUpdate=UIPortrait_OnUpdate_UpdatePartyPortrait(-1)
				OnRender=UIPortrait_OnRender_RenderPartyPortrait() draggable=false
				ambground_intens=".4" ambgroundcolor_r=".7" ambgroundcolor_g=".55" ambgroundcolor_b=".4"
				ambsky_intens=".8" ambskycolor_r=".3" ambskycolor_g=".4" ambskycolor_b=".78"        
				diffusecolor_r=.9 diffusecolor_g=.8 diffusecolor_b=.6
				light_intens=0 >
		
        				<UIPointLight active="true" pos_x="0" pos_y="1" pos_z="1" radius="4" intensity=".2" 
        				color_r="1" color_g=".6" color_b="0" 
        				speccolor_r=".5" speccolor_g=".2" speccolor_b="0" />

     
        				<UIPointLight active="true" pos_x="1" pos_y="1" pos_z="1" radius="3" intensity="2.0" 
        				color_r=".31" color_g=".42" color_b=".58" 
        				speccolor_r=".31" speccolor_g=".42" speccolor_b=".58" />

     
        				<UIPointLight active="true" pos_x="-2" pos_y="1" pos_z="1" radius="3" intensity="2.5" 
        				color_r=".6" color_g=".55" color_b=".5" 
        				speccolor_r=".6" speccolor_g=".55" speccolor_b=".5" />

			</UIPortrait>
            <UIIcon name="default_icon" x=119 y=0 width=78 height=86 hidden=true img="p_m_unknown.tga" />

		</UIPane>

		<UIScrollBar name="SB" style="STYLE_SB_THIN"></UIScrollBar>	
	</UIListBox>
All I did to make sure it showed was to make sure I used images that I knew I had (changed names in XML) and just made oPC used throughout the script instead of OBJECT_SELF.

Cheers,
Lance.

#10
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

I wasn't suggesting that there would be a problem, I was just expressing an interest in the implementation of a mana system like this with a bar, which I haven't yet seen.  I meant it as a little encouragement.  There are a lot of things that I'd like to see, which would pose no problem to create, but either no one has yet had the interest to do so, or has not yet taken the time.


Hi Tchos,

Sorry ... my earlier post came across a little abrupt ... not intentional. :)

I just thought I had missed another point you were making ... that obviously was not there.

Anyway, hopefully, you can see the thing can be done from my post above.

Cheers,
Lance.

#11
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

Thanks everyone for their help, especially Lance Botelle, reading the first line of your xml code gave me the solution.

And yes, I think it's your tutorial that I've read. ^^

 

I have found what the problem was.

 

the partybar.xml was missing the line  scriptloadable="true" . Right at the beginning when you define the UIscene. Pretty much the xml was ignoring all GUI scripts from module, for some reason...

 

Adding that line solved everything. There was even no need to change the .nss script code.



#12
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

Thanks everyone for their help, especially Lance Botelle. Yes I think it's your tutorial that I've read. ^^
 
I have found what the problem was.
 
the partybar.xml was missing the line  scriptloadable="true" . Right at the beginning when you define the UIscene. Pretty much the xml was ignoring all GUI scripts from module, for some reason...
 
Adding that line solved everything. There was even no need to change the .nss script code.


Hi Clangeddin86,

Glad you found my tutorial helpful ... and as you are probably aware now, I mention that scriptloadable point in my tutorial. ;)

PAGE 8: UIScene: ... Finally, the scriptloadable is always required as TRUE, as this allows the module to use the GUI.

HOWEVER, is this your own XML then? (I am guessing it is from the changes I see) You do know that the OC PartBar.xml DOES have this line already in it ... unless you removed it during an edit of course. ;)

Anyway, glad you now have it up and running,

Cheers,

Lance.


 



#13
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

Hi Clangeddin86,

Glad you found my tutorial helpful ... and as you are probably aware now, I mention that scriptloadable point in my tutorial. ;)

PAGE 8: UIScene: ... Finally, the scriptloadable is always required as TRUE, as this allows the module to use the GUI.

HOWEVER, is this your own XML then? (I am guessing it is from the changes I see) You do know that the OC PartBar.xml DOES have this line already in it ... unless you removed it during an edit of course. ;)

Anyway, glad you now have it up and running,

Cheers,

Lance.


 

 

This happened because I modified an xml I downloaded (it's horizontal party frames by cyricc from here. )

I took that scriptloadable=true thing for granted, but I suppose the original creator of the xml removed it and I really didn't think about that possibility.



#14
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

I thought I had it won, but it appears the GUI wants to give me more trouble.

The script so far only works for the main character, it does not work for other party members.

As you can see, the floating numbers over their characters are their actual values in terms of MP, but the GUI either does not report them at all (partybar, only the mana bar's background appears for them and nothing else) or it reports the value of the main character on character screens of other characters (even when they're controlled, like in this case).

 

NWN2_Test_Screen_2.jpg



#15
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

By the way, I have dropped the custom UI by cyricc and just remade mine from scratch. I'll post the codes here again (both nss and xml) in case someone wants to help me once again.

// This scripts defines the maximum mana of a creature


void main()

{	

	object oPC = OBJECT_SELF;
	
	int Levels = GetTotalLevels(oPC, 0);

	int Class_1 = GetClassByPosition(1, oPC);
	int Class_2 = GetClassByPosition(2, oPC);
	int Class_3 = GetClassByPosition(3, oPC);
	int Class_4 = GetClassByPosition(4, oPC);
	
	int CLVL_1 = GetLevelByClass(Class_1, oPC);
	int CLVL_2 = GetLevelByClass(Class_2, oPC);
	int CLVL_3 = GetLevelByClass(Class_3, oPC);
	int CLVL_4 = GetLevelByClass(Class_4, oPC);
	
	int C_HP_1 = StringToInt(Get2DAString("classes", "HitDie", Class_1));
	int C_HP_2 = StringToInt(Get2DAString("classes", "HitDie", Class_2));
	int C_HP_3 = StringToInt(Get2DAString("classes", "HitDie", Class_3));
	int C_HP_4 = StringToInt(Get2DAString("classes", "HitDie", Class_4));
	
	int C_SK_1 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_1));
	int C_SK_2 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_2));
	int C_SK_3 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_3));
	int C_SK_4 = StringToInt(Get2DAString("classes", "SkillPointBase", Class_4));
	
	int C_MP_1 = 18 - C_HP_1 - C_SK_1;
	int C_MP_2 = 18 - C_HP_2 - C_SK_2;
	int C_MP_3 = 18 - C_HP_3 - C_SK_3;
	int C_MP_4 = 18 - C_HP_4 - C_SK_4;
	
	int MaxCls = CLVL_1 * C_MP_1 + CLVL_2 * C_MP_2 + CLVL_3 * C_MP_3 + CLVL_4 * C_MP_4;
	int MaxWis = Levels * GetAbilityModifier(4, oPC);
	int MaxTot = MaxCls + MaxWis;
	if (MaxTot < Levels)
	{
		MaxTot = Levels;
	}
	string MaxTot_String = IntToString(MaxTot);
	SetLocalInt(oPC, "Clangeddin_Maximum_Mana", MaxTot);
	
	//Current Mana
	
	int FirstCheck = GetLocalInt(oPC, "Clangeddin_Mana_First_Time");
	
	if (FirstCheck == 0)
	{
		SetLocalInt(oPC, "Clangeddin_Current_Mana", MaxTot);
		SetLocalInt(oPC, "Clangeddin_Mana_First_Time", 1);
	}
	
	object oRester = GetLastPCRested();
	
	if (oRester == oPC)
	{
		SetLocalInt(oPC, "Clangeddin_Current_Mana", MaxTot);
	}
	
	int Current_MP = GetLocalInt(oPC, "Clangeddin_Current_Mana");
	string CMP_String = IntToString(Current_MP);
	string Display_Message = CMP_String + "/" + MaxTot_String;
	
	float mp_ratio = IntToFloat(Current_MP) / IntToFloat(MaxTot);
	
	SetGUIObjectText(oPC, "SCREEN_CHARACTER", "MP_RATIO", -1, Display_Message);
	SetGUIObjectText(oPC, "SCREEN_PARTY_BAR", "MP_BAR_TEXT", -1, Display_Message);
	SetGUIProgressBarPosition(oPC, "SCREEN_PARTY_BAR", "MP_BAR", mp_ratio);
	
	FloatingTextStringOnCreature(Display_Message, oPC, TRUE, 2.0);
	
}

partybar.xml

<?xml version="1.0" encoding="utf-8">

<UIScene name="SCREEN_PARTY_BAR" x=ALIGN_RIGHT y=ALIGN_TOP width=212 height=602 scriptloadable="true"
capturemouseclicks=false capturemouseevents=false priority="SCENE_INGAME"/>
	
	<UIListBox name="PARTY_LIST" x=0 y=0 width=212 height=PARENT_HEIGHT xPadding=0 yPadding=0 
		showpartialchild=true scrollbaronright=true unequalcontrols=true scrollsegmentsize=60 hidescrollbarwhennotneeded=true capturemouseclicks=false
		update=true OnUpdate=UIListBox_OnUpdate_UpdatePartyBar() 	>

		<UIPane name="CHAR_BOX" x=ALIGN_LEFT y=ALIGN_TOP width=197 height=120 prototype=true capturemouseclicks=false capturemouseevents=false >

			<!-- status effect grid -->
			<UIGrid name="STATUSEFFECT_GRID" columns=4 rows=3 x=0 y=5 xPadding=1 yPadding=1 capturemouseclicks=false capturemouseevents=false >
				<UIButton name="EFFECT_BUTTON_1" width=20 height=20 style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,9) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_2" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,6) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_3" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,3) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_4" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,0) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_5" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,10) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_6" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,7) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_7" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,4) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_8" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,1) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_9" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,11) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_10" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,8) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_11" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,5) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
				<UIButton name="EFFECT_BUTTON_12" style="STYLE_BUFF_BUTTON" capturemouseclicks=false capturemouseevents=false 
					update=true OnUpdate=UIButton_OnUpdate_CheckStatusIcons("PARTY_BAR_SLOT",-1,2) 
					OnToolTip=UIObject_Tooltip_DisplayStatusIcon(OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT) >
				</UIButton>
			</UIGrid>

			<!--<UIText name="current_hp" x="125" y="15" width="58" height="30" align="left" valign="top" fontfamily="Special_Font" style="2" 
			update=true OnUpdate=UIText_OnUpdate_DisplayHealth("CURRENT_HEALTH") />

			<UIText name="max_hp" x="125" y="45" width="58" height="30" align="right" valign="bottom" fontfamily="Special_Font" style="2" 
			update=true OnUpdate=UIText_OnUpdate_DisplayHealth("MAX_HEALTH") />

			<!-- portrait -->
			<UIButton name="PM_PORTRAIT" x=119 y=0 width=78 height=86 handleactiontarget=true 
				OnLeftClick=UIButton_Input_PossessCompanion("PARTY_BAR_SLOT",-1)
				OnRightClick=UIButton_Input_TargetCompanion("PARTY_BAR_SLOT",-1)
				OnLeftDoubleClick=UIButton_Input_CameraCompanion("PARTY_BAR_SLOT",-1)
				OnMouseDropReceived=UIButton_OnDropReceived_PartyItemTransfer()
				OnRadialRequest=UIObject_OnRadial_DisplayActionTargetRadial()
				OnToolTip=UIObject_Tooltip_DisplayPartyBarData("FULLNAME",OBJECT_X,OBJECT_Y,SCREEN_TOOLTIP_2,ALIGN_NONE,ALIGN_NONE,0,0,ALIGN_LEFT)
				update=true OnUpdate=UIButton_OnUpdate_UpdatePlayerState(-1,"p_m_frame_selection","p_nc_frame") >
				<UIFrame state=base		fill="p_m_frame_noselect.tga" />
				<UIFrame state=up		fill="b_empty.tga" />
				<UIFrame state=down		fill="b_empty.tga" />
				<UIFrame state=focused	fill="b_empty.tga" />
				<UIFrame state=hilited	fill="b_empty.tga" />
				<UIFrame state=hifocus	fill="b_empty.tga" />
				<UIFrame state=disabled fill="b_empty.tga" />
			</UIButton>
			
			<!-- frame states -->
			<UIIcon name="PORTRAIT_FRAME_DEAD"		x=119 y=0 width=78 height=86 img="p_m_dead2.tga"			hidden=true ignoreevents=true 
				update=true OnUpdate=UIObject_OnUpdate_CheckCharacterHealth("DEAD") draggable=false />
			<UIIcon name="PORTRAIT_FRAME_DYING"		x=119 y=0 width=78 height=86 img="p_m_dying.tga"			hidden=true ignoreevents=true 
				update=true OnUpdate=UIObject_OnUpdate_CheckCharacterHealth("DYING") draggable=false />
			<UIIcon name="PORTRAIT_FRAME_LEVELUP"	x=119 y=0 width=78 height=86 img="p_m_level_up.tga"			hidden=true ignoreevents=true
				update=true OnUpdate=UIObject_OnUpdate_CheckForLevelUp() draggable=false />
			<UIIcon name="PORTRAIT_FRAME_PARTYLEADER" x=119 y=0 width=78 height=86 img="p_mp_party_leader.tga"	hidden=true ignoreevents=true
				update=true OnUpdate=UIObject_OnUpdate_CheckForPartyLeader() draggable=false />

			<!-- hp bar -->
			<UIText name="HP_BAR_TEXT" 			x=121 	y=78 width=64 height=15 color="black" align="center" valign="middle"
				update=true OnUpdate=UIObject_OnUpdate_GetCharacterData("PARTY_BAR_SLOT","HP_RATIO") />
			<UIProgressBar name="HP_BAR"		x=121	y=78 width=64 height=15 vertical=false img="p_m_health_fill.tga"
				update=true OnUpdate=UIProgressBar_OnUpdate_DisplayPartyHPPercentage(-1) >
			</UIProgressBar>
			<UIIcon name="HP_BAR_BG"			x=121 	y=78 width=64 height=15 img="p_m_health_bg.tga" />
			
			<!-- mp bar -->
			<UIText name="MP_BAR_TEXT" 			x=121 	y=93 width=64 height=15 color="black" align="center" valign="middle" />
			<UIProgressBar name="MP_BAR"		x=121	y=93 width=64 height=15 vertical=false img="p_m_mana_fill.tga" >	</UIProgressBar>
			<UIIcon name="MP_BAR_BG"			x=121 	y=93 width=64 height=15 img="p_m_health_bg.tga" />
			
			<!-- Character Custom Portrait icon -->
			<UIIcon name="CUSTOM_PORTRAIT_ICON"  x=121 y=13 width=64 height=64 hidden=true />

			<!-- character render             -->    	
			<UIPortrait name="PORTRAIT_BG" x=121 y=13 width=64 height=64 hidden=true prototype=true texture="p_m_bg_dark.tga"
				update=true OnUpdate=UIPortrait_OnUpdate_UpdatePartyPortrait(-1)
				OnRender=UIPortrait_OnRender_RenderPartyPortrait() draggable=false
				ambground_intens=".4" ambgroundcolor_r=".7" ambgroundcolor_g=".55" ambgroundcolor_b=".4"
				ambsky_intens=".8" ambskycolor_r=".3" ambskycolor_g=".4" ambskycolor_b=".78"        
				diffusecolor_r=.9 diffusecolor_g=.8 diffusecolor_b=.6
				light_intens=0 >
		
        				<UIPointLight active="true" pos_x="0" pos_y="1" pos_z="1" radius="4" intensity=".2" 
        				color_r="1" color_g=".6" color_b="0" 
        				speccolor_r=".5" speccolor_g=".2" speccolor_b="0" />

     
        				<UIPointLight active="true" pos_x="1" pos_y="1" pos_z="1" radius="3" intensity="2.0" 
        				color_r=".31" color_g=".42" color_b=".58" 
        				speccolor_r=".31" speccolor_g=".42" speccolor_b=".58" />

     
        				<UIPointLight active="true" pos_x="-2" pos_y="1" pos_z="1" radius="3" intensity="2.5" 
        				color_r=".6" color_g=".55" color_b=".5" 
        				speccolor_r=".6" speccolor_g=".55" speccolor_b=".5" />

			</UIPortrait>
            <UIIcon name="default_icon" x=119 y=0 width=78 height=86 hidden=true img="p_m_unknown.tga" />

		</UIPane>

		<UIScrollBar name="SB" style="STYLE_SB_THIN"></UIScrollBar>	
	</UIListBox>


#16
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

It doesn't work for party members because your UI can only be edited with scripts that target you, the PC. To access a party member's character icon on your party bar you need to give it a different name than the others because any calls to edit will use the first UI item (chronologically in the XML) with the desired name. Once they have a different name you need to execute a script with the PC as a target that sets the party member's MP.

 

I'm not actually quite sure how you'd go about making unique names in this particular UI because the listbox is populated by a game function instead of a script.



#17
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

By the way, I have dropped the custom UI by cyricc and just remade mine from scratch. I'll post the codes here again (both nss and xml) in case someone wants to help me once again.


Hi Clangeddin86,

Now you are coming up against the same issues I use to encounter with respect to GUIs working for all PCs/Players. Thankfully, I resolved the issues for all my GUIs and this one can (hopefully) be resolved too. :)

There are two ways to approach this (that I can see):-

1) Design your own custom GUI covering your new gaming design that displays each PCs mana bar one under the other in one new GUI (which you can then affect as desired).
2) Fiddle around with the x,y coordinates to make as many new GUI boxes as there will be PCs to appear in the portrait parts, using the HIDE GUI functions to not display your new GUIs when not required. (This is what you are currently trying to do.)

At a glance, and assuming the second approach, as I say, you will need to:-

A ) Define GUI boxes to appear under each PC as required. (Use HIDE GUI functions once the max PCs has been reached.)
B ) Ensure each new GUI mana box has its own unique name, using "NAME="(which you will update via your script). E.g. Name=MP_DISPLAY_01, Name=MP_DISPLAY_02, Name=MP_DISPLAY_03, Name=MP_DISPLAY_04, etc ... and the same for MP_BAR_01 and MP_BAR_BG_01, etc, etc.
C ) Assuming all your PCs (inc companions) rest when the Main PC rests, write a loop in your rest script to check the results for every faction member whose portrait you want to update. (*)

(*) I will make the assumption that every PC "rests" when the Main PC rests. However, I know that this may not be the case, as even in my own campaign, each PLAYER can rest their own group of PCs in a MP game. If yours is also catering for MP and you are also allowing PLAYERS to rest their own group of PCs independent of one another, then much more coding is involved.

With respect to "C" above, companions can also have their mana bar updated on their HB script if you set a variable on each of the companions who have rested (at the time the Main PC rests), which calls the progress bar update for them.

Now, I will assume you are all OK with general scripting for now, and so your main issue is with the XML script. As I say above, you need to design as many "MANA GUI" boxes as you wish to allow potential companions, and design them into the PartBar GUI, with the ability to HIDE them from your own initialisation code according to the actual number of portraits being displayed.

NOW, having said all that, there may be a way to automate the "bars per companion displayed", but I do not know of any way to do it, as I have not looked at this XML very closely. So, while I believe you should be able to achieve what you want, I also believe that you will need to add as many XML sections (that designs the Mana box) as you will potentially need.

Sorry for any repetition in this post .... Rather say too much that too little. ;)

Cheers,
Lance.

EDIT (EXAMPLE):-

<!-- mp bar -->
107. <UIText name="MP_BAR_TEXT_01" x=121 y=93 width=64 height=15 color="black" align="center" valign="middle" />
108. <UIProgressBar name="MP_BAR_01" x=121 y=93 width=64 height=15 vertical=false img="p_m_mana_fill.tga" > </UIProgressBar>
109. <UIIcon name="MP_BAR_BG_01" x=121 y=93 width=64 height=15 img="p_m_health_bg.tga" />

<!-- mp bar 2 -->
107. <UIText name="MP_BAR_TEXT_02" x=121 y=93 width=64 height=15 color="black" align="center" valign="middle" />
108. <UIProgressBar name="MP_BAR_02" x=121 y=93 width=64 height=15 vertical=false img="p_m_mana_fill.tga" > </UIProgressBar>
109. <UIIcon name="MP_BAR_BG_02" x=121 y=93 width=64 height=15 img="p_m_health_bg.tga" />
 
etc
 
NB: You would need to correct the x and y cords for every mana box to appear in the correct place.
 
Using the following line would stop the text from appearing if not needed ...

SetGUIObjectHidden(oPlayer, "SCREEN_PARTY_BAR", "MP_BAR_TEXT_02", TRUE);

Use similar lines to HIDE the other aspects of the GUI for the same portrait.

#18
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

<SNIP> What you have looks very similar to what I did to make a stamina bar appear next to the HP bar ...<SNIP>


Hi P-E,

Did you make a bar appear next to *every* party member or just the Main PC? If the former, what approach did you use?

Thanks,
Lance.

#19
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

Lance, I understand what you're trying to say, but wouldn't I need to be able to get the number of party members in one's party as well as their position on the screen? (for example, on that screen Beavil is 2nd and Aime is 3rd)

As far as I'm aware of, there are no such functions in the toolset.

And yeah, I'd like to make these changes possible for Multiplayer and games with multiples parties as well. =>

 

Thanks again for the help.



#20
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

Lance, I understand what you're trying to say, but wouldn't I need to be able to get the number of party members in one's party as well as their position on the screen? (for example, on that screen Beavil is 2nd and Aime is 3rd)
As far as I'm aware of, there are no such functions in the toolset.
And yeah, I'd like to make these changes possible for Multiplayer and games with multiples parties as well. =>
 
Thanks again for the help.


Hi Clangeddin86,

As I say, I am not familiar with this particular XML, but if you are looking at MP and multiple parties, then you may have to go full custom GUI, with a fixed display for each PC. There probably is a way to associate the additional GUIs with the individual portraits, but I do not know the answer without looking at it more closely, and I don't have that much spare time just now.

It will be interesting to hear what P-E answers to my query about their own additional bar. Maybe therein lies an answer.

If, however, I get more time, I will try to find another way ... or potential solution.

Personally, on something like this, unless an answer offers itself reasonably quickly (and straightforward) I would be inclined to go with my own GUI ... even if its an adaption of my own "HP Bar" .... Make a "Mana Bar" version instead. (See blog link.)

Cheers,
Lance.

#21
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

Hi P-E,

Did you make a bar appear next to *every* party member or just the Main PC? If the former, what approach did you use?

Thanks,
Lance.

Just the main PC.  For the former you need a custom UI with fixed prebuilt party member icons, and even then that might break game functions.



#22
BartjeD

BartjeD
  • Members
  • 249 messages

Have you tried attaching a 1, 2, 3, 4 to the UI Object name? It might be that the party portrait listbox just increments new entries. Or you could try the party member's name, or its 'object' translated to a string. Its a guessing game unless you're willing to redo the party portraits entirely.

 

That could be done dynamically, with a listbox. I don't think it will break the game if you remove or redo that UI. But its a lot more work. Guessing it might turn out to be easier if Obsidian did it simple, like with an incrementing number at the end for each new companion. But then I guess another problem would be keeping track of who-is-who.



#23
Clangeddin86

Clangeddin86
  • Members
  • 220 messages

I have somehow managed to cope with this with a "not as elegant as I initially planned" solution.

I just made a new GUI screen that tracks the mana of members of your faction (party?) from scratch.

It could not be done with the partybar screen because Obsidian had the brilliant idea of making the faction leader whoever you control (and also the first member of faction), that means that any time I rested or casted a spell with a different character selected, all the bars would be messed up.

No idea how this works in multiplayer, but here's the final result. (at the moment it's designed for a max of 20 faction members, but I could extend it to as many as I want.)

 

I can also share all the code involved if anyone is interested. Would be the least I could do after all the help I got here. =)

 

NWN2_Mana_UI.jpg


  • Loki_999 aime ceci

#24
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

I have somehow managed to cope with this with a "not as elegant as I initially planned" solution.
I just made a new GUI screen that tracks the mana of members of your faction (party?) from scratch.
It could not be done with the partybar screen because Obsidian had the brilliant idea of making the faction leader whoever you control (and also the first member of faction), that means that any time I rested or casted a spell with a different character selected, all the bars would be messed up.
No idea how this works in multiplayer, but here's the final result. (at the moment it's designed for a max of 20 faction members, but I could extend it to as many as I want.)
 
I can also share all the code involved if anyone is interested. Would be the least I could do after all the help I got here. =)

Hi Clangeddin86,

That GUI looks neat! And I actually *prefer* it being independent of the portraits! It means you can see the mana levels of all quickly (in my opinion).

I would be interested to check out your code ... it's all learning! :)

Also, (re MP), depending on how you are going to allow players to control the party will dictate the rest of it. For instance, I believe the DEFAULT position is that each player plays their own PC, but ONLY the leader gets to control the companions. I have altered the code quite considerably to work that each player can choose which companions they control within the party!

E.g. Two players join a game and each player can contact and play two companions each! Furthermore, these companions only obey the player's MainPC commands and rest/wait when they do. Yet, these companions can be taken over by any player at any time if need be.

Another function to look at that may be helpful with reference to the "prime" PC is to consider the GetIsPCHost function. However, for me to pull off what I needed for my MP control, I needed to write my own GetMainPC() function, which basically tracks the MainPC (of each player) as an object on any companions they control.

Let me know when and where I can take a look at your code.

Many Thanks.
Lance.



#25
Tchos

Tchos
  • Members
  • 5 042 messages

I'm interested, too.