Jump to content


Photo

3D FPS Boss


  • Please log in to reply
6 replies to this topic

#1 Elrovan

Elrovan

    GMC Member

  • New Member
  • 4 posts
  • Version:GM8

Posted 23 May 2012 - 05:38 PM

I've been working with GML for a short time, through Game Maker's Companion, and through a set of tutorials on designing a first-person shooter. I've completed the game, but I want to add more to it to make it more interesting. I'm currently trying to get a boss set up, but I can't figure out how to code it. I'd like the boss to be hit 5 times with the weapon before he is destroyed, and changes to the dead boss object. Does anyone have any suggestions on how to code for counting the hits, and then destroying it properly?
  • 0

#2 Elrovan

Elrovan

    GMC Member

  • New Member
  • 4 posts
  • Version:GM8

Posted 23 May 2012 - 05:39 PM

And a note, I wasn't sure whether to post this in the 3D forum, or this one, as it deals with coding that I am not familiar with, so I apologize if it's in the wrong forum.
  • 0

#3 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 06:25 PM

And a note, I wasn't sure whether to post this in the 3D forum, or this one, as it deals with coding that I am not familiar with, so I apologize if it's in the wrong forum.

My solution almost seems too easy to work. In the create event for your boss, set a var called num_hits and set it to 5. Then in the step event, put a check var if num_hits = 0
change instance to dead boss. In the colision event for whatever hits the boss, put boss_obj.num_hits = -1 and check the relative box.

Let me know if this works please.
  • 0

#4 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 06:33 PM


And a note, I wasn't sure whether to post this in the 3D forum, or this one, as it deals with coding that I am not familiar with, so I apologize if it's in the wrong forum.

My solution almost seems too easy to work. In the create event for your boss, set a var called num_hits and set it to 5. Then in the step event, put a check var if num_hits = 0
change instance to dead boss. In the colision event for whatever hits the boss, put boss_obj.num_hits = -1 and check the relative box.

Let me know if this works please.


Just a heads up, if you put 3d in your topic title and put it in the intermediate/Advanced section some people get intimidated by "3d" and may not even read your post reguardless of weather or not they can help. Usually if a person hasn't done 3d before they won't bother to read it unless they are trying to learn something. You probably already knew that, but I'm just saying.
  • 0

#5 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 23 May 2012 - 06:40 PM

I mean novice/Intermediate not Intermediate/advanced.
  • 0

#6 Elrovan

Elrovan

    GMC Member

  • New Member
  • 4 posts
  • Version:GM8

Posted 24 May 2012 - 06:09 PM

Here's the code for my gun object, which checks what I hit and reacts accordingly. I'm not sure how I would input the events involving the boss. On first tests, your solution didn't work, but that could be an error on my part in entering it in.

{
  // check whether you can shoot
  if (not can_shoot) exit;
  can_shoot = false;
  // show the animation and play the sound
  image_speed = 0.4;
  image_index = 0;
  sound_play(snd_shot);
  // determine what you hit
  var xx, yy, ii;
  xx = global.camx;
  yy = global.camy;
  repeat (50)
  {
    xx += 4*global.camcos;
    yy -= 4*global.camsin;
    ii = instance_position(xx,yy,obj_wall_basic);
    if (ii == noone) 
    {
        ii = instance_position(xx,yy,obj_monster_basic);
        if (ii == noone) continue;
        with (ii) instance_destroy();
      break;
    }
    if object_is_ancestor(ii.object_index,obj_plant_basic) continue;
    if (ii.object_index == obj_barrel) || (ii.object_index == obj_door) 
       with (ii) instance_destroy();
    break;
    }
}

  • 0

#7 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 342 posts
  • Version:GM8.1

Posted 24 May 2012 - 06:18 PM

Here's the code for my gun object, which checks what I hit and reacts accordingly. I'm not sure how I would input the events involving the boss. On first tests, your solution didn't work, but that could be an error on my part in entering it in.

{
  // check whether you can shoot
  if (not can_shoot) exit;
  can_shoot = false;
  // show the animation and play the sound
  image_speed = 0.4;
  image_index = 0;
  sound_play(snd_shot);
  // determine what you hit
  var xx, yy, ii;
  xx = global.camx;
  yy = global.camy;
  repeat (50)
  {
    xx += 4*global.camcos;
    yy -= 4*global.camsin;
    ii = instance_position(xx,yy,obj_wall_basic);
    if (ii == noone) 
    {
        ii = instance_position(xx,yy,obj_monster_basic);
        if (ii == noone) continue;
        with (ii) instance_destroy();
      break;
    }
    if object_is_ancestor(ii.object_index,obj_plant_basic) continue;
    if (ii.object_index == obj_barrel) || (ii.object_index == obj_door) 
       with (ii) instance_destroy();
    break;
    }
}


Another way to do it would be to give the boss his own healthbar, doesn't matter if you already have one. You don't even have to show it if you don't want to. Set 2 vars in the create event for your boss. global.boss_health and global.boss_max_health. Use those vars as the values for the min and max health when giving your boss the health bar, note that the healhbars work on percent and cant go above 100. put global.boss_max_health var to 100, put global.boss_health at 100, whenever the boss is hit set global.boss_health to -20 (relative) then in the step event put check var if global.boss_health = 0 destroy_instance(boss_obj).
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users