PDA

View Full Version : Modified WesQuests.cpp for multi item turnins and more


Wiz
10-16-2002, 12:33 AM
I've been working a little on WesQuests.cpp, and here's my custom version of it, for anyone who'd want.

First of all, you need to make some minor changes to other files. Client.h must be modified to replace the current checkquests line with:


void CheckQuests(const char* zonename, const char* message, int32 npc_id, int32 item_id = 0, Mob* t_npc);


The t_npc trigger must be added to existing references to CheckQuests as well, such as dying, talking, etc.

The following line must be added to attack.cpp (NPC::Damage) where it does zone->AddAggroMob(), as well as anywhere else the mob gains aggro on something (NPCAi.cpp, for example)


other->CastToClient()->CheckQuests(zone->GetShortName(),"%%attack%%",this->GetNPCTypeID(), 0, this);


This must be added to mob.h:


int8 flag[60];


And this to Mob::Mob in mob.cpp:


for (int m = 0; m < 60; m++)
{
flag[m]=0;
}


This version sports the following triggers and effects:

TRIGGER_ATTACK - Makes the event take place when the mob gets into combat.

TRIGGER_FLAGS X X X X - Makes the event take place when a certain amount of "flags" have been set onto the NPC. X's are represented by flag numbers. Any flags NOT used should be set to 0. So for example, if the event should be run when the npc has set the flags 1, 2 and 5, it should be: TRIGGER_FLAGS 1 2 5 0. A trigger_flags will automatically unset all flags it the check is passed.

Effects:

FACTION_CHECK 1-6 - This is put in a block to check against faction. If the faction check is failed, the npc gives a "Will not deal with you" message and aborts.

Least required faction:
1: Ally
2: Kindly
3: Warmly
4: Amiably
5: Indifferent
6: Apprehensive

An NPC will NEVER respond to hail, flags or item event if it's threatingly or scowls to the person.

ADDCASH copper_amount - Adds copper_amount cash to the player.

NPC_FLAG X Y - Sets NPC flag X to Y. Please note - Don't use flag 50. It's reserved.

PLAYER_FLAG X Y - Sets PC flag X to Y. These are used for FLAG_CHECK.

FLAG_CHECK X - Checks PC flag X. If it's not > 0, aborts.

CHANCE X - Checks X against a d100. If the d100 beats X, aborts.

Additionally, this WesQuests removes the need for NPC_SCRIPT 99 etc at the top of the .qst files, since it's completely unnecessary with individual npc files.

One little bug I haven't been able to fix: You need to add END_FILE at the end of each .qst file with this, otherwise it creates a good bit of lag for a while. Working on that for the next version.

Below follows some examples of what you can do with this:


TRIGGER_DEATH {
CHANCE 5
SPAWN_NPC 366
}
END_FILE


5% chance of spawning NPC 366 on death of the mob.


TRIGGER_TEXT:Hail:{
SAY:Rrr, ya want a fight? Huh? Hah! Don't look so scared, just joking with ya. //Simple hail message
}
TRIGGER_TEXT:What sparring gloves:{
FACTION_CHECK 5 //Checks that faction is at least indifferent
SAY:Hmf! Can't get any proper sparring gloves for hand combat nowadays. The stuff we get breaks after a week! The tailor, Vayla, used to make us real stuff, but she said she ran out of materials. If you can get me four pairs of sparring gloves, and give them to my novices, I'd be grateful.
}
//Below are the old broken sparring gloves you get back when you give new ones to the novices.
TRIGGER_ITEM:3011:{
FACTION_CHECK 5
NPC_FLAG 1 1 //Sets flag 1 to 1
}
TRIGGER_ITEM:3012:{
FACTION_CHECK 5
NPC_FLAG 2 1 //Sets flag 2 to 1
}
TRIGGER_ITEM:3013:{
FACTION_CHECK 5
NPC_FLAG 3 1 //Sets flag 3 to 1
}
TRIGGER_ITEM:3014:{
FACTION_CHECK 5
NPC_FLAG 4 1 //Sets flag 4 to 1
}
TRIGGER_ATTACK {
SAY:YAR! AXE TO THE HEAD! //Attack message
}
TRIGGER_DEATH {
SAY:*cough* Good fight... good fi... argh.
}
TRIGGER_FLAGS 1 2 3 4 { //Always put trigger_flags last in the file. This will run when all 4 items are given in.
CHANGEFACTION 28 20
EXP 100
SAY:Thanks, sonny. Now I might be able to teach these bullheads something. Here, I think Wargus'll want this.
SPAWN_ITEM 3015
}
END_FILE //Put this at the end


WesQuests.cpp (http://wiz.addr.com/files/WesQuests.cpp)

Have fun. :)

Wiz
10-16-2002, 03:11 AM
Uploaded a small fix, NPC's were calling faction checks on attacks/deaths.

Trumpcard
10-16-2002, 03:13 AM
Very cool stuff... Wes and some others are rewriting the quest stuff if I remember correctly, hopefully all these new additions will be rolled in.

Having them not respond due to faction makes me want to work on getting 'sneak' in for rogues.. I use to love that aspect of playing one.

Wynsom
10-17-2002, 05:08 AM
Good stuff! I'll be implementing this on the Tigurius server soon as a get a free chunck of time.

DeletedUser
10-17-2002, 08:23 AM
FYI Wes and Solar are revamping the quest code, been planned for a while :P

Wiz
10-18-2002, 05:56 AM
Forgot to document one effect:

CUMULATIVE_FLAG - This adds one to flag 50.

TRIGGER_FLAGS 50 amt - This will check 50 for a certain amount. This is for multis of the same item, say you want 3 bone chips to result in a reward.

TRIGGER_ITEM:bonechip:{
CUMULATIVE_FLAG
}
TRIGGER_FLAGS 50 3{
Reward here
}

cybert
01-26-2003, 12:16 AM
Just 1 question about the CUMULATIVE_FLAG

Well, maybe 2 questions.

How do you reset the flag to 0 (zero) once the turn ins are complete? Are stackable items implemented in this? Does not seem to work for me. If i put a stack of 4, I get 1 increment on the flag.

For example, bone chips for faction. if i turn in 4 stacks of 4 I should get 4 faction hits. I am only getting 1.
Then each time i turn in a single bone chip i get another fation hit. Am i missing something?

-=CyberT=-

Wiz
01-26-2003, 04:14 AM
You need to put the faction hit under TRIGGER_FLAGS 50 4, which will automatically reset it to 0.

Drawde
01-26-2003, 04:33 AM
Looks very interesting - I'll have to see if I can incorporate some of these into my quest addon. Faction changes and (working) cash rewards in particular look useful.
Would it be possible to implement a single trigger command for multi-item turn-ins: E.g TRIGGER_MULTIITEM:13073:13073:13068:13068 which would be triggered when turning in 2 bone chips and 2 bat wings (think they are the right numbers). Because many quests require you to turn in several different items - e.g the Bard epic quest requires you to collect various parts for a lute.

cybert
01-26-2003, 12:11 PM
You need to put the faction hit under TRIGGER_FLAGS 50 4, which will automatically reset it to 0.

OK I have edited the script again to give the faction and exp. This quest should now work exactly like EQ Live.

Here is my script as it is currently written.....

NPC_SCRIPT 37919{
TRIGGER_TEXT:Hail, Trooper Mozo:{
EMOTE:looks on you smugly. 'And what are you? Some sort of adventurer. Bah!! You will be shaken by the first undead you come across. Wetting your pants you shall be. Ha ha!! I doubt you could even [kill the decaying skeletons].'
}

TRIGGER_TEXT:kill the decaying skeletons:{
SAY:You kill skeletons?!! I think not!! They will bounce you with no trouble at all. Ten silver says you cannot collect four bone chips!! When Velious melts!! Hah!
}

TRIGGER_ITEM:13073:{
CUMULATIVE_FLAG
}
TRIGGER_ITEM:13073:{
CUMULATIVE_FLAG
}
TRIGGER_ITEM:13073:{
CUMULATIVE_FLAG
}
TRIGGER_ITEM:13073:{
CUMULATIVE_FLAG
}

TRIGGER_FLAGS 50 4{
EMOTE:gasps in astonishment. Wha..? This!! But.. I.. Why you.. I oughta.. Alright!! A bet is a bet. Here you go. A few silver pieces for your achievement. What?!! You thought I would give ten? Fat chance! Now get lost or I will haul you in for impersonating a froglok.
CHANGEFACTION 2058 10
CHANGEFACTION 2213 10
CHANGEFACTION 2363 10
CHANGEFACTION 2347 10
CHANGEFACTION 2080 10
GIVE_CASH 70
EXP 100
}
}

Problem is that I get no notification of the faction adjustment. And then every time I turn in just 1 bone chip, I get more exp and the cash. The flag is not resetting.

Is the faction message supposed to show up and how do I check what my actual faction values are?

-=CyberT=-

Wiz
01-26-2003, 08:09 PM
CHANGEFACTION is broken, unfortunately. The flag not resetting thing is odd. A NPC_FLAG 50 0 would reset it, but it should do so automatically. Try changing to:

TRIGGER_FLAGS 50 4 {

Edgar1898
01-27-2003, 09:33 AM
My change faction works fine, I think I made a small change to it. Ill check when I get home but I know for a fact it works for my scripts.

Edgar1898
01-27-2003, 02:10 PM
I know what I did. It was getting hung up on checking to see if the input was a number, so I just removed the check:
else if (strstr(command,"CHANGEFACTION") != NULL) {
this->CastToClient()->SetFactionLevel2(this->CastToClient()->CharacterID(),atoi(sep.arg[1]), this->CastToClient()->GetClass(), this->CastToClient()->GetRace(), this->CastToClient()->GetDeity(), atoi(sep.arg[2]));
this->CastToClient()->Message(0,BuildFactionMessage(GetCharacterFactionL evel(atoi(sep.arg[1])),atoi(sep.arg[1]),atoi(sep.a rg[2])));
ps = true;
}
It works fine now...

cybert
01-27-2003, 04:33 PM
Awesome, I cant wait to get this recompiled and test it.

edit...

Finally got it recompiled with changes and it is working great. Now, I was assuming that in order to be able to accept all 4 bone chips at once, I needed to have 4 trigger_item lines for same item. with cumulative_flag being incremented in all 4 lines it gives the "award" on every turn-in after the original 4. if i change the last trigger to not increment teh flag, it works properly but does not register the fourth item in the same turn in. so i have gone back to requiring 1 item at a time. works perfectly that way. Just a little slow.

Well, at least the faction changes are working now.
-=CyberT=-

Wiz
01-30-2003, 01:45 AM
In order for it to increment 4 items at a time, you have to change the item trading in client_process to use TradeList[0-3] not just 0.

cybert
01-30-2003, 04:18 AM
use TradeList[0-3] not just 0.

I am assuming here that in client-process.cpp you were speaking of line 3245 that says...
CheckQuests(zone->GetShortName(), "%%item%%", tmp->CastToNPC()->GetNPCTypeID(), TradeList[0], tmp);

and change the code to this...
CheckQuests(zone->GetShortName(), "%%item%%", tmp->CastToNPC()->GetNPCTypeID(), TradeList[0-3], tmp);

I've done this and now get nothing when turing in items. Still looking through the code but for now I'm dealing... :)

Trumpcard
01-30-2003, 04:34 AM
Im amazed that even compiled...

I didnt think you could put an array range in..

You might want to try something more like this, but don't know 100% if it will work, im just guessing...

CheckQuests(zone->GetShortName(), "%%item%%", tmp->CastToNPC()->GetNPCTypeID(), TradeList[0], tmp);
CheckQuests(zone->GetShortName(), "%%item%%", tmp->CastToNPC()->GetNPCTypeID(), TradeList[1], tmp);
CheckQuests(zone->GetShortName(), "%%item%%", tmp->CastToNPC()->GetNPCTypeID(), TradeList[2], tmp);
CheckQuests(zone->GetShortName(), "%%item%%", tmp->CastToNPC()->GetNPCTypeID(), TradeList[3], tmp);

cybert
01-30-2003, 04:40 AM
Got it working for a 4 identical item turn in. 1 in each slot. Here is the code change...

for (int inum = 0; inum<4; inum++) {
if (TradeList[inum] != NULL)
CheckQuests(zone->GetShortName(), "%%item%%", tmp->CastToNPC()->GetNPCTypeID(), TradeList[inum], tmp);
}

