Fishing System

Post Reply
EDGECOM
Posts: 50
Joined: Sat Aug 04, 2012 8:31 am

Fishing System

Post by EDGECOM » Thu Aug 23, 2012 1:55 pm

well I have been working on the fishing system in my spare time and I have all the messages working and skill up and the ability to catch rusty items

I am currently working on building a database for fishing up monsters so that will come soon :)

here is a quick overview of the system

25% chance to catch nothing
25% chance to catch monster ( when I get it working I still have to figure out if I need to use monster pool or if I need to make one )
25% change to catch items
25% chance to catch fish

if you have no fishing gear equiped you can fish up to 5 level of your current skill. if you have fishing gear you can fish 9 levels ( 5 + 4 )

point system is random but based on skill if your fishing within 5 levels the max skill up you could get is .5 if your fishing within 9 the max is .9

if your skill is 5 levels higher than the fishing you catch you will get a critical bite

your rod has a 50% chance to break I was using the flag coloum in the rod table I hope thats what its for if not I will add my own so anything over 6 has a 50% chance to break

I am posting this now to see if I need to add or remove anything

Note: if you get alot of "you did not catch anything messages" please check the database to make sure that the rod and or bait is linked to the fish or item I have added a few to the database but it would take me forever to add them all. I hoping if I release it now the coummunity can help :) while I work on the monster part.

I have tested this system from 0-20 and have not had any problems. I know the code is a bit messy I will clean it up when I get the monster part working I plan on removing the globals and making them into a struct.

I hope everyone enjoys the work thus far

Side Note: I have set a few fish min and max to 200 in the database this is because I need to find more information on them I do not know if thay are rare fish or what level they are if anyone finds any information or knows please let me know and i will fix it

here is a link to a good fishing guide http://wiki.ffxiclopedia.org/wiki/Category:Fishing
Attachments
EDGECOM Fishing system.zip
(25.32 KiB) Downloaded 226 times

DeVeous
Posts: 40
Joined: Sun Jul 22, 2012 8:11 pm

Re: Fishing System

Post by DeVeous » Thu Aug 23, 2012 2:34 pm

Very freakin sweet :)

EDGECOM
Posts: 50
Joined: Sat Aug 04, 2012 8:31 am

Re: Fishing System

Post by EDGECOM » Mon Aug 27, 2012 1:09 pm

well this is just an update I have been working on a spawn system for the fishing monsters the current spawn system only allows one mob to be spawned at a time so I need to make my own instancing system I guess this is going to be fun. humm.. or maybe a pool meh at anyrate I will figure it out.

I have not uploaded any new updates yet I will also fix my zip file and make it into a proper patch file cause I am a noob :mrgreen:

bluekirby0
Developer
Posts: 707
Joined: Sun Jul 22, 2012 12:11 am

Re: Fishing System

Post by bluekirby0 » Sun Sep 16, 2012 11:22 pm

If you need to spawn "minions" with another mob, you can use:

Code: Select all

onMobSpawn(mob)
    local self = mob:getID()
    for local  i = self+1, self+2, 1 do -- Change the +2 here if you need more mobs.
        SpawnMob(i)
    end
end

onMobEngaged(mob,target)
    for local  i = self+1, self+2, 1 do
        GetMobByID(i):updateEnmity(target) -- Causes the "minion" characters to become aggressive along with the main mob (use if appropriate)
    end
end

onMobDeath(mob,killer)
    local self = mob:getID()
    for local  i = self+1, self+2, 1 do
        DespawnMob(i) -- Causes the "minions" to despawn if the master is killed.
    end
end
It may require a bit of tweaking to fit the situation. You can put this into the mob's script for the single mob you can spawn with the current system and take out anything that isn't appropriate for the situation.

EDGECOM
Posts: 50
Joined: Sat Aug 04, 2012 8:31 am

Re: Fishing System

Post by EDGECOM » Mon Sep 24, 2012 3:19 pm

I am using the code below witch I am going to change the while to an if and so on this works fine the problem i am having is I need a way to remove the mob from the zone via the m_mobList because if I keep adding to the zone they will stay there and keep respawning and I fear this may lag the server after a ton of them are spawned I want to be able to remove them to keep the server rescources down and all that stuff.

