Object* Object_create_hash(Hashmap *hash) { Object *obj = Object_allocate(); obj->type = tHash; obj->value.as_hash = hash; return obj; }
Object* Object_create_string(bstring value) { Object *obj = Object_allocate(); obj->type = tString; obj->value.as_string = value; return obj; }
Object* Object_create_array(DArray *array) { Object *obj = Object_allocate(); obj->type = tArray; obj->value.as_array = array; return obj; }
Object* Object_create_integer(int value) { Object *obj = Object_allocate(); obj->type = tInteger; obj->value.as_integer = value; return obj; }
void Cannon_throw_items(cannon_t *c) { int i, dir; itemobject_t *item; double velocity; for (i = 0; i < NUM_ITEMS; i++) { if (i == ITEM_FUEL) continue; c->item[i] -= Cannon_get_initial_item(c, (Item_t)i); while (c->item[i] > 0) { int amount = world->items[i].max_per_pack - (int)(rfrac() * (1 + world->items[i].max_per_pack - world->items[i].min_per_pack)); LIMIT(amount, 0, c->item[i]); if (rfrac() < (options.dropItemOnKillProb * CANNON_DROP_ITEM_PROB) && (item = ITEM_PTR(Object_allocate())) != NULL) { item->type = OBJ_ITEM; item->item_type = i; item->color = RED; item->obj_status = GRAVITY; dir = (int)(c->dir - (CANNON_SPREAD * 0.5) + (rfrac() * CANNON_SPREAD)); dir = MOD2(dir, RES); item->id = NO_ID; item->team = TEAM_NOT_SET; Object_position_init_clpos(OBJ_PTR(item), c->pos); velocity = rfrac() * 6; item->vel.x = tcos(dir) * velocity; item->vel.y = tsin(dir) * velocity; item->acc.x = 0; item->acc.y = 0; item->mass = 10; item->life = 1500 + rfrac() * 512; item->item_count = amount; item->pl_range = ITEM_SIZE / 2; item->pl_radius = ITEM_SIZE / 2; world->items[i].num++; Cell_add_object(OBJ_PTR(item)); } c->item[i] -= amount; } } }