Solved Minor Help

Question that is answered or resolved.
For some reason my player can't connect any attack after the first attack connects. The animations play but there is no move contact or damage. I have the attack boxes set as well as damage and pause times and I added atchain 1 2 4 3 in the header so I can't think of what could be causing this also the first attack seems to rarely to connect as well so any info on the issue would be appreciated.
 
Code:
fmap {int}

~{int} determines which remap to use by the entity if it gets frozen by an freeze attack (See 'freeze' for more info about freeze attack).
~You have to declare that remap with 'remap' before using this obviously.
~If hero has 'fmap' set, the respective remap can't be selected at select screen and continue option.
~If enemy has 'fmap' set, the respective remap can be used in levels. You might want to avoid using the remap unless you want to see Icemen on your levels.
 
Quoting the manual doesn't change a thing - you're getting caught up in the nomenclature. fmap works with palette and alternatepal just fine. Better actually.

Remap is woefully out dated - make your life easier and don't use it.

DC
 
Actually, I should have said before... who use freeze maps of any kind? That technique is also outdated, because OpenBOR allows tinting.

Why is tinting better? A couple of reasons...

  • You don't have to bother making freeze maps at all. BIG timer saver. Once set up it just works on every entity now and forever.
  • No keeping track of palettes, numbers, fmaps, or anything else. See also: It just works.
  • It looks cooler. Because your using a tint effect and not reverting to a generic effect palette, the entity retains its unique look and colors under the frozen hue.

How to do it? Normally you'd use takedamage script and some checks here and there, but there's also simple a "brute force" yet just as effective method that's plug and play:

[list type=decimal]
[*]Create an update.c file in your scripts folder.
[*]Paste the code below into it.
[/list]

That's it. From now on any time your entities are frozen they'll get a frozen tint slapped on them until unfrozen. Simple as that. You don't need fmap anymore, and in fact it will get in the way - so just remove it.

If you want you can play around with the lines changedrawmethod(ent, "tintmode", 6); and changedrawmethod(ent, "tintcolor", rgbcolor(0x00,0x00,0xff)); to adjust the tinting effect to suit your liking. The first is what transparency mode is used (same as alpha in the manual) and the second is Hex colors.

Then go wild adding burn tints, poison tints, you name it. :)

Have fun!

Code:
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 identifier.
    for(i=0; i<ent_count; i++)
    {
        // Get entity pointer.
		ent = getentity(i);

		// Run tint freeze on entity.
        tint_freeze(ent);
    }
}

void tint_freeze(void ent)
{
    // tint_freeze
    // Caskey, Damon V.
    // 2015-05-04
    //
    // Apply freeze color to all frozen entities.

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

    // If entity is frozen, apply a freeze tint. Otherwise reset to normal.
    if(getentityproperty(ent, "aiflag", "frozen") == 1)
    {
        changedrawmethod(ent, "tintmode", 6);
        changedrawmethod(ent, "tintcolor", rgbcolor(0x00,0x00,0xff));
    }
    else
    {
       changedrawmethod(ent, "reset", 1);
    }
}
 
I added the code to the update.c but in game nothing happens when the enemy is frozen, is there something I need to add to the characters file or something? I replaced remap with palette and alternate pal also
 
Nope (no other adds needed). It's all self contained. Something should have happened good or bad. Where is the update.c file located? Did you already have some code there?

DC
 
Thegr8test said:
its in the scripts folder with the other scripts, the only other code in the file is the zoom script. Should I import it through another script?

Post it here and let's have a look.

DC
 
When I imported it through the grabscript.c it still didn't work it also caused a bug with enemies projectiles where they're not spawned so I just removed it

Code:
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();        
   }
}

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 identifier.
    for(i=0; i<ent_count; i++)
    {
        // Get entity pointer.
		ent = getentity(i);

		// Run tint freeze on entity.
        tint_freeze(ent);
    }
}

void tint_freeze(void ent)
{
    // tint_freeze
    // Caskey, Damon V.
    // 2015-05-04
    //
    // Apply freeze color to all frozen entities.

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

    // If entity is frozen, apply a freeze tint. Otherwise reset to normal.
    if(getentityproperty(ent, "aiflag", "frozen") == 1)
    {
        changedrawmethod(ent, "tintmode", 6);
        changedrawmethod(ent, "tintcolor", rgbcolor(0x00,0x00,0xff));
    }
    else
    {
       changedrawmethod(ent, "reset", 1);
    }
}
 
