* *
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 28, 2017, 12:51:09 PM

Login with username, password and session length

Binding Flames/etc into Target With Script

  • 4 Replies
  • 266 Views
*

Offline Miru

  • Sr. Member
  • ****
  • 354
Binding Flames/etc into Target With Script
« on: July 10, 2017, 02:22:51 PM »
I have installed Damon Caskey's element attack tint script, but I also want to add  generated flames onto burned targets with this tint script as well. The flames should be able to fit on the target, and depend based on size of target and damage. Also, how do you make the burn effect cycle colors ala KOF?

Similarity, with Freeze, I'd like to add clusters of ice on targets that dissapear once they thaw, and electric sparks for SHOCK.

Another problem that emerged is that the tint script is now conflicting with the zoom script.
« Last Edit: July 24, 2017, 11:52:39 PM by Miru »
Here to sprite.

*

Offline nsw25

  • Hero Member
  • *****
  • 1715
    • Thatcher Productions
Re: Tint Script Help!
« Reply #1 on: July 10, 2017, 11:33:29 PM »
There is some issues with the tinting demo DC provided. I brought this up almost 2 years ago and didn't get any help... you will though so good luck, its certainly a cool feature to implement. I'm glad someone else has asked about it so I can linger around and see if this tint script gets updated ;)

FYI issues raised before in case you ran into it also.

http://www.chronocrash.com/forum/index.php?topic=2236.msg35733#msg35733
Bad ass babes
http://store.steampowered.com/app/529000/

see more of my games and projects at
www.thatcherproductions.org

*

Offline Miru

  • Sr. Member
  • ****
  • 354
Re: Tint Script Help!
« Reply #2 on: July 11, 2017, 10:29:42 AM »
Here is the code I use for the tints:


This code is for UPDATED
Quote
// Import functions.
#import "data/scripts/common/effect_tint.c"

void main(){

    void    ent         = NULL();   // Target entity pointer.
    int     ent_count   = 0;        // Entity count.
    int     i           = 0;        // Loop counter.

    // Get entity count.
    ent_count = openborvariant("ent_max");

    // Loop over each entity index.
    for(i=0; i<ent_count; i++)
    {
        // Get entity pointer.
      ent = getentity(i);

      // Execute tint effect on entity.
        effect_tint(ent);
    }

    // If you have any screen controlling functions, such
    // as full screen zooming, place them here.


}

void zoom()
{
   void vscreen = openborvariant("vscreen");
   int maxz=openborvariant("PLAYER_MAX_Z")+1000;
   int zoom_value=getglobalvar("zoomvalue");
   int zoom_x=getglobalvar("zoomx");
   int zoom_y=getglobalvar("zoomy");
   void ent=getglobalvar("zoomentity");
   int px=getentityproperty(ent,"x") +  zoom_x - openborvariant("xpos");
   int py=getentityproperty(ent,"z") + zoom_y - openborvariant("ypos") - getentityproperty(ent,"a");
   void zoom_scr = getglobalvar("zoomscreen");
   if(!zoom_scr){
      zoom_scr = allocscreen(openborvariant("hResolution"),openborvariant("vResolution"));
      setglobalvar("zoomscreen",zoom_scr);
   }
   clearscreen(zoom_scr);

   //draw what we need
   drawspriteq(zoom_scr,0,openborconstant("MIN_INT"),maxz,0,0);
   //setup drawMethod
   changedrawmethod(NULL(),"reset",1);
   changedrawmethod(NULL(),"enabled",1);
   changedrawmethod(NULL(),"scalex",zoom_value);
   changedrawmethod(NULL(),"scaley",zoom_value);
   changedrawmethod(NULL(),"centerx",px);
   changedrawmethod(NULL(),"centery",py);
   //Draw the resized customized screen to main screen.
   drawscreen(zoom_scr,px,py, maxz+1);
   changedrawmethod(NULL(),"enabled", 0);
   drawspriteq(vscreen, 0, maxz+1,maxz+1, 0, 0);
   drawspriteq(vscreen, 0, maxz+2,openborconstant("MAX_INT"), 0, 0);
   clearspriteq();
}


void main(){
   if(getglobalvar("zoomentity"))
   {
      zoom();       
   }
}

