<commit_before>#ifndef SAMPLEDEEDTASK_H_
#define SAMPLEDEEDTASK_H_

#include "server/zone/managers/resource/ResourceManager.h"
#include "server/zone/managers/combat/CombatManager.h"
#include "server/zone/managers/creature/CreatureManager.h"
#include "server/zone/managers/creature/DnaManager.h"
#include "server/zone/objects/creature/CreatureObject.h"
#include "server/zone/objects/tangible/deed/pet/PetDeed.h"
#include "server/zone/objects/creature/CreatureAttribute.h"
#include "server/zone/templates/mobile/CreatureTemplate.h"
#include "server/zone/templates/tangible/DnaSampleTemplate.h"
#include "server/zone/objects/tangible/component/genetic/GeneticComponent.h"
#include "engine/engine.h"

class SampleDeedTask : public Task {

private:
	enum Phase { BEGIN, SAMPLING, END} currentPhase;
	int waitCount;
	ManagedReference<PetDeed*> deed;
	ManagedReference<CreatureObject*> player;
public:

	SampleDeedTask(PetDeed* obj, CreatureObject* playo) : Task() {
		currentPhase = BEGIN;
		waitCount = 0;
		deed = obj;
		player = playo;
	}
	void run() {
		if (deed == NULL)
			return;
		if (deed->isGenerated()) {
			return;
		}
		if(!player->hasSkill("outdoors_bio_engineer_novice") || !deed->isASubChildOf(player)) {
			return;
		}
		Locker locker(player);
		Locker crosslocker(deed,player);
		player->removePendingTask("sampledeed");

		int mindCost = player->calculateCostAdjustment(CreatureAttribute::FOCUS, 200);
		int skillMod = player->getSkillMod("dna_harvesting");
		int cl = deed->getLevel();
		switch(currentPhase){
			case BEGIN:
				// We should be good to go now and try the sample
				if (player->getHAM(CreatureAttribute::MIND) < mindCost) {
					player->sendSystemMessage("@bio_engineer:harvest_dna_attrib_too_low");
				} else {
					player->inflictDamage(player, CreatureAttribute::MIND, mindCost, false, true);
					player->sendSystemMessage("@bio_engineer:harvest_dna_begin_harvest");
					currentPhase = SAMPLING;
					player->addPendingTask("sampledeed",this,1000);
				}
				break;
			case SAMPLING:
				if (waitCount == 9) {
					currentPhase = END;
				}else {
					waitCount++;
				}
				player->addPendingTask("sampledeed",this,1000);
				break;
			case END:
				int count = deed->getSampleCount();
				int level = deed->getLevel();
				int skillMod = player->getSkillMod("dna_harvesting");
				float rollMod = (((skillMod-level)/level))  + (skillMod-level);
				int sampleRoll = System::random(100);
				sampleRoll += System::random(player->getSkillMod("luck") + player->getSkillMod("force_luck"));
				int maxSamples = ceil(skillMod/25);
				deed->incrementSampleCount();
				if ((30 + rollMod) < sampleRoll) {
					// failure but we increment the count
					player->sendSystemMessage("@bio_engineer:harvest_dna_failed");
				} else {
					player->sendSystemMessage("@bio_engineer:harvest_dna_succeed");
					award(cl,rollMod);
					if (count >= maxSamples ){
						// nuke deed you killed it
						ManagedReference<SceneObject*> deedContainer = deed->getParent();
						if (deedContainer != NULL) {
							deed->destroyObjectFromWorld(true);
						}
					}
				}
				break;
		}
		return;
	}

	void award(int cl, float rollMod) {<commit_msg>[fix] max sampels per deed is 1/2 of wild creatures i.e. 3 max at max level<commit_after>#ifndef SAMPLEDEEDTASK_H_
#define SAMPLEDEEDTASK_H_

#include "server/zone/managers/resource/ResourceManager.h"
#include "server/zone/managers/combat/CombatManager.h"
#include "server/zone/managers/creature/CreatureManager.h"
#include "server/zone/managers/creature/DnaManager.h"
#include "server/zone/objects/creature/CreatureObject.h"
#include "server/zone/objects/tangible/deed/pet/PetDeed.h"
#include "server/zone/objects/creature/CreatureAttribute.h"
#include "server/zone/templates/mobile/CreatureTemplate.h"
#include "server/zone/templates/tangible/DnaSampleTemplate.h"
#include "server/zone/objects/tangible/component/genetic/GeneticComponent.h"
#include "engine/engine.h"

class SampleDeedTask : public Task {

private:
	enum Phase { BEGIN, SAMPLING, END} currentPhase;
	int waitCount;
	ManagedReference<PetDeed*> deed;
	ManagedReference<CreatureObject*> player;
public:

	SampleDeedTask(PetDeed* obj, CreatureObject* playo) : Task() {
		currentPhase = BEGIN;
		waitCount = 0;
		deed = obj;
		player = playo;
	}
	void run() {
		if (deed == NULL)
			return;
		if (deed->isGenerated()) {
			return;
		}
		if(!player->hasSkill("outdoors_bio_engineer_novice") || !deed->isASubChildOf(player)) {
			return;
		}
		Locker locker(player);
		Locker crosslocker(deed,player);
		player->removePendingTask("sampledeed");

		int mindCost = player->calculateCostAdjustment(CreatureAttribute::FOCUS, 200);
		int skillMod = player->getSkillMod("dna_harvesting");
		int cl = deed->getLevel();
		switch(currentPhase){
			case BEGIN:
				// We should be good to go now and try the sample
				if (player->getHAM(CreatureAttribute::MIND) < mindCost) {
					player->sendSystemMessage("@bio_engineer:harvest_dna_attrib_too_low");
				} else {
					player->inflictDamage(player, CreatureAttribute::MIND, mindCost, false, true);
					player->sendSystemMessage("@bio_engineer:harvest_dna_begin_harvest");
					currentPhase = SAMPLING;
					player->addPendingTask("sampledeed",this,1000);
				}
				break;
			case SAMPLING:
				if (waitCount == 9) {
					currentPhase = END;
				}else {
					waitCount++;
				}
				player->addPendingTask("sampledeed",this,1000);
				break;
			case END:
				int count = deed->getSampleCount();
				int level = deed->getLevel();
				int skillMod = player->getSkillMod("dna_harvesting");
				float rollMod = (((skillMod-level)/level))  + (skillMod-level);
				int sampleRoll = System::random(100);
				sampleRoll += System::random(player->getSkillMod("luck") + player->getSkillMod("force_luck"));
				// max samples 1/2 of real creatures
				int maxSamples = ceil(skillMod/25)/2;
				deed->incrementSampleCount();
				if ((30 + rollMod) < sampleRoll) {
					// failure but we increment the count
					player->sendSystemMessage("@bio_engineer:harvest_dna_failed");
				} else {
					player->sendSystemMessage("@bio_engineer:harvest_dna_succeed");
					award(cl,rollMod);
					if (count >= maxSamples ){
						// nuke deed you killed it
						ManagedReference<SceneObject*> deedContainer = deed->getParent();
						if (deedContainer != NULL) {
							deed->destroyObjectFromWorld(true);
						}
					}
				}
				break;
		}
		return;
	}

	void award(int cl, float rollMod) {
{'fraction_non_alphanumeric': 0.1342959167831082, 'fraction_numerical': 0.007141748175749107, 'mean_word_length': 4.3416252072968495, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6202889', 'n_tokens_mistral': 2595, 'n_tokens_neox': 2160, 'n_words': 391}