Here you go. When I first wrote you the update script for tinting I assumed you didn't already have one, but obviously you do for zooming. It's a simple matter of incorporating both.

Replace your update.c with the following code, and make sure to get rid of all fmap commands.

How do you handle burn effects in your module? Tinting works great for those too.

Code:
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.
        tint_effect(ent);
    }

    // Execute zoom function.
    if(getglobalvar("zoomentity"))
    {
      zoom();
    }
}

void tint_effect(void ent)
{
    // tint_effect
    // Caskey, Damon V.
    // 2015-05-04
    //
    // Apply color tint for hit effects.

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

    // If entity is frozen, apply a freeze tint.
    if(getentityproperty(ent, "aiflag", "frozen") == 1)
    {
        changedrawmethod(ent, "tintmode", 6);
        changedrawmethod(ent, "tintcolor", rgbcolor(0, 0, 255));

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

    ///////
        // if you want to add other tint effects, like burning, put them here.
    ///////

    // If we got this far without exiting, there was no effect to apply.
    // Clear any previous tints.
    changedrawmethod(ent, "reset", 1);
}

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();
}
 
Nothing wrong with Burn animation - that is in fact how we could check to tint them. The only issue is if you are using generic burn sprites for everyone, like the old Capcom games. Tinting would still work (it works no matter what), but would just look kind of silly.

Also, I left something out of the code above but just re-posted. So make sure to copy latest version.

DC
 
Thegr8test said:
Just got a chance to add the new code and it works and looks great like you said thanks for adjusting it for me ;)

Glad you like it! OpenBOR's drawmethod capabilities are very powerful. Used right they can really enhance the look of a module and save you tons of time in the process.

DC
 
Here's a more advanced version. Instead of being tinted or not tinted, this one will gradually fade the entity from frozen tint back to normal as the freeze effect gets closer to expiring. You can actually watch as they "thaw out".

Code:
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.
        tint_effect(ent);
    }

    // Execute zoom function.
    if(getglobalvar("zoomentity"))
    {
      zoom();
    }
}

void tint_effect(void ent)
{
    // tint_effect
    // Caskey, Damon V.
    // 2015-05-04
    //
    // Apply color tint for hit effects.

    float time_percentage   = 0.0;
    int time_effect         = 0;
    float time_remaining    = 0.0;
    float time_current      = 0.0;
    float time_initial      = 0.0;

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

    time_current    += openborvariant("elapsed_time");
    time_initial    += getentityvar(ent, "effect_time_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_time_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 orginal
        // freeze time is left.
        time_percentage = (time_remaining) / (time_initial);

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

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

    ///////
        // if you want to add other tint effects, like burning, put them here.
    ///////

    // If we got this far without exiting, there was no effect to apply.
    // Clear any previous tints and entity vars..
    changedrawmethod(ent, "reset", 1);
    setentityvar(ent, "effect_time_initial", NULL());
}

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();
}
 
BeasTie said:
Cool script.

Is it hard to edit if we wanted to make one for burn and poison etc. too?

Not at all. If you look closely, I even left comments in the code that show you where to put it. It would probably look something like this:

Code:
// Get animation.
        int animation_id = getentityproperty(ent, "animationid");
        
        // Burn tinting.
        if(animation_id == openborconstant("ANI_BURN") || animation_id == openborconstant("ANI_BPAIN"))
        {            
            // Set transparency mode for tint, and color
            // on % of initial freeze time is left.
            changedrawmethod(ent, "tintmode", 6);
            changedrawmethod(ent, "tintcolor", rgbcolor(255, 102, 0); 
            
            return;
        }
        
        // Shock tinting
        // Burn tinting.
        if(animation_id == openborconstant("ANI_SHOCK") || animation_id == openborconstant("ANI_SPAIN"))
        {            
            // Set transparency mode for tint, and apply color
            // on % of initial freeze time is left.
            changedrawmethod(ent, "tintmode", 6);
            changedrawmethod(ent, "tintcolor", rgbcolor(255, 255, 0); 
            
            return;
        }
...and so on...

There are more elegant methods, but I wrote it like this so you guys could just plug and play.

DC
 
Back
Top Bottom