JSValueRef js_obj_position_place_random_node_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception) { int idx; char name[name_str_len]; obj_type *obj; node_type *node; if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx)); obj=object_get_attach(j_obj); // find random node script_value_to_string(cx,argv[0],name,name_str_len); idx=map_find_random_node(&map,name,-1); if (idx==-1) return(script_null_to_value(cx)); // move player node=&map.nodes[idx]; object_set_position(obj,node->pnt.x,node->pnt.y,node->pnt.z,0.0f,0); object_telefrag_players(obj,FALSE); return(script_null_to_value(cx)); }
JSValueRef js_obj_position_move_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception) { d3pnt add; obj_type *obj; if (!script_check_param_count(cx,func,argc,1,exception)) return(script_null_to_value(cx)); obj=object_get_attach(j_obj); script_value_to_point(cx,argv[0],&add); object_set_position(obj,(obj->pnt.x+add.x),(obj->pnt.y+add.y),(obj->pnt.z+add.z),obj->ang.y,0); object_telefrag_players(obj,FALSE); return(script_null_to_value(cx)); }
JSValueRef js_map_object_move_to_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception) { d3pnt pnt; obj_type *obj; if (!script_check_param_count(cx,func,argc,3,exception)) return(script_null_to_value(cx)); obj=script_find_obj_from_uid_arg(cx,argv[0],exception); if (obj==NULL) return(script_null_to_value(cx)); script_value_to_point(cx,argv[1],&pnt); object_set_position(obj,pnt.x,pnt.y,pnt.z,script_value_to_float(cx,argv[2]),0); object_telefrag_players(obj,FALSE); return(script_null_to_value(cx)); }
JSValueRef js_obj_position_place_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception) { float ang_y; d3pnt pnt; obj_type *obj; if (!script_check_param_count(cx,func,argc,2,exception)) return(script_null_to_value(cx)); obj=object_get_attach(j_obj); script_value_to_point(cx,argv[0],&pnt); ang_y=script_value_to_float(cx,argv[1]); object_set_position(obj,pnt.x,pnt.y,pnt.z,ang_y,0); object_telefrag_players(obj,FALSE); return(script_null_to_value(cx)); }
void game_reset_single_object(obj_type *obj,bool reposition) { spot_type *spot; obj->score.kill=obj->score.death=obj->score.suicide=obj->score.goal=obj->score.score=0; obj->spawning=TRUE; obj->input_freeze=FALSE; obj->death_trigger=FALSE; object_stop(obj); if (reposition) { spot=script_find_network_spot(obj); if (spot!=NULL) object_set_position(obj,spot->pnt.x,spot->pnt.y,spot->pnt.z,spot->ang.y,0); } object_spawn(obj); }
JSValueRef js_obj_position_place_network_spot_func(JSContextRef cx,JSObjectRef func,JSObjectRef j_obj,size_t argc,const JSValueRef argv[],JSValueRef *exception) { obj_type *obj; spot_type *spot; if (!script_check_param_count(cx,func,argc,0,exception)) return(script_null_to_value(cx)); obj=object_get_attach(j_obj); // get spot spot=script_find_network_spot(cx,obj,exception); if (spot==NULL) return(script_null_to_value(cx)); // move player object_set_position(obj,spot->pnt.x,spot->pnt.y,spot->pnt.z,spot->ang.y,0); object_telefrag_players(obj,FALSE); return(script_bool_to_value(cx,TRUE)); }
int object_start(spot_type *spot,char *name,int type,int bind,char *err_str) { int idx; obj_type *obj; weapon_type *weap; // create object idx=object_create(name,type,bind); if (idx==-1) { strcpy(err_str,"Out of memory"); return(-1); } obj=server.obj_list.objs[idx]; // player default setup if (obj->type==object_type_player) { obj->team_idx=net_team_none; obj->spawn_spot.name[0]=0x0; obj->hidden=FALSE; obj->tint_color_idx=setup.network.tint_color_idx; obj->character_idx=setup.network.character_idx; server.player_obj_idx=obj->idx; } // regular object setup else { // if there's an editor display model, then // default model to it if (spot->display_model[0]!=0x0) { obj->draw.on=TRUE; strcpy(obj->draw.name,spot->display_model); } // attach object to spot object_set_position(obj,spot->pnt.x,spot->pnt.y,spot->pnt.z,spot->ang.y,0); obj->turn.ang_to.y=spot->ang.y; } // parameters obj->spawn_spot.script[0]=0x0; obj->spawn_spot.params[0]=0x0; if (spot!=NULL) { strcpy(obj->spawn_spot.script,spot->script); strcpy(obj->spawn_spot.params,spot->params); } // if networked player or multiplayer bot, run rules // to pick the team if (net_setup.mode!=net_mode_none) { if ((obj->type==object_type_player) || (obj->type==object_type_bot_multiplayer)) object_multiplayer_setup(obj); } // start script if (!object_start_script(obj,FALSE,err_str)) { server.obj_list.objs[idx]=NULL; free(obj); return(-1); } // load object model if (!model_draw_load(&obj->draw,"Object",obj->name,FALSE,err_str)) { server.obj_list.objs[idx]=NULL; free(obj); return(-1); } // setup held weapon if (obj->held_weapon.current_idx!=-1) { weap=weapon_find_current(obj); weapon_set(obj,weap); } return(obj->idx); }