PDA

View Full Version : Functions


cofruben
04-25-2004, 04:03 AM
I've done the following perl functions:permaclass(class),permarace(race),permag ender(gender),surname("surname") and scribespells().Scribespells scribes all spells to the user,up to his level,so if the user is lvl 9,he will get all spells up to 9.I am adding more functions at the moment,so look here sometimes.Be sure to use correct ID's,and strings(like surname,cannot be number).

This goes into parser.cpp,for example by line 800:

else if (!strcmp(strlwr(command),"addldonpoint")) {
if (mob && mob->IsClient())
mob->CastToClient()->UpdateLDoNPoints(atoi(arglist[0]),atoi(arglist[1]) );
}
else if (!strcmp(strlwr(command),"surname")) { //Cofruben:-Changes the last name.
if (mob && mob->IsClient())
{
mob->CastToClient()->ChangeLastName(arglist[0]);
mob->CastToClient()->Message(15,"Your surname has been changed/set to: %s",arglist[0]);
}
else
mob->CastToClient()->Message(15,"Error changing/setting surname");
}
else if (!strcmp(strlwr(command),"permaclass")) {//Cofruben:-Makes the client the class specified
mob->CastToClient()->SetBaseClass(atoi(arglist[0]));
mob->CastToClient()->Save(2);
mob->CastToClient()->Kick();
}
else if (!strcmp(strlwr(command),"permarace")) {//Cofruben:-Makes the client the race specified
mob->CastToClient()->SetBaseRace(atoi(arglist[0]));
mob->CastToClient()->Save(2);
mob->CastToClient()->Kick();
}
else if (!strcmp(strlwr(command),"permagender")) {//Cofruben:-Makes the client the gender specified
mob->CastToClient()->SetBaseGender(atoi(arglist[0]));
mob->CastToClient()->Save(2);
mob->CastToClient()->Kick();
}
else if (!strcmp(strlwr(command),"scribespells")) {//Cofruben:-Scribe spells for user up to his actual level.
int book_slot;
int16 curspell;
for(curspell = 0, book_slot = 0; curspell < SPDAT_RECORDS && book_slot < MAX_PP_SPELLBOOK; curspell++)
{
if
(
spells[curspell].classes[WARRIOR] != 0 &&
spells[curspell].classes[mob->CastToClient()->GetPP().class_-1] <= mob->CastToClient()->GetLevel() &&
spells[curspell].skill != 52
)
{
mob->CastToClient()->ScribeSpell(curspell, book_slot++);
}
}
}
else if (!strcmp(strlwr(command),"changedeity")) { //Cofruben:-Changes the deity.
if (mob && mob->IsClient())
{
mob->CastToClient()->SetDeity(atoi(arglist[0]));
mob->CastToClient()->Message(15,"Your Deity has been changed/set to: %i",arglist[0]);
mob->CastToClient()->Save(1);
mob->CastToClient()->Kick();
}
else
mob->CastToClient()->Message(15,"Error changing Deity");
}


this goes to embparser.cpp,before myra comment for example(line ~412):

"sub permagender{push(@cmd_queue,{func=>'permagender',args=>join(',',@_)});}"//Cofruben:-New perma functions
"sub permarace{push(@cmd_queue,{func=>'permarace',args=>join(',',@_)});}"
"sub scribespells{push(@cmd_queue,{func=>'scribespells',args=>join(',',@_)});}"
"sub permaclass{push(@cmd_queue,{func=>'permaclass',args=>join(',',@_)});}"
"sub surname{push(@cmd_queue,{func=>'surname',args=>join(',',@_)});}"
"sub addldonpoint{push(@cmd_queue,{func=>'addldonpoint',args=>join(',',@_)});}"
"sub changedeity{push(@cmd_queue,{func=>'changedeity',args=>join(',',@_)});}"

add this in client.h,for deity change:

inline void SetDeity(uint32 i) {m_pp.deity=i;}

Hope it helps.

smogo
04-26-2004, 03:15 AM
It certainly does. :) Just added it to Quest Repository CVS code.

Note that these may break the char record if used unproperly, but, well, quests writers be carefull !

How about writting a short 'how to add more functions to quests', that describes argument declaration, and so and so ... More people could contribute and have custom functions in their quests.

KhaN
05-01-2004, 08:47 PM
/drool
In which release this will be added ?

KhaN
05-15-2004, 01:25 AM
Corfuben, i have a question. Is it possible to ass a PERL command to change deity ?

Dave987
05-15-2004, 03:01 AM
Nice work, thanks alot :wink:

Charmy
05-15-2004, 05:53 AM
Very nice, this will come in handy for sure, could put a guy in the pok that casts perma illusions so you can go into cities that you are normally KoS, and khan had a good idea on the deity change, only question i would have with that is deity based spells. would it just make it so you couldn't mem the spell? or would you crash each time you opened your spell book =/? if i knew how to code it i would try =(, anyway thanks for the cool code =) nice work.

animepimp
05-15-2004, 08:12 AM
I haven't really looked at the code for it but it would probably have no effect on spells you already know but you wouldn't be able to learn new spells that have a restricted diety because it is most likely only checked when learning the spell. I say this because this is how equipment works, if you equip something and change classes the equipment continues to work until you take it off.

cofruben
05-17-2004, 12:45 AM
I didnt find any client function to change the deity,so you will have to make three things things.

in parser.cpp add this:

else if (!strcmp(strlwr(command),"changedeity")) { //Cofruben:-Changes the deity.
if (mob && mob->IsClient())
{
mob->CastToClient()->SetDeity(atoi(arglist[0]));
mob->CastToClient()->Message(15,"Your Deity has been changed/set to: %i",arglist[0]);
mob->CastToClient()->Save(1);
mob->CastToClient()->Kick();
}
else
mob->CastToClient()->Message(15,"Error changing Deity");
}


add this to embparser.cpp

"sub changedeity{push(@cmd_queue,{func=>'changedeity',args=>join(',',@_)});}"


and finally,add this to client.h:

inline void SetDeity(uint32 i) {m_pp.deity=i;}


here is a list of deity:
Agnostic 396
Veeshan 200
Bertoxxulous 201
Brell_Serilis 202
Cazic-Thule 203
Erollisi Marr 204
Bristlebane 205
Innoruuk 206
Karana 207
Mithaniel Marr 208
Prexus 209
Quellious 210
Rallos Zek 211
Rodcet Nife 212
Solusek Ro 213
Tribunal 214
Tunare 215


See you later.

KhaN
05-17-2004, 12:47 AM
wow ... very nice and thanks corfuben :)
/bow

cofruben
05-17-2004, 12:59 AM
just edited the code,was not working because I had no chance to test it.It works good now.

Dave987
05-17-2004, 09:58 AM
Heh heh , honored to work with ya corf.. you are "teh l337" .. way to go man :wink: