PDA

View Full Version : Can anyone make a script for this...


NostalgiaEQ
10-08-2016, 06:15 AM
I need a script that prevents someone from looting an item from a corpse that has a required or recommended level above their current level. Is this possible? Willing to donate. Thanks. And/or makes the item on the corpse invisible to the player that doesn't meet the req lvl, race, class.

Shin Noir
10-08-2016, 03:00 PM
I don't think this is in the realm of built in quest scripts, it sounds like a source change to me.

NostalgiaEQ
10-08-2016, 03:42 PM
I don't think this is in the realm of built in quest scripts, it sounds like a source change to me.

Hmm k is it possible to edit the source? I remember reading someone saying they can disable buttons and things like that.

Nerdgasm
10-08-2016, 06:17 PM
Thought there was a script that put loot on mobs based off of level, but I cannot think of a script that would prevent you entirely from looting said item or making said item invisible to a person not of that class/race/level...

Maybe that level script could add a factor in for checking race/class? -shrug- not something I'm familiar with... Sorry I couldn't be of much help.

NostalgiaEQ
10-08-2016, 06:44 PM
Thought there was a script that put loot on mobs based off of level, but I cannot think of a script that would prevent you entirely from looting said item or making said item invisible to a person not of that class/race/level...

Maybe that level script could add a factor in for checking race/class? -shrug- not something I'm familiar with... Sorry I couldn't be of much help.

Thanks for that. The use of this would be to allow anyone to loot a corpse but only people high enough level to use items could loot them. Like allowing a server wide boss fight type thing.

Uleat
10-08-2016, 06:56 PM
Anyone to loot..but, only high enough to use it sounds like current default server behavior.


If you're talking about being able to equip items and they have a yellow background because you don't meet the level requirements..

..that's a client behavior found in Underfoot and higher clients.

The server really isn't coded to handle that issue at the moment.

NostalgiaEQ
10-08-2016, 09:01 PM
Sorry what I meant was anyone could "loot the corpse" but can only remove items off the corpse that they can use. So basically the corpses are all unlocked but if your level 5 for example you couldn't loot level 70 req items from the corpse.

Uleat
10-08-2016, 09:51 PM
The scripts work because of a trigger event in the loot corpse function: https://github.com/EQEmu/Server/blob/master/zone/corpse.cpp#L1173

By the time you get to this point..there's not much you can do without a recode..especially since there's no conditional on the call.


Ideally, you would want to not send the packet for any item they can't use.

Code Ref: https://github.com/EQEmu/Server/blob/master/zone/corpse.cpp#L1015

You could add something like this:

