Jump to content

check if potion is already active


Go to solution Solved by Doose,

Recommended Posts

  • Premium

Check if the affect is active then return.

 

char_item.cpp:

example:

 

case APPLY_ATT_SPEED:
									if (FindAffect(AFFECT_ATT_SPEED, POINT_ATT_SPEED))
									{
										ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
										return false;
									}
									else
									{
										AddAffect(AFFECT_ATT_SPEED, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true);
#ifdef ENABLE_EFFECT_EXTRAPOT	
										EffectPacket(SE_SPEEDUP_GREEN);
#endif
									}
									break;

 

Edited by Hunger
Link to comment
Share on other sites

  • Developer

You can make use of the 'FindAffect' function which returns 'nullptr' (if the player doesn't have the affect) or a pointer to the affect.

 

CAffect* FindAffect(DWORD dwType, BYTE bApply = APPLY_NONE) const;

if (ch->FindAffect(AFFECT_COLLECT)) { // Checks if the player has the affect AFFECT_COLLECT.
  // code if the player has the AFFECT_COLLECT.
} else {
 // code if the player doesn't have the affect. 
}



You can also use it like this:
if (ch->FindAffect(AFFECT_COLLECT, POINT_HT)) // Checks for AFFECT_COLLECT that gives POINT_HT(Vitality).

 

P.S: I used 'AFFECT_COLLECT' as an example, you can get a list of the affects from affects.h

Edited by Finnis
  • Lmao 1

r

Link to comment
Share on other sites

  • Active+ Member
  • Solution
On 3/11/2021 at 11:31 AM, Jordan said:

I'd like to check if as example a green potion is already active and want to block it when it is already active.

Someone know how to do this? Or is there maybe already a How To for it? I haven't found it.

 

Thanks for help!

Go in char_item.cpp

For purple potion:

 

Find: case USE_ABILITY_UP:

In: 

                                case APPLY_MOV_SPEED:
                                    AddAffect(AFFECT_MOV_SPEED, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true);
                                    break;

 

Change for:

 

                                case APPLY_MOV_SPEED:
                                    if (FindAffect(AFFECT_MOV_SPEED))
                                    {
                                        ChatPacket(CHAT_TYPE_INFO, LC_TEXT("BU_ETKI_DEVAM_EDIYOR"));
                                        return false;
                                    }
                                    AddAffect(AFFECT_UNIQUE_ABILITY, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true, true);
                                    break;

 

---------

 

For green potion:

 

find: case USE_ABILITY_UP:

in:

                                case APPLY_ATT_SPEED:
                                    AddAffect(AFFECT_ATT_SPEED, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true);
                                    break;

 

 

Change for:

 

 

                                case APPLY_ATT_SPEED:
                                    if (FindAffect(AFFECT_ATT_SPEED))
                                    {
                                        ChatPacket(CHAT_TYPE_INFO, LC_TEXT("BU_ETKI_DEVAM_EDIYOR"));
                                        return false;
                                    }
                                    AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true, true);
                                    break;

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.