std::wstring SLintXmlResult::replaceByEntities(const std::wstring & seq) { std::vector<wchar_t> buf; for (auto c : seq) { if (c == L'<') { pushEntity(buf, L"<", 7); } else if (c == L'>') { pushEntity(buf, L">", 7); } else if (c == L'\'') { pushEntity(buf, L"'", 7); } else if (c == L'\"') { pushEntity(buf, L""", 7); } else if (c == L'&') { pushEntity(buf, L"&", 7); } else { buf.push_back(c); } } return std::wstring(buf.begin(), buf.end()); }
static void iceBlockTouch(Entity *other) { Entity *temp; pushEntity(other); if (other->type == WEAPON && (other->flags & ATTACKING)) { if (self->takeDamage != NULL && !(self->flags & INVULNERABLE)) { self->takeDamage(other, other->damage); } } else if (other->type == PROJECTILE && other->parent != self) { if (self->takeDamage != NULL && !(self->flags & INVULNERABLE)) { self->takeDamage(other, other->damage); } temp = self; self = other; self->die(); self = temp; } }
static void touch(Entity *other) { pushEntity(other); if (self->type == MANUAL_DOOR) { if (other->type == PLAYER && self->active == FALSE) { /* Look through the player's inventory */ if (removeInventoryItemByObjectiveName(self->requires) == TRUE) { setInfoBoxMessage(60, 255, 255, 255, _("Used %s"), _(self->requires)); self->action = &moveToTarget; self->active = TRUE; } else { setInfoBoxMessage(60, 255, 255, 255, _("%s is needed to open this door"), _(self->requires)); } } } else if (other->type == PLAYER && self->active == FALSE && self->mental == 0) { setInfoBoxMessage(60, 255, 255, 255, _("This door is locked")); } }
static void touch(Entity *other) { if (other->flags & ATTACKING) { takeDamage(other, other->damage); } if (self->inUse == TRUE && self->touch != NULL) { pushEntity(other); } }
static void touch(Entity *other) { if (self->active == TRUE || self->health == 1) { entityTouch(other); } else { pushEntity(other); } }
static void touch(Entity *other) { if (strcmpignorecase(other->name, self->name) != 0) { pushEntity(other); } if (other->standingOn == self && other->type == PLAYER && self->health == 0) { self->health = 1; } }
std::wstring CovHTMLCodePrinter::replaceByEntities(const std::wstring & seq) { std::vector<wchar_t> buf; // if seq contains 100 chars and there are 8 special chars // then it will contain after the loop 148 chars. // So we should avoid the buf resizment. buf.reserve(1.5 * seq.length()); for (auto c : seq) { if (c == L'<') { pushEntity(buf, L"<", 7); } else if (c == L'>') { pushEntity(buf, L">", 7); } else if (c == L'\'') { pushEntity(buf, L"'", 7); } else if (c == L'\"') { pushEntity(buf, L""", 7); } else if (c == L'&') { pushEntity(buf, L"&", 7); } else { buf.push_back(c); } } return std::wstring(buf.begin(), buf.end()); }
static void touch(Entity *other) { Entity *e; pushEntity(other); if (other->standingOn == self) { if (self->thinkTime < 5) { playSoundToMap("sound/item/inflate", -1, self->x, self->y, 0); self->health++; } if (self->health == 3) { if (self->thinkTime < 5) { e = addBubble(self->x, self->y, "item/bubble"); e->x = self->face == LEFT ? getLeftEdge(self) : getRightEdge(self); e->x += self->face == LEFT ? -e->w : e->w; e->y = self->y + self->h / 2 - e->h / 2; e->dirX = self->face == LEFT ? -e->speed : e->speed; } self->thinkTime = 60; } else if (self->health > 3) { self->health = 3; self->thinkTime = 60; } else { self->thinkTime = 10; } setEntityAnimationByID(self, self->health + 3); } }
static void touch(Entity *other) { if (other->type != PLAYER) { self->flags |= OBSTACLE; } else { self->flags &= ~OBSTACLE; } pushEntity(other); self->flags &= ~OBSTACLE; }
static void touch(Entity *other) { if (strcmpignorecase(other->name, "weapon/flaming_arrow") == 0) { self->active = TRUE; other->inUse = FALSE; } else if ((other->flags & ATTACKING) && !(self->flags & INVULNERABLE)) { takeDamage(other, other->damage); } else { pushEntity(other); } }
static void touch(Entity *other) { float dirY = other->dirY; pushEntity(other); if (other->standingOn == self) { dirY *= other->weight; dirY /= 25; dirY *= 14; if (abs(dirY) > self->maxHealth && self->maxThinkTime == 0) { self->maxHealth = dirY > 14 ? 14 : dirY; self->maxThinkTime = 1; } } }
static void touch(Entity *other) { int mirrorLeft, mirrorRight, beamMid; if (strcmpignorecase(other->name, "item/light_beam") == 0) { if (other != self->target) { /* Light moving vertically */ if (other->dirY > 0 && self->mental == 0) /* Upright mirror */ { other->endY = self->y + self->h / 2; other->x = other->startX; other->y = other->startY; other->box.h = other->endY - other->y; mirrorLeft = self->x + self->w / 2 - 4; mirrorRight = self->x + self->w / 2 + 4; beamMid = other->x + other->w / 2; if (beamMid >= mirrorLeft && beamMid <= mirrorRight) { if (self->face == LEFT) { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2; self->target->y = self->y + self->h / 2 - 6; self->target->dirX = -self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } else { self->target->startX = self->x + self->w / 2; self->target->box.w = self->target->startX - self->target->x; } } else { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2; self->target->y = self->y + self->h / 2 - 6; self->target->dirX = self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } else { self->target->x = self->x + self->w / 2; self->target->startX = self->target->x; self->target->box.w = self->target->endX - self->target->x; } } self->thinkTime = 2; } } else if (other->dirY < 0 && self->mental == 1) /* Upside down mirror */ { other->y = self->y + self->h / 2; other->box.h = other->startY - other->y; mirrorLeft = self->x + self->w / 2 - 4; mirrorRight = self->x + self->w / 2 + 4; beamMid = other->x + other->w / 2; /*if (beamMid >= mirrorLeft && beamMid <= mirrorRight)*/ { if (self->face == LEFT) { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2 - 2; self->target->y = self->y + self->h / 2; self->target->dirX = -self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } } else { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2; self->target->y = self->y + self->h / 2 + 6; self->target->dirX = self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } } self->thinkTime = 2; } } /* Lift moving horizontally */ else if (other->dirX > 0 && self->face == LEFT) { other->endX = self->x + self->w / 2; other->box.w = other->endX - other->x; mirrorLeft = self->y + self->h / 2 - 4; mirrorRight = self->y + self->h / 2 + 4; beamMid = other->y + other->h / 2; /*if (beamMid >= mirrorLeft && beamMid <= mirrorRight)*/ { if (self->mental == 0) /* Upright mirror */ { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2 - 2; self->target->y = self->y + self->h / 2; self->target->dirY = -self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } else { self->target->x = self->x + self->w / 2 - 2; self->target->startX = self->x + self->w / 2; } } else /* Upside down mirror */ { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2 - 2; self->target->y = self->y + self->h / 2; self->target->dirY = self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } } self->thinkTime = 2; } } else if (other->dirX < 0 && self->face == RIGHT) { other->x = self->x + self->w / 2; other->box.w = other->startX - other->x; mirrorLeft = self->y + self->h / 2 - 4; mirrorRight = self->y + self->h / 2 + 4; beamMid = other->y + other->h / 2; /*if (beamMid >= mirrorLeft && beamMid <= mirrorRight)*/ { if (self->mental == 0) /* Upright mirror */ { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2 - 2; self->target->y = self->y + self->h / 2; self->target->dirY = -self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } else { self->target->x = self->x + self->w / 2 - 2; self->target->startX = self->x + self->w / 2; } } else /* Upside down mirror */ { if (self->target == NULL) { self->target = addLightBeam(0, 0, "item/light_beam"); self->target->x = self->x + self->w / 2 - 2; self->target->y = self->y + self->h / 2; self->target->dirY = self->target->speed; self->target->startX = self->target->x; self->target->startY = self->target->y; } } self->thinkTime = 2; } } } } else { if (other->type != PLAYER) { self->flags |= OBSTACLE; } else { self->flags &= ~OBSTACLE; } pushEntity(other); self->flags &= ~OBSTACLE; } }
static void touch(Entity *other) { pushEntity(other); }