View Single Post
  #1  
Old 10-16-2002, 12:33 AM
Wiz
Dragon
 
Join Date: Feb 2002
Posts: 583
Default Modified WesQuests.cpp for multi item turnins and more

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:

Code:
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)

Code:
other->CastToClient()->CheckQuests(zone->GetShortName(),"%%attack%%",this->GetNPCTypeID(), 0, this);
This must be added to mob.h:

Code:
	int8    flag[60];
And this to Mob::Mob in mob.cpp:

Code:
	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:

Code:
TRIGGER_DEATH {
CHANCE 5
SPAWN_NPC 366
}
END_FILE
5% chance of spawning NPC 366 on death of the mob.

Code:
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

Have fun. :)
Reply With Quote