May 28, 2023, 09:48:24 pm

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Due to a rise in bot activity, new posters need to be approved before posting.

Join the community Discord server!

Pages: [1] 2

Author Topic: [Client-Side] Mark Death Location {request}  (Read 2635 times)

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
[Client-Side] Mark Death Location {request}
« on: January 19, 2018, 04:58:36 pm »

DeathMarker.gml by BassMakesPaste,
+Client sided
+Marker on Death Event
+Simplistic

+/- No fading, just instant destruction on player touch

-Small chance of visual distraction
-No Name

Code: [Select]
//Credits to BassMakesPaste 2018

globalvar death_marker;
death_marker = id;
DeathObject = object_add();
object_set_sprite(DeathObject, DeadS);

/*Starts the event on player death*/
object_event_add(Character, ev_destroy, 0, '
    if (player == global.myself)      /*Remove this line if you want global markers*/
        instance_create(x,y, death_marker.DeathObject);
');

/*Identifies who created the skull (I could totally be wrong, just interpreting)*/
object_event_add(DeathObject, ev_create, 0, '
    owner = global.myself;
    alpha = 1;
');

/*Places Marker at player origin (gun axis)*/
object_event_add(DeathObject, ev_step, ev_step_begin, '
    if (!instance_exists(owner.object))
        if (owner.object != -1)
           alpha = min(1 , distance_to_point(owner.object.x,owner.object.y)/100);
');

/*Remove or comment out this section to not destroy skulls on player contact*/
object_event_add(DeathObject, ev_collision, Character, '
    if (other.player == owner)
        instance_destroy();
');

/*Shadow skull used to help visibility when background is (near) white*/
object_event_add(DeathObject, ev_draw, 0, '
    draw_sprite_ext(sprite_index, image_index, x-1, y-1, 1, 1, 0, c_black, 1);
    draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, 0, c_white, 1);
');

DeathMarkerColour.gml by Saniblues,
+Client sided
+Marker on Death
+Identifies Marker with PlayerName
+Identifies Player with TeamColour
+'Animated' (Floats up and down a set distance)
+Fades when close until destruction on player touch

-Higher chance of visual distraction
-No commenting (the code is beyond my current understand -Spazz)

Code: [Select]
//Created by Saniblues 2018

global.DeathObject = object_add();

object_event_add(global.DeathObject,ev_step,ev_step_begin, '
if instance_exists(global.myself.object){
y = ystart + (5 * sin(current_time / 200));
if distance_to_object(global.myself.object) <= 100{
image_alpha = 0.9 * distance_to_object(global.myself.object) / 100;
if image_alpha <= 0.05 instance_destroy();
}
}
');

object_event_add(global.DeathObject,ev_draw,0, '
var i, o;
draw_set_alpha(image_alpha);
for(i = -1;i<=1;i+=2){
for(o = -1;o<=1;o+=2){
draw_sprite_ext(sprite_index,image_index,x+i,y+o,1,1,0,col,image_alpha);
}
}
draw_sprite_ext(sprite_index,image_index,x,y,1,1,0,c_white,image_alpha);
draw_set_halign(fa_center);
draw_text(x,y - 16,string(name));
draw_set_alpha(1);
');

object_event_add(Character, ev_destroy, 0, '
if (player = global.myself){
/*
with(global.DeathObject){
if name = global.myself.name instance_destroy();
}
*/
with(instance_create(x,y,global.DeathObject)){
name = other.player.name;
if other.team = 0 col = c_red
else col = c_blue;
sprite_index = DeadS;
image_alpha = 1;
if name != global.myself.name instance_destroy();
}
}
');


(click to show/hide)
« Last Edit: March 05, 2018, 02:39:24 pm by Spazz »
Logged

<3 Bustatunez

BassMakesPaste

  • Full Member
  • ***
  • Karma: 22
  • Offline Offline
  • Posts: 590
  • Tweaking his nipples.
Re: [Request] Mark Death Location
« Reply #1 on: February 08, 2018, 02:06:16 pm »

GML is super fucking easy compared to C++ and Java. Imagine if you had a GUI that handled your objects for you and could only have single inheritance. Also no pointers or complex data structures except for the ones that they give you.

I haven't had Gang Garrison on my computer in years, so I can't test this out:
Code: [Select]
globalvar death_marker = id;

object_event_add(Character, ev_destroy, 0)
{
    if (player == global.myself)
        instance_create(x,y, death_marker.DeathObject);
}

object_event_add(death_marker.DeathObject, ev_create, 0)
{
    owner = global.myself;
    alpha = 1;
}

object_event_add(death_marker.DeathObject, ev_step, ev_step_begin)
{
    if (!instance_exists(owner.object))
        if (owner.object != -1)
           alpha = min(1 , distance_to_point(player.object.x,player.object.y))/100);
}

object_event_add(death_marker.DeathObject, ev_collision, Character)
{
    if (other.player == owner)
        instance_destroy();
}

object_event_add(death_marker.DeathObject, ev_draw, 0)
{
    draw_sprite_ext(SkullS,1,x,y,1,1,0,c_white,alpha);
}
« Last Edit: February 08, 2018, 02:07:01 pm by BassMakesPaste »
Logged
Quote
<ThouBot> Thou neighboreth finds nay m'rcy in thou eaye. Thou common-kissing nut-hook.
<BassMakesPaste> nut-hook
<BassMakesPaste> thoubot, what is a nut-hook
<ThouBot> Thou'seth face..
<MrRatermat> OH BURN

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #2 on: February 08, 2018, 06:57:01 pm »

(click to show/hide)
« Last Edit: March 02, 2018, 03:39:32 pm by Spazz »
Logged

<3 Bustatunez

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #3 on: February 08, 2018, 10:23:15 pm »

Merged old posts, spammy. Switching SkullS to DeadS fixes the problem, but as always present others.

No errors on boot or spawn.

[edit]Yet there's a skull on the player before death that follows them around, rip

But dying (Death, Class switch, Team switch) at all then throws up these three with the latter two repeating.
Code: [Select]
___________________________________________
ERROR in
action number 1
of Create Event
for object Character:

Error in code at line 3:
       team = player.team;
                     ^
at position 20: Unknown variable team

___________________________________________
ERROR in
action number 1
of  Step Event
for object Character:

In script charSetSolids:
Error in code at line 6:
       solid = ((team != other.team or other.intel) and !global.mapchanging);
                               ^
at position 30: Unknown variable team

___________________________________________
ERROR in
action number 1
of Begin Step Event
for object Character:

Error in code at line 3:
       if (burnDuration > 0)
          ^
at position 9: Unknown variable burnDuration

Edit: I'm tired, and probably changing this wrong entirely. So I'm just going to head off.
« Last Edit: March 04, 2018, 11:18:48 am by Spazz »
Logged

<3 Bustatunez

[FR]YB

  • 2013 Haxxy Award Winner
  • *
  • Karma: 28
  • Offline Offline
  • Posts: 642
  • There are 11 people playing holy sh
Re: [Request] Mark Death Location
« Reply #4 on: February 09, 2018, 05:55:51 am »

Not tested because I'm hosting, but this hopefully works

EDIT: tested, tweaked a bit, now works
If this gets listed, all credit to BassMakesPaste, obviously

Code: [Select]
globalvar death_marker;
death_marker = id;
DeathObject = object_add();
object_set_sprite(DeathObject, DeadS);

object_event_add(Character, ev_destroy, 0, '
    if (player == global.myself)
        instance_create(x,y, death_marker.DeathObject);
');

object_event_add(DeathObject, ev_create, 0, '
    owner = global.myself;
    alpha = 1;
');

object_event_add(DeathObject, ev_step, ev_step_begin, '
    if (!instance_exists(owner.object))
        if (owner.object != -1)
           alpha = min(1 , distance_to_point(owner.object.x,owner.object.y)/100);
');

object_event_add(DeathObject, ev_collision, Character, '
    if (other.player == owner)
        instance_destroy();
');
« Last Edit: February 09, 2018, 08:18:05 am by [FR]YB »
Logged

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #5 on: February 09, 2018, 01:19:28 pm »

Awesome, the code is a bit different but it works. However I wasn't looking for an instance_destroy() but some sort of fade. Did not realize it be behind the player to begin with so I just removed

Code: [Select]
object_event_add(DeathObject, ev_collision, Character, '
    if (other.player == owner)
        instance_destroy();
');

And it functions perfectly, thanks for the help!
Logged

<3 Bustatunez

PrOF

  • Heroic Member
  • ****
  • Karma: 43
  • Offline Offline
  • Posts: 600
  • Sometimes a dev. Only sometimes
Re: [Request] Mark Death Location
« Reply #6 on: February 09, 2018, 03:31:51 pm »

Added to the Client-side plugin directory under the name "Death Marker" - Author BassMakesPaste
Logged

Derpduck

  • 2011 Haxxy Finalist
  • *
  • Karma: 42
  • Offline Offline
  • Posts: 5770
Re: [Request] Mark Death Location
« Reply #7 on: February 09, 2018, 03:46:29 pm »

Gradually lower alpha then destroy when it goes below 0 to fade it.
And you can change the depth of it if you want too.
« Last Edit: February 09, 2018, 03:47:18 pm by Derpduck [LORD] »
Logged

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #8 on: February 09, 2018, 03:59:00 pm »

The request has no mention of destruction. The fade was in case the sprite was layered above the player and the player could no longer properly see the section. Hence 'fade when near', not 'fade out' and certainly not 'instance_destroy'

Since the code has layered it below the client user, but above any ally/opponent, this works flawlessly.
« Last Edit: February 09, 2018, 03:59:21 pm by Spazz »
Logged

<3 Bustatunez

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #9 on: March 02, 2018, 03:37:38 pm »

What would I change to register another players death location? (Or just everyone on the server, client sided)
Ex. Spectating another and regardless of their death, a marker is also placed?

Yes this will then spam the sprite, but I'm looking to use it in controlled environments.
If anyone is curious, this is to help determine who proceeded farthest in a race type map
Logged

<3 Bustatunez

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #10 on: March 02, 2018, 03:54:46 pm »

Talked to YB, was simply the removal of
Code: [Select]
if (player == global.myself) to allow a client to see global death markers
Logged

<3 Bustatunez

BassMakesPaste

  • Full Member
  • ***
  • Karma: 22
  • Offline Offline
  • Posts: 590
  • Tweaking his nipples.
Re: [Request] Mark Death Location
« Reply #11 on: March 03, 2018, 06:34:06 pm »

One could presumably add a statement to the draw event of the death object in order to draw the name of the individual:

Code: [Select]
if (instance_exists(owner))
{
    draw_set_halign(fa_left);
    draw_set_valign(fa_bottom);

    if (owner.team == TEAM_RED)
    {
    draw_set_color(c_red);
    } else if (owner.team == TEAM_BLUE {
    draw_set_color(c_blue);
    } else {
    draw_set_color(c_grey);
    }

    draw_text(x, y, owner.name)
}

This may need to be modified to fit GM8, however.
Logged
Quote
<ThouBot> Thou neighboreth finds nay m'rcy in thou eaye. Thou common-kissing nut-hook.
<BassMakesPaste> nut-hook
<BassMakesPaste> thoubot, what is a nut-hook
<ThouBot> Thou'seth face..
<MrRatermat> OH BURN

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #12 on: March 03, 2018, 06:57:30 pm »

Oh neat, I'll see what it can do.

However if a player died on a white background, the white DeadS would just blend in.
So YB pitched this,
Code: [Select]
object_event_add(DeathObject, ev_draw, 0, '
    draw_sprite_ext(sprite_index, image_index, x, y, 1.2, 1.2, 0, c_black, 1);
    draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, 0, c_white, 1);
');

Yet Scaling is garbage, so I used a disgusting method to visually get what I wanted,
Code: [Select]
object_event_add(DeathObject, ev_draw, 0, '
    draw_sprite_ext(sprite_index, image_index, x+1, y+1, 1, 1, 0, c_black, 1);
    draw_sprite_ext(sprite_index, image_index, x+1, y-1, 1, 1, 0, c_black, 1);
    draw_sprite_ext(sprite_index, image_index, x-1, y-1, 1, 1, 0, c_black, 1);
    draw_sprite_ext(sprite_index, image_index, x-1, y+1, 1, 1, 0, c_black, 1);
    draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, 0, c_white, 1);
');

Besides that, sometimes though it'll scrunch up the skull and I don't know why.
Logged

<3 Bustatunez

Spazz

  • Seasoned Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 1933
  • Almost too much seasoning.
Re: [Request] Mark Death Location
« Reply #13 on: March 03, 2018, 07:43:37 pm »

Just noticed something extremely odd, reward objects that are part of death gibs collide with the skulls.
Something like Heenok's Crown
Logged

<3 Bustatunez

Saniblues

  • Onion Knight
  • Administrator
  • *****
  • Karma: -1305
  • Offline Offline
  • Posts: 12409
Re: [Request] Mark Death Location
« Reply #14 on: March 04, 2018, 01:30:40 am »

I've never once made a plugin before, in spite of the fact that I am a moderator of this subforum. That being said, I wrote this based on my experience not modding this game.

Code: [Select]
global.DeathObject = object_add();

object_event_add(global.DeathObject,ev_step,ev_step_begin, '
if instance_exists(global.myself.object){
y = ystart + (5 * sin(current_time / 200));
if distance_to_object(global.myself.object) <= 100{
image_alpha = 0.9 * distance_to_object(global.myself.object) / 100;
if image_alpha <= 0.05 instance_destroy();
}
}
');
object_event_add(global.DeathObject,ev_draw,0, '
draw_set_alpha(image_alpha);
draw_sprite(sprite_index,image_index,x,y);
draw_set_halign(fa_center);
draw_text(x,y - 16,string(name));
draw_set_alpha(1);
');

object_event_add(Character, ev_destroy, 0, '
if (player = global.myself){
with(global.DeathObject){
if name = global.myself.name instance_destroy();
}
with(instance_create(x,y,global.DeathObject)){
name = other.player.name;
sprite_index = DeadS;
image_alpha = 1;
if name != global.myself.name instance_destroy();
}
}
');
Logged
Quote from: mop
Quote from: MR MAGN3TIC
I don't like it.  :nah:
Oh, well, you might as well pack up and stop now, because he doesn't like it
I'm bored out of my skull, Lets play a different game!
Lets take a visit down below And cast the world in flames!

Pages: [1] 2
 

Page created in 0.042 seconds with 36 queries.