Jump to content

Recommended Posts

Hello, im trying to give players bonuses like attack/deff/movement
I wriote simple qeust

Spoiler

quest affect begin

    state start begin

        when 20024.chat."Gimme 5 attack" begin

            affect.add_collect(apply.ATT_GRADE_BONUS,5,60*60*24*365*60)

            say("Att Bonus Raises: 5")

        end

    end

end

But when i talk to this npc  i dont recieve bonuses, triued with affect.add and affect.add_collect but it seems not to work.
Thanks in advance

  • Metin2 Dev 1
Link to comment
https://metin2.dev/topic/29132-affectadd-problem/
Share on other sites

  • Honorable Member

Try using affect.add_collect_point(affect_type, affect_value, affect_duration).

quest collect_att_grade_bonus begin
	state start begin
		when 20024.chat."Collect Attack Grade Bonus!" with get_global_time() > pc.getqf("duration") begin
			-- Set initial values.
			local affect_type = POINT_ATT_GRADE_BONUS -- 95
			local affect_value = 5
			local affect_duration = 60 * 60 * 24 * 365 * 60 -- 60 years

			-- Prevent adding the affect collect point again. #2
			if pc.getqf("duration") > get_global_time() then
				say("You have already received this reward.")
				return
			end

			-- Add the affect collect point.
			affect.add_collect_point(affect_type, affect_value, affect_duration)

			-- Set a duration to prevent doubling this point. #1
			pc.setqf("duration", get_global_time() + affect_duration)

			say("Your attack grade bonus has been increased.")
			say_reward(string.format("Attack Grade Bonus: +%d", affect_value))
		end
	end
end

Both affect.add_collect and affect.add_collect_point are very similar, the only difference is that one handles apply types and the other point types.

	// affect.add_collect
	int affect_add_collect(lua_State* L)
	{
		[. . .]

		// @arg1 Apply Type
		//       NOTE: Apply types can be found @ enum EApplyTypes inside the common/length.h file.
		// @arg2 Value
		// @arg3 Duration
		//                                        arg1                 arg2       arg3             
		//                                         ↓                    ↓          ↓               
		ch->AddAffect(AFFECT_COLLECT, aApplyInfo[applyOn].bPointType, value, 0, duration, 0, false);
		return 0;
	}

	// affect.add_collect_point
	int affect_add_collect_point(lua_State* L)
	{
		[. . .]
		// @arg1 Point Type
		//       NOTE: Point types can be found @ enum EPointTypes inside the game/char.h file.
		// @arg2 Value
		// @arg3 Duration
		//                               arg1      arg2       arg3             
		//                                ↓         ↓          ↓               
		ch->AddAffect(AFFECT_COLLECT, point_type, value, 0, duration, 0, false);
		return 0;
	}

 

Edited by Owsap
Clarification.
  • Good 1
Link to comment
https://metin2.dev/topic/29132-affectadd-problem/#findComment-149519
Share on other sites

  • Honorable Member

Your quest doesn't have errors @Mefarious, but the reason why it doesn't work for you is that you probably removed the "apply" array, resulting in calling a nil value on the 1st parameter of add_collect.

Either you restore it or use the bonus id directly: 53 for ATT_GRADE_BONUS.

In case you want to restore it, copy this into your questlib.lua, then /reload q and try the quest again:

apply = {
	["MAX_HP"] = 1,
	["MAX_SP"] = 2,
	["CON"] = 3,
	["INT"] = 4,
	["STR"] = 5,
	["DEX"] = 6,
	["ATT_SPEED"] = 7,
	["MOV_SPEED"] = 8,
	["CAST_SPEED"] = 9,
	["HP_REGEN"] = 10,
	["SP_REGEN"] = 11,
	["POISON_PCT"] = 12,
	["STUN_PCT"] = 13,
	["SLOW_PCT"] = 14,
	["CRITICAL_PCT"] = 15,
	["PENETRATE_PCT"] = 16,
	["ATTBONUS_HUMAN"] = 17,
	["ATTBONUS_ANIMAL"] = 18,
	["ATTBONUS_ORC"] = 19,
	["ATTBONUS_MILGYO"] = 20,
	["ATTBONUS_UNDEAD"] = 21,
	["ATTBONUS_DEVIL"] = 22,
	["STEAL_HP"] = 23,
	["STEAL_SP"] = 24,
	["MANA_BURN_PCT"] = 25,
	["DAMAGE_SP_RECOVER"] = 26,
	["BLOCK"] = 27,
	["DODGE"] = 28,
	["RESIST_SWORD"] = 29,
	["RESIST_TWOHAND"] = 30,
	["RESIST_DAGGER"] = 31,
	["RESIST_BELL"] = 32,
	["RESIST_FAN"] = 33,
	["RESIST_BOW"] = 34,
	["RESIST_FIRE"] = 35,
	["RESIST_ELEC"] = 36,
	["RESIST_MAGIC"] = 37,
	["RESIST_WIND"] = 38,
	["REFLECT_MELEE"] = 39,
	["REFLECT_CURSE"] = 40,
	["POISON_REDUCE"] = 41,
	["KILL_SP_RECOVER"] = 42,
	["EXP_DOUBLE_BONUS"] = 43,
	["GOLD_DOUBLE_BONUS"] = 44,
	["ITEM_DROP_BONUS"] = 45,
	["POTION_BONUS"] = 46,
	["KILL_HP_RECOVER"] = 47,
	["IMMUNE_STUN"] = 48,
	["IMMUNE_SLOW"] = 49,
	["IMMUNE_FALL"] = 50,
	["SKILL"] = 51,
	["BOW_DISTANCE"] = 52,
	["ATT_GRADE_BONUS"] = 53,
	["DEF_GRADE_BONUS"] = 54,
	["MAGIC_ATT_GRADE"] = 55,
	["MAGIC_DEF_GRADE"] = 56,
	["CURSE_PCT"] = 57,
	["MAX_STAMINA"] = 58,
	["ATTBONUS_WARRIOR"] = 59,
	["ATTBONUS_ASSASSIN"] = 60,
	["ATTBONUS_SURA"] = 61,
	["ATTBONUS_SHAMAN"] = 62,
	["ATTBONUS_MONSTER"] = 63,
	["MALL_ATTBONUS"] = 64,
	["MALL_DEFBONUS"] = 65,
	["MALL_EXPBONUS"] = 66,
	["MALL_ITEMBONUS"] = 67,
	["MALL_GOLDBONUS"] = 68,
	["MAX_HP_PCT"] = 69,
	["MAX_SP_PCT"] = 70,
	["SKILL_DAMAGE_BONUS"] = 71,
	["NORMAL_HIT_DAMAGE_BONUS"] = 72,
	["SKILL_DEFEND_BONUS"] = 73,
	["NORMAL_HIT_DEFEND_BONUS"] = 74,
	["PC_BANG_EXP_BONUS"] = 75,
	["PC_BANG_DROP_BONUS"] = 76,
	["EXTRACT_HP_PCT"] = 77,
	["RESIST_WARRIOR"] = 78,
	["RESIST_ASSASSIN"] = 79,
	["RESIST_SURA"] = 80,
	["RESIST_SHAMAN"] = 81,
	["ENERGY"] = 82,
	["DEF_GRADE"] = 83,
	["COSTUME_ATTR_BONUS"] = 84,
	["MAGIC_ATTBONUS_PER"] = 85,
	["MELEE_MAGIC_ATTBONUS_PER"] = 86,
	["RESIST_ICE"] = 87,
	["RESIST_EARTH"] = 88,
	["RESIST_DARK"] = 89,
	["ANTI_CRITICAL_PCT"] = 90,
	["ANTI_PENETRATE_PCT"] = 91,
	["BLEEDING_REDUCE"] = 92,
	["BLEEDING_PCT"] = 93,
	["ATTBONUS_WOLFMAN"] = 94,
	["RESIST_WOLFMAN"] = 95,
	["RESIST_CLAW"] = 96,
};

 

Edited by Syreldar
  • Good 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
https://metin2.dev/topic/29132-affectadd-problem/#findComment-149520
Share on other sites

THANKS to all of you guys but i found problem...
I really didnt except that name of quest can cause such a problem! Name of quest cannot be "affect" i had to rename it
ANDD! what is really important! I found a solution to STACKS same affect bonuses!! I really appreciate your help if someonme wants to know how to stack exacly same values i can help now you instead of taking help only.

14 hours ago, WeedHex said:

Remember that you can't add 2 same collect bonus.

Now i know how to stacks same values ? thanks anyway!

Edited by Mefarious
  • Metin2 Dev 1
Link to comment
https://metin2.dev/topic/29132-affectadd-problem/#findComment-149528
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.