News:

For links to other Unlimited Adventures web pages, be sure to check the sticky in the General Discussion board.

Main Menu

Can Players Change Combat Icons?

Started by GoldBoxFan, November 11, 2011, 11:02:20 AM

Previous topic - Next topic

manikus

I'm trying to lay catch-up here...maybe you already tried this and it didn't work...

There are two functions that retrieve an index:
$IndexOf( Actor )   -> use in conjunction with $Name( String ) if you have a specific name
$MyIndex(  )      -> use for the active party member

Also, I would really like to use the icon index feature, and would very much like to use it as a GPDL function, not as part of the Logic Block.

manikus

Quote from: Mechanaut on October 23, 2017, 09:57:15 AM
I consider myself less than a novice with GDPL (at the moment), but in another (indie) game that I extensively mod, we have several functions available to access party characters... by name, variable party position, character ordinal (unchanging, and probably like your PC Index); as well as by race, class, and  inventory checks like :hasItem("dagger"), status checks like :hasCondition('paralyzed').  Iterating the list of PCs with these allows detection of champions that meet criteria.
DC can do all of these, including checking to see if items are readied and where in the enventory they are located. If anyone wants examples, just let me know.

Quote from: Mechanaut on October 23, 2017, 09:57:15 AM
Hypothetically, with equivalents to the above, perhaps a script could be written that checks the time, moon phase, and for any lycanthropes in the party; and updates their combat icons to a werewolf icon.  Or similarly checks for equipped shields, and updates the icon if one exists* for equipped shield.
Yes, we can do this in DC. In the not-so-distant past, I had tried something similar to the shield idea for a special weapon, and it worked.

Quote from: Mechanaut on October 23, 2017, 09:57:15 AM
*Do I recall correctly that DC avatars can technically have more than two frames?
Yes. In theory any even number of cells can be used - never tried more than 6 myself.

Mechanaut

Quote from: manikus on October 23, 2017, 01:38:39 PM
Yes. In theory any even number of cells can be used - never tried more than 6 myself.
So in theory, icons could become an optionally standardized sprite sheet; with several images that could be used if present.  An avatar could have one cell with a shield, and one for each class of weapon; possibly one for a corpse, and perhaps another for unconscious. Possibly three for a common transformation —or transition into animal forms, for those that can do that?

**Clever use of XOR could probably be allow loading only the changes (per cell) needed to update the icon from one cell to the next?

manikus

Quote from: Mechanaut on October 23, 2017, 02:32:29 PM
Quote from: manikus on October 23, 2017, 01:38:39 PM
Yes. In theory any even number of cells can be used - never tried more than 6 myself.
So in theory, icons could become an optionally standardized sprite sheet; with several images that could be used if present.  An avatar could have one cell with a shield, and one for each class of weapon; possibly one for a corpse, and perhaps another for unconscious. Possibly three for a common transformation —or transition into animal forms, for those that can do that?

**Clever use of XOR could probably be allow loading only the changes (per cell) needed to update the icon from one cell to the next?

In theory, yes. :)

Nol Drek

Quote from: Paul R. Stevens on October 23, 2017, 09:10:04 AM
Next, we need to to know how you want to identify
the particular character (or combatant).  You don't
like to use the character's name.  You suggested the
character index.  Another possibility is some attribute
of the character such as his class, his race, an
object in his possession, a spell he has memorized,
a special ability, an ASL entry, etc.  In combat,
a spell effect might be used to select the icon.

So I leave it to you to decide what might work best.

I believe that I can already write a script which checks the class, race, objects possessed, etc. for each party member using existing functions.

If $VAR target; stores the index of a character or combatant that I have selected in my script using existing functions, and iconIndex is an integer, then I want to be able to:

$SET_CHAR_ICON_INDEX(target,iconIndex)

So I am requesting a function: $SET_CHAR_ICON_INDEX(string,string)
"The time has come," the Walrus said, "to talk of many things:
Of shoes — and ships — and sealing-wax — of cabbages — and kings —
And why the sea is boiling hot — and whether pigs have wings."

