Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @description Create the player ship and destroy the build objects
- // This script takes no inputs
- // initialize owner, cannot be local var as other objects will access it
- owner = noone;
- // every type of build object need to be accounted for
- // ship is the first thing that needs to be converted
- with (obj_build_ship) {
- // create ship object
- inst = instance_create(x,y,obj_ship);
- // this script is only used for the player ship
- inst.controller = HUMAN;
- // player faction is 1, enemy is 2
- inst.faction = 1;
- // set the ship sprite equal to the build ship sprite
- inst.sprite_index = sprite_index;
- // assign this ship as owner for future converted objects
- other.owner = inst;
- // destroy obj_build_ship
- instance_destroy();
- }
- with (obj_build_block) {
- // spawn object
- inst = instance_create(x,y,obj_block);
- // get owner to pass through to new object
- owner = other.owner;
- with(inst) {
- // initialize scale
- image_xscale = other.image_xscale;
- image_yscale = other.image_yscale;
- // assign object owner to the associated ship
- owner = other.owner;
- // Set offsets, how far components are from the center of the ship
- X_offset = x-owner.x;
- Y_offset = y-owner.y;
- // create physics fixture
- scr_add_fixture(1, owner);
- }
- // destroy obj_build_block
- instance_destroy();
- }
- with (obj_build_turbine) {
- // spawn object
- inst = instance_create(x,y,obj_turbine);
- // set owner to pass through to object
- owner = other.owner;
- with(inst) {
- // set owner to associated ship
- owner = other.owner;
- // Set offsets, how far components are from the center of the ship
- X_offset = x-owner.x;
- Y_offset = y-owner.y;
- // create physics fixture, turbines weigh more than blocks
- scr_add_fixture(3, owner);
- // with obj_ship ------ this code is outdated, turbines no longer act like engines
- with(owner) {
- // assign turbine a reference number
- other.engine_number = engine_count;
- // add turbine to obj_ship's list of engines
- engine_array[engine_count] = other.id;
- // increase obj_ship's engine count (starts at 0)
- engine_count += 1;
- }
- }
- // destroy obj_build_turbine
- instance_destroy();
- }
- with (obj_build_wind_catcher) {
- // get owner to pass through to object
- owner = other.owner;
- // spawn object
- inst = instance_create(x,y,obj_wind_catcher);
- with(inst) {
- // set owner to associated ship
- owner = other.owner;
- // Set offsets, how far components are from the center of the ship
- X_offset = x-owner.x;
- Y_offset = y-owner.y;
- // create physics fixture
- scr_add_fixture(1, owner);
- }
- // destroy (obj_build_wind_catcher)
- instance_destroy();
- }
- with (obj_build_rudder) {
- // get owner to pass through to object
- owner = other.owner;
- // spawn object
- inst = instance_create(x,y,obj_rudder);
- with(inst) {
- // set owner to associated ship
- owner = other.owner;
- // Set offsets, how far components are from the center of the ship
- X_offset = x-owner.x;
- Y_offset = y-owner.y;
- // create physics fixture
- scr_add_fixture(1, owner);
- }
- // destroy obj_build_rudder
- instance_destroy();
- }
- with (obj_build_slot_weapon_med) {
- // get owner to pass through to object
- owner = other.owner;
- // get sprite assigned to build slot, convert into map key, get associated object
- key = string_delete(sprite_get_name(sprite_index), 1, 4);
- // check if an item has been placed
- if (key != "build_slot_weapon_med") { // if no item has been chosen for slot then create nothing
- /// the key serves as general reference, if you want the objects cost then add "_cost" to the key
- // example key_temp = "gun_med_2_object"
- key_temp = key + "_object";
- // use the key to spawn corresponding object in weapon list
- inst = instance_create(x,y, global.weapon_info[? key_temp]);
- // with the weapon
- with(inst) {
- // other refers to the build_slot, assign gun to instance of obj_ship
- owner = other.owner;
- /// all cannons have 'gun' within their key
- // if buildable is a gun then add to ship gun array
- if (string_pos("gun", other.key)) {
- with(owner) {
- // gun_count is total amount of guns generated for the ship
- // gun_number is this guns particular index value in the array of all guns
- // assign gun a reference number
- other.gun_number = gun_count;
- // update gun array
- gun_array[gun_count] = other.id;
- // increase gun count, starts at 0
- gun_count += 1;
- }
- // these three values are currently redundant. They are overwritten in scr_gun_common_values
- home_angle = other.home_angle;
- max_angle = other.max_angle;
- current_angle = home_angle;
- }
- // Set offsets, how far components are from the center of the ship
- X_offset = x-owner.x;
- Y_offset = y-owner.y;
- // create physics fixture
- scr_add_fixture(3, owner);
- }
- }
- // destroy build slot
- instance_destroy();
- }
- instance_destroy();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement