PDA

View Full Version : quest::collectitems


Secrets
11-16-2008, 07:57 AM
all credit for this goes to aza77, i'm just post it before it gets lost:

questmgr.cpp

int QuestManager::collectitems_processSlot(sint16 slot_id, uint32 item_id,
bool remove)
{
ItemInst *item;
int quantity = 0;

item = initiator->GetInv().GetItem(slot_id);

// If we have found matching item, add quantity
if (item && item->GetID() == item_id)
{
// If item is stackable, add its charges (quantity)
if (item->IsStackable())
{
quantity = item->GetCharges();
}
else
{
quantity = 1;
}

// Remove item from inventory
if (remove)
{
initiator->DeleteItemInInventory(slot_id, 0, true);
}
}

return quantity;
}

// Returns number of item_id that exist in inventory
// If remove is true, items are removed as they are counted.
int QuestManager::collectitems(uint32 item_id, bool remove)
{
int quantity = 0;
int slot_id;

for (slot_id = 22; slot_id <= 29; ++slot_id)
{
quantity += collectitems_processSlot(slot_id, item_id, remove);
}

for (slot_id = 251; slot_id <= 330; ++slot_id)
{
quantity += collectitems_processSlot(slot_id, item_id, remove);
}

return quantity;
}


questmgr.h non-protected area:

int collectitems(uint32 item_id, bool remove);
int collectitems_processSlot(sint16 slot_id, uint32 item_id, bool remove);

perlparser.cpp

XS(XS__collectitems);
XS(XS__collectitems)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: collectitems(item_id, remove?)");

uint32 item_id = (int)SvIV(ST(0));
bool remove = ((int)SvIV(ST(1))) == 0?false:true;

int quantity =
quest_manager.collectitems(item_id, remove);

XSRETURN_IV(quantity);
}

let me know if i'm missing anything. I think I got it all, though..

example of how it would work in a script:

sub EVENT_SAY {
my $itemstotake = quest::collectitems(1337, 0);
my $credittostore = $qglobals{credit} ? $qglobals{credit} : 0;
if($text=~/hail/i)
{
$credittostore += $itemstotake;
quest::collectitems(1337, 1);
quest::setglobal("credit", $credittostore, 5, "F");
quest::say("Ha! I will take all those items off you now, and tell you how many I have taken, while storing it in a global that adds items to itself! All at once! Muhahaha!");
quest::say("You now have $credittostore items!");
}
}


hopefully that's not too confusing on how to use it.

the script basically takes items from your character, or counts how many you have if you specify 0 on the remove flag. pretty neat command.
have fun!

Angelox
01-06-2009, 07:30 AM
Great piece of code, thanks Secrets!
Nice to see code submissions coming in still -

As for this;
This is the reason that the user gave:
This person has directly stolen code from the Raid Addicts source code.. He was a paid employee of Raid Addicts and was able to get this out of our source.. Azamorra donated this source to my server and told me to not give it to anyone else DIRECTLY... * Please delete this post and warn this user.. He has been fired from my project...

If I started to feel this way about code and submissions, then I'd stop submitting code to the SVN.
I hate to think ANYONE is hoarding code, since all other people here do is give away their best in code, time and work - Personally, If I were hoarding anything EqEmu related, I would feel ashamed.

demonstar55
01-06-2009, 12:05 PM
Great piece of code, thanks Secrets!
Nice to see code submissions coming in still -

As for this;


If I started to feel this way about code and submissions, then I'd stop submitting code to the SVN.
I hate to think ANYONE is hoarding code, since all other people here do is give away their best in code, time and work - Personally, If I were hoarding anything EqEmu related, I would feel ashamed.

To me, that quote sounds like you're saying RA applies changes to the EQEmu source and doesn't give it back to the project... which breaks the agreement set in the GPL, which this project uses...

Secrets
01-06-2009, 12:48 PM
This person has directly stolen code from the Raid Addicts source code.. He was a paid employee of Raid Addicts and was able to get this out of our source.. Azamorra donated this source to my server and told me to not give it to anyone else DIRECTLY... * Please delete this post and warn this user.. He has been fired from my project...

Yeah, about this guy...

1) How is stealing? As far as I know, you're profiting off of an opensource project, and other people who volunteer to your community.

2) You claim I am a paid employee. I did not sign any contract, I did not fill out a work permit, or any of that. I am a volunteer who you gave money to over paypal. You have no one to blame but yourself.

3) aza77 gave it to your server, however, that was a donation. It's not your code, it's not mine. I submitted it to prevent it from being lost in raid addicts code forever, it's quite useful, you know.