http://www.noldrek.com

manikus

Quote from: Nol Drek on October 23, 2017, 08:23:43 PM
If $VAR target; stores the index of a character or combatant that I have selected in my script using existing functions, and iconIndex is an integer, then I want to be able to:

$SET_CHAR_ICON_INDEX(target,iconIndex)

So I am requesting a function: $SET_CHAR_ICON_INDEX(string,string)

Duly noted. :) I have added it to the list, but modified it to requesst both $GET_CHAR_ICON_INDEX() and $SET_CHAR_ICON_INDEX().

Paul R. Stevens

Editor and engine 3.32 implement Get and Set Icon Index.

Untested, of course.

manikus

Nice. Thanks, Paul. :)

I'll whip up something to test this and get back to everyone. The benedit of me doing this will mean I can provide an example of how the functions work.

manikus

Paul, engine 3.32 crashes spectacularly. :) I've attached a mini-mod to  show you when it occurs.

I've included the special icon, but you will need to add the rest of the Resources as usual.

Paul R. Stevens

I changed a 'G' to a 'S' and released engine version 3.33.
It seems to crash less often.

Nol Drek

Sorry this has taken me a while to test, but it works very well. Thank you, Paul!

The following simple GPDL script, attached to a Logic Block event, will set the icons of all 6 party members to icon index 2:
$SET_CHAR_ICON_INDEX( 0, 2 );
$SET_CHAR_ICON_INDEX( 1, 2 );
$SET_CHAR_ICON_INDEX( 2, 2 );
$SET_CHAR_ICON_INDEX( 3, 2 );
$SET_CHAR_ICON_INDEX( 4, 2 );
$SET_CHAR_ICON_INDEX( 5, 2 );


But, you might ask, what if there are not 6 party members? A more efficient way to change combat icons is to create a Special Ability named "ChangeIcon" with a script named "SetIconIndex". The code is less redundant and it will work for any size party.

Now the GPDL script in your logic block is:
$ForEachPartyMember( "ChangeIcon", "SetIconIndex" );

And the "ChangeIcon" Special Ability has the following "SetIconIndex" script:
$VAR me;
me = $IndexOf( $CharacterContext(  ) );
$SET_CHAR_ICON_INDEX( me, 2 );
"The time has come," the Walrus said, "to talk of many things:
Of shoes — and ships — and sealing-wax — of cabbages — and kings —
And why the sea is boiling hot — and whether pigs have wings."

http://www.noldrek.com

manikus

Thanks, Nol.

I hae actually made a demo to show the use of this feature, but after I made it, I thought it was pretty narrow, so have been meaning to update it and upload it. I will try and utilize your Logic Block approach as part of my effort. :)

manikus

#57
In leiu of adding a Special Ability to your party members, you can rewrite the initial function to handle any size party.


$VAR psz;
psz = $PARTYSIZE() -# 1;
$WHILE (psz >=# 0)
{
$SET_CHAR_ICON_INDEX(psz,2);
psz = psz -# 1;
};


manikus


Nol Drek

I did not realize that you could have a while loop in a GPDL script. It does not appear in the list of functions (probably because it is a control structure, not a function) on the right side of the script editor. I saw $ForEachPartyMember (SpecialAbilityName, ScriptName) and assumed that a for-each loop was my only option.

There are three control structures I can use in my scripts - $IF, $SWITCH, and $WHILE.

I will change the script to use the following $WHILE loop.

$VAR partyIndex;
partyIndex = 0;
$WHILE ( partyIndex <# $PARTYSIZE() ) {
    $SET_CHAR_ICON_INDEX( partyIndex, 2 );
    partyIndex = partyIndex +# 1;
};


I'm not sure why I prefer to increment the loop control variable and have meaningful variable names. Old dog doing old tricks, I guess.

Thanks for pointing me towards $WHILE  :)
"The time has come," the Walrus said, "to talk of many things:
Of shoes — and ships — and sealing-wax — of cabbages — and kings —
And why the sea is boiling hot — and whether pigs have wings."

http://www.noldrek.com