Customizing some very specific things.

masterurat
Posts: 81
Joined: Sat May 03, 2014 7:05 pm

Customizing some very specific things.

Post by masterurat » Mon May 05, 2014 1:23 am

So I have been going over the various lua scripts and briefly over the source code, and there is just too much for me to manually read over all of it by myself, so, I was wondering if people could point me towards the parts I am looking for to edit for a custom server.

#1: I would like to, on character creation, set unlocked jobs for players to only have 2 unlocked, depending on what starting job they choose. (1 from the melee classes of war/mnk/thf, default of war if they dont choose any of the three melee classes as a start. And then 1 from blm/whm/rdm, defaulting rdm if they don't choose a mage class to start)

IE: Player starts as a warrior. Game detects this on character creation so it then locks away thf/mnk/blm/whm.

Or: Player chooses whm, game locks away Thf/mnk/blm/rdm leaving just whm+war as unlocked jobs.

I think this part is possible.

Second: How hard would it be to add a detection for a player on level up to automatically unlock a job? Particularily, this would be how a player unlocks the other starting jobs. 1 level 10 mage class unlocks the next, then having a level 10 + another level 15 mage class unlocks the third of the starters. Same goes for melee.

Example: Player starts as War. Levels war to level 10 and unlocks monk. Levels monk or war to 15 and the other to 10, thf gets unlocked.


#2: In terms of the quests done to unlock advanced jobs, how hard would it be to do something like "level 30 monk and level 15 war required to start this quest" from the current "level 30 any job to start this quest" I assume not that hard, considering AF quests would check you have a specific job at the right level, right?

#3: How hard is it to remove the maximum crafting skill cap among all skills? IE you can only have 1 skill up to 100, or two to 80, or three to 70, and if you go past that other skills start delevelling. I want to completely remove this stupid cap entirely. I am fine with players on my server capping all of their crafting skills up to 100.

#4: I want to fix the code for dropping items to the loot in the game, by making it so (nearly) all armor that drops has randomized augments added on to it. I would like to construct different tables of augments different slots would get (IE feet would frequently roll move speed, kick attacks, evasion, whereas body might roll +defense, all that jazz)

For now my first step for this is being able to just intercept a specific piece of gear, lets say leather vest, and make it drop with 3 random augments, and make rarabs in saruta drop it, then move forward from there once I verify it works quite well.

#5: This is going to be the hardest to implement I am very sure. Step 1: I want to remove the death timer until auto warp down from 60 minutes to only 3 minutes. I want to remove reraise, raise II, raise III, and tractor from the game, as well as all npcs that sell auto reraise.

And finally, when a player times out on their death timer, I want the game to automatically delete their character. Yes, you heard me. This is what I want. In other words, I am attempting to make a "hardcore" ffxi server, with a whole different play dynamic. Zerging and zombieing no longer become an option.

Oh, also, I would obviously need a way to fix ninja's 2 hour, because as it stands it is kind of terribad on a hardcore server. I would probably just program in Ninja's new 2 hour, not sure how hard that would be.

Other minor tweaks Id like to make, but these 5 here are my first and foremost highest priorities to make the server what I want it to be. Is any of this strictly impossible (I am pretty fluent in .net and decent with lua so if you guys can just point me to where the code for these things are, I can probably piece it together)

I understand this is a HUGE project, but I would love any kind of help people can offer on this. I was a massive fan of ffxi in its early days and its sensation of how hardcore it felt. I want to expand on that, creating a new ffxi 2.0 with significantly higher challenge, more dynamic character creation with less limitations, and better rewards. It will be a long journey but this is my first step.

Thank you all for your time :)

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Customizing some very specific things.

Post by kjLotus » Mon May 05, 2014 2:32 am

#1 i don't know off the top of my head, its in like 6 different places (new chars go to a script, levelling up is done in charutils... etc)
#2 is pretty easy, just find the NPC that starts the quest and add extra checks
#3 i don't know exactly where it is, but probably in synthutils trying to skill up
#4 isn't really possible yet because augments don't work
#5 isn't that hard either really, just find the SmallPacket0xwhatever that is received when a user hits the home point button when dead (same as when it times out)
and as a side note, nin have mikage as of.. today, so you'd just have to change it to level 1 instead of 96

