Help with setflag
Help with setflag
I've created two new functions SetFlagGoodGuy and SetFlagBadGuy in the same area as SetFlagBlue, etc..
now, these other functions both return a number, but I don't know how that relates to anything. I've created custom flags and I want to attach those to these new functions so that they may be displayed. I've made the necesarry changes in UpdateFlag().
Any other places I'll have to make changes? Also do I have to worry about the behavior for these flags? They are designed to just operate as if the flag owners were regular Blue people.
now, these other functions both return a number, but I don't know how that relates to anything. I've created custom flags and I want to attach those to these new functions so that they may be displayed. I've made the necesarry changes in UpdateFlag().
Any other places I'll have to make changes? Also do I have to worry about the behavior for these flags? They are designed to just operate as if the flag owners were regular Blue people.
-
Maarc
- Developer
- Posts: 576
- Joined: Sat Mar 27, 2004 6:22 am
- Location: Fleet, UK
- Has thanked: 0
- Been thanked: 0
- Contact:
Not really understanding what you're trying to ask here. I'm guessing you made 2 new flag states (0x10 and 0x20), one for good, one for bad. Have you created two new IsSomething() funcs as well? eg IsInnocent, IsNeutral, etc, like just above SetFlagBlue. Because you'll need them to access later.
But yes, you're adding flags, so you're going to have to add logic in a number of spots. Your flags won't piggy back on any others, so anywhere that deals with flag logic (do a find in files for something like "IsInnocent"), you'll have to add your own custom code, I'm sure. A quick glance through sees things like:
* WillResultInCriminal
* HandleFieldEffects
* AttackTarget
* HandleHealerAI
* callGuards
* criminal
* FlagColour
* PlayerAttack
* spell checks galore
* almost anything in ai.cpp
and you'd want to look at adding properties to the JS engine to expose it. Look for all references to CCP_MURDERER to start with.
But why do you think you need more flags? Is there perhaps another way you can achieve what you want?
But yes, you're adding flags, so you're going to have to add logic in a number of spots. Your flags won't piggy back on any others, so anywhere that deals with flag logic (do a find in files for something like "IsInnocent"), you'll have to add your own custom code, I'm sure. A quick glance through sees things like:
* WillResultInCriminal
* HandleFieldEffects
* AttackTarget
* HandleHealerAI
* callGuards
* criminal
* FlagColour
* PlayerAttack
* spell checks galore
* almost anything in ai.cpp
and you'd want to look at adding properties to the JS engine to expose it. Look for all references to CCP_MURDERER to start with.
But why do you think you need more flags? Is there perhaps another way you can achieve what you want?
Why can't the flag states piggy back? They already have the same exact functionality as an existing state.
How about if I just modified the "SetFlagBlue" flag to take an extra parameter (karma) so it can further specify which color to flag the name?
It's not that I need more flags, it's just that I want to make use of blue and red names. See I have changed the code so everyone is pretty much either green, gray, orange or beige. Friends, Neutrals, Criminal/Enemy, Animals.
Now I just want to make it so people with higher karma have blue names and people with lower karma have red names.
How about if I just modified the "SetFlagBlue" flag to take an extra parameter (karma) so it can further specify which color to flag the name?
It's not that I need more flags, it's just that I want to make use of blue and red names. See I have changed the code so everyone is pretty much either green, gray, orange or beige. Friends, Neutrals, Criminal/Enemy, Animals.
Now I just want to make it so people with higher karma have blue names and people with lower karma have red names.
-
Maarc
- Developer
- Posts: 576
- Joined: Sat Mar 27, 2004 6:22 am
- Location: Fleet, UK
- Has thanked: 0
- Been thanked: 0
- Contact:
Because not all states are potentially combinable. You can't be innocent and a murderer, or innocent and a criminal. Though perhaps there should be room for being both criminal and a murderer (though I think murderer tends to take precedence).
Effective display colour in that regard is done via CChar::FlagColour. You'll see orange/green based on guild/racial enemies, ofr instance, as well as blue/grey/red based on innocence, criminality and murder, for instance. If you manipulate that function, then it should display blue/red names differently, though obviously doesn't alter the server rulesets with regards to attacking and so forth. But it'll alter the name and highlight display, I should think.
Effective display colour in that regard is done via CChar::FlagColour. You'll see orange/green based on guild/racial enemies, ofr instance, as well as blue/grey/red based on innocence, criminality and murder, for instance. If you manipulate that function, then it should display blue/red names differently, though obviously doesn't alter the server rulesets with regards to attacking and so forth. But it'll alter the name and highlight display, I should think.
I don't see how this is relevant though. No states are being combined. The system is entirely cosmetic. People with Blue names, Gray Names, and Red Names still highlight blue.Maarc wrote:Because not all states are potentially combinable. You can't be innocent and a murderer, or innocent and a criminal. Though perhaps there should be room for being both criminal and a murderer (though I think murderer tends to take precedence).
I'm having trouble figuring out what is the exact function which is the final step for applying the color to the name from where all flagging must pass through, since that's where I want to run the check. From what you were saying it sounds like the actually flagging of color is done in a bunch of different places and has no one universal method location. But if FlagColor is the mother of all flagging, then I suppose I would have to make it look something like this:
Code: Select all
FlagColors CChar::FlagColour( CChar *toCompare )
{
FlagColors retVal = FC_INNOCENT;
GUILDRELATION gComp = GR_UNKNOWN;
SI08 rComp = 0;
SIl6 nCurKarma = toCompare->GetKarma();
if( ValidateObject( toCompare ) )
{
if( !IsIncognito() )
{
gComp = GuildSys->Compare( this, toCompare );
rComp = Races->Compare( this, toCompare );
}
}
if( IsInvulnerable() )
retVal = FC_INVULNERABLE;
else if( IsMurderer() )
retVal = FC_MURDERER;
else if( IsCriminal() )
retVal = FC_CRIMINAL;
else if( IsNeutral() )
retVal = FC_NEUTRAL;
else if( rComp != 0 || gComp != GR_UNKNOWN )
{
if( gComp == GR_ALLY || gComp == GR_SAME || rComp > 0 )
retVal = FC_FRIEND;
else if( gComp == GR_WAR || rComp < 0 )
retVal = FC_ENEMY;
}
//else if( gComp == GR_WAR || rComp <0> 10000)
if(retVal == FC_INNOCENT){
if(nCurKarma > 10000)
retVal = FC_GOOD;
else if (nCurKarma < -10000)
retVal = FC_BAD;
else
retVal = FC_INNOCENT;
}
return retVal;
}
-
Maarc
- Developer
- Posts: 576
- Joined: Sat Mar 27, 2004 6:22 am
- Location: Fleet, UK
- Has thanked: 0
- Been thanked: 0
- Contact:
If all you want to do, and nothing else, is change the text of the single click on a person, effectively, that's simple enough. CPISingleClick::Handle() calls CSocket::ShowCharName()
That's it. Either change CSocket::GetFlagColour() (which calls CChar::FlagColour()), or hack your values in there.
The point is, though, those states are relevant. Flag colour only returns colour information based on server flag status: eg are they a criminal?
The purpose of GetFlagColour/FlagColour is to return the text colour for their name, as well as the colour they will highlight, because they're identical in nature, really.
But if you don't want them to highlight differently and just have different coloured names, that's all you have to do. Line 1558 of cSocket.cpp.
As far as FC_INNOCENT goes, it's an enum of our own in enums.h:
Code: Select all
toAdd.Colour( GetFlagColour( mChar, i ) );
The point is, though, those states are relevant. Flag colour only returns colour information based on server flag status: eg are they a criminal?
The purpose of GetFlagColour/FlagColour is to return the text colour for their name, as well as the colour they will highlight, because they're identical in nature, really.
But if you don't want them to highlight differently and just have different coloured names, that's all you have to do. Line 1558 of cSocket.cpp.
As far as FC_INNOCENT goes, it's an enum of our own in enums.h:
Code: Select all
enum FlagColors
{
FC_INNOCENT = 1,
FC_FRIEND,
FC_NEUTRAL,
FC_CRIMINAL,
FC_ENEMY,
FC_MURDERER,
FC_INVULNERABLE
};
Code: Select all
if(retVal == FC_INNOCENT){
if(nCurKarma >= 10000)
retVal = FC_GOOD;
else if (nCurKarma <= -10000)
retVal = FC_BAD;
}-
Maarc
- Developer
- Posts: 576
- Joined: Sat Mar 27, 2004 6:22 am
- Location: Fleet, UK
- Has thanked: 0
- Been thanked: 0
- Contact:
An IDE is your friend 
cBaseObject.cpp, line 2029
It's a simple retrieval, nothing more. The issue is more likely either Karma(), which is calculation upon killing. But even more so, I suspect it's just the numbers you chose. We cap at -10000 and 10000, because that's the numbers that the UO client uses. -10000 is the lowest it can be for evil people, 10000 is the highest. So the classic old "Lord" titles are there. But that's best of the best, and worst of the worst
0 is the neutral balance point, with roughly 1000 being the guard area, I think, before you wander into dangerous (plus or minus).
I just don't think, unless they're at max/min karma, you'll find players with karma that high/low.
Code: Select all
SI16 CBaseObject::GetKarma( void ) const
{
return karma;
}
It's a simple retrieval, nothing more. The issue is more likely either Karma(), which is calculation upon killing. But even more so, I suspect it's just the numbers you chose. We cap at -10000 and 10000, because that's the numbers that the UO client uses. -10000 is the lowest it can be for evil people, 10000 is the highest. So the classic old "Lord" titles are there. But that's best of the best, and worst of the worst
I just don't think, unless they're at max/min karma, you'll find players with karma that high/low.
Could it be possible that cChar.cpp is not finding the GetKarma Function for some reason?
I've tested the conditional using a random number generator. Half the time, people will come up with blue names, and the other half they come up with red names. So there's definately no problem with the actual flags.
I've included cBaseObject.h into cChar.cpp
I've tested the conditional using a random number generator. Half the time, people will come up with blue names, and the other half they come up with red names. So there's definately no problem with the actual flags.
I've included cBaseObject.h into cChar.cpp
Oh god, I've discovered the problem. toCompare doesn't refer to the object that is recieving the flag, it is referring to the person who is viewing the flag.
That means this script will make all innocents have blue names if YOUR karma is over 1000, or red names if your karma is under -1000.
Obviously, I need a way to reference the actual NPC, I guess this isn't the method I'm looking for
That means this script will make all innocents have blue names if YOUR karma is over 1000, or red names if your karma is under -1000.
Obviously, I need a way to reference the actual NPC, I guess this isn't the method I'm looking for
-
Maarc
- Developer
- Posts: 576
- Joined: Sat Mar 27, 2004 6:22 am
- Location: Fleet, UK
- Has thanked: 0
- Been thanked: 0
- Contact:
Ah, yup, that'd do it alright
You have to refer to the right objects.
As far as repurcussions, all you're doing is recolouring names. The fact that they all show as blue otherwise means the rep flagging's still fine. It just means you can't trust the colour of the name to determine if you can attack them
As far as repurcussions, all you're doing is recolouring names. The fact that they all show as blue otherwise means the rep flagging's still fine. It just means you can't trust the colour of the name to determine if you can attack them
