コード例 #1
0
ファイル: ai.c プロジェクト: JavaProphet/Basin
int32_t ai_attackmelee(struct world* world, struct entity* entity, struct aitask* ai) {
	struct ai_attackmelee_data* amd = ai->data;
	entity->ai->lookHelper_speedYaw = 30.;
	entity->ai->lookHelper_speedPitch = 30.;
	entity->ai->lookHelper_x = entity->attacking->x;
	struct boundingbox bb;
	getEntityCollision(entity->attacking, &bb);
	entity->ai->lookHelper_y = entity->attacking->y + ((bb.maxY - bb.minY) * .9); // TODO: real eye height
	entity->ai->lookHelper_z = entity->attacking->z;
	double dist = entity_distsq(entity->attacking, entity);
	amd->delayCounter--;
//TODO: cansee
	if ((amd->longMemory || 1) && amd->delayCounter <= 0 && ((amd->targetX == 0. && amd->targetY == 0. && amd->targetZ == 0.) || entity_distsq_block(entity->attacking, amd->targetX, amd->targetY, amd->targetZ) >= 1. || randFloat() < .05)) {
		amd->targetX = entity->attacking->x;
		amd->targetY = entity->attacking->y;
		amd->targetZ = entity->attacking->z;
		if (dist > 1024.) amd->delayCounter += 10;
		else if (dist > 256.) amd->delayCounter += 5.;
		//TODO: set path
	}
	if (--amd->attackTick <= 0) amd->attackTick = 0;
	struct entity_info* ei = getEntityInfo(entity->type);
	struct entity_info* ei2 = getEntityInfo(entity->attacking->type);
	float reach = ei->width * 2. * ei->width * 2. + ei2->width;
	if (dist <= reach && amd->attackTick <= 0) {
		amd->attackTick = 20;
		swingArm(entity);
		damageEntityWithItem(entity->attacking, entity, -1, NULL);
	}
	return 0;
}
コード例 #2
0
ファイル: ai.c プロジェクト: JavaProphet/Basin
int ai_shouldattackmelee(struct world* world, struct entity* entity, struct aitask* ai) {
	if (entity->attacking == NULL || entity->attacking->health <= 0. || (entity->type == ENT_PLAYER && (entity->data.player.player->gamemode == 1 || entity->data.player.player->gamemode == 3))) return 0;
	struct entity_info* ei = getEntityInfo(entity->type);
	struct entity_info* ei2 = getEntityInfo(entity->attacking->type);
	if (ei == NULL || ei2 == NULL || !hasFlag(ei2, "livingbase")) return 0;
	return entity->attacking != NULL;
	//float reach = ei->width * 2. * ei->width * 2. + ei2->width;
	//return reach >= entity_distsq(entity->attacking, entity);
}
コード例 #3
0
// --------------------------------------------------------------------------
void ModelScaleProperty::setScale(int oid, const Vector3 &scale) {
    EntityInfo *ei = getEntityInfo(oid);

    // Bugfix for zero sized scale. Dunno why those appear, but anyway
    // this helps...
    if ((scale.x == 0) || (scale.y == 0) || (scale.z == 0))
        return;

    ei->setScale(scale);
};
コード例 #4
0
ファイル: ai.c プロジェクト: JavaProphet/Basin
int ai_shouldnearestattackabletarget(struct world* world, struct entity* entity, struct aitask* ai) {
	struct ai_nearestattackabletarget_data* data = ai->data;
	if (data->chance > 0 && rand() % data->chance != 0) return 0;
	double cd = data->targetDist * data->targetDist;
	struct entity* ce = NULL;
	BEGIN_HASHMAP_ITERATION(world->entities)
	struct entity* ie = value;
	if (!hasFlag(getEntityInfo(ie->type), "livingbase") || ie == entity) continue;
	double dsq = entity_distsq(entity, value);
	if (ie->type == ENT_PLAYER) {
		struct player* pl = ie->data.player.player;
		if (pl->gamemode == 1 || pl->gamemode == 3 || pl->invulnerable) continue;
		int sk = hasFlag(getEntityInfo(entity->type), "skeleton");
		int zo = hasFlag(getEntityInfo(entity->type), "zombie");
		int cr = hasFlag(getEntityInfo(entity->type), "creeper");
		if (sk || zo || cr) {
			struct slot* hs = inventory_get(pl, pl->inventory, 5);
			if (hs != NULL) {
				if (sk && hs->damage == 0) dsq *= 2.;
				else if (zo && hs->damage == 2) dsq *= 2.;
				else if (cr && hs->damage == 4) dsq *= 2.;
			}
		}
	}
	if (dsq < cd) {
		//TODO check teams, sight
		cd = dsq;
		ce = value;
	}
	END_HASHMAP_ITERATION(world->entities)
	if (entity->attacking != NULL && ce != entity->attacking) put_hashmap(entity->attacking->attackers, entity->id, NULL);
	if (ce != NULL && entity->attacking != ce) {
		put_hashmap(ce->attackers, entity->id, entity);
	}
	entity->attacking = ce;
	return 0;
}
コード例 #5
0
ファイル: entityidentifier.cpp プロジェクト: EtlamGit/minutor
QColor EntityIdentifier::getPenColor(const QString id) const {
  return getEntityInfo(id).penColor;
}
コード例 #6
0
ファイル: entityidentifier.cpp プロジェクト: EtlamGit/minutor
QColor EntityIdentifier::getBrushColor(const QString id) const {
  return getEntityInfo(id).brushColor;
}