Log in

View Full Version : Item links triggered by quest scripts!


killspree
08-24-2003, 05:05 PM
This is something I saw requested recently and figured I'd code it into 4.4 for the time being, since it's the most functional version atm - it's easily converted to 5.0, though. The jist of this code is that it allows folks writing quests to have the NPC link a player an item on the correct trigger, much like a link is shown when players loot corpses. I figure this is a neat little feature to have and will be great for those serverops wanting to give players a preview of their possible rewards for completing specific quests.

So here we go!

parser.cpp ~line 2021 add:
else if (strstr(strlwr(arglist[0]),"itemlink")) {
const Item_Struct* item = 0;
int16 itemid = atoi(arglist[1]);
item = database.GetItem(itemid);
mob->CastToClient()->Message(0, "%s tells you, '%c00%i %s%c",other->GetName(),0x12, item->item_nr, item->name, 0x12);
}
NOTE: the space within the message between 00%i and %s is needed or the link text will be cut off.

parser.cpp ~line 2299 change:
#ifdef GUILDWARS

strn0cpy(com_list, "if 0|break 1|while 0|spawn 6|dbspawnadd 2|echo 1|summonitem 1|castspell 2|say 1|emote 1|shout 1|depop 1|cumflag 1|flagclient 2|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 0|save 0|setallskill 1|attack 1|movepc 4|setguild 2|setsky 1|movegrp 4|rebind 4|gmmove 3|cityfaction 1|report 0|", sizeof(com_list));

#else

strn0cpy(com_list, "if 0|break 1|while 0|spawn 6|dbspawnadd 2|echo 1|summonitem 1|castspell 2|say 1|emote 1|shout 1|depop 1|cumflag 1|flagclient 2|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 0|save 0|setallskill 1|attack 1|movepc 4|setguild 2|setsky 1|movegrp 4|rebind 4|gmmove 3|", sizeof(com_list));

#endif



#ifdef GUILDWARS2

strn0cpy(com_list, "if 0|break 1|while 0|spawn 6|dbspawnadd 2|echo 1|summonitem 1|castspell 2|say 1|emote 1|shout 1|depop 1|cumflag 1|flagclient 2|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 0|save 0|setallskill 1|attack 1|movepc 4|setguild 2|setsky 1|movegrp 4|rebind 4|gmmove 3|cityfaction 1|report 0|giveguildfunds 1|sayavailablefunds 0|", sizeof(com_list));

#endif

To:
#ifdef GUILDWARS

strn0cpy(com_list, "if 0|break 1|while 0|spawn 6|dbspawnadd 2|echo 1|summonitem 1|castspell 2|say 1|emote 1|shout 1|depop 1|cumflag 1|flagclient 2|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 0|save 0|setallskill 1|attack 1|movepc 4|setguild 2|setsky 1|movegrp 4|rebind 4|gmmove 3|cityfaction 1|report 0|itemlink 1|", sizeof(com_list));

#else

strn0cpy(com_list, "if 0|break 1|while 0|spawn 6|dbspawnadd 2|echo 1|summonitem 1|castspell 2|say 1|emote 1|shout 1|depop 1|cumflag 1|flagclient 2|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 0|save 0|setallskill 1|attack 1|movepc 4|setguild 2|setsky 1|movegrp 4|rebind 4|gmmove 3|itemlink 1|", sizeof(com_list));

#endif



#ifdef GUILDWARS2

strn0cpy(com_list, "if 0|break 1|while 0|spawn 6|dbspawnadd 2|echo 1|summonitem 1|castspell 2|say 1|emote 1|shout 1|depop 1|cumflag 1|flagclient 2|exp 1|level 1|safemove 1|rain 1|snow 1|givecash 4|pvp 1|doanim 1|addskill 2|flagcheck 1|me 1|write 2|settarget 2|follow 1|sfollow 0|save 0|setallskill 1|attack 1|movepc 4|setguild 2|setsky 1|movegrp 4|rebind 4|gmmove 3|cityfaction 1|report 0|giveguildfunds 1|sayavailablefunds 0|itemlink 1|", sizeof(com_list));

#endif

basic_functions.h ~line 344 add:
if (strstr(string,"itemlink")) { return 1; }

NOTE: My parser.cpp for 4.4 is HEAVILY modified, and is fairly old - I hand-merged a good bit of the 4.4 stuff in. The line numbers in the release source may not be the same, so I suggest you don't attempt to add this code unless you know where it should go within the files.

An example script of the code would be as follows:
EVENT_SAY{
if($1 == "Hail") { say("Greetings, $name! You seem like the adventurous type, is this [true]?") }
if($1- =~ "true") { say("Aha! I knew it! Well, lets see here... I may have something for you, and if you accept, I would be willing to give you a [choice] of rewards.") }
if($1- =~ "choice") { say("So you're interested, eh? I'll assume so and give you a glimpse of what you're in for if you can accomplish the goal! Your choices would be either a [sword], a [dagger], or a [club]. Just let me know which peaks your interest and I'll give you a bit o' taste of what you can expect!") }
if($1- =~ "sword") { itemlink("itemid") }
if($1- =~ "dagger") { itemlink("itemid") }
if($1- =~ "club") { itemlink("itemid") }
}

This of course is very basic code - if someone wants they can modify it to display the link within custom text, I'm sure.

Enjoy!

Scorpx725
08-24-2003, 06:36 PM
Wowa thats long! Thanks though, this should help me add a bit of creativity to my quests. :D