I think it invalidates the zoom because the zoom acceptance code and the tint code are both named "main". When I renamed the tint code "tint" it ceased to work.


This is the code to the tint script itself:

Quote
#ifndef EFFECT_TINT_CON

    // These are core functionality constants. Unless
    // you know what you're doing, leave them alone.
    #define     EFFECT_TINT_CON 1
    #define     EFFECT_TINT_VAR_KEY "effect_tint"

    // The various settings go here so we can keep them
    // all in one place. Feel free to play around with them.
    #define     EFFECT_TINT_BURN           rgbcolor(255, 102, 0)    // Burn color.
    #define     EFFECT_TINT_BURN_MODE      1                        // Burn tint alpha mode

    #define     EFFECT_TINT_FREEZE         255                      // Freze color (maximum blue intensity).
    #define     EFFECT_TINT_FREEZE_MODE    1                        // Freeze tint alpha mode.

    #define   EFFECT_TINT_SHOCK   rgbcolor(255, 255, 153)
    #define   EFFECT_TINT_SHOCK_MODE   4

    #define   EFFECT_TINT_STEAL   rgbcolor (0, 202, 101)
    #define   EFFECT_TINT_STEAL_MODE   3

#endif

void effect_tint(void ent)
{
    // effect_tint
    // License - http://www.caskeys.com/dc/?p=5067
    // Caskey, Damon V.
    // 2015-05-04
    //
    // Apply color tint for hit effects.

    float time_percentage   = 0.0;  // Calculated time percentage.
    int time_effect         = 0;    // The normal set time for an effect to expire.
    float time_remaining    = 0.0;  // Actuall time in seconds before an effect will expire.
    float time_current      = 0.0;  // The current engine time.
    float time_initial      = 0.0;  // Time an effect was applied.
    int   map_default       = 0;    // Remap entity was spawned into play with.
    int   animation         = 0;    // Animation ID currently in use.

    int rgb_r = 0,  // RGB color settings.
        rgb_g = 0,
        rgb_b = 0;

    // Verify entity or exit.
    if(typeof(ent) != openborconstant("VT_PTR")) return;
    if(!getentityproperty(ent, "exists")) return;

    // First lets turn drawmethod on. If we don't, nothing below will
    // work at all.
    changedrawmethod(ent, "enabled", 1);

    // For time controlled effects, we need to know
    // current time and the time an effect was first
    // applied.
    time_current    += openborvariant("elapsed_time");
    time_initial    += getentityvar(ent, EFFECT_TINT_VAR_KEY + "_initial");

    // If entity is frozen, apply a freeze tint.
    if(getentityproperty(ent, "aiflag", "frozen") == 1)
    {
        // First we need to know how long the entity is meant to be frozen.
        time_effect = getentityproperty(ent, "freezetime");

        // Now let's see if we have a time when the freeze took place.
        // If not, this, entity was just frozen, so let's
        // record the time to an entity var.
        if(!time_initial)
        {
            time_initial = time_effect - time_current;
            setentityvar(ent, EFFECT_TINT_VAR_KEY + "_initial", time_initial);
        }

        // How much time is left before freeze effect is set to expire?
        time_remaining  = time_effect - time_current;

        // Now let's find out want to know what % of the original
        // freeze time is left. Then we'll multiply that by
        // maximum intensity of 255 and apply it to blue color setting.
        time_percentage = (time_remaining) / (time_initial);
        rgb_b = EFFECT_TINT_FREEZE * time_percentage;

        // Make green sam intensity as blue - this makes a much
        // stronger looking freeze effect than blue alone.
        rgb_g = rgb_b;

        // Unless fmap is set to -1, OpenBOR ALWAYS applies an fmap on frozen entities.
        // Since the default fmap is 0, that means entities without an fmap revert
        // back to their default palette. Obviously we don't we don't want that since
        // the whole point is to use dynamic tinting instead of a remap. To fix the
        // problem we'll get the map that entity was spawned into play with (ie. was
        // using before being set to an fmap), and force the engine to use it here.
        map_default = getentityproperty(ent, "mapdefault");
        changedrawmethod(ent, "remap", map_default);

        // Set transparency mode for tint, and apply blue intensity based
        // on % of initial freeze time is left.
        changedrawmethod(ent, "tintmode", EFFECT_TINT_FREEZE_MODE);
        changedrawmethod(ent, "tintcolor", rgbcolor(0, rgb_g, rgb_b));

        // No reason to do anything else, so exit the function.
        return;
    }


    // For most effects checking the animations will work, so
    // let's grab the current animation here.
    animation = getentityproperty(ent, "animationid");

    // In a burning animation? Then we'll apply burn tint.
    if(animation == openborconstant("ANI_BURN") || animation == openborconstant("ANI_BURNPAIN"))
    {
        // Set transparency mode for tint, and apply tint color.
        changedrawmethod(ent, "tintmode", EFFECT_TINT_BURN_MODE);
        changedrawmethod(ent, "tintcolor", EFFECT_TINT_BURN);

        // Nothing else to do, so exit the function.
        return;
    }

    ///////

    // If you want to add other tint effects, like shock, poison,
    // and so on, put them here. Use the burn example as a
    // template.

// In a shock animation? Then we'll apply shock tint.
    if(animation == openborconstant("ANI_SHOCK") || animation == openborconstant("ANI_SHOCKPAIN"))
    {
        // Set transparency mode for tint, and apply tint color.
        changedrawmethod(ent, "tintmode", EFFECT_TINT_SHOCK_MODE);
        changedrawmethod(ent, "tintcolor", EFFECT_TINT_SHOCK);

        // Nothing else to do, so exit the function.
        return;
    }

    ///////

    ///////

    // If we got this far without exiting, there was no effect to apply.
    // Clear any previous tints and entity vars.
    changedrawmethod(ent, "tintmode", 0);
    changedrawmethod(ent, "tintcolor", 0);

    setentityvar(ent, EFFECT_TINT_VAR_KEY + "_initial", NULL());
}

