Slow_Motion Posted June 29, 2009 Report Share Posted June 29, 2009 The damage that Shadow does to the enemy isnt showing heres my code, // Draw HUD counters draw_set_font(global.fntHUD); draw_set_color(c_white); draw_text(enemy_basic.x,enemy_basic.y,enemy_basic.atk[/CODE]i tried enemy_basic.hp didn't work.Heres what i want,i need it to pop out of the enemy like goes up a little then disappears. What happens is the dmg dosn't show at alli also need help with Random Damage. Heres my code,with enemy_basic collision with Shadow,[CODE]if other.combo>0 && other.atk>0{if floor(random(1))=1 then{hp=-1}if floor(random(1))=1 then{hp=-2}if floor(random(1))=1 then{hp=-3}if floor(random(1))=1 then{hp=-4}if floor(random(1))=1 then{hp=-5}if floor(random(1))=1 then{hp=-6}if floor(random(1))=1 then{hp=-7}if floor(random(1))=1 then{hp=-8}if floor(random(1))=1 then{hp=-9}if floor(random(1))=1 then{hp=-10}if floor(random(1))=1 then{hp=-11}if floor(random(1))=1 then{hp=-12}if floor(random(1))=1 then{hp=-13}if floor(random(1))=1 then{hp=-14}if floor(random(1))=1 then{hp=-15}if floor(random(1))=1 then{hp=-16}if floor(random(1))=1 then{hp=-17}if floor(random(1))=1 then{hp=-18}if floor(random(1))=1 then{hp=-19}if floor(random(1))=1 then{hp=-20}if floor(random(1))=1 then{hp=-21}if floor(random(1))=1 then{hp=-22}if floor(random(1))=1 then{hp=-23}if floor(random(1))=1 then{hp=-24}if floor(random(1))=1 then{hp=-25}if floor(random(1))=1 then{hp=-26}}[/CODE]i tried (random(2),(random(3),etcInstead what happens is almost half the enemy's hp is gone with one combo.Any help!? Extra: Shadow's max atk should be 26.Im using GM7ProIm using Full Engine by Damizen and Gamer DeeSonic fgx I think... Link to comment Share on other sites More sharing options...
Vexus Posted June 29, 2009 Report Share Posted June 29, 2009 Frankly, the way you went about it is very confusing. Since there will be multiple enemies, the text will only appear above the first enemy... I think... I'm not sure. The random damage code baffles me even more. I recommend a solution of using a simple, separate object that you can manipulate properly. Here is what to do (its been tested): Make a new object and call it objEffect_Damage. Give the object the following codes and events:// ==== CREATE EVENT ==== _progress = 0; _dmg = 0; alarm[0] = 30; vspeed = -1/3; // ==== ALARM[0] EVENT ==== _progress += 1; if( _progress == 1 ){ alarm[0] = 30; vspeed = 0; exit; } if( _progress == 2 )instance_destroy(); // ==== DRAW EVENT ==== draw_set_font(global.fntHUD); draw_set_color(c_white); draw_set_halign(fa_center); draw_set_valign(fa_middle); draw_text( x, y, _dmg); Then, you are going to completely replace the code of enemy_basic's Collision with Shadow event into this:if( other.combo > 0 && other.atk > 0 ) { var _obj, _dmg; _dmg = floor( random( 26.9 ) ); _obj = instance_create( x, y-30,objEffect_Damage); _obj._dmg = _dmg; hp -= _dmg; } The second line of this code: "_dmg -= floor( random( 26.9 ) )", deals the random damage you want. You can always change the value of this when you need to. That should do it for now. 1 Link to comment Share on other sites More sharing options...
Slow_Motion Posted June 29, 2009 Author Report Share Posted June 29, 2009 dosn't work quite right i get an error ___________________________________________ERROR inaction number 1of Collision Event with object Shadowfor object enemy_basic:Error in code at line 3: _dmg -= floor( random( 26.9 ) );at position 6: Unknown variable _dmg[/CODE]do i have to give it _dmg variable? i tried adding it didnt work did i do something wrong? Link to comment Share on other sites More sharing options...
Vexus Posted June 29, 2009 Report Share Posted June 29, 2009 Sorry, made a mistake with that last code. Get rid of the "-" in that code. There is also another error in the last line, where the variable is "dmg" when it should be "_dmg". I seem to mess up every time I don't proof-read my stuff more than once... I'll edit my last post. Link to comment Share on other sites More sharing options...
Slow_Motion Posted June 29, 2009 Author Report Share Posted June 29, 2009 It works! +rep ;D Another Problem, Shadow does multiple damage from 1 kick. It kills the enemy to fast, You can clearly see thats multiple, ALOT of dmg my attack code is With Enemy_basic collision with shadow: if( other.combo > 0 && other.atk > 0 ) { var _obj, _dmg; _dmg = floor( random( 26.9 ) ); _obj = instance_create( x, y-30,objEffect_Damage); _obj._dmg = _dmg; hp -= _dmg;}[/CODE]Do i need to change something? Link to comment Share on other sites More sharing options...
Vexus Posted June 29, 2009 Report Share Posted June 29, 2009 The problem would be with the conditions (the if statement on the first line). What you need to do is something is make it so the attack only happens on ONE frame, instead of ALL of them. To do this, you need to first go to object "Shadow" and add a new variable in the CREATE event. We'll call it "_frame" Now go to the event where Shadow starts his attack (probably a KEY PRESS event). In the code where he starts the attack, change the variable _frame to the sub-image of the sprite you want to actually make the attack work... I think for that kick animation it is frame 2. Go back to the "enemy_basic" object's Shadow COLLISION event, and change the first line toif( other.combo > 0 && other.atk > 0 && other.image_index == other._frame ) { This should make it so only one frame in the animation is able to do damage, which is what you want. Link to comment Share on other sites More sharing options...
Slow_Motion Posted June 29, 2009 Author Report Share Posted June 29, 2009 it works i think, but the damage stops showing =.=. Edit: im useing this if( other.combo > 0 && other.atk > 0 && other.image_index == other._frame=103) {[/CODE]this stops the damage numbersand i used [CODE]if( other.combo > 0 && other.atk > 0 && other.image_index == other._frame ) {[/CODE]This makes even more dmg comeEdit 2: i put this in his kick 1 animationin Draw event for Shadow[CODE] // -> Kick 1 animation if (action==12 && combo=1) { animation=12; animations_framemin=101; animations_framemax=103; animations_return=103; animations_speed=20; atk=1 hsp=xdir if animations_frame=103 {_frame=1 action=0} }[/CODE] Link to comment Share on other sites More sharing options...
Slow_Motion Posted July 1, 2009 Author Report Share Posted July 1, 2009 Sorry for double post but, can anyone help me with this? Link to comment Share on other sites More sharing options...
Recommended Posts