Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello again Yal, happy July :) Here's some things I've been having trouble understanding lately: 

How to use properly reference a AMP (friend and foe) within obj_battlecontrol. I'm working on shield system, (where mons have to break through a shield before being able to attack the enemies HP) 

I'm trying to do a check on a new stat (shieldHP) and if the AMP's shieldHP stat is >1, a visual shield object will appear in front of a mon after it's summoned.

 My problem is  simply trying to understand how you have been using the amp.id variable in obj_battlecontrol do to similar stat checks. I've tried a few things and placing the code in a few spots. I don't think I quite get what variable to place in front of it (with the period separating amp_id. 

Here's the current code I'm trying in bcontrolstate_ACTIONSELECT_STEP 1 (around line 320)

var getshld = monster_get_maxshld_hp(action_monster.amp_id);

if(getshld > 1) {

instance_create_depth(cx,cy,d_player + -100,obj_battlemonster_sheild)} 

the error messages basically keep saying the xyz.amp_id variable is undefined. Any help understanding this is greatly appreciated as always :)

I think you're going about this the wrong way - if you want a visual effect on a per-monster basis it might be easier to have obj_battlemonster handle it? It's already aware of which AMP data block it owns so it's a bit easier than going through the control (who manages a ton of monsters at once) Plus, with your current approach you'll create a new shield effect object every turn - if you don't remove them afterwards you'll end up with dozens or hundreds of them in every battle...

In the draw event, add some new code like this:

if(state == bmonsterstate_NORMAL){ //Monster is guaranteed to be alive and valid in this state
  if(global.active_monster_party[amp_id,amp_SHIELDHP] > 0){
     draw_sprite_ext(spr_shield,0,x+dx,y+dy,image_xscale*drawscale,image_yscale,image_angle,image_blend,image_alpha)
  }
}

There's ways to refine it, like adding effects whenever the shield status changes (broken / regenerated) by keeping track of the status the previous step and doing stuff when it's different from the current step. But the important part for now is making it draw properly.