Changed the quest to have a single TRIGGER_ITEM and it is working perfectly. Now to get the charges working... :)

mByte
01-30-2003, 05:00 AM
Changed the quest to have a single TRIGGER_ITEM and it is working perfectly. Now to get the charges working... :)

That would be cool to hand in a stack, i know for the longest time maybe still the case you cannot hand in stacked items on eqlive, as it treats it as 1 item.

Drawde
01-31-2003, 09:22 AM
Sounds very impressive! Looks like I'd better wait for the next EQEmu version before doing any more quest work.

froglok20
01-31-2003, 06:04 PM
after seeing the LEVEL_CHECK script command i got thinking and added CLASS_CHECK sort of the same, just checks class. its intened for single class only quests at the moment, i might update it abit. here is the code for it (to be added in wesquest.cpp)

else if (strstr(command,"CLASS_CHECK") != NULL) {
int8 classpc = this->GetClass();
int8 classreq = atoi(sep.arg[1]);
if(classpc != classreq)
{
entity_list.NPCMessage(other,true,200,0,"%s says, 'I will have nothing to do with such as you. Begone.'",other->GetName());
break;
}

ps = true;
}

so enjoy it, ill proberly next work on a RANDOM_TEM_SPAWN for nobo quests you sometimes get monye, noob items or random spells soon (when im not working)

enjoy

froglok20
01-31-2003, 06:13 PM
hehe forgot to explain how to use it

in ya quest file just add

LEVEL_CHECK 12 (or class number)

this will only allow wizards to do the quest. full list of classes are as followed (from ref sheet)

1 Warrior
2 Cleric
3 Paladin
4 Ranger
5 Shadow Knight
6 Druid
7 Monk
8 Bard
9 Rogue
10 Shaman
11 Necromancer
12 Wizard
13 Magician
14 Enchanter
15 Beastlord
16 Banker
17 GM Warrior
18 GM Cleric
19 GM Paladin
20 GM Ranger
21 GM ShadowKnight
22 GM Druid
23 GM Monk
24 GM Bard
25 GM Rogue
26 GM Shaman
27 GM Necromancer
28 GM Wizard
29 GM Magician
30 GM Enchanter
31 GM Beastlord
32 Shopkeeper


so if you only wanted a banker to be able to do the quest you would add

CLASS_CHECK 16

froglok20
02-03-2003, 02:41 PM
hey iv added 2 new functions to wesquest.cpp thry are

HAVE_ITEM (will check if you have a Item, on, in inventory or in the bank)

and

HAVE_ITEM_ON (will check if you have the item on your person )

examples:

HAVE_ITEM_ON 26776

HAVE_ITEM 1000

hope ya enjoy them

Code:

else if (strstr(command,"HAVE_ITEM_ON") != NULL) // Have a item on them, in their inventory
{
int8 hio = 0;

for (int inum=0; inum<80; inum++) {

if (inum < 10 && this->pp.cursorbaginventory[inum] == atoi(sep.arg[1]))
hio = 1;

if (inum < 30 && this->pp.inventory[inum] == atoi(sep.arg[1]) )
inum = 1;

if (inum < 80 && this->pp.containerinv[inum] == atoi(sep.arg[1]) )
hio = 1;
}
if(!hio)
{
entity_list.NPCMessage(other,true,200,0,"%s says, 'I will have nothing to do with such as you. Begone.'",other->GetName());
break;
}
ps = true;
}

else if (strstr(command,"HAVE_ITEM") != NULL) // Have a item on them, in their inventory or in the bank
{
int8 hiob = 0;

for (int inumb=0; inumb<80; inumb++) {

if (inumb < 80 && this->pp.bank_inv[inumb] == atoi(sep.arg[1]) )

if (inumb < 10 && this->pp.cursorbaginventory[inumb] == atoi(sep.arg[1]))
hiob = 1;

if (inumb < 30 && this->pp.inventory[inumb] == atoi(sep.arg[1]) )
hiob = 1;

if (inumb < 80 && this->pp.containerinv[inumb] == atoi(sep.arg[1]) )
hiob = 1;
}
if(!hiob)
{
entity_list.NPCMessage(other,true,200,0,"%s says, 'I will have nothing to do with such as you. Begone.'",other->GetName());
break;
}
ps = true;
}