masterurat
Posts: 81
Joined: Sat May 03, 2014 7:05 pm

Re: Customizing some very specific things.

Post by masterurat » Mon May 05, 2014 2:49 am

Ok I found the script for step 1 in player.lua, however I see all these commands like player:addKeyItem, player:unlockjob, etc.

Where do I find the list of where all these commands are coming from? I checked all the imported lua scripts and those functions/subs aren't listed there. Is there some kind of global set of functions somewhere?

Edit: Here we go found it in baseentity...

However there is only code fore unlockJob, but no way for me to lock jobs.

Code: Select all

inline int32 CLuaBaseEntity::unlockJob(lua_State *L)
{
    DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
	DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_PC);

	DSP_DEBUG_BREAK_IF(lua_isnil(L,-1) || !lua_isnumber(L,-1));

    CCharEntity* PChar = (CCharEntity*)m_PBaseEntity;

    JOBTYPE JobID = (JOBTYPE)lua_tointeger(L,-1);

    if (JobID < MAX_JOBTYPE)
    {
        PChar->jobs.unlocked |= (1 << JobID);

        if (JobID == JOB_NON) JobID = JOB_WAR;
		if (PChar->jobs.job[JobID] == 0) PChar->jobs.job[JobID] = 1;

        charutils::SaveCharJob(PChar, JobID);
        PChar->pushPacket(new CCharJobsPacket(PChar));
    }
    return 0;
}
So I need to create a reverse script that does the same but subtracts the job value instead of adds it @_@

Code: Select all

inline int32 CLuaBaseEntity::lockJob(lua_State *L)
{
    DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
	DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_PC);

	DSP_DEBUG_BREAK_IF(lua_isnil(L,-1) || !lua_isnumber(L,-1));

    CCharEntity* PChar = (CCharEntity*)m_PBaseEntity;

    JOBTYPE JobID = (JOBTYPE)lua_tointeger(L,-1);

    if (JobID < MAX_JOBTYPE)
    {
 
         JOBTYPE CheckJobs ~= (1 << JobID);
  
        PChar->jobs.unlocked &= CheckJobs;

        if (JobID == JOB_NON) JobID = JOB_WAR;
		if (PChar->jobs.job[JobID] == 0) PChar->jobs.job[JobID] = 1;

        charutils::SaveCharJob(PChar, JobID);
        PChar->pushPacket(new CCharJobsPacket(PChar));
    }
    return 0;
}
I think that is right.

Step 1: Get the bitshifted job, IE Job_monk would give me 000010

Step 2: flip the bits via not, so I end up with 111101. (all done in the line JOBTYPE CheckJobs ~= (1 << JobID); )

Step 3: Check the players current jobs against this flipped bit check with AND bitwise gate. IE

whateverbits111111 ~ 00000...0111101 results in whateverbits111101

Does this look right?
Last edited by masterurat on Mon May 05, 2014 3:22 am, edited 1 time in total.

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Customizing some very specific things.

Post by kjLotus » Mon May 05, 2014 3:09 am

ya they're all in the files in the lua folder under src

masterurat
Posts: 81
Joined: Sat May 03, 2014 7:05 pm

Re: Customizing some very specific things.

Post by masterurat » Mon May 05, 2014 4:05 am

Ok so I did some changes in player.lua, particularily made it so that regardless what race you start as, you get your nation's ring.

Not noticing the change happening in game, even recompiled the game DSGame-server.exe... Still no change.

What the new lua script is:

Code: Select all

-- ADD NATION SPECIFIC STARTGEAR
 	switch (player:getNation()) : caseof
	{
 		-- SANDY CITIZEN
		[0] = function (x)
			player:addItem(0x34B7);
			player:addKeyItem(MAP_OF_THE_SAN_DORIA_AREA);
		end,

 		-- BASTOK CITIZEN
		[1] = function (x)
			player:addItem(0x34B9);
			player:addKeyItem(MAP_OF_THE_BASTOK_AREA);
		end,

 		-- WINDY CITIZEN
	 	[2] = function(x)
			player:addItem(0x34B8);
			player:addKeyItem(MAP_OF_THE_WINDURST_AREA);
 		end,

		default = function (x) end,
	}
