Gm Commands

Place your questions about osirose here

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Gm Commands

Postby Etoile on Tue Feb 03, 2009 5:36 pm

Hi
I wanted to know if there is a way to change the NpcVar via Gm Commands or at least to display it
Thanks
Etoile
Jelly Bean
Jelly Bean
 
Posts: 18
Joined: Tue Oct 14, 2008 8:34 pm

Re: Gm Commands

Postby PurpleYouko on Tue Feb 03, 2009 6:20 pm

yes it is possible but a lot depends on which server you are running.

Also this isn't client editing. Let me know which server you are working with and I will move the thread and give you some more specific information
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Gm Commands

Postby Etoile on Tue Feb 03, 2009 10:55 pm

On osIrose Server
Etoile
Jelly Bean
Jelly Bean
 
Posts: 18
Joined: Tue Oct 14, 2008 8:34 pm

Re: Gm Commands

Postby PurpleYouko on Tue Feb 03, 2009 11:49 pm

OK thread moved to the osirose forums.

I will post up some code for you in the morning. I am out of time now unfortunately.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Gm Commands

Postby PurpleYouko on Wed Feb 04, 2009 5:27 pm

OK here we go.
I have looked through the current osirose SVN and compared it to my osprose code.

I assume that by NPCVar you mean ObjVar[0] which is in fact used to control events and stuff via AIP. In the LUA (client side) it is referred to as NPCVar0 and in the server it is used to set the variable "eventid" which osirose currently does not support.......
Unfortunately osirose has fallen a long way behind osprose and osrose rev 81 in the way it handles AIP so this might get a bit complicated and messy. I am going to attempt to transfer the code from osprose into osirose and tell you exactly what I did here to make it work.

here goes.
First we add handling for the eventid variable in the CNPCData structure
in datatypes.h struct CNPCData find
  1. UINT aggresive;
  2.     UINT shp;
  3.     UINT dialogid;

After, add


Now we will just transplant a complete GM command over from osprose. You will probably need to modify the required access level since i have it hard coded at 300 right now.
in gmcommands.cpp find
  1.  
  2. else
  3.     {
  4.         Log( MSG_WARNING, "Invalid GM Command '%s' by '%s'", command, thisclient->CharInfo->charname);
  5.     }
  6.     return true;

BEFORE, add
  1.  
  2. else if (strcmp(command, "dialog")==0 && thisclient->Session->accesslevel >= 300)
  3.     {
  4.         //can be a very dangerous tool to use
  5.         UINT npc;
  6.         UINT dialog;
  7.         UINT eventid;
  8.         if ((tmp = strtok(NULL, " "))==NULL)return true;
  9.             npc = atoi(tmp);
  10.         if ((tmp = strtok(NULL, " "))==NULL)return true;
  11.             dialog = atoi(tmp);
  12.         if ((tmp = strtok(NULL, " "))==NULL)return true;
  13.             eventid = atoi(tmp);
  14.         if(thisclient->ChangeDialog(npc, dialog, eventid))
  15.         {
  16.             char buffer2[200];
  17.             sprintf ( buffer2, "dialog for npc %i set to %i event set to %i", npc, dialog, eventid );
  18.             SendPM(thisclient, buffer2);
  19.         }
  20.         else
  21.         {
  22.             char buffer2[200];
  23.             sprintf ( buffer2, "dialog and event for npc %i not changed", npc );
  24.             SendPM(thisclient, buffer2);
  25.         }
  26.     }


this bit gets kind of messy because it really requires AIP to be able to change the eventid of an NPC and osirose doesn't have very complete AIP handling yet.
go to Worldpackets.cpp and find function bool CWorldServer::pakSpawnNPC( CPlayer* thisclient, CNPC* thisnpc )
We are going to mess around with the way NPCs are spawned a bit. ;)
Find this
  1. if (thisnpc->npctype == 1115) ADDBYTE( pak, GServer->Config.Cfmode ) // Burland Clan Field open/close
  2.         else ADDBYTE ( pak, 0 );

This sets up a special case for Burtland who owns the clan fields. It adds a byte to the 0x791 packet that spawns an NPC. It will either the value held in Config.Cfmode or zero depending on whether the npc is Burtland or not.
This byte is the one that the client reads into NPCVar0 and is used to activate or modify events that the NPC is capable of handling. We need to change this so that the value that we set in the new GM command will be sent instead.
This code will screw up the Config.Cfmode value completely so bear that in mind. The Config value will no longer set the clanfield to open or closed at boot up. You will however, be able to open or close clanfields manually from within the game with your GM command.

Well anyway, replace that bit of code with this. i just commented out the original so that you can switch back easily.
  1.  
  2. //if (thisnpc->npctype == 1115) ADDBYTE( pak, GServer->Config.Cfmode ) // Burland Clan Field open/close
  3.     //    else ADDBYTE ( pak, 0 );
  4.     if(thisnpc->thisnpc->eventid != 0)
  5.     {
  6.         ADDBYTE (pak, thisnpc->thisnpc->eventid);
  7.     }
  8.     else
  9.     {
  10.         ADDBYTE( pak, 0 );
  11.     }