Code: Select all

uint16 mobtozone(uint32 mobid, float mob_x, float mob_y, float mob_z, uint8 mob_r, uint8 ZoneID)
	{

		uint32 mob_returnID = 0;
		//CZone* PZone = new CZone(ZoneID, conquest::GetCurrentRegion(ZoneID));
		///CZone* PZone2 = zoneutils::GetZone(ZoneID);
		//ShowDebug(CL_GREEN"PZone: %u \n" CL_RESET, PZone);
		ShowDebug(CL_GREEN"PZone2: %u \n" CL_RESET, zoneutils::GetZone(ZoneID));


		const int8* fmtQuery = "SELECT name, mobid, pos_rot, pos_x, pos_y, pos_z, \
					respawntime, spawntype, dropid, HP, MP, minLevel, maxLevel, \
					modelid, mJob, sJob, cmbSkill, cmbDelay, behavior, links, mobType, \
					systemid, mobsize, speed, \
					STR, DEX, VIT, AGI, `INT`, MND, CHR, EVA, DEF, \
					Slash, Pierce, H2H, Impact, \
					Fire, Ice, Wind, Earth, Lightning, Water, Light, Dark, Element, \
					mob_pools.familyid, name_prefix, unknown \
					FROM mob_groups, mob_pools, mob_spawn_points, mob_family_system \
					WHERE mob_groups.poolid = mob_pools.poolid \
					AND mob_groups.groupid = mob_spawn_points.groupid \
					AND mob_family_system.familyid = mob_pools.familyid \
					AND mob_groups.zoneid = %u;";
					
		int32 ret = Sql_Query(SqlHandle, fmtQuery, ZoneID);

		if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0) 
		{	
			while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
			{
				CloneID = CloneID + 1; 
				//CloneID = rand()%65534; 
				uint32 getmobid = Sql_GetUIntData(SqlHandle,1);
			if (getmobid == mobid){

				CMobEntity* PMob = new CMobEntity;
				uint32 newmobid = (mobid / 2) + CloneID;
				PMob->name.insert(0,Sql_GetData(SqlHandle,0));
				//PMob->id = CloneID;
				PMob->id = (uint32)Sql_GetUIntData(SqlHandle,1);
				//PMob->targid = (uint16)PMob->id & 0x0FFF;
				PMob->targid = CloneID & 0x0FFF;
				
				ShowDebug(CL_GREEN"NewMobID: %u \n" CL_RESET, PMob->id);

				PMob->m_SpawnPoint.rotation = mob_r;
				PMob->m_SpawnPoint.x = mob_x;
				PMob->m_SpawnPoint.y = mob_y;
				PMob->m_SpawnPoint.z = mob_z;

				PMob->m_RespawnTime = (uint32)25 * 1000;
				//PMob->m_RespawnTime = Sql_GetUIntData(SqlHandle,6) * 1000;
				//PMob->m_SpawnType   = (SPAWNTYPE)Sql_GetUIntData(SqlHandle,7);
				PMob->m_SpawnType   = (SPAWNTYPE)SPAWNTYPE_NORMAL;
				PMob->m_DropID		= Sql_GetUIntData(SqlHandle,8);

				PMob->HPmodifier = (uint32)Sql_GetIntData(SqlHandle,9);
				PMob->MPmodifier = (uint32)Sql_GetIntData(SqlHandle,10);

				PMob->m_minLevel = (uint8)Sql_GetIntData(SqlHandle,11);
				PMob->m_maxLevel = (uint8)Sql_GetIntData(SqlHandle,12);

				memcpy(&PMob->look,Sql_GetData(SqlHandle,13),22);

				PMob->SetMJob(Sql_GetIntData(SqlHandle,14));
				PMob->SetSJob(Sql_GetIntData(SqlHandle,15));

				PMob->m_Weapons[SLOT_MAIN]->setSkillType(Sql_GetIntData(SqlHandle,16));
				PMob->m_Weapons[SLOT_MAIN]->setDelay((Sql_GetIntData(SqlHandle,17) * 1000)/60);

				//PMob->m_Behaviour  = (uint16)Sql_GetIntData(SqlHandle,18);
				PMob->m_Behaviour  = (BEHAVIOUR)BEHAVIOUR_AGGRO_TRUESIGHT;
                PMob->m_Link       = (uint8)Sql_GetIntData(SqlHandle,19);
				PMob->m_Type       = (MOBTYPE)MOBTYPE_FISHED;
				PMob->m_EcoSystem  = (ECOSYSTEM)Sql_GetIntData(SqlHandle,21);
				PMob->m_ModelSize += (uint8)Sql_GetIntData(SqlHandle,22);
				
				PMob->speed    = (uint8)Sql_GetIntData(SqlHandle,23);
				PMob->speedsub = (uint8)Sql_GetIntData(SqlHandle,23);

				PMob->setModifier(MOD_SLASHRES, (uint16)(Sql_GetFloatData(SqlHandle,33) * 1000));
				PMob->setModifier(MOD_PIERCERES,(uint16)(Sql_GetFloatData(SqlHandle,34) * 1000));
				PMob->setModifier(MOD_HTHRES,   (uint16)(Sql_GetFloatData(SqlHandle,35) * 1000));
				PMob->setModifier(MOD_IMPACTRES,(uint16)(Sql_GetFloatData(SqlHandle,36) * 1000));

                PMob->setModifier(MOD_FIREDEF,    (int16)((Sql_GetFloatData(SqlHandle, 37) - 1) * -1000)); // These are stored as floating percentages 
                PMob->setModifier(MOD_ICEDEF,     (int16)((Sql_GetFloatData(SqlHandle, 38) - 1) * -1000)); // and need to be adjusted into modifier units.
                PMob->setModifier(MOD_WINDDEF,    (int16)((Sql_GetFloatData(SqlHandle, 39) - 1) * -1000)); // Higher DEF = lower damage.  
                PMob->setModifier(MOD_EARTHDEF,   (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -1000)); // Negatives signify increased damage.
                PMob->setModifier(MOD_THUNDERDEF, (int16)((Sql_GetFloatData(SqlHandle, 41) - 1) * -1000)); // Positives signify reduced damage.
                PMob->setModifier(MOD_WATERDEF,   (int16)((Sql_GetFloatData(SqlHandle, 42) - 1) * -1000)); // Ex: 125% damage would be 1.25, 50% damage would be 0.50
                PMob->setModifier(MOD_LIGHTDEF,   (int16)((Sql_GetFloatData(SqlHandle, 43) - 1) * -1000)); // (1.25 - 1) * -1000 = -250 DEF
                PMob->setModifier(MOD_DARKDEF,    (int16)((Sql_GetFloatData(SqlHandle, 44) - 1) * -1000)); // (0.50 - 1) * -1000 = 500 DEF

                PMob->setModifier(MOD_FIRERES,    (int16)((Sql_GetFloatData(SqlHandle, 37) - 1) * -100)); // These are stored as floating percentages 
                PMob->setModifier(MOD_ICERES,     (int16)((Sql_GetFloatData(SqlHandle, 38) - 1) * -100)); // and need to be adjusted into modifier units.
                PMob->setModifier(MOD_WINDRES,    (int16)((Sql_GetFloatData(SqlHandle, 39) - 1) * -100)); // Higher RES = lower damage.  
                PMob->setModifier(MOD_EARTHRES,   (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -100)); // Negatives signify lower resist chance.
                PMob->setModifier(MOD_THUNDERRES, (int16)((Sql_GetFloatData(SqlHandle, 41) - 1) * -100)); // Positives signify increased resist chance.
                PMob->setModifier(MOD_WATERRES,   (int16)((Sql_GetFloatData(SqlHandle, 42) - 1) * -100)); 
                PMob->setModifier(MOD_LIGHTRES,   (int16)((Sql_GetFloatData(SqlHandle, 43) - 1) * -100)); 
                PMob->setModifier(MOD_DARKRES,    (int16)((Sql_GetFloatData(SqlHandle, 44) - 1) * -100)); 

				PMob->m_Element = (uint8)Sql_GetIntData(SqlHandle,45);
				PMob->m_Family = (uint16)Sql_GetIntData(SqlHandle,46); 
				PMob->m_name_prefix = (uint8)Sql_GetIntData(SqlHandle,47); 
				PMob->m_unknown = (uint32)Sql_GetIntData(SqlHandle,48); 
				PMob->PBattleAI = new CAIMobDummy(PMob);
				//PMob->PBattleAI->SetCurrentAction(PMob->m_SpawnType == SPAWNTYPE_NORMAL ? ACTION_SPAWN : ACTION_NONE,CloneID);
				PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN,CloneID);
			
				// Killer Effect
                switch (PMob->m_EcoSystem)
	            {
		            case SYSTEM_AMORPH:   PMob->addModifier(MOD_BIRD_KILLER,     5); break;
		            case SYSTEM_AQUAN:    PMob->addModifier(MOD_AMORPH_KILLER,   5); break;
		            case SYSTEM_ARCANA:   PMob->addModifier(MOD_UNDEAD_KILLER,   5); break;
		            case SYSTEM_BEAST:    PMob->addModifier(MOD_LIZARD_KILLER,   5); break;
		            case SYSTEM_BIRD:     PMob->addModifier(MOD_AQUAN_KILLER,    5); break;
		            case SYSTEM_DEMON:    PMob->addModifier(MOD_DRAGON_KILLER,   5); break;
		            case SYSTEM_DRAGON:   PMob->addModifier(MOD_DEMON_KILLER,    5); break;
		            case SYSTEM_LIZARD:   PMob->addModifier(MOD_VERMIN_KILLER,   5); break;
                    case SYSTEM_LUMINION: PMob->addModifier(MOD_LUMORIAN_KILLER, 5); break;
                    case SYSTEM_LUMORIAN: PMob->addModifier(MOD_LUMINION_KILLER, 5); break;
		            case SYSTEM_PLANTOID: PMob->addModifier(MOD_BEAST_KILLER,    5); break;
		            case SYSTEM_UNDEAD:   PMob->addModifier(MOD_ARCANA_KILLER,   5); break;
		            case SYSTEM_VERMIN:   PMob->addModifier(MOD_PLANTOID_KILLER, 5); break;
	            }
				//DA and TA
				if(PMob->GetMJob()==JOB_WAR && PMob->m_minLevel >= 25 || PMob->GetSJob()==JOB_WAR && PMob->m_minLevel >= 50){
					PMob->addModifier(MOD_DOUBLE_ATTACK,15);
				}
				if(PMob->GetMJob()==JOB_THF && PMob->m_minLevel >= 55){
					PMob->addModifier(MOD_TRIPLE_ATTACK,7);
				}
				
				zoneutils::GetZone(ZoneID)->InsertMOB(PMob);
				PMob->SetDespawnTimer(20);
				//PMob->PBattleAI->SetCurrentAction(ACTION_ATTACK,CloneID);
				PMob->PBattleAI->CheckCurrentAction(gettick());

				mob_returnID = PMob->id;
				luautils::OnMobInitialise(PMob);

                //return CloneID;
			}
				
			}
		}

				//zoneutils::GetZone(ZoneID)->ZoneServer(-1);
				//g_PZoneList[ZoneID] = zoneutils::GetZone(ZoneID);

				//if (zoneutils::GetZone(ZoneID)->GetIP() != 0)
				//{
				//	luautils::OnZoneInitialise(zoneutils::GetZone(ZoneID)->GetID());
				//}

		return CloneID;
	}
I know the code is a bit messy I will make it look pretty when I figure out how to delete the mob

User avatar
diatanato
Developer
Posts: 112
Joined: Thu Aug 30, 2012 9:59 pm

Re: Fishing System

Post by diatanato » Tue Sep 25, 2012 12:31 am

Monsters should be added in a zone only at the moment of server loading. They can't be deleted never. If you don't satisfy these conditions, then you mean have written a bad code

P.S. don't do any clones

Post Reply