void effect::drawcone(vec &o, vec dir, vec &axis, int angle, float radius, float size, int type, int elapse) { if(size <= 0) return; size *= this->size; int fade, gravity, num; setvars(this, type, fade, gravity, num); num *= angle * (particle == PART_STREAK || particle == PART_LIGHTNING ? 1 : partmul) / size / 30 * (elapse ? logf(elapse) / 3 : 1); num = max<int>(1, num); loopi(num) { vec ray = vec(dir).rotate(rnd(angle + 1) * RAD, axis).rotate(rnd(360), dir).mul(radius); switch(particle) { case PART_EXPLOSION: case PART_EXPLOSION_BLUE: ray.mul(rnd(101)/100.f).add(o); particle_fireball(ray, size, particle, fade, colour, size); break; case PART_STREAK: case PART_LIGHTNING: if(!curtime) return; particle_flare(o, ray.add(o), fade, particle, colour, size); break; default: ray.mul(rnd(101)/100.f).add(o); particle_splash(particle, 2, fade, ray, colour, size, max<int>(1, size * 2), gravity); break; } } }
void effect::drawaura(rpgent *d, float size, int type, int elapse) { if(size <= 0) return; size *= this->size; int fade, gravity, num; setvars(this, type, fade, gravity, num); num *= .2 * PI * d->radius / (1 + size) * partmul * (elapse ? logf(elapse) / 3 : 1); if(elapse && !num && rnd(int(10 / partmul))) return; //sometimes particles should not be drawn num = max<int>(1, num); loopi(num) { vec pos = vec(rnd(360) * RAD, 0).mul(d->radius + size).add(d->feetpos()); switch(particle) { case PART_EXPLOSION: case PART_EXPLOSION_BLUE: particle_fireball(pos, size, particle, fade, colour, size); break; case PART_STREAK: case PART_LIGHTNING: if(!curtime) return; particle_flare(pos, vec(0, 0, d->eyeheight + d->aboveeye).add(pos), fade, particle, colour, size); break; default: if(gravity >= 0) pos.add(vec(0, 0, d->eyeheight + d->aboveeye)); particle_splash(particle, 2, fade, pos, colour, size, max<int>(1, size * 2), gravity); break; } } }
void effect::drawwield(vec &from, vec &to, float size, int type, int elapse) { if(size <= 0) return; if(particle == PART_STREAK || particle == PART_LIGHTNING) { drawline(from, to, size, type, elapse); return; } size *= this->size; int fade, gravity, num; setvars(this, type, fade, gravity, num); num *= partmul * (elapse ? (logf(elapse) / 3) : 1) / (1 + size); if(elapse && !num && rnd(int(10 / partmul))) return; num = max<int>(1, num); vec delta = vec(to).sub(from); loopi(num) { vec pt = vec(delta).mul((float) rnd(0x10000) / 0xFFFF).add(from); switch(particle) { case PART_EXPLOSION: case PART_EXPLOSION_BLUE: particle_fireball(pt, size * 2, particle, fade, colour, size * 4); break; default: particle_splash(particle, 2, fade, pt, colour, size, max<int>(1, size * 5), gravity); } } }
/* Creates a new object */ NODE *newobj(void) { NODE *result = newnode(OBJECT); NODE *binding = newnode(CONS); setcar(binding, theName(Name_licenseplate)); setobject(binding, newplate()); setvars(result, binding); return result; }
/* Initializes Object Logo */ void obj_init(void) { logo_object = newobj(); current_object = logo_object; setvars(logo_object, cons(theName(Name_name), getvars(logo_object))); setobject(getvars(logo_object), make_static_strnode("Logo")); /* [[initlist] [exist output self]] */ askexist = cons(cons(theName(Name_initlist), NIL), cons(cons(theName(Name_exist), cons(theName(Name_output), cons(theName(Name_self), NIL))), NIL)); }
void effect::drawsplash(vec &o, vec dir, float radius, float size, int type, int elapse) { if(size <= 0) return; size *= this->size; int fade, gravity, num; setvars(this, type, fade, gravity, num); num *= .1 * radius / (1 + size) * partmul * (elapse ? logf(elapse) / 3 : 1); if(elapse && !num && rnd(int(10 / partmul))) return; //sometimes particles should not be drawn num = max(1, num); switch(particle) { case PART_EXPLOSION: case PART_EXPLOSION_BLUE: particle_fireball(o, radius ? radius : size, particle, fade, colour, size); break; case PART_STREAK: case PART_LIGHTNING: if(!curtime) break; if(!radius) //assume num == 1 { vec offset = vec(dir).mul(-2 * size).add(o); particle_flare(offset, o, fade, particle, colour, size); } else { num = (num / 2 + num % 2); loopi(num) { vec offset = vec(rnd(360) * RAD, (90 - rnd(180)) * RAD).mul(radius); vec offset2 = vec(rnd(360) * RAD, rnd(360) * RAD).mul(radius); particle_flare(vec(o).sub(offset), vec(o).add(offset2), fade, particle, colour, size); } } break; default: particle_splash(particle, num, fade, o, colour, size, max<int>(1, radius), gravity); break; } }
bool effect::drawline(vec &from, vec &to, float size, int type, int elapse) { if(size <= 0) return false; size *= this->size; int fade, gravity, num; setvars(this, type, fade, gravity, num); num *= from.dist(to) / (10 * size) * partmul * (elapse ? logf(elapse) / 3 : 1); if(particle == PART_STREAK || particle == PART_LIGHTNING) num /= 2; num = min<int>(min(num, linemaxsteps), from.dist(to) / linemininterval); if(!num) return false; vec delta = vec(to).sub(from).div(num); loopi(num) { switch(particle) { case PART_EXPLOSION: case PART_EXPLOSION_BLUE: particle_fireball(from, size * 2, particle, fade, colour, size * 2); break; case PART_STREAK: case PART_LIGHTNING: { if(!curtime) return false; vec start = vec(rnd(360) * RAD, rnd(360) * RAD).mul(4 * size).add(from); vec end = vec(delta).mul(1.5).add(start); particle_flare(start, end, fade, particle, colour, size); break; } default: particle_splash(particle, 2, fade, from, colour, size, max<int>(1, size * 5), gravity); break; } from.add(delta); } return true; }
/* Creates the object variable named Symbol, or the object variables named , * SymbolList within the current object. * @params - Symbol or SymbolList */ NODE *lhave(NODE *args) { if (is_list(car(args))) { if (cdr(args) != NIL) { err_logo(TOO_MUCH, NIL); /* too many inputs */ } args = car(args); } /* now args is always a list of symbols. args should not equal to NIL because that is checked for before. */ while (args != NIL && NOT_THROWING) { NODE *sym = intern(car(args)); NODE *binding = assoc(sym, getvars(current_object)); if (binding == NIL) { setvars(current_object, cons(sym, getvars(current_object))); setobject(getvars(current_object), UNBOUND); } args = cdr(args); } return UNBOUND; }