Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Damage help


Recommended Posts

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 all

ss3.png

i 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),etc

Instead what happens is almost half the enemy's hp is gone with one combo.

Any help!? :D

Extra: Shadow's max atk should be 26.

Im using GM7Pro

Im using Full Engine by Damizen and Gamer Dee

Sonic fgx I think...

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

dosn't work quite right i get an error

___________________________________________
ERROR in
action number 1
of Collision Event with object Shadow
for 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

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

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

Image2.png

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

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 to
    if( 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

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 numbers

and i used

[CODE]if( other.combo > 0 && other.atk > 0 && other.image_index == other._frame ) {[/CODE]

This makes even more dmg come

Edit 2: i put this in his kick 1 animation

in 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...