Solved Weapon Model Change Based on Defined Palette

Question that is answered or resolved.

maxman

Well-known member
I'm trying to have a player model switch to a weapon model, but both models have different palettes from each other. For example, one player model has 16 colors, while a weapon model has 34 colors. The colors are not exactly the same at all. It does work well when I use palette none, but when I define palette, along with alternatepal for both models, they get messy colors. Plus, it crashes.

10-8-2023 10-55-56 PM.png

Player model:
Code:
name AthenaXI
type player
health 100
speed 11
weapons Athena94 AthenaXI
#palette data/chars/heroes/athena/xi/idle00.png
palette none
#alternatepal data/chars/heroes/athena/xi/paltest.png

com d f a freespecial

script @script
void main(){
    int index = getlocalvar("player");
    void self = getplayerproperty(index, "entity");
    if(self != NULL()){
        changeentityproperty(self, "name", "Athena");
    }
}
@end_script



anim idle
    loop 1
    offset 39 108
    delay 8
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle01.png
    frame data/chars/heroes/athena/xi/idle02.png
    frame data/chars/heroes/athena/xi/idle03.png
    frame data/chars/heroes/athena/xi/idle04.png
    frame data/chars/heroes/athena/xi/idle05.png
    frame data/chars/heroes/athena/xi/idle06.png
    frame data/chars/heroes/athena/xi/idle07.png

anim walk
    loop 1
    offset 32 108
    delay 8
    frame data/chars/heroes/athena/xi/walk00.png
    frame data/chars/heroes/athena/xi/walk01.png
    frame data/chars/heroes/athena/xi/walk02.png
    frame data/chars/heroes/athena/xi/walk03.png
    frame data/chars/heroes/athena/xi/walk04.png
    frame data/chars/heroes/athena/xi/walk05.png
    frame data/chars/heroes/athena/xi/walk06.png
    frame data/chars/heroes/athena/xi/walk07.png
    frame data/chars/heroes/athena/xi/walk08.png
    frame data/chars/heroes/athena/xi/walk09.png
    frame data/chars/heroes/athena/xi/walk10.png
    frame data/chars/heroes/athena/xi/walk11.png

anim pain
    offset 39 108
    delay 8
    frame data/chars/heroes/athena/xi/idle00.png
    #frame data/chars/heroes/athena/xi/idle01.png
    #frame data/chars/heroes/athena/xi/idle02.png
    #frame data/chars/heroes/athena/xi/idle03.png
    #frame data/chars/heroes/athena/xi/idle04.png
    #frame data/chars/heroes/athena/xi/idle05.png
    #frame data/chars/heroes/athena/xi/idle06.png
    #frame data/chars/heroes/athena/xi/idle07.png

anim fall
    offset 39 108
    delay 8
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle01.png
    frame data/chars/heroes/athena/xi/idle02.png
    frame data/chars/heroes/athena/xi/idle03.png
    frame data/chars/heroes/athena/xi/idle04.png
    frame data/chars/heroes/athena/xi/idle05.png
    frame data/chars/heroes/athena/xi/idle06.png
    frame data/chars/heroes/athena/xi/idle07.png

anim rise
    offset 39 108
    delay 8
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle01.png
    frame data/chars/heroes/athena/xi/idle02.png
    frame data/chars/heroes/athena/xi/idle03.png
    frame data/chars/heroes/athena/xi/idle04.png
    frame data/chars/heroes/athena/xi/idle05.png
    frame data/chars/heroes/athena/xi/idle06.png
    frame data/chars/heroes/athena/xi/idle07.png

anim freespecial
    offset 39 108
    delay 8
    weaponframe 7 1 #weaponframe {frame} {weapon}
    frame data/chars/heroes/athena/xi/idle00.png
    frame data/chars/heroes/athena/xi/idle01.png
    frame data/chars/heroes/athena/xi/idle02.png
    frame data/chars/heroes/athena/xi/idle03.png
    frame data/chars/heroes/athena/xi/idle04.png
    frame data/chars/heroes/athena/xi/idle05.png
    frame data/chars/heroes/athena/xi/idle06.png
    frame data/chars/heroes/athena/xi/idle07.png

10-8-2023 10-55-24 PM.png

