demonstar55
05-07-2009, 01:54 AM
So on PEQ at least, some keyed doors are handled by perl (no idea if AX does the same) but mainly this applies to VP, I know a few people used their augments on PEQ and were sad they couldn't get back into VP, so I decided to look into it and try to fix check_hasitem.pl to check for the augment, which I realized with our current set of tools we can't do, so I had to do crap etc etc
this is still not a good idea to use it as an augment (what if you die!)
All of these files are from rev478
zone/client.h
line 618 is the define for GetItemIDAt so I just added this below it at line 619
uint32 GetAugmentIDAt(sint16 slot_id);
zone/inventory.cpp
right below the Client::GetItemIDAt function I added the new function
GetItemIDAt is lines 214-221
below it add
// Returns an augment's ID that's in an item (returns INVALID_ID if not found)
uint32 Client::GetAugmentIDAt(sint16 slot_id) {
const ItemInst* inst = m_inv[slot_id];
sint16 i;
if (inst)
for (i = 0; i < 5; i++)
if (inst->GetAugmentItemID(i))
return inst->GetAugmentItemID(i);
// None found
return INVALID_ID;
}
These will become lines 223-234
Only problem I can see with this is that it checks through all the augslots, but should only return the first, might want to change it to accept slot_id, and augslot_id and then would just have the perl script change each slot
That should take care of the functions, now for the perl crap
zone/perl_client.cpp
on line 2633 it starts the XS(XS_Client_GetItemIDAt) function (lines 2633-2657)
below it I added
XS(XS_Client_GetAugmentIDAt); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_GetAugmentIDAt)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::GetAugmentIDAt(THIS, slot_id)");
{
Client * THIS;
uint32 RETVAL;
dXSTARG;
sint16 slot_id = (sint16)SvIV(ST(1));
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Client *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Client");
if(THIS == NULL)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash.");
RETVAL = THIS->GetAugmentIDAt(slot_id);
XSprePUSH; PUSHu((UV)RETVAL);
}
XSRETURN(1);
}
becoming lines 2659-2684
the following lines are what they should be at after adding the above
on line 3724 is the GetItemIDAt thing
newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$");
below it add
newXSproto(strcpy(buf, "GetAugmentIDAt"), XS_Client_GetAugmentIDAt, file, "$$");
this will be line 3725
now for the check_hasitem.pl
I just defined
my $augid1;
and above each if statment add
$augid1=$client->GetAugmentIDAt($slot1);
and change the if to
if($itemid1==$itmchk || $augid1==$itmchk)
I'll post a the full quest file on PEQ since I believe it's their file or something :P
http://www.projecteq.net/phpBB2/viewtopic.php?p=32013#32013
this is still not a good idea to use it as an augment (what if you die!)
All of these files are from rev478
zone/client.h
line 618 is the define for GetItemIDAt so I just added this below it at line 619
uint32 GetAugmentIDAt(sint16 slot_id);
zone/inventory.cpp
right below the Client::GetItemIDAt function I added the new function
GetItemIDAt is lines 214-221
below it add
// Returns an augment's ID that's in an item (returns INVALID_ID if not found)
uint32 Client::GetAugmentIDAt(sint16 slot_id) {
const ItemInst* inst = m_inv[slot_id];
sint16 i;
if (inst)
for (i = 0; i < 5; i++)
if (inst->GetAugmentItemID(i))
return inst->GetAugmentItemID(i);
// None found
return INVALID_ID;
}
These will become lines 223-234
Only problem I can see with this is that it checks through all the augslots, but should only return the first, might want to change it to accept slot_id, and augslot_id and then would just have the perl script change each slot
That should take care of the functions, now for the perl crap
zone/perl_client.cpp
on line 2633 it starts the XS(XS_Client_GetItemIDAt) function (lines 2633-2657)
below it I added
XS(XS_Client_GetAugmentIDAt); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_GetAugmentIDAt)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::GetAugmentIDAt(THIS, slot_id)");
{
Client * THIS;
uint32 RETVAL;
dXSTARG;
sint16 slot_id = (sint16)SvIV(ST(1));
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(Client *,tmp);
}
else
Perl_croak(aTHX_ "THIS is not of type Client");
if(THIS == NULL)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash.");
RETVAL = THIS->GetAugmentIDAt(slot_id);
XSprePUSH; PUSHu((UV)RETVAL);
}
XSRETURN(1);
}
becoming lines 2659-2684
the following lines are what they should be at after adding the above
on line 3724 is the GetItemIDAt thing
newXSproto(strcpy(buf, "GetItemIDAt"), XS_Client_GetItemIDAt, file, "$$");
below it add
newXSproto(strcpy(buf, "GetAugmentIDAt"), XS_Client_GetAugmentIDAt, file, "$$");
this will be line 3725
now for the check_hasitem.pl
I just defined
my $augid1;
and above each if statment add
$augid1=$client->GetAugmentIDAt($slot1);
and change the if to
if($itemid1==$itmchk || $augid1==$itmchk)
I'll post a the full quest file on PEQ since I believe it's their file or something :P
http://www.projecteq.net/phpBB2/viewtopic.php?p=32013#32013