hitflash palette help

Gurtag

Member
hello guys, i am working on a char that have several alternatepals and would like its effects colors/palette match with the char palette in use, i had no trouble with projectile or otter entities as i use a spawnmap script by ilu, but with hitflashes i cant seem to find a way to implement it, is there a method or script to do this with hitflashes?
 
The only way I can think of is if the hit flashes share the same alternate pallets as the character and are shown together in the same frame of animation but that would look cheap and nasty, not sure how you'd spawn hitflash on an individual palette bases, maybe spawn hitflashes as a projectile entity
 
danno said:
maybe spawn hitflashes as a projectile entity

hey there and yea that is what i was doing, wanted to ask around if there was something to do with the hitflashes directly like a command or script, i see now that there isnt so gess i will have to spanwn projectiles with follow/facke hitflashes afterward, thanks for your help mate.
 
This isn't that hard to do guys. You'd run this as part of the flash's onspawnscript. If I am reading this right, you want the flash to have a set of alternate palettes lined up with the entity's (i.e. you want flash to display with its palette#2 if the entity is on palette#2).

This is easiset to do in the flash itself, using its onspawnscript. Let's break it down...

[list type=decimal]
[*]First, the flash needs some way to know what entity to get properties from. No problem. openborvariant("lasthit_target") gives you the last entity to take a hit, which will always be the one that caused a flash to spawn.
[*]Now you need to know the palette index the entity is using. You have the entity, so just grab that using entity property function getentityproperty(<last hit entity>, "map").
[*]Now that you have the map index, set the flash's map entity property to match.
[/list]

That's really all there is to it.  :)

HTH,
DC
 
Gurtag said:
hello guys, i am working on a char that have several alternatepals and would like its effects colors/palette match with the char palette in use, i had no trouble with projectile or otter entities as i use a spawnmap script by ilu, but with hitflashes i cant seem to find a way to implement it, is there a method or script to do this with hitflashes?

Won't it be the case to get the parent map index and apply it, kinda what I do with that spawnmap function?
 
hey ilu and yes i am using that script of yours to spawn most effects but i dont know how to aply it to a hitflash entity, since they spawn by hitflash command instead of script  :-\
 
when using hitflash in this manner inside fireball.txt

anim idle

loop 0
delay 3
offset 26 26
hitflash uniflash
hitfx data/chars/tony/sound/bhit.wav
frame data/chars/tony/u2.png



does the engine recognise fireball as the parent of uniflash? the reason I ask is because I've tried matching uniflash to fireball's palette in both onspawnscript or forcing it via animation scripts but its not working

C-like:
void self = getlocalvar("self");
    void parent = getentityproperty(self, "parent");
    int  parentpal = getentityproperty (parent, "map");
 
    if(parent){
        changeentityproperty(self, "map", parentpal);
    }
}

I've tried several combinations of above parent script but nada, so I'm thinking "parent" is not working because maybe I'm not using a scripted hitflash.

for visual reference I'm trying to match the hitflash palette with the fireball palette

 
when using hitflash in this manner inside fireball.txt

anim idle

loop 0
delay 3
offset 26 26
hitflash uniflash
hitfx data/chars/tony/sound/bhit.wav
frame data/chars/tony/u2.png



does the engine recognise fireball as the parent of uniflash? the reason I ask is because I've tried matching uniflash to fireball's palette in both onspawnscript or forcing it via animation scripts but its not working

C-like:
void self = getlocalvar("self");
    void parent = getentityproperty(self, "parent");
    int  parentpal = getentityproperty (parent, "map");
 
    if(parent){
        changeentityproperty(self, "map", parentpal);
    }
}

I've tried several combinations of above parent script but nada, so I'm thinking "parent" is not working because maybe I'm not using a scripted hitflash.

for visual reference I'm trying to match the hitflash palette with the fireball palette


Flashes don't have parents or owners at all. Parent is only ever set by the engine on summonframe, or spawnframe. Owner is set when spawning with one of the projectile functions. There are a couple of different ways to get what you want, I'll need to be at my desk though to post them out.

DC
 
when using hitflash in this manner inside fireball.txt

anim idle

loop 0
delay 3
offset 26 26
hitflash uniflash
hitfx data/chars/tony/sound/bhit.wav
frame data/chars/tony/u2.png



does the engine recognise fireball as the parent of uniflash? the reason I ask is because I've tried matching uniflash to fireball's palette in both onspawnscript or forcing it via animation scripts but its not working

C-like:
void self = getlocalvar("self");
    void parent = getentityproperty(self, "parent");
    int  parentpal = getentityproperty (parent, "map");
 
    if(parent){
        changeentityproperty(self, "map", parentpal);
    }
}

I've tried several combinations of above parent script but nada, so I'm thinking "parent" is not working because maybe I'm not using a scripted hitflash.