if(client && item) {
if (item->ReqLevel && (item->ReqLevel > client->GetLevel()))
continue;

ItemInst* inst = database.CreateItem(item, item_data->charges, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);



That would eliminate lower levels from seeing the item on the corpse..but, not disturb the actual corpse looting process.

NostalgiaEQ
10-08-2016, 10:20 PM
Interesting. So would it be possible to block the item packet being sent as well as prevent them from seeing it? What I'm understanding is that script will prevent low levels from seeing the item but it would still be there and they could remove it from the corpse is that correct? Or are you saying the item will just not be present at all if a low level loots the corpse, then the corpse would dissapear like there was nothing on it?

If it isn't possible to fully do what I want with this, another option would be is it possible to "instance" the corpse so multiple people can loot the items off it? Mabye as part of the fix in addition.

For example if we can block an item from bieng on a corpse if the person looting doesn't meet the lvl req, and also have the corpse instanced so multiple people can loot the same corpse, then the people who do meet the req will all be able to loot the item and those that don't meet the req would not.

Uleat
10-08-2016, 10:40 PM
That would be a minor code change and a recompile would be needed.

But, yes... The item would be invisible to clients who did not meet the level requirement..but, still remain on the corpse - which would keep it from disappearing
after closing the loot window.

The client can only loot items that it can see..so, no loot packets would ever come from the client for those items.


Instancing the corpse for multiple individuals is not a viable option since nothing server-side is set up for that (code, database, etc...)

That would just be asking for major issues down the road.

You'd probably be better off just adding multiples of that item..like certain keys are handled.

NostalgiaEQ
10-08-2016, 10:46 PM
That would be a minor code change and a recompile would be needed.

But, yes... The item would be invisible to clients who did not meet the level requirement..but, still remain on the corpse - which would keep it from disappearing
after closing the loot window.


Amazing, so that meets my requirements then it seems! I will give it a go within the next couple days and let you know. Also how could I modify the code to include checks for class and race in addition to level? Thanks a bunch!

Uleat
10-08-2016, 10:49 PM
Just remember that's off the cuff...

Keep an eye out for in-game issues and let me know if that doesn't compile - I'll double-check the property references.

NostalgiaEQ
10-08-2016, 11:02 PM
Cool. How can I modify that code to check for class and race in addition to level.

Basically to check for level and race and class.

Uleat
10-08-2016, 11:25 PM
That's a little more involved since items use bitmasks instead of integral values for those fields..

Currently, this is a good code reference for it: https://github.com/EQEmu/Server/blob/master/common/item_base.cpp#L170

But, you could just do:

if (item->ReqLevel && (item->ReqLevel > client->GetLevel()))
continue;
if (item->Races && (item->Races & ~GetPlayerRaceBit(client->GetRace())))
continue;
if (item->Classes && (item->Classes & ~GetPlayerClassBit(GetPlayerClassValue(client->GetClass()))))
continue;

NostalgiaEQ
10-08-2016, 11:33 PM
Of course, that's genius. I really really appreciate it! I will give it a go and let you know how it works. Hopefuly others can find it useful as well.

demonstar55
10-09-2016, 01:57 PM
A loot denial should 100% possible, epic 1.5/2.0 use it after all. We don't support this yet, but we need to figure it out. I know there is some state involved with looting, so I've been wanting to get a packet capture on live to make sure we do it right, but that requires doing some epic stuff out of order :P

This could also be a very simple reply like we already do on some failure cases.

NostalgiaEQ
10-09-2016, 03:22 PM
another quick question: what does rule value zone:markmqwarplt do and zone:mqwarpdetectiondistancefactor do exactly? If I lower the value on the distance factor will I catch more possible warps?

Uleat
10-09-2016, 07:12 PM
I was thinking about that code snippet last night and you may have issues with a person looting their own corpse.

Let me know if that is the case..we can just encapsulate those three checks inside a parent one.


EDIT: Something like:

if(client && item) {
if (!client->GetGM() && (!IsPlayerCorpse() || (IsPlayerCorpse() && (char_id != client->CharacterID())))) {
if (item->ReqLevel && (item->ReqLevel > client->GetLevel()))
continue;
if (item->Races && (item->Races & ~GetPlayerRaceBit(client->GetRace())))
continue;
if (item->Classes && (item->Classes & ~GetPlayerClassBit(GetPlayerClassValue(client->GetClass()))))
continue;
}

ItemInst* inst = database.CreateItem(item, item_data->charges, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);

NostalgiaEQ
10-09-2016, 07:19 PM
I was thinking about that code snippet last night and you may have issues with a person looting their own corpse.

Let me know if that is the case..we can just encapsulate those three checks inside a parent one.

Shouldn't be an issue on my server at least for now because I have naked corpses on. But my visual studio trial from akka's installer expired so I'm looking into figuring out how to recompile the server code so I should know within a couple days.

Darkscis
10-09-2016, 09:43 PM
Shouldn't be an issue on my server at least for now because I have naked corpses on. But my visual studio trial from akka's installer expired so I'm looking into figuring out how to recompile the server code so I should know within a couple days.

You just need to register and create an account for free. Sign in with that and you can continue to use VS.

NostalgiaEQ
10-11-2016, 12:10 AM
Thanks for the info on visual studio.

Thanks for the code update. So what I did is highlight the text on 1015 and pasted the snippet. Is that the right way to do it or do I need to delete more? Working on getting compiler up.

Edit: actually replaced line 1015 and 1016 with that.

Also when my compiler is up how exactly do I open this folder in there to compile?

Edit: figuring it out, need cmake and VS15

Uleat
10-11-2016, 08:03 PM
I made a change to the code snippet..oversight of untested code :/

The changed logic is correct - sorry about that!


There is no code 'replacement' involved.

Just go to the end of line 1015, press enter, then paste this on the new line:

if (!client->GetGM() && (!IsPlayerCorpse() || (IsPlayerCorpse() && (char_id != client->CharacterID())))) {
if (item->ReqLevel && (item->ReqLevel > client->GetLevel()))
continue;
if (item->Races && (item->Races & ~GetPlayerRaceBit(client->GetRace())))
continue;
if (item->Classes && (item->Classes & ~GetPlayerClassBit(GetPlayerClassValue(client->GetClass()))))
continue;
}


If you 'remove' any of the current code, you will have issues.

Shin Noir
10-11-2016, 08:07 PM
RIP Mr Beanatar. :(

NostalgiaEQ
10-12-2016, 04:10 AM
I made a change to the code snippet..oversight of untested code :/

The changed logic is correct - sorry about that!


There is no code 'replacement' involved.

Just go to the end of line 1015, press enter, then paste this on the new line:

if (!client->GetGM() && (!IsPlayerCorpse() || (IsPlayerCorpse() && (char_id != client->CharacterID())))) {
if (item->ReqLevel && (item->ReqLevel > client->GetLevel()))
continue;
if (item->Races && (item->Races & ~GetPlayerRaceBit(client->GetRace())))
continue;
if (item->Classes && (item->Classes & ~GetPlayerClassBit(GetPlayerClassValue(client->GetClass()))))
continue;
}


If you 'remove' any of the current code, you will have issues.

Thanks a ton, just having trouble figuring out how to get zlib installed so I can compile the server.

ghanja
10-12-2016, 10:46 AM
https://github.com/EQEmu/Server/wiki/MySQL-and-ZLIB-Dependencies

NostalgiaEQ
10-12-2016, 08:28 PM
https://github.com/EQEmu/Server/wiki/MySQL-and-ZLIB-Dependencies

Great thank you. So there are 2 header files, 2 lib files and an exp file. How exactly do I proceed? Do I move these files somewhere?

ghanja
10-12-2016, 09:49 PM
http://wiki.eqemulator.org/p?Complete_Windows-based_Server_Setup_Guide

Step 4b

NostalgiaEQ
10-12-2016, 10:02 PM
So I downloaded all those dependencies from that link then came up with the idea to paste them into the dependencies folder in the server source folder. Awesomely I put it in Cmake and it worked. Then I double clicked the sln file that was in the new folder cmake created and it ran in Visual studio then I clicked build button at the top and built it. This ran and 12 succeeded and 2 failed. So this then created a bunch of files in the bin folder. I pasted these files into the a copy of the old server folder I was running beforeand tried to start it up and got some unnamed errors for loginserver.exe, ucs.exe, etc. So I'm thinking those errors in visual studio are to blame. I don't know this is all very complicated and pretty far out of my league, I have compiled a program from source mabye once or twice. If you could give me any pointers it would be much appreciated.

Uleat
10-12-2016, 10:16 PM
The 2 'failed' binaries are definitely a problem.

You probably copied the last compile binaries for those failed files over and they probably don't match up.


You need to figure out what caused the failures on those 2 projects.

You can build once to get through all of the code-check messaging, then build again and that will help narrow down the messages to what is actually causing the failure.


EDIT: I'm going to take a stab and say that some external link can't be found..

NostalgiaEQ
10-13-2016, 02:09 AM
Woo got the server up! Turns out I guess the server source was 32 bit; I was using 64 bit zlib and compiling and all that since Akkas server I was using was 64 bit. Switched everything to 32 bit and it worked.

So the item edit is definitely doing something. Right now the only items I can see on the corpses is items that say NONE for race and class. Those are the only items I have been able to see. So if we could figure out how to allow for ALL class and race items to be looted by everyone that may be the only fix needed. It looks like even items that would work on a given race and class I'm playing don't show up either.

Hmm I do have GM powers so I'll try with no GM powers.
I tried with no GM power and it was still the same, nothing would show up besides items that were set to Race:none Class:none

The 2 'failed' binaries are definitely a problem.

You probably copied the last compile binaries for those failed files over and they probably don't match up.


You need to figure out what caused the failures on those 2 projects.

You can build once to get through all of the code-check messaging, then build again and that will help narrow down the messages to what is actually causing the failure.


EDIT: I'm going to take a stab and say that some external link can't be found..

NostalgiaEQ
10-25-2016, 01:29 PM
Uleat if you could contact me since your private messaging is off either here or nostalgiaeq@gmail.com I want to donate to your dev fund.

I think I am going to try to use the type of code you provided but in the lore item code instead so if they have the same item OR they don't meet the req's they get the same message; can see the item but not loot it.