<commit_before>// Copyright © 2011 <NAME> and <NAME>
// Licensed under the MIT License. See LICENSE for details.
#include "../../include/mid.h"
#include "enemy.h"
#include <stdio.h>

Img *nousimg;

_Bool nousinit(Enemy *e, int x, int y){
	e->hp = 1;
	e->data = 0;
	bodyinit(&e->body, x*Twidth+3, y*Theight, Twidth-3, Theight);
	return 1;
}

void nousfree(Enemy *e){
}

void nousupdate(Enemy *e, Player *p, Zone *z){
	e->ai.update(e, p, z);
	bodyupdate(&e->body, z->lvl);

	if(isect(e->body.bbox, playerbox(p))){
		int dir = e->body.bbox.a.x > p->body.bbox.a.x ? -1 : 1;
		playerdmg(p, 1, dir);
	}

	if(p->sframes > 0 && isect(e->body.bbox, swordbbox(&p->sw))){
		sfxplay(untihit);
		e->hp--;

		if(e->hp <= 0){
			Enemy splat = {};
			enemyinit(&splat, EnemySplat, 0, 0);
			splat.body = e->body;
			nousfree(e);
			*e = splat;
			return;
		}
	}
}

void nousdraw(Enemy *e, Gfx *g){
	Rect clip;
	if(e->body.vel.x < 0)
		clip = (Rect){
			{ 0, 0 },
			{ 32, 32 }
		};
	else
		clip = (Rect){
			{ 32, 0 },
			{ 64, 32 }
		};

	Point p = e->body.bbox.a;
	p.x -= 3;
	camdrawreg(g, nousimg, clip, p);
}

_Bool nousscan(char *buf, Enemy *e){
	if (!defaultscan(buf, e))
		return 0;

	aiwalker(&e->ai, 2);

	return 1;
}

_Bool nousprint(char *buf, size_t sz, Enemy *e){
	return defaultprint(buf, sz, e);
}
<commit_msg>Nous drops coins now. Fixes issue 8.<commit_after>// Copyright © 2011 <NAME> and <NAME>
// Licensed under the MIT License. See LICENSE for details.
#include "../../include/mid.h"
#include "enemy.h"
#include <stdio.h>

Img *nousimg;

_Bool nousinit(Enemy *e, int x, int y){
	e->hp = 1;
	e->data = 0;
	bodyinit(&e->body, x*Twidth+3, y*Theight, Twidth-3, Theight);
	return 1;
}

void nousfree(Enemy *e){
}

void nousupdate(Enemy *e, Player *p, Zone *z){
	e->ai.update(e, p, z);
	bodyupdate(&e->body, z->lvl);

	if(isect(e->body.bbox, playerbox(p))){
		int dir = e->body.bbox.a.x > p->body.bbox.a.x ? -1 : 1;
		playerdmg(p, 1, dir);
	}

	if(p->sframes > 0 && isect(e->body.bbox, swordbbox(&p->sw))){
		sfxplay(untihit);
		e->hp--;

		if(e->hp <= 0){
			Enemy splat = {};
			enemyinit(&splat, EnemySplat, 0, 0);
			splat.body = e->body;
			nousfree(e);
			*e = splat;
			Item coin = {};
			Point gridcoord = { // BARF
				e->body.bbox.a.x / Twidth,
				e->body.bbox.a.y / Theight
			};
			iteminit(&coin, ItemCopper, gridcoord);
			zoneadditem(z, z->lvl->z, coin);
			return;
		}
	}
}

void nousdraw(Enemy *e, Gfx *g){
	Rect clip;
	if(e->body.vel.x < 0)
		clip = (Rect){
			{ 0, 0 },
			{ 32, 32 }
		};
	else
		clip = (Rect){
			{ 32, 0 },
			{ 64, 32 }
		};

	Point p = e->body.bbox.a;
	p.x -= 3;
	camdrawreg(g, nousimg, clip, p);
}

_Bool nousscan(char *buf, Enemy *e){
	if (!defaultscan(buf, e))
		return 0;

	aiwalker(&e->ai, 2);

	return 1;
}

_Bool nousprint(char *buf, size_t sz, Enemy *e){
	return defaultprint(buf, sz, e);
}

{'fraction_non_alphanumeric': 0.21141649048625794, 'fraction_numerical': 0.024312896405919663, 'mean_word_length': 2.9929676511954995, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 53, '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': '3774439', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1284, 'n_words': 309}