for visual reference I'm trying to match the hitflash palette with the fireball palette

You can try to use a conjunction of ondoattack/onspawn, I'm using a similar way on the SORX to change some graphic effects according to the game settings.

The ways I have in mind are:

Method 1
- put an ondoattack (or even didhit) event in the fireball.txt entity, then make this script to spawn the uniflash.txt based on the target's coordinates, allowing you to change many things, including map.
- optionally you can use takedamage in all entities in order to spawn custom hitflashes based on the attacker, I'm doing it in the SORX for the robots to avoid certain blood flashes based on the game settings.

Method 2
- put an ondoattack event in the fireball.txt entity, then make this script to save the map number into a variable.
- put an onspawn event in the uniflash.txt entity, then make this script to change map number based on the variable previously saved.

Another method I thought of is by using DC's entity enumeration on the uniflash onspawn event and then putting some conditions in order to change map, but I think the previous methods may work better.
 
I was worried I was going to have to script custom hitflashes, now I have to mess around with co ordinates and do math and stuff :ROFLMAO:

@danno, The simplest method I can think of is the one suggested by @Kratus. No need for coordinates or anything, and avoids an enumeration loop.

  1. Set a global variable in the fireball / beam and populate it with the current palette pointer or palette index of the fireball.
  2. In the onspawn event of flash, look for that variable, and if populated, set itself to match accordingly.
  3. In the onkill event of fireball, delete the global.

HTH,
DC
 
Thanks DC, I'm in the middle of writing a didhit script at the moment and just figuring out the co ordinates aspect of the script.

C-like:
void main(){
    void self       = getlocalvar("self");
    void target     = getlocalvar("target");
    float x         = getentityproperty(target, "x");
    float y         = getentityproperty(target, "a");
    float z         = getentityproperty(target, "z");
    void flash      = spawnbind("uniflash", target, x, y, z);
    int  parentmap  = getentityproperty(self, "map");
    int  dir        = getentityproperty(flash, "direction");
    int  tdir       = getentityproperty(target, "direction");
    if (flash)
    {changeentityproperty (flash, "map", parentmap);}
    if (tdir ==1)
    {changeentityproperty (dir, 1);}
    else if (tdir ==0)
    {changeentityproperty (dir, 0);}

    }

everything's working excepting the binding co ordinates to target which I'm working on as we speak.

 
Last edited:
Thanks DC, I'm in the middle of writing a didhit script at the moment and just figuring out the co ordinates aspect of the script.

C-like:
void main(){
    void self       = getlocalvar("self");
    void target     = getlocalvar("target");
    float x         = getentityproperty(target, "x");
    float y         = getentityproperty(target, "a");
    float z         = getentityproperty(target, "z");
    void flash      = spawnbind("uniflash", target, x, y, z);
    int  parentmap  = getentityproperty(self, "map");
    int  dir        = getentityproperty(flash, "direction");
    int  tdir       = getentityproperty(target, "direction");
    if (flash)
    {changeentityproperty (flash, "map", parentmap);}
    if (tdir ==1)
    {changeentityproperty (dir, 1);}
    else if (tdir ==0)
    {changeentityproperty (dir, 0);}

    }

everything's working excepting the binding co ordinates to target which I'm working on as we speak.


I am a moron. Forget what I said earlier. It doesn't take into account multiplayer, and it's more complex than it needs to be.

You can just use the last hit system variable: openborvariant("lasthit_attacker")

So all you need is to get that value in the flash spawn event - it will always be the Beam, and do your palette match. No globals and more stable in multiplayer.

DC
 
everything's working excepting the binding co ordinates to target which I'm working on as we speak.
Currently the best method I'm using for accurate coordinates is by generating custom hitflashes using the takedamage on all target characters.
I didn't test but the DC's method looks good too.
 
@danno Tested DC's method and for this case it's really better.
Here's the code, I did two methods. Put one of them in an onspawscript.c file and call this event in the hitflash header.

Code:
void main()
{//Reusable for all hitflashes based on flash name
    void self        = getlocalvar("self");
    void attacker    = openborvariant("lasthit_attacker");
    void name        = getentityproperty(attacker, "defaultname");
    int map            = getentityproperty(attacker, "map");

    if(name == "fireball"){
        changeentityproperty(self, "map", map);
    }
}

void main()
{//Always change palette no matter the flash name
    void self        = getlocalvar("self");
    void attacker    = openborvariant("lasthit_attacker");
    int map            = getentityproperty(attacker, "map");

    changeentityproperty(self, "map", map);
}
 
I would of never thought to use openborvariant("lasthit_attacker");


Thanks everyone, I was starting to pull my hair out over the target binding in didhitscript because it didn't "look" right. onspawnscript is much easier, accurate and functional.
 
Last edited:
Back
Top Bottom