I think either turning the zoom into a separate script or redoing this within the main script would be a good fix.
« Last Edit: July 11, 2017, 05:55:32 PM by Miru »
Here to sprite.

*

Offline Bloodbane

  • Hero Member
  • *****
  • 3055
  • Dark Dragon
Re: Tint Script Help!
« Reply #3 on: July 13, 2017, 01:31:50 AM »
 I thought there's worse problem here. Anyways, try this new main:

Code: [Select]
void main(){

    void    ent         = NULL();   // Target entity pointer.
    int     ent_count   = 0;        // Entity count.
    int     i           = 0;        // Loop counter.

    // Get entity count.
    ent_count = openborvariant("ent_max");

    // Loop over each entity index.
    for(i=0; i<ent_count; i++)
    {
        // Get entity pointer.
      ent = getentity(i);

      // Execute tint effect on entity.
        effect_tint(ent);
    }

    // If you have any screen controlling functions, such
    // as full screen zooming, place them here.

   if(getglobalvar("zoomentity"))
   {
      zoom();       
   }
}

 Delete the other main{} and use this main only

*

Offline Miru

  • Sr. Member
  • ****
  • 354
Re: Tint Script Help!
« Reply #4 on: July 13, 2017, 10:44:41 AM »
I thought there's worse problem here. Anyways, try this new main:

Code: [Select]
void main(){

    void    ent         = NULL();   // Target entity pointer.
    int     ent_count   = 0;        // Entity count.
    int     i           = 0;        // Loop counter.

    // Get entity count.
    ent_count = openborvariant("ent_max");

    // Loop over each entity index.
    for(i=0; i<ent_count; i++)
    {
        // Get entity pointer.
      ent = getentity(i);

      // Execute tint effect on entity.
        effect_tint(ent);
    }

    // If you have any screen controlling functions, such
    // as full screen zooming, place them here.

   if(getglobalvar("zoomentity"))
   {
      zoom();       
   }
}

 Delete the other main{} and use this main only

Used that and it worked wonders. Thank you so much Bloodbane!

(all i need to do now is to figure out how to add bind flames/etc with this)
Here to sprite.

 

Recent

Members
  • Total Members: 6226
  • Latest: esc
Stats
  • Total Posts: 45171
  • Total Topics: 3096
  • Online Today: 39
  • Online Ever: 316
  • (January 04, 2013, 09:43:02 AM)
Users Online
Users: 2
Guests: 33
Total: 35