Advertiser Content
Seen 3 Days Ago
Posted June 7th, 2019
11 posts
2.7 Years


DEACTIVATE WILD ENCOUNTERS WITH A FLAG


With this method, we will avoid the wild encounters, we will find pokemon if we try to fish, and can battle with encounters by script. This acts like a permanent repel

To create the system, we just need to edit the "src/field_control_avatar.c", we will find this function:

static bool8 CheckStandardWildEncounter(u16 metatileBehavior)
{
    if (sWildEncounterImmunitySteps < 4)
    {
        sWildEncounterImmunitySteps++;
        sPreviousPlayerMetatileBehavior = metatileBehavior;
        return FALSE;
    }

    if (StandardWildEncounter(metatileBehavior, sPreviousPlayerMetatileBehavior) == TRUE)
    {
        sWildEncounterImmunitySteps = 0;
        sPreviousPlayerMetatileBehavior = metatileBehavior;
        return TRUE;
    }

    sPreviousPlayerMetatileBehavior = metatileBehavior;
    return FALSE;
}
Which as its name describes it, it checks if there will be a wild encounter, so, we are going to add a conditional, which checks any flag, to let the code continue. The flags list is at "include/constants/flags.h".

To check a flag in a .c file, we will use

FlagGet(FLAG)
So, now, knowing this, we will add a conditional to check if a flag is set, I'm going to use an unused flag, you can use any (if you know what you're doing).

static bool8 CheckStandardWildEncounter(u16 metatileBehavior)
{
	if (FlagGet(FLAG_UNUSED_0x020) != 0){
	
		if (sWildEncounterImmunitySteps < 4)
		{
			sWildEncounterImmunitySteps++;
			sPreviousPlayerMetatileBehavior = metatileBehavior;
			return FALSE;
		}

		if (StandardWildEncounter(metatileBehavior, sPreviousPlayerMetatileBehavior) == TRUE)
		{
			sWildEncounterImmunitySteps = 0;
			sPreviousPlayerMetatileBehavior = metatileBehavior;
			return TRUE;
		}

		sPreviousPlayerMetatileBehavior = metatileBehavior;
		return FALSE;
	}
}
As you see, I've enclosed all the code in the conditional, and you could think why not to enclose just the second conditional, which is the one that executes the wild encounter. Well, that's just to avoid execute unnecessary code. Now, we have the .c file ready to use. That was easy, wasn't it?

Now, let's just create the script which active and deactivate the flag

Route117_CheckWildEncounter::
	checkflag FLAG_UNUSED_0x020
	vgoto_if 1, Route117_ActivatedFlag
	setflag FLAG_UNUSED_0x020
	msgbox Route117_Text_FlagActivated, MSGBOX_NPC
	end

Route117_ActivatedFlag::
	clearflag FLAG_UNUSED_0x020
	msgbox Route117_Text_FlagDeactivated, MSGBOX_NPC
	end

Route117_Text_FlagActivated: 
	.string "Wild encounter activated$"
	
Route117_Text_FlagDeactivated: 
	.string "Wild encounter deactivated$"
And that's it!

Now, just set the script label to an NPC, compile, and test it :smile:

U.Flame

Humbled Beginner

Age 24
Male
Sapphire City
Seen 1 Day Ago
Posted 2 Days Ago
1,286 posts
11.4 Years
I wonder how broken a game could be if this was an item. Like a permanent repel you can just toggle on and off?
Hacks I'm working on:
(Name in Progress) My main project, actively in development
Tales of Link GBA Remake: Secondary project, developing whenever I'm able.
3rd Gen Multiplayer Project: Research and development, really just experimenting for the moment
Pokemon Cursed/Creepy White: Group project, on hiatus for now with plans to return eventually.
Animal Crossing Wild World playing as an animal: experimental, messing with models and textures

Hacks I've worked on in the past:
Pokemon Ruby Destiny Broken Timeline (pre-reboot) - Assisted with maps
Pokemon HeartGold Prince Boo Edition - Experimental project with three small changes. Made at the request of YouTube LPer PrinceBoo21.

Recently came to realize I know significantly less than I thought I did. Basically, years of self-taught experience amounted to very little. After seeking tutorials and help, I've become more competent, but I have a long way to go. I look forward to learning more, in the meantime, I'll call myself a beginner, not a veteran.

Times I've been ninja'd: 18
Times I've ninja'd people: 3
Seen 3 Days Ago
Posted June 7th, 2019
11 posts
2.7 Years
I wonder how broken a game could be if this was an item. Like a permanent repel you can just toggle on and off?
Well, apply this to an object could be pretty simple. Just copying the repel function into a new item (probably a Key Item), remove the steps counter/limitation and create a condition asigned to a flag or something like that. Yup, you can toggle it everytime you want.
Advertiser Content