PDA

View Full Version : setstat + incstat


aza77
04-10-2006, 10:07 AM
i missed a tool to set the stats of a character to a specific value. i needed it for a quest and as a result i got a command for guides/gms too. the old setstats is now incstats and still works like it did before. with these changes you can use quest::setstat(type,value) for example quest::setstat(0,80) would set the strength to 80. quest::incstat(type,value) for example quest::incstat(0,8) would raise the strength by 16. #setstat and #incstat work the same. oh and don't forget to add the incstat to addon.ini. the version 728 at the diff file is the updated 767.

diff -u -r EQEmu-0.6.6-767/zone/client.cpp EQEmu-0.6.6-728/zone/client.cpp
--- EQEmu-0.6.6-767/zone/client.cpp 2006-04-10 18:46:14.000000000 +0200
+++ EQEmu-0.6.6-728/zone/client.cpp 2006-04-10 22:52:52.000000000 +0200
@@ -1063,7 +1063,7 @@
UpdateWho();
}

-void Client::SetStats(int8 type,sint16 increase_val){ //changed the command to set the given skillpoints aza
+void Client::SetStats(int8 type,sint16 set_val){ //changed the command to set the given skillpoints
if(type>STAT_DISEASE){
printf("Error in Client::SetStats, received invalid type of: %i\n",type);
return;
@@ -1072,74 +1072,74 @@
IncreaseStat_Struct* iss=(IncreaseStat_Struct*)outapp->pBuffer;
switch(type){
case STAT_STR:
- if(increase_val>0)
- iss->str=increase_val;
- if((increase_val)<0)
+ if(set_val>0)
+ iss->str=set_val;
+ if(set_val<0)
m_pp.STR=0;
- else if((increase_val)>255)
+ else if(set_val>255)
m_pp.STR=255;
else
- m_pp.STR=increase_val;
+ m_pp.STR=set_val;
break;
case STAT_STA:
- if(increase_val>0)
- iss->sta=increase_val;
- if((increase_val)<0)
+ if(set_val>0)
+ iss->sta=set_val;
+ if(set_val<0)
m_pp.STA=0;
- else if((increase_val)>255)
+ else if(set_val>255)
m_pp.STA=255;
else
- m_pp.STA=increase_val;
+ m_pp.STA=set_val;
break;
case STAT_AGI:
- if(increase_val>0)
- iss->agi=increase_val;
- if((increase_val)<0)
+ if(set_val>0)
+ iss->agi=set_val;
+ if(set_val<0)
m_pp.AGI=0;
- else if((increase_val)>255)
+ else if(set_val>255)
m_pp.AGI=255;
else
- m_pp.AGI=increase_val;
+ m_pp.AGI=set_val;
break;
case STAT_DEX:
- if(increase_val>0)
- iss->dex=increase_val;
- if((increase_val)<0)
+ if(set_val>0)
+ iss->dex=set_val;
+ if(set_val<0)
m_pp.DEX=0;
- else if((increase_val)>255)
+ else if(set_val>255)
m_pp.DEX=255;
else
- m_pp.DEX=increase_val;
+ m_pp.DEX=set_val;
break;
case STAT_INT:
- if(increase_val>0)
- iss->int_=increase_val;
- if((increase_val)<0)
+ if(set_val>0)
+ iss->int_=set_val;
+ if(set_val<0)
m_pp.INT=0;
- else if((increase_val)>255)
+ else if(set_val>255)
m_pp.INT=255;
else
- m_pp.INT=increase_val;
+ m_pp.INT=set_val;
break;
case STAT_WIS:
- if(increase_val>0)
- iss->wis=increase_val;
- if((increase_val)<0)
+ if(set_val>0)
+ iss->wis=set_val;
+ if(set_val<0)
m_pp.WIS=0;
- else if((increase_val)>255)
+ else if(set_val>255)
m_pp.WIS=255;
else
- m_pp.WIS=increase_val;
+ m_pp.WIS=set_val;
break;
case STAT_CHA:
- if(increase_val>0)
- iss->cha=increase_val;
- if((increase_val)<0)
+ if(set_val>0)
+ iss->cha=set_val;
+ if(set_val<0)
m_pp.CHA=0;
- else if((increase_val)>255)
+ else if(set_val>255)
m_pp.CHA=255;
else
- m_pp.CHA=increase_val;
+ m_pp.CHA=set_val;
break;
}
QueuePacket(outapp);
@@ -1148,7 +1148,7 @@

void Client::IncStats(int8 type,sint16 increase_val){
if(type>STAT_DISEASE){
- printf("Error in Client::SetStats, received invalid type of: %i\n",type);
+ printf("Error in Client::IncStats, received invalid type of: %i\n",type);
return;
}
EQZonePacket* outapp = new EQZonePacket(OP_IncreaseStats,sizeof(IncreaseStat_ Struct));


diff -u -r EQEmu-0.6.6-767/zone/client.h EQEmu-0.6.6-728/zone/client.h
--- EQEmu-0.6.6-767/zone/client.h 2006-04-10 18:46:13.000000000 +0200
+++ EQEmu-0.6.6-728/zone/client.h 2006-04-10 22:55:25.000000000 +0200
@@ -597,7 +597,7 @@
void PutLootInInventory(sint16 slot_id, const ItemInst &inst, ServerLootItem_Struct** bag_item_data = 0);
bool AutoPutLootInInventory(ItemInst& inst, bool try_worn = false, bool try_cursor = true, ServerLootItem_Struct** bag_item_data = 0);
void SummonItem(uint32 item_id, sint8 charges = 0, uint32 aug1=0, uint32 aug2=0, uint32 aug3=0, uint32 aug4=0, uint32 aug5=0);
- void SetStats(int8 type,sint16 increase_val);
+ void SetStats(int8 type,sint16 set_val);
void IncStats(int8 type,sint16 increase_val);
void DropItem(sint16 slot_id);
void SendItemLink(const ItemInst* inst, bool sendtoall=false);

diff -u -r EQEmu-0.6.6-767/zone/perl_client.cpp EQEmu-0.6.6-728/zone/perl_client.cpp
--- EQEmu-0.6.6-767/zone/perl_client.cpp 2006-04-10 18:47:29.000000000 +0200
+++ EQEmu-0.6.6-728/zone/perl_client.cpp 2006-04-10 22:54:28.000000000 +0200
@@ -2561,7 +2561,7 @@
{
dXSARGS;
if (items != 3)
- Perl_croak(aTHX_ "Usage: Client::SetStats(THIS, type, increase_val)");
+ Perl_croak(aTHX_ "Usage: Client::SetStats(THIS, type, set_val)");
{
Client * THIS;
int8 type = (int8)SvUV(ST(1));
@@ -2582,7 +2582,7 @@
}

XS(XS_Client_IncStats); /* prototype to pass -Wmissing-prototypes */
-XS(XS_Client_IncStats)
+XS(XS_Client_IncStats) //old setstat command aza
{
dXSARGS;
if (items != 3)
@@ -2601,7 +2601,7 @@
if(THIS == NULL)
Perl_croak(aTHX_ "THIS is NULL, avoiding crash.");

- THIS->SetStats(type, increase_val);
+ THIS->IncStats(type, increase_val);
}
XSRETURN_EMPTY;
}
@@ -3417,6 +3417,7 @@
newXSproto(strcpy(buf, "DeleteItemInInventory"), XS_Client_DeleteItemInInventory, file, "$$;$$");
newXSproto(strcpy(buf, "SummonItem"), XS_Client_SummonItem, file, "$$;$");
newXSproto(strcpy(buf, "SetStats"), XS_Client_SetStats, file, "$$$");
+ newXSproto(strcpy(buf, "IncStats"), XS_Client_IncStats, file, "$$$");
newXSproto(strcpy(buf, "DropItem"), XS_Client_DropItem, file, "$$");
newXSproto(strcpy(buf, "BreakInvis"), XS_Client_BreakInvis, file, "$");
newXSproto(strcpy(buf, "GetGroup"), XS_Client_GetGroup, file, "$");

aza77
04-10-2006, 10:08 AM
diff -u -r EQEmu-0.6.6-767/zone/perlparser.cpp EQEmu-0.6.6-728/zone/perlparser.cpp
--- EQEmu-0.6.6-767/zone/perlparser.cpp 2006-03-19 05:09:26.000000000 +0100
+++ EQEmu-0.6.6-728/zone/perlparser.cpp 2006-04-10 21:12:27.000000000 +0200
@@ -355,6 +355,21 @@
XSRETURN_EMPTY;
}

+XS(XS__incstat); //old setstat command aza
+XS(XS__incstat)
+{
+ dXSARGS;
+ if (items != 2)
+ Perl_croak(aTHX_ "Usage: incstat(stat, value)");
+
+ int stat = (int)SvIV(ST(0));
+ int value = (int)SvIV(ST(1));
+
+ quest_manager.incstat(stat, value);
+
+ XSRETURN_EMPTY;
+}
+
XS(XS__castspell);
XS(XS__castspell)
{
@@ -1479,6 +1494,7 @@
newXS(strcpy(buf, "spawn2"), XS__spawn2, file);
newXS(strcpy(buf, "unique_spawn"), XS__unique_spawn, file);
newXS(strcpy(buf, "setstat"), XS__setstat, file);
+ newXS(strcpy(buf, "incstat"), XS__incstat, file);
newXS(strcpy(buf, "castspell"), XS__castspell, file);
newXS(strcpy(buf, "selfcast"), XS__selfcast, file);
newXS(strcpy(buf, "addloot"), XS__addloot, file);

diff -u -r EQEmu-0.6.6-767/zone/questmgr.cpp EQEmu-0.6.6-728/zone/questmgr.cpp
--- EQEmu-0.6.6-767/zone/questmgr.cpp 2006-03-19 05:09:26.000000000 +0100
+++ EQEmu-0.6.6-728/zone/questmgr.cpp 2006-04-10 19:46:05.000000000 +0200
@@ -268,6 +268,11 @@
initiator->SetStats(stat, value);
}

+void QuestManager::incstat(int stat, int value) { //old setstat command aza
+ if (initiator)
+ initiator->IncStats(stat, value);
+}
+
void QuestManager::castspell(int spell_id, int target_id) {
if (npc) {
Mob *tgt = entity_list.GetMob(target_id);

diff -u -r EQEmu-0.6.6-767/zone/questmgr.h EQEmu-0.6.6-728/zone/questmgr.h
--- EQEmu-0.6.6-767/zone/questmgr.h 2006-03-19 05:09:26.000000000 +0100
+++ EQEmu-0.6.6-728/zone/questmgr.h 2006-04-10 19:19:37.000000000 +0200
@@ -50,6 +50,7 @@
int16 spawn2(int npc_type, int grid, int unused, float x, float y, float z, float heading);
int16 unique_spawn(int npc_type, int grid, int unused, float x, float y, float z, float heading = 0);
void setstat(int stat, int value);
+ void incstat(int stat, int value); //old setstat command
void castspell(int spell_id, int target_id);
void selfcast(int spell_id);
void addloot(int item_id, int charges = 0);

diff -u -r EQEmu-0.6.6-767/zone/command.cpp EQEmu-0.6.6-728/zone/command.cpp
--- EQEmu-0.6.6-767/zone/command.cpp 2006-03-21 04:26:31.000000000 +0100
+++ EQEmu-0.6.6-728/zone/command.cpp 2006-04-10 23:28:47.000000000 +0200
@@ -152,7 +152,8 @@
command_add("bind","Sets your targets bind spot to their current location",200,command_bind) ||
command_add("sendop","[opcode] - LE's Private test command, leave it alone",200,command_sendop) ||
command_add("optest","solar's private test command",255,command_optest) ||
- command_add("setstat","Increases or Decreases a client's stats permanently.",200,command_setstat) ||
+ command_add("setstat","Sets the stats to a specific value.",255,command_setstat) ||
+ command_add("incstat","Increases or Decreases a client's stats permanently.",200,command_incstat) ||
command_add("help","[search term] - List available commands and their description, specify partial command as argument to search",0,command_help) ||
command_add("version","- Display current version of EQEmu server",0,command_version) ||
command_add("eitem","- Changes item stats",200,command_eitem) ||
@@ -671,6 +672,17 @@
}
else{
c->Message(0,"This command is used to permanently increase or decrease a players stats.");
+ c->Message(0,"Usage: #setstat {type} {value the stat should be}");
+ c->Message(0,"Types: Str: 0, Sta: 1, Agi: 2, Dex: 3, Int: 4, Wis: 5, Cha: 6");
+ }
+}
+
+void command_incstat(Client* c, const Seperator* sep){
+ if(sep->arg[1][0] && sep->arg[2][0] && c->GetTarget()!=0 && c->GetTarget()->IsClient()){
+ c->GetTarget()->CastToClient()->IncStats(atoi(sep->arg[1]),atoi(sep->arg[2]));
+ }
+ else{
+ c->Message(0,"This command is used to permanently increase or decrease a players stats.");
c->Message(0,"Usage: #setstat {type} {value by which to increase or decrease}");
c->Message(0,"Note: The value is in increments of 2, so a value of 3 will actually increase the stat by 6");
c->Message(0,"Types: Str: 0, Sta: 1, Agi: 2, Dex: 3, Int: 4, Wis: 5, Cha: 6");

diff -u -r EQEmu-0.6.6-767/zone/command.h EQEmu-0.6.6-728/zone/command.h
--- EQEmu-0.6.6-767/zone/command.h 2006-01-13 07:57:03.000000000 +0100
+++ EQEmu-0.6.6-728/zone/command.h 2006-04-10 23:31:06.000000000 +0200
@@ -69,6 +69,7 @@
void command_sendop(Client *c, const Seperator *sep);
void command_optest(Client *c, const Seperator *sep);
void command_setstat(Client *c, const Seperator *sep);
+void command_incstat(Client *c, const Seperator *sep);
void command_help(Client *c, const Seperator *sep);
void command_version(Client *c, const Seperator *sep);
void command_eitem(Client *c, const Seperator *sep);

fathernitwit
04-11-2006, 01:34 AM
changes look good, can you post a link to this diff in a file, the forums make it kinda a pain to apply the patch.

aza77
04-11-2006, 03:52 AM
http://www.projectf.org/downloads/diff.txt

fathernitwit
04-11-2006, 02:18 PM
hmm... the diff didnt quite come out right, it looks like your base revision (EQEmu-0.6.6-767) ended up with some of your changes made in it as well. You can see a good example of this in the client.h section, theres no line for IncStats().

anyways, I think I got it applied. Im going to wait to commit it until we get this finished up.

I think theres an issue in SetStats, when your filling out the IncreaseStats struct to send to the client. You set the value (like iss->str=set_val;) to the whole value, when you really need to calculate the delta in the stat and store that.