Weapon model:
Code:
name Athena94
type none
health 100
speed 13
weaploss 3
weapons AthenaXI Athena94
com d f a freespecial
#palette data/chars/heroes/athena/94/0_1.png
palette none
#alternatepal data/chars/heroes/athena/94/paltest.png


anim idle
    loop 1
    delay 9
    offset 132 203
    frame data/chars/heroes/athena/94/0_1.png
    frame data/chars/heroes/athena/94/0_2.png
    frame data/chars/heroes/athena/94/0_3.png
    frame data/chars/heroes/athena/94/0_4.png
    frame data/chars/heroes/athena/94/0_5.png

anim walk

    loop 1
    delay 9
    offset 132 203
    frame data/chars/heroes/athena/94/1_1.png
    frame data/chars/heroes/athena/94/1_2.png
    frame data/chars/heroes/athena/94/1_3.png
    frame data/chars/heroes/athena/94/1_4.png
    frame data/chars/heroes/athena/94/1_5.png
    frame data/chars/heroes/athena/94/1_6.png

anim freespecial
    delay 9
    weaponframe 4 0
    offset 132 203
    frame data/chars/heroes/athena/94/0_1.png
    frame data/chars/heroes/athena/94/0_2.png
    frame data/chars/heroes/athena/94/0_3.png
    frame data/chars/heroes/athena/94/0_4.png
    frame data/chars/heroes/athena/94/0_5.png

Do those palettes have to be the same or have to be combined as a palette? Do I need to switch to a fake weapon model for spawning another player model? What can I do?
 
Solution
But unless you wanna import some animations from the base model, the base and alternate model can have different color table.

Also, why are you using this?
C-like:
script @script
void main(){
    int index = getlocalvar("player");
    void self = getplayerproperty(index, "entity");
    if(self != NULL()){
        changeentityproperty(self, "name", "Athena");
    }
}
@end_script

"Script" is a nickname for updatescript and it runs constantly and you should use it when you really need someting to be run in every tick - for example, to defeat OpenBOR default gravity velocity (which I've learned later that I can simply change MAXTOSSSPEED).

On your example, you are telling the engine to change the model name to Athena in every single...
But unless you wanna import some animations from the base model, the base and alternate model can have different color table.

Also, why are you using this?
C-like:
script @script
void main(){
    int index = getlocalvar("player");
    void self = getplayerproperty(index, "entity");
    if(self != NULL()){
        changeentityproperty(self, "name", "Athena");
    }
}
@end_script

"Script" is a nickname for updatescript and it runs constantly and you should use it when you really need someting to be run in every tick - for example, to defeat OpenBOR default gravity velocity (which I've learned later that I can simply change MAXTOSSSPEED).

On your example, you are telling the engine to change the model name to Athena in every single tick, which is a waste of resource.

For those cases when you want to change a character name with script, I suggest using "spawnscript".
But there is a catch: when changing models, the alternate model won't fire any spawnscript you set on it because, technically, it isn't spawning at all.
In this case, you need to use onspawnscript:

onmodelcopyscript {path}

  • This command defines which script is run when entity change its model (weapon). This should be used in weapon models whenever you have spawn scripts since there is no spawn in weapon models.
 
Solution
Thank you! onmodelcopyscript works like a charm! I've never used it before! I don't need to use palette none for this anymore. I can use alternate palettes without any problem after using this trick.

I did it for both models.

Player:
Code:
onspawnscript @script
void main(){
    changeentityproperty(getlocalvar("self"), "name", "Athena");
}
@end_script

Weapon model:
Code:
onmodelcopyscript @script
void main(){
    changeentityproperty(getlocalvar("self"), "name", "Athena");
}
@end_script

Problem solved!
 
"Script" is a nickname for updatescript and it runs constantly and you should use it when you really need someting to be run in every tick - for example, to defeat OpenBOR default gravity velocity (which I've learned later that I can simply change MAXTOSSSPEED).

On your example, you are telling the engine to change the model name to Athena in every single tick, which is a waste of resource.
Good to know. I didn't know that. I thought that "script" is just an entity script. I think I read something that it's an "updateentity" script using "script", but I couldn't recognize it for how it's used for.
 
Back
Top Bottom