Troubles with pure skills

01/24/2013 14:21 derpingson#1
Hello, i've been trying to add pure skills to my Archer Master npc,
CODE 1

CODE 2:

the difference between the 2 codes is
PHP Code:
if (!client.AddSpell(LearnableSpell(10313))) 
can you please help me? i'm confused
01/24/2013 16:09 pro4never#2
Not sure how the addspell method works in your source but there's a bit of poor logic involved here. Lets map it out.


You have 3 possible conditions


#1: You already know the skill.
#2: You qualify for the skill.
#3: You do not qualify for the skill.


Condition one is the simplest to check for. We just need to know if we already know the skill.

Condition two is a touch more difficult because we have to run a number of comparisons (current class, previous class, etc). Still pretty simple.



So... we end up with logic that flows something like...


Code:
if(user.KnowsSkill(skillID))
{	
	//Tell user they already know skill
}
else
{
	if(is pure archer)
	{
		//Learn the skill
	}
	else
	{
		//Tell them they don't qualify
	}
}
01/24/2013 17:34 -Sensei-#3
Chang the checker to..

If(client.entity.reborn >= 2)
{
dial;og here.
}



Dont use this,, this only checks for reborn ^^.. I missunderstood something :>..
01/24/2013 17:45 go for it#4
Quote:
Originally Posted by -Sensei- View Post
Chang the checker to..

If(client.entity.reborn >= 2)
{
dial;og here.
}
Code:
If(client.entity.reborn >= 2)
{
dialog here.
}
that check if the account is second reborn

Code:
if (client.Entity.Class == 45 && client.Entity.FirstRebornClass == 45 && client.Entity.SecondRebornClass == 45) 
                                    { 
dialog;
                                    }
but this check if the account is archer and was pure archer


back on topic
what confuse you is
Code:
                                        if (!client.AddSpell(LearnableSpell(10313))) 
                                        { 
                                            dialog.Text("You already know this skill."); 
                                            dialog.Option("Thank you master.", 255); 
                                            dialog.Send(); 
                                            break; 
                                        }
native trinity base doesn't have learnablespell method but AddSpell is a bool which add the spell if it failed return false
so your code will work pretty much the same if you removed learnablespell method
Code:
                                        if (!client.AddSpell(10313)) 
                                        { 
                                            dialog.Text("You already know this skill."); 
                                            dialog.Option("Thank you master.", 255); 
                                            dialog.Send(); 
                                            break; 
                                        }
but anyway you don't even need this check or this dialog , just treat him as he don't have the spell all the time , but if it false : the user won't get any notification
01/25/2013 12:44 derpingson#5
the "you already know this skill isn't important" so i made this

PHP Code:
 case 30:
                                {

                                    if (
client.Entity.Reborn >= && client.Entity.SecondRebornClass >= 22 && client.Entity.SecondRebornClass <= 25 && client.Entity.Class >= 22 && client.Entity.Class <= 25 && client.Entity.FirstRebornClass >= 22 && client.Entity.FirstRebornClass <= 25)
                                        {
                                            
Interfaces.ISkill spell = new Conquer_Online_Server.Network.GamePackets.Spell(true);
                                            
spell.ID 10311;
                                            
client.AddSpell(spell);
                                            
dialog.Text("Congratulations! you have learned Perseverance.");
                                            
dialog.Option("Thank you."255);
                                            
dialog.Send();
                                        }
                                        else
                                        {
                                            
dialog.Text("You are not allowed, I think you're not promoted yet or you're not pure Warrior.");
                                            
dialog.Option("Thank you."255);
                                            
dialog.Send();
                                        }                
                                    break;
                                } 

but it still gives the skill to any 2rb warrior, WTH i'm doing wrong!!!!
01/25/2013 13:56 go for it#6
about
Code:
                                    if (client.Entity.Reborn >= 2 && client.Entity.SecondRebornClass >= 22 && client.Entity.SecondRebornClass <= 25 && client.Entity.Class >= 22 && client.Entity.Class <= 25 && client.Entity.FirstRebornClass >= 22 && client.Entity.FirstRebornClass <= 25)
no warrior can reborn until first , second reb class is 25 , so you got useless check over there
replace it with
Code:
if (client.Entity.Class > 21 && client.Entity.Class < 26 && client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25)
add break point on this check and run , open the database , figure out what's wrong , but this should work fine
01/25/2013 15:37 pro4never#7
Why does no one use enumerated jobs? There's a reason TQ numbered them the way they did.


JobType = job / 10
JobLebel = job % 10


You can now enumerate them if you wish or create helper method (isWarrior, isArcher, etc)

There's no need for such... extensive (and expensive) logical checks)
01/26/2013 10:55 derpingson#8
i was a bit curious about how other sources are handling this, so i got a 5672 one and i found something i couldn't understand
Quote:
dialogs.Text("You have learned the XP Skills.");
dialogs.Option("Thank you master.", 0xff);
dialogs.Send();
client.AddSpell(LearnableSpell(0x456));
client.AddSpell(LearnableSpell(0x3f7));
why are the IDs like this "0x3f7"? i mean all the source is based on these numbers & letters

if someone knows what are these, i'm dying to know lol
01/26/2013 11:09 go for it#9
this "numbers and letters" are hex
i see it pointless to use hex in such cases
you can simply convert that values to dec from windows calculator (view ~> programmer) , or you can google it or use calculator
anyway here is the formula
Hexadecimal - Wikipedia, the free encyclopedia
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]

that piece of code you provide is not complete

Code:
dialogs.Text("You have learned the XP Skills.");
dialogs.Option("Thank you master.", 0xff);
dialogs.Send();
[B]the 3 above sending npc dialog to the client with one option of 255 which do nothing
[/B]client.AddSpell(LearnableSpell(0x456));
client.AddSpell(LearnableSpell(0x3f7));
[B]this add spell to the client , and most likely learnablespell is a method with checks for each skill but im not sure cuz i duno what source you working at[/B]
01/26/2013 11:31 derpingson#10
thank you very much

it was useful to me,

thank you all :)