I literally just cut out the check for the player's race, and just made it give the item to them regardless of race... But it isn't working. I rebooted the server from scratch, and also recompiled just in case...

Im not getting any errors, but nothing changed. Made a mithra and taru from sandoria, neither got the ring.

masterurat
Posts: 81
Joined: Sat May 03, 2014 7:05 pm

Re: Customizing some very specific things.

Post by masterurat » Tue May 06, 2014 4:24 am

Code: Select all

inline int32 CLuaBaseEntity::getJobLevel(lua_State *L)
{
	DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
	DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_PC);

	DSP_DEBUG_BREAK_IF(lua_isnil(L, -1) || !lua_isnumber(L, -1));

	CCharEntity* PChar = (CCharEntity*)m_PBaseEntity;

	JOBTYPE JobID = (JOBTYPE)lua_tointeger(L, -1);
	if (JobID == JOB_NON) JobID = JOB_WAR;

	if (JobID < MAX_JOBTYPE)
	{
		return PChar->jobs.job[JobID];
	}
	else return 0;
}
So I tried adding this code to luabaseentity.cpp (and declaring it and etc) to be able to call a specific non main job's level on the character, but it is just crashing my server when I call it in the lua script.

Am I declaring something wrong here? I must be missing something obvious.

The .exe compiles without any error, so it must be some small issue I am having here. Did I write something wrong?

Also if there already exists an easier way within the lua script to get the level of a job that isnt the characters main job, I would love to know! Because as far as I am seeing I only see a method for getting the players main job, sub job, main level, and sub job level, but no way to call other levels of jobs they arent on at the moment (and this is something I would like to have)

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Customizing some very specific things.

Post by kjLotus » Tue May 06, 2014 4:44 am

couple things to note here:
1. run your server from visual studio so you can see where it breaks
2. returning values to your script is done with lua_pushxxx, and the return value of the function specifies how many values were pushed on the lua stack (because a lua function can return more than 1 value)

masterurat
Posts: 81
Joined: Sat May 03, 2014 7:05 pm

Re: Customizing some very specific things.

Post by masterurat » Tue May 06, 2014 4:59 am

Code: Select all

inline int32 CLuaBaseEntity::getJobLevel(lua_State *L)
{
	DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL);
	DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype != TYPE_PC);

	DSP_DEBUG_BREAK_IF(lua_isnil(L, -1) || !lua_isnumber(L, -1));

	CCharEntity* PChar = (CCharEntity*)m_PBaseEntity;

	JOBTYPE JobID = (JOBTYPE)lua_tointeger(L, -1);
	if (JobID == JOB_NON) JobID = JOB_WAR;

	if (JobID < MAX_JOBTYPE)
	{
		lua_pushinteger(L, PChar->jobs.job[JobID]);
		return 1;
	}
	lua_pushinteger(L, 0);
	return 1;
}
Ah ok, is this what I want then? Testing it right now to make sure it works.

Edit: Seems to be working right. If you know of a better way I could have written this though, or if any of that was unnecessary or if there's any catches I should be adding, let me know. I have worked with lua and C++ before but this is my first time working with them being together with an interpreter @_@

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Customizing some very specific things.

Post by kjLotus » Tue May 06, 2014 5:32 am

thats looks fine, i'd push nil for errors though instead of 0, easier to catch them script side

masterurat
Posts: 81
Joined: Sat May 03, 2014 7:05 pm

Re: Customizing some very specific things.

Post by masterurat » Tue May 06, 2014 6:43 am

Ok next big question, I found the packet for homepointing, first off just to make sure, if I make a person's character get deleted in here, this only triggers when they homepoint from death, right? Warping wont trigger this, right?

Second: How on earth do I delete an account, I'm not seeing anything in the code anywhere for a delete account function. This is my next big thing to add and it's an even bigger headscratcher than the last.

Post Reply