JSValueRef js_weap_crosshair_color_get_blue(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { weapon_type *weap; weap=weapon_get_attach(j_obj); return(script_float_to_value(cx,weap->crosshair.col.b)); }
JSValueRef js_obj_hit_angle_get_z(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { obj_type *obj; obj=object_get_attach(j_obj); return(script_float_to_value(cx,obj->hit.ang.z)); }
JSValueRef js_model_get_resize(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { model_draw *draw; draw=script_find_model_draw(j_obj); return(script_float_to_value(cx,draw->resize)); }
JSValueRef js_obj_motion_vector_get_z(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { obj_type *obj; obj=object_get_attach(j_obj); return(script_float_to_value(cx,obj->motion.vct.z)); }
JSBool js_model_bone_get_brightness_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval) { char pose_name[name_str_len],bone_name[name_str_len]; float bright; model_draw *draw; // get proper draw setup draw=script_bone_function_setup(); if (draw==NULL) return(JS_FALSE); // get bone light script_value_to_string(argv[0],pose_name,name_str_len); script_value_to_string(argv[1],bone_name,name_str_len); if (!model_get_bone_brightness(draw,pose_name,bone_name,&bright)) { JS_ReportError(js.cx,"Named pose or bone does not exist: %s,%s",pose_name,bone_name); return(JS_FALSE); } *rval=script_float_to_value(bright); return(JS_TRUE); }
JSValueRef js_obj_sight_get_lookFieldAngle(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { obj_type *obj; obj=object_get_attach(j_obj); return(script_float_to_value(cx,obj->sight.look_angle)); }
JSValueRef js_obj_forward_speed_get_walk(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { obj_type *obj; obj=object_get_attach(j_obj); return(script_float_to_value(cx,obj->forward_move.max_walk_speed)); }
JSValueRef js_obj_thrust_get_maxSpeed(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { obj_type *obj; obj=object_get_attach(j_obj); return(script_float_to_value(cx,obj->thrust.max_speed)); }
JSValueRef js_weap_hand_angle_get_z(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { weapon_type *weap; weap=weapon_get_attach(j_obj); return(script_float_to_value(cx,weap->hand.ang.z)); }
JSBool js_weap_crosshair_pickup_color_get_blue(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { weapon_type *weap; weap=weapon_find_uid(js.attach.thing_uid); *vp=script_float_to_value(weap->crosshair.pickup_col.b); return(JS_TRUE); }
JSBool js_obj_health_get_fallDamageFactor(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { obj_type *obj; obj=object_find_uid(js.attach.thing_uid); *vp=script_float_to_value(obj->fall.damage_factor); return(JS_TRUE); }
JSBool js_weap_hand_get_bobAngle(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { weapon_type *weap; weap=weapon_find_uid(js.attach.thing_uid); *vp=script_float_to_value(weap->hand.bounce_ang); return(JS_TRUE); }
JSBool js_obj_vert_speed_get_deceleration(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { obj_type *obj; obj=object_find_uid(js.attach.thing_uid); *vp=script_float_to_value(obj->vert_move.decelerate); return(JS_TRUE); }
JSBool js_weap_zoom_get_lookFactor(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { weapon_type *weap; weap=weapon_find_uid(js.attach.thing_uid); *vp=script_float_to_value(weap->zoom.look_factor); return(JS_TRUE); }
JSValueRef js_proj_action_get_auto_bounceReduce(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { proj_setup_type *proj_setup; proj_setup=proj_setup_get_attach(j_obj); if (proj_setup==NULL) return(script_null_to_value(cx)); return(script_float_to_value(cx,proj_setup->action.bounce_reduce)); }
JSBool js_obj_hit_angle_get_z(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { obj_type *obj; obj=object_find_uid(js.attach.thing_uid); *vp=script_float_to_value(obj->hit.ang.z); return(JS_TRUE); }
JSBool js_weap_zoom_get_fovMaximum(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { weapon_type *weap; weap=weapon_find_uid(js.attach.thing_uid); *vp=script_float_to_value(weap->zoom.fov_max); return(JS_TRUE); }
JSBool js_obj_turn_speed_get_facingWalk(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { obj_type *obj; obj=object_find_uid(js.attach.thing_uid); *vp=script_float_to_value(obj->turn.walk_speed); return(JS_TRUE); }
JSBool js_obj_turn_speed_get_topDownAngleOffset(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { obj_type *obj; obj=object_find_uid(js.attach.thing_uid); *vp=script_float_to_value(obj->turn.top_down_ang_offset); return(JS_TRUE); }
JSValueRef js_model_light_color_get_blue(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { model_draw *draw; model_draw_light *light; draw=script_find_model_draw(j_obj); light=&draw->lights[draw->script_light_idx]; return(script_float_to_value(cx,light->col.b)); }
JSBool js_proj_motion_angle_get_z(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { proj_type *proj; proj=proj_get_attach(); if (proj==NULL) return(JS_TRUE); *vp=script_float_to_value(proj->motion.ang.z); return(JS_TRUE); }
JSBool js_model_light_get_exponent(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { model_draw *draw; model_draw_light *light; draw=js_find_model_draw(j_obj,TRUE); light=&draw->lights[draw->script_light_idx]; *vp=script_float_to_value(light->exponent); return(JS_TRUE); }
JSBool js_model_halo_get_maxAlpha(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { model_draw *draw; model_draw_halo *halo; draw=js_find_model_draw(j_obj,TRUE); halo=&draw->halos[draw->script_halo_idx]; *vp=script_float_to_value(halo->max_alpha); return(JS_TRUE); }
JSBool js_multiplayer_bot_get_from_min_max_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval) { float skill,min,max; min=script_value_to_float(argv[0]); max=script_value_to_float(argv[1]); skill=(float)setup.network.bot.skill; *rval=script_float_to_value(min+(((max-min)*skill)/4.0f)); return(JS_TRUE); }
void script_defines_create_constants_set(script_type *script,script_define_type *defines,bool user_defined) { int i; float f; bool is_float; script_define_type *define; // run through the defines define=defines; while (TRUE) { if (define->value_int==-1) break; // determine how to set property // built in defines are always numbers, but // users can be strings or numbers if (!user_defined) { script_set_single_property(script->cx,script->global_obj,define->name,script_int_to_value(script->cx,define->value_int),(kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete)); } else { if (script_defines_is_number(define->value_str,&is_float)) { if (!is_float) { i=atoi(define->value_str); script_set_single_property(script->cx,script->global_obj,define->name,script_int_to_value(script->cx,i),(kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete)); } else { f=(float)atof(define->value_str); script_set_single_property(script->cx,script->global_obj,define->name,script_float_to_value(script->cx,f),(kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete)); } } else { script_set_single_property(script->cx,script->global_obj,define->name,script_string_to_value(script->cx,define->value_str),(kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete)); } } define++; } }
JSBool js_event_get_message_data_func(JSContext *cx,JSObject *j_obj,uintN argc,jsval *argv,jsval *rval) { int idx; // get index idx=JSVAL_TO_INT(argv[0]); if ((idx<0) || (idx>=max_msg_data)) { JS_ReportError(js.cx,"Message data index out of bounds"); return(JS_FALSE); } // get data *rval=JSVAL_NULL; switch (js.attach.get_msg_data[idx].type) { case d3_jsval_type_int: *rval=INT_TO_JSVAL(js.attach.get_msg_data[idx].data.d3_int); break; case d3_jsval_type_float: *rval=script_float_to_value(js.attach.get_msg_data[idx].data.d3_float); break; case d3_jsval_type_boolean: *rval=BOOLEAN_TO_JSVAL(js.attach.get_msg_data[idx].data.d3_boolean); break; case d3_jsval_type_string: *rval=script_string_to_value(js.attach.get_msg_data[idx].data.d3_string); break; } return(JS_TRUE); }
JSBool js_camera_angle_get_z(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { *vp=script_float_to_value(camera.ang.z); return(JS_TRUE); }
JSValueRef js_camera_angle_get_z(JSContextRef cx,JSObjectRef j_obj,JSStringRef name,JSValueRef *exception) { return(script_float_to_value(cx,map.camera.ang_offset.z)); }
JSBool js_camera_chase_slop_get_z(JSContext *cx,JSObject *j_obj,jsval id,jsval *vp) { *vp=script_float_to_value(camera.chase_slop.z); return(JS_TRUE); }