4) Do not delete this post, or warn this user; I have done nothing wrong by contributing code to a GPL project that was kept from it.

I have a long list of lies KingMort has said, such as, "SOE donates to my server", "Sony Developers play and test content here", etc... I could pull up a few quotes from last night too. "I am a registered government business", "I am registered with the state, and you stole from my server, all I have to do is call the Department of Justice to have you fined", etc.

I'm just saying, KingMort, you dedicate almost your entire life to this server in hopes you can profit on another companies' game, yet, you call me out and try and have me arrested because I distribute code on your server to an open-source community whose codebase you use? I find that greedy and selfish, and highly illegal in itself for various reasons.

This guy is a complete lunatic, Angelox. Pay no mind to him.

Richardo
01-06-2009, 01:35 PM
As soon as KingMort provides me with actual evidence that Aza77 did in fact donate this bit of code ONLY for the use of KMRA. This post stays. As for your threats in the PM you sent me KingMort, you're more than welcome to file a complaint against Secrets. I am not convinced that this is legally your code and I am also not convinced you are telling the complete truth.


It's a damn shame that you can't share such a minuet useful utility to the project that has given you so much.

Secrets
01-06-2009, 01:44 PM
I would also like to present further proof of stealing from a GPL Project.

http://egov.sos.state.or.us/br/pkg_web_name_srch_inq.show_detl?p_be_rsn=1340731&p_srce=BR_INQ&p_print=FALSE

He is a registered business that profits off of a GPL project.

Nice.

Yeormom
01-06-2009, 02:13 PM
There are a lot of businesses that resell GPL software. As long as he maintains the proper rights and distributes the GPL license, it's fair use.

However, the scope of the source shared is very small and would not be difficult for any competent coder to write so it's not worth arguing once it's been released to public domain.

Secrets
01-06-2009, 02:23 PM
There are a lot of businesses that resell GPL software. As long as he maintains the proper rights and distributes the GPL license, it's fair use.

However, the scope of the source shared is very small and would not be difficult for any competent coder to write so it's not worth arguing once it's been released to public domain.

true. however, i've yet to see any proof that this custom work his KingMort's actual work.

also, since he is using GPL v2,
Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

KingMort did not select a licence for his code, thus the code is public domain.

Andrew80k
01-06-2009, 03:31 PM
I'm pretty sure the GPL version < 3 only requires the source to be "made available" only if the binaries are distributed or sold. Google does this a lot. While you use their stuff they don't actually distribute it so they are not required to make the source available. If the binaries of the RA server have ever been distributed or sold to ANYONE though, that makes them subject to the that section of the GPL and the source would be required to be made available. It's a pretty crappy thing to do too. Profit from an open source project and then not contribute anything back to it is reprehensible.

Rogean
01-06-2009, 03:42 PM
Mort.. You're retarded.

Government Registered Business? Get the fuck outta here kid.

demonstar55
01-06-2009, 04:01 PM
I don't really know the GPL all that well, but judging by the basic idea and my personal beliefs what he is doing should be against the license and therefore what he is doing is illegal and if he is complaining and causing problems I think we should possibly try to see if what he is doing is against the GPL and I know that there should be people able to help us and make him stop committing a crime and give us the code back, since it's what the GPL should dictate him to do

Kobaz
01-06-2009, 04:51 PM
I do know the GPL very well, and Andrew80k is spot on - if there is no distribution of the binaries there is no obligation to make the source available.

There is another issue though, in that if a commercial entity makes a profit using the commercial secrets of another entity's trade secrets, and does it by circumventing that 2nd entity's endeavours to protect its' trade secrets, and it can be shown that this was done in bad faith, then there *may* be a case for the 2nd entity to take action against the 1st entity. Attempting to make money from something that relies on SOEs property being used outside the license (unlike say alla, which doesn't require you to have EQ to use it) is bold and legally a grey area.

I would think that any attempt to claim damages for distribution of emu source would result in a claim by SOE for a share in those damages. It's what I'd do.

KLS
01-06-2009, 07:40 PM
I'm not going to get into the petty drama, if Aza wants this removed he can PM me and I will other than that I'm locking this cause it's not going anywhere but flamesville.

trevius
01-06-2009, 10:51 PM
EDIT: Sorry, started this post before this thread was locked, but got hung up for a few hours and didn't submit it until much after the lock. I am leaving it here anyway. If someone thinks it needs to be removed for any reason, feel free, but I don't think there is anything to spread the flames. I actually meant to post about stopping the flames too, but this post was long enough as-is, lol.

I think the point to keep in mind with all of this is that this project would be no where if it wasn't for people sharing new code that they write with the entire project. From the beginning, the emulator code has evolved by dozens of people helping and sharing with the community. In the movie "A Beautiful Mind", they mention Nash's equilibrium theorem, which says that the best possible result is for each person in a non-cooperative activity to do what is best for themselves AND the group. So, to apply that to eqemu, it means that if everyone shared their own code, it would be better for the emulator as a whole, which in turn would be better for each individual server.

By only doing what is best for your own server and keeping all code additions to yourself, you are hurting potential for your server to grow. Sure, if each server had their own special code additions, they would each benefit from a certain number of players who enjoyed those additions. If those additions were not shared, each server would lose potential for player retention that may have been added by the additions other servers have made. This means that every server would be much weaker than they would be if the code was shared by all. By making all servers weaker this way, it weakens the project as a whole because none of the servers are getting the benefits of shared code between them. And by doing that, it means that players are more likely to stop playing the emulator sooner than they may have if there were more working systems and code additions to keep them interested longer. Imagine how many players the emulator would have now if we were still running on the server code from 6 years ago. There wouldn't be much interest in the project and it probably would have died due to lack of interest long before now.

While it certainly isn't all about competition (at least for most), there is still some competition between servers. Most servers want as many players as they can get/handle. All servers should consider that by growing the community, it grows the pool of total players who play the emulator, which will then grow the potential for how many players they can possibly get on their server. IMO, the competition aspect should be done 100% in content, support, quality and attitude. Each of those are things that can give each server an individual advantage that can't easily (if at all) be shared with the rest of the community to make it better as a whole. Basically, it should be your database and service quality that define how good your server is in comparison to other servers, not the code itself.

Each code addition to public source helps the entire project and everyone can benefit from it. We have been lucky that there are many members who are following this concept even if they aren't consciously aware that they are doing it. Just to think of all of the additions that have been made over the past few months with the new SVN is pretty amazing. I am sure there is plenty of eqemu related code out there that would make a huge impact, but is being kept locked away by the servers that use it. I am sure projects like EQClassic and Shards of Delaya have an abundance of code that would be great for eqemu to have. I imagine both of those projects have benefited greatly from the open source of EQEmu, and don't consider themselves to be affiliated with EQEmu so they keep their additions private. I am not trying to point fingers anywhere or make anyone feel bad, I am just trying to use examples. Perhaps if SoD opened it's source, we could merge their code into the SVN and they would be able to receive all of the updates from SVN for their server instead of either trying to add them in manually or just ignoring them completely and missing out on tons of great new features/fixes. As far as I know, the EQClassic project has died, so any code additions they came up with are now all wasting away as far as I know, which is just, well, a waste.

As many know, I have been working on getting Secrets of Faydwer (and all previous expansions) working for the emulator. Now, I could very easily keep this to myself and have it only running on my server. Doing that may give me a few extra players who already have the expansion, or who may want to check out the new features and content enough to get a copy of it. But, a large number of the eqemu player-base wouldn't waste the time/money to get the SoF expansion just to play on one server. If I was to share the code once I get it working (and I 100% plan to), it would allow the entire emulator to upgrade to allow SoF on their own servers. This would be something that would push most of the community to get a copy of SoF to use with the emulator to gain all of the benefits from it. It could also bring more new players to the emu, because it will have moved 2 years into the future instead of being stuck with an old and limited client.

All server admins should be well aware that large number of the eqemu player-base jumps from server to server from time to time. So, by helping to increase the over-all player-base between all servers is actually helping your own server in the end. Keeping code privately to a single server may help that server get or retain more players, but it is blocking the potential for the entire project to grow it's player-base. And since many players move around from server to server before settling on a new home, the bigger the entire project player-base is, the more potential for higher player numbers on your server is. So, let's say that your server gets 5% of the over-all project player-base (making up numbers here), and something happens that increases that total number of players project-wide, then your number of players will almost certainly rise too (at least eventually). Without making forward advances, improvements and additions to the current emu code, we can't expect an over-all rise in players for the entire project. But, if people continue sharing code and making advances, the project will remain alive and active and maybe even continue to grow.

I know I probably went way more in depth than needed here, but it is something I have been wanting to mention for a while. Keeping updates to the public source privately is actually hurting anyone who does it in the long run. None of us would be here now if it wasn't for people giving back to the community what the community has given to them 100 fold already from the public source. Everyone certainly has their right to keep source changes privately, but I don't think they realize that they are doing themselves as much bad as they are good by doing so.