Example #1
0
void run_projectiles_slice(int tick)
{
	int				n;
	proj_type		*proj;
	
	for (n=0;n!=server.count.proj;n++) {
		proj=&server.projs[n];

		object_clear_contact(&proj->contact);
	   
			// projectile counts
			
		proj->count++;
		if (proj->parent_grace>0) proj->parent_grace--;

			// moving projectiles
			
		if (!proj->stick) {
			projectile_speed(proj);

			if (projectile_move(proj)) {
				projectile_mark_dispose(proj);
				continue;
			}
			
			projectile_gravity(proj);
		}
		
			// stuck projectiles
			
		else {
			projectile_stick(proj);
		}
		
		projectile_collision(proj);
		
		if (projectile_hit(tick,proj,FALSE)) {
			projectile_mark_dispose(proj);
		}
	}
		
	projectile_dispose();
}
Example #2
0
void object_move_swim(obj_type *obj)
{
	int				i_xmove,i_ymove,i_zmove,hit_obj_uid;
    float			xmove,ymove,zmove,liq_speed_alter;

		// get object motion
		
	object_motion_setup(obj,&xmove,&ymove,&zmove);
	object_motion_lock(obj,&xmove,&ymove,&zmove);
	object_motion_set_script_property(obj,xmove,ymove,zmove);

		// clear all contacts

	object_clear_contact(&obj->contact);

		// speed cuts

	liq_speed_alter=object_liquid_alter_speed(obj);
	
	xmove*=liq_speed_alter;
  	zmove*=liq_speed_alter;
	ymove*=liq_speed_alter;

		// falling in water

	if (ymove>=0) object_move_y_fall(obj);

	if ((obj->air_mode==am_ground) || (ymove<0)) {
		if (obj->force.vct.y>0) obj->force.vct.y=0;
		obj->force.gravity=gravity_start_power;
	}

        // moving x/z

	i_xmove=(int)xmove;
	i_ymove=(int)ymove;
	i_zmove=(int)zmove;
	
	if ((i_xmove!=0) || (i_zmove!=0) || (i_ymove!=0)) {
		
		if (object_move_xz_slide(obj,&i_xmove,&i_ymove,&i_zmove)) {
		
				// pushing objects
				
			if (!object_push_with_object(obj,i_xmove,i_zmove)) {
				
				i_xmove=(int)xmove;
				i_ymove=(int)ymove;
				i_zmove=(int)zmove;

				hit_obj_uid=obj->contact.obj_uid;
				object_move_xz_slide(obj,&i_xmove,&i_ymove,&i_zmove);
				obj->contact.obj_uid=hit_obj_uid;
			}
		}

			// move standing objects

		if ((i_xmove!=0) || (i_zmove!=0)) object_move_with_standing_object(obj,i_xmove,i_zmove);
	}

		// bounces
		
	object_move_xz_bounce(obj);
	
        // move Y

	object_move_y_fly(obj,i_ymove);
}
Example #3
0
void object_move_normal(obj_type *obj)
{
	int				i_xmove,i_ymove,i_zmove,
					start_y,fall_damage,hit_obj_uid;
    float			xmove,zmove,ymove;
	bool			bump_once,push_once,old_falling;
	d3pnt			old_pnt;

		// get object motion
		
	object_motion_setup(obj,&xmove,&ymove,&zmove);
	object_motion_slope_alter_movement(obj,&xmove,&zmove);
	object_motion_lock(obj,&xmove,&ymove,&zmove);
	object_motion_set_script_property(obj,xmove,ymove,zmove);

		// save old settings

	old_falling=(obj->air_mode==am_falling);

		// get int version of movement

	i_xmove=(int)xmove;
	i_zmove=(int)zmove;
	i_ymove=(int)ymove;

		// special check for non-moving objects that can retain their
		// position and not run physics.  They must be standing on
		// non-moveable meshes and not be a player

	if ((i_xmove==0) && (i_zmove==0) && (i_ymove==0) && (!obj->player)) {
	
			// are we standing on a non-moving mesh?
			// if so, mark no hit collisions and return

		if (obj->contact.stand_poly.mesh_idx!=-1) {

			if (!map.mesh.meshes[obj->contact.stand_poly.mesh_idx].flag.moveable) {
				obj->contact.hit_poly.mesh_idx=-1;
				return;
			}

		}
	}

		// clear all contacts

	object_clear_contact(&obj->contact);

		// move the object in y space at the projected
		// x/z position
		//
		// we want to make sure that we move over land
		// features before they get blocked by wall-like
		// features in the map
		//
		// also, remember the y change and use that when
		// running the x/z ray trace collisions to continue
		// to avoid land features that might block foward
		// movement

	memmove(&old_pnt,&obj->pnt,sizeof(d3pnt));

	start_y=obj->pnt.y;

	obj->pnt.x=obj->pnt.x+i_xmove;
	obj->pnt.z=obj->pnt.z+i_zmove;

	if (i_ymove<0) {
		object_move_y_up(obj,i_ymove);
	}
	else {
		object_move_y_fall(obj);
		object_move_y_down(obj,i_ymove);
	}

	obj->pnt.x=old_pnt.x;
	obj->pnt.z=old_pnt.z;

		// add in the last y change. we use this
		// information in the next move to help
		// the object move over radically bumping
		// ground
		//
		// we only use the y change in x/z movement
		// if we are going up

	i_ymove=(obj->pnt.y-start_y)+obj->motion.last_y_change;
	if (i_ymove>0) i_ymove=0;

	obj->motion.last_y_change=obj->pnt.y-start_y;

		// if on ground, stop all downward motion
		// and forces
	
	if (obj->air_mode==am_ground) {
		if (obj->force.vct.y>0) obj->force.vct.y=0;
		obj->force.gravity=gravity_start_power;
	}

		// now we move the object in x/z space
		//
		// we also add in the y movement into the
		// collision detection to help eliminate
		// land features that could hold up the
		// object

	if ((i_xmove!=0) || (i_zmove!=0)) {
	
			// try to move a number of times
			// bumping up or hitting another object
			// can force the move to stop and then
			// need to be retried
			
		bump_once=FALSE;
		push_once=FALSE;
		hit_obj_uid=-1;
	
			// attempt to move
			
		while (TRUE) {

			if (!object_move_xz_slide(obj,&i_xmove,&i_ymove,&i_zmove)) break;

				// run any potential bump ups
				// if we are bumping up, then eliminate any
				// additional y movement

			if (!bump_once) {

				if (object_bump_up(obj)) {
					
					bump_once=TRUE;
					
					obj->pnt.x=old_pnt.x;
					obj->pnt.z=old_pnt.z;
					
					i_xmove=(int)xmove;
					i_ymove=0;
					i_zmove=(int)zmove;
					
					continue;
				}

			}
			
				// push objects, then
				// try the movement again
				// save the hit object uid so
				// the hit still registers

			if (!push_once) {
			
				if (!object_push_with_object(obj,i_xmove,i_zmove)) {
				
					push_once=TRUE;

					memmove(&obj->pnt,&old_pnt,sizeof(d3pnt));
					
					i_xmove=(int)xmove;
					i_ymove=(int)ymove;
					i_zmove=(int)zmove;

					hit_obj_uid=obj->contact.obj_uid;

					continue;
				}

			}
		
			break;
		}
		
			// potentially, pushing could reset the object
			// hit ID, so we reset it here
			
		if (hit_obj_uid!=-1) obj->contact.obj_uid=hit_obj_uid;

			// additional movements if we actually moved
			
		if ((i_xmove!=0) || (i_zmove!=0)) {

				// move objects standing on object

			object_move_with_standing_object(obj,i_xmove,i_zmove);

				// objects with automatic bouncing

			object_move_xz_bounce(obj);
		}
	}
	
		// check for objects that have finished falling
		// here we do any damage and send any landing
		// events
	
    if (obj->air_mode!=am_falling) {
    
        if (old_falling) {
            if (obj->fall.dist>map_enlarge) {
			
					// get damage
					
				if (obj->fall.dist>=obj->fall.damage_minimum_height) {
					fall_damage=(int)(((float)(obj->fall.dist-obj->fall.damage_minimum_height))*obj->fall.damage_factor);
					if (fall_damage!=0) object_damage(obj,NULL,NULL,NULL,NULL,fall_damage);
				}
				
					// send the land events
					
                scripts_post_event_console(&obj->attach,sd_event_land,0,0);
                object_post_move_animation_event(obj,sd_event_animation_object_land);
            }
        }
        
        obj->fall.dist=0;
        obj->fall.change=FALSE;

		return;
	}
	
		// check for objects that have started falling
	
	if ((obj->fall.dist>map_enlarge) && (!obj->fall.change)) {
		scripts_post_event_console(&obj->attach,sd_event_fall,0,0);
		scripts_post_event_console(&obj->attach,sd_event_animation_object,sd_event_animation_object_fall,0);
		obj->fall.change=TRUE;
	}
}
Example #4
0
File: objects.c Project: rzel/dim3
int object_create(char *name,int type,int bind)
{
	int				n,idx;
	obj_type		*obj;

		// find a unused object

	idx=-1;

	for (n=0;n!=max_obj_list;n++) {
		if (server.obj_list.objs[n]==NULL) {
			idx=n;
			break;
		}
	}

	if (idx==-1) return(-1);

		// create memory for new object

	obj=(obj_type*)malloc(sizeof(obj_type));
	if (obj==NULL) return(-1);

		// put in list

	server.obj_list.objs[idx]=obj;

		// initial setup
		
	strcpy(obj->name,name);

	obj->idx=idx;
	obj->type=type;
	obj->bind=bind;
	
	obj->next_spawn_sub_event=sd_event_spawn_init;

		// initialize object
	
	obj->hidden=FALSE;
	obj->suspend=FALSE;
	obj->scenery.on=FALSE;
	obj->fly=FALSE;
	obj->single_speed=FALSE;
	obj->side_step=TRUE;
	obj->floating=TRUE;
	obj->quick_reverse=TRUE;
	obj->no_slide=FALSE;
	obj->crawl=TRUE;
	obj->open_doors=FALSE;
	obj->hide_all_weapons=FALSE;
	obj->find_on=TRUE;
	obj->hit_box.on=FALSE;

	obj->script_spawned=FALSE;
	obj->dispose_trigger=FALSE;

	obj->contact.object_on=TRUE;
	obj->contact.projectile_on=TRUE;
	obj->contact.force_on=TRUE;
	obj->contact.pushable=FALSE;
	obj->contact.collision_mode=collision_mode_cylinder;
	
	obj->pickup.on=FALSE;
	obj->pickup.ignore=FALSE;
	
	obj->damage.on=FALSE;
	obj->damage.crushable=FALSE;
	obj->damage.invincible=FALSE;
	obj->damage.in_damage=FALSE;
	
	obj->tint_color_idx=0;
	obj->character_idx=0;
	
	obj->input.mode=im_fpp;
	obj->input.freeze=FALSE;
	obj->input.respawn_freeze=FALSE;
	
	obj->in_collide_event=FALSE;
	obj->death_trigger=FALSE;

	obj->last_spawn_spot_idx=-1;
	
	obj->lock.x=obj->lock.y=obj->lock.z=FALSE;
	
	obj->damage_obj_idx=-1;
	
	obj->team_idx=net_team_none;

	obj->spawn_spot.name[0]=0x0;
	obj->spawn_spot.script[0]=0x0;
	obj->spawn_spot.params[0]=0x0;
	
	obj->click.on=FALSE;
	obj->click.distance=1500;
	obj->click.crosshair_up_idx=-1;
	obj->click.crosshair_down_idx=-1;
	
	object_clear_size(&obj->size);
	object_clear_position(&obj->pnt);
	object_clear_angle(&obj->ang);
	object_clear_motion(&obj->motion);
	object_clear_force(&obj->force);
	object_clear_movement(&obj->forward_move);
    object_clear_movement(&obj->side_move);
	object_clear_movement(&obj->vert_move);
	object_stop(obj);

	obj->sight.side_angle=20.0f;
	obj->sight.look_angle=0.0f;
	obj->sight.distance=22000;
	
    obj->bump.on=TRUE;
    obj->bump.high=450;
	obj->bump.smooth_factor=0.1f;
	obj->bump.smooth_offset=0;

	obj->slope_gravity=TRUE;
	
	obj->bounce.mesh_idx=-1;
	obj->bounce.factor=0.0f;
	
	obj->turn.ignore_mouse=FALSE;
	obj->turn.only_when_moving=FALSE;
	obj->turn.restrict_player_turning=FALSE;

	obj->face.obj_idx=-1;
	object_clear_angle(&obj->face.ang);
	
	obj->thrust.speed=0.5f;
	obj->thrust.max_speed=60.0f;
	obj->thrust.vct.x=obj->thrust.vct.y=obj->thrust.vct.z=0.0f;
	obj->thrust.drag=FALSE;
	
	obj->look.ang_add=0;
	obj->look.up_angle=80;
	obj->look.down_angle=35;
	obj->look.effect_weapons=TRUE;
	
	obj->duck.on=TRUE;
    obj->duck.mode=dm_stand;
    obj->duck.y_move=0;
    obj->duck.y_add=16;
    obj->duck.y_change=300;
	
	obj->jump.on=TRUE;
    obj->jump.y_add=32;
	
	obj->climb.on=FALSE;
	obj->climb.poly_ptr.mesh_idx=-1;
	
	obj->kickback.size=100;

	obj->vehicle.on=FALSE;
	obj->vehicle.use_vehicles=TRUE;
	obj->vehicle.in_enter=obj->vehicle.in_exit=FALSE;
	obj->vehicle.attach_obj_idx=-1;

	obj->radar.on=FALSE;
	obj->radar.icon[0]=0x0;
	obj->radar.icon_idx=-1;
	obj->radar.motion_only=FALSE;
	obj->radar.always_visible=FALSE;
	obj->radar.fade_start_tick=0;
	
	obj->status.health.value=obj->status.health.start_value=obj->status.health.max_value=100;
	obj->status.health.recover_tick=obj->status.health.recover_count=0;
	obj->status.health.recover_amount=1;
	obj->status.health.factor=1.0f;
	obj->status.armor.value=obj->status.armor.start_value=obj->status.armor.max_value=0;
	obj->status.armor.recover_tick=obj->status.armor.recover_count=0;
	obj->status.armor.recover_amount=1;
	obj->status.armor.factor=1.0f;
	obj->status.mesh_harm_count=0;
	
	object_clear_draw(&obj->draw);
	obj->ambient.on=FALSE;
    
    obj->held_weapon.mode=wm_held;
    obj->held_weapon.swap_tick=0;
	obj->held_weapon.current_idx=obj->held_weapon.next_idx=-1;
	obj->held_weapon.bounce_y=0;
	
	obj->crosshair_draw.on=FALSE;
	obj->crosshair_draw.alt_tick=0;

	obj->melee.strike_bone_name[0]=0x0;
	obj->melee.strike_pose_name[0]=0x0;
	obj->melee.object_strike_bone_name[0]=0x0;
	obj->melee.object_strike_pose_name[0]=0x0;
	obj->melee.radius=0;
	obj->melee.distance=0;
	obj->melee.damage=0;
	obj->melee.force=0;
	obj->melee.fall_off=TRUE;
	
	obj->hit_box.obj_hit_box_idx=-1;
	obj->hit_box.proj_hit_box_idx=-1;
	
	obj->count=0;
	obj->item_count=0;

	obj->turn.ang_add.y=0;
	obj->turn.fix_ang_add.y=0;
	obj->turn.ang_to.y=0;
	obj->turn.walk_speed=obj->turn.run_speed=obj->turn.crawl_speed=obj->turn.air_speed=1;
	obj->turn.walk_motion_speed=obj->turn.run_motion_speed=obj->turn.crawl_motion_speed=obj->turn.air_motion_speed=1;
	obj->turn.key_speed=1.8f;
	obj->turn.top_down_ang_offset=0.0f;

	obj->air_mode=am_ground;

    obj->liquid.mode=lm_out;
	obj->liquid.bob_y_move=0;

	obj->fall.dist=0;
	obj->fall.damage_minimum_height=3000;
	obj->fall.damage_factor=0.0f;
    obj->fall.started=FALSE;
	obj->fall.land_event_ok=FALSE;
	
	obj->last_move_animation_event=-1;
	obj->last_turn_animation_event=-1;

	obj->auto_walk.mode=aw_none;
	obj->auto_walk.dodge.on=FALSE;

	obj->label.text.str[0]=0x0;
	obj->label.bitmap.idx=-1;
	obj->label.bar.value=-1.0f;

	obj->debug.str[0]=0x0;
	
	object_clear_contact(&obj->contact);
	object_clear_touch(&obj->touch);
	object_clear_hit(&obj->hit);
	object_clear_pickup(&obj->pickup);
	object_clear_watch(&obj->watch);

	object_clear_remote(&obj->remote);

	object_grow_clear(obj);
	
	obj->score.kill=obj->score.death=obj->score.suicide=obj->score.goal=obj->score.score=0;
	obj->score.place=1;
	
		// clear weapons

	for (n=0;n!=max_weap_list;n++) {
		obj->weap_list.weaps[n]=NULL;
	}
	
		// connections for animated effects
		
	obj->draw.connect.obj_idx=idx;
	obj->draw.connect.weap_idx=-1;
	obj->draw.connect.proj_idx=-1;
	obj->draw.connect.net_sound=FALSE;
	obj->draw.connect.motion_vct.x=0.0f;
	obj->draw.connect.motion_vct.y=0.0f;
	obj->draw.connect.motion_vct.z=0.0f;
	
	return(idx);
}