Now we need to go and set up the header for ChangeDialog since we are about to change the way it works a little
in Player.h, find
  1.  
  2. bool ChangeDialog( unsigned int npc, unsigned int dialog );
  3.  

Replace with this. Once again, i just commented the original so that you can switch back easily.
  1.  
  2. //bool ChangeDialog( unsigned int npc, unsigned int dialog );
  3.         bool ChangeDialog( unsigned int npc, unsigned int dialog, unsigned int eventid = 0 );
  4.  

Now we actually modify the changedialog function so go find this in Playerfunctions.cpp
  1. bool CPlayer::ChangeDialog(unsigned int npc, unsigned int dialog )

Replace the entire function with this. (Again, i left the original code in place but commented out. You can delete it once you are good and happy with the new way that stuff works now.
  1.  
  2. /*bool CPlayer::ChangeDialog(unsigned int npc, unsigned int dialog )
  3. {
  4.     CMap* map = GServer->MapList.Index[Position->Map];
  5.     for(unsigned i=0; i<map->NPCList.size(); i++)
  6.     {
  7.         CNPC* thisnpc = map->NPCList.at(i);
  8.        
  9.         if(thisnpc->thisnpc->id = npc)
  10.         {
  11.             CNPC* newnpc = thisnpc;
  12.             map->DeleteNPC(thisnpc);
  13.             newnpc->thisnpc->dialogid = dialog;
  14.             GServer->pakSpawnNPC (this, newnpc);
  15.         }    
  16.     }
  17.     return true;
  18. }*/
  19.  
  20. bool CPlayer::ChangeDialog(unsigned int npc, unsigned int dialog, unsigned int eventid )
  21. {
  22.     CMap* map = GServer->MapList.Index[Position->Map];
  23.     if(map == NULL)
  24.         return true;
  25.     for(unsigned i=0; i<map->NPCList.size(); i++)
  26.     {
  27.         CNPC* thisnpc = map->NPCList.at(i);
  28.  
  29.         if(thisnpc->npctype == npc)
  30.         {
  31.             //Log(MSG_INFO,"Found NPC %i with dialog %i",thisnpc->npctype, thisnpc->thisnpc->dialogid);
  32.             CNPC* newnpc = thisnpc;
  33.             this->ClearObject( thisnpc->clientid );
  34.             newnpc->thisnpc->dialogid = dialog;
  35.             newnpc->thisnpc->eventid = eventid;
  36.             GServer->ObjVar[npc][0] = eventid;
  37.             VisibleNPCs.push_back( newnpc );
  38.             GServer->pakSpawnNPC( this, newnpc );
  39.         }
  40.     }
  41.     return true;
  42. }

Damn it... :(
This is getting more involved than I even thought it would. Need to add more definitions :lol:
In worldserver.h, find
  1. fpAiCond aiCondFunc[35];
  2.         fpAiAct aiActFunc[40];

after, add
  1.  
  2. int ObjVar[2000][20];  //NPC variables used in AI


Well it actually compiles correctly at this point so it should work for you.
I have no way to test it though because i don't have an operational osirose server or client to try it out with.
The AIP still isn't going to make this NPCVar change at any time because it simply doesn't have handling for it but at least now that you have the ObjVar[][] structure set up, it will be relatively easy to port code over from osprose or osrose rev 81 if you are handy with coding stuff.

Right now. how to use the new GM command?
It is composed of 3 parts. npc, dialog and eventid
/dialog[npcid][dialogid][eventid]

lets say we want to make Judy in Zant say something different.
her NPC number is 1201 (you can get this from LIST_NPC.STB. It's the row number)
Her normal dialog is 305 (you can get this from list_npc sql table)
her eventid defaults to 0 as do all the NPCs but if you care to set it to a different number, who knows what might happen :lol: Look in the CON file LUA scripts to find out what NPCVar0 needs to be set to in order to make stuff happen.

try setting /dialog 1201 305 3 then talk to judy
If it all worked right (and you have the spring quest in your files) then she should send you off to get cherry blossoms from cherry smoulies.
2 will start a valentines day quest. there are loads more in there (EM01-101.CON is where Judy's stuff is stored)

To open clan fields you need to type /dialog 1115 215 2
To close them again type /dialog 1115 215 0

Give it a try and see what fun stuff you can find out. be careful though. It's possible to really screw up you quests if you take one of these out of order.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Gm Commands

Postby Etoile on Wed Feb 04, 2009 7:41 pm

Alright !
Thanks a lot :)
Etoile
Jelly Bean
Jelly Bean
 
Posts: 18
Joined: Tue Oct 14, 2008 8:34 pm


Return to Question Zone

Who is online

Users browsing this forum: No registered users and 1 guest

cron