Solved Problem with Using MPRate

Question that is answered or resolved.

maxman

Well-known member
I tried using this script I made, but when I execute it and run the game, it crashes as I press an attack button. Is there something wrong with changing the property of mprate?

C:
void mpRate(float Rate){
    void self = getlocalvar("self");
    changeentityproperty(self, "mprate", Rate);
}

Code:
name Terry
type player
health 100
nodieblink 1
speed 10
mprate 1
gfxshadow 1
icon data/chars/heroes/KOF_2K3_Terry_Sprite.7z/terry.png 1
diesound data/sounds/heroes/terry/06_terry_00009.wav

animationscript data/scripts/animation/default.c

Code:
anim attack
    offset 140 188
    delay 4
    #cancel 0 0 0 a2 freespecial24 #Special
    cancel 2 4 1 a2 freespecial12 # L H
    bbox 126 94 42 94
    @cmd mpRate 2
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/95_0.png
    attack 145 92 64 25 6 0 0 0 0 0
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/113_1.png
    attack 0
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/95_0.png
    @cmd mpRate 1
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/95_0.png

Code:
Total Ram: 4171603968 Bytes
 Free Ram: 911011840 Bytes
 Used Ram: 6303744 Bytes

debug:nativeWidth, nativeHeight, bpp, Hz  1366, 768, 24, 60
OpenBoR v3.0 Build 6391, Compile Date: Apr  8 2020

Game Selected: ./Paks/ROD MAXED OUT!.pak

FileCaching System Init......    Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video.............    480x272 (Mode: 1)

Loading menu.txt.............    Done!
Loading fonts................    1 2 3 4 5 6 7 8 Done!
Timer init...................    Done!
Initialize Sound..............  
Loading sprites..............    Done!
Loading level order..........    Done!
Loading model constants......    Done!
Loading script settings......    Done!
Loading scripts..............    Done!
Loading models...............

Joystick: "UNKNOWN" connected at port: 0 at 2025-01-30 18:38:00
Cacheing 'Flash' from data/chars/misc/flash.txt
Cacheing 'Axel' from data/chars/heroes/Axel/axel.txt
Cacheing 'Mai_Frost' from data/chars/mai/mai.txt
Cacheing 'Terry' from data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt
Cacheing 'Aki' from data/chars/Aki/Aki.txt
Cacheing 'Shinryu' from data/chars/heroes/KOF_099_Jhun_Sprite.7z/shinryu.txt
Cacheing 'Clark' from data/chars/heroes/clark/clark.txt
Cacheing 'Athena' from data/chars/heroes/athena/xi/athenaxi.txt
Cacheing 'Kim' from data/chars/kim/kim.txt
Cacheing 'Evy' from data/chars/Vanessa/Vanessa.txt
Cacheing 'Hanzo' from data/chars/heroes/hanzo/hanzo.txt
Cacheing 'reweap' from data/chars/misc/reweap.txt
Cacheing 'Athena94' from data/chars/heroes/athena/94/athena94.txt
Cacheing 'Atena95' from data/chars/heroes/athena/95/atena95.txt
Cacheing 'Aten94' from data/chars/heroes/athena/aten94.txt
Cacheing 'Aten95' from data/chars/heroes/athena/aten95.txt
Cacheing 'coll1' from data/bgs/select/col1.txt
Cacheing 'coll1b' from data/bgs/select/col1b.txt
Cacheing 'coll2' from data/bgs/select/col2.txt
Cacheing 'coll2b' from data/bgs/select/col2b.txt
Cacheing 'coll3' from data/bgs/select/col3.txt
Cacheing 'coll3b' from data/bgs/select/col3b.txt
Cacheing 'coll4' from data/bgs/select/col4.txt
Cacheing 'coll4b' from data/bgs/select/col4b.txt
Cacheing 'coll5' from data/bgs/select/col5.txt
Cacheing 'coll5b' from data/bgs/select/col5b.txt
Cacheing 'TerrySel' from data/bgs/select/terrysel.txt
Cacheing 'powave' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/powave.txt
Cacheing 'burnknuc' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt
Cacheing 'bkdust' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/bkdust.txt
Cacheing 'powdunk' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/powdunk.txt
Cacheing 'pgeyser' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/pgeyser.txt
Cacheing 'JoeD' from data/chars/joe/joed.txt
Cacheing 'JoeNPC' from data/chars/joe/joenpc.txt
Cacheing 'ShermieNPC' from data/chars/shermie/shermienpc.txt
Cacheing 'K'NPC' from data/chars/k/knpc.txt
Cacheing 'Hotdog' from data/chars/misc/hotdog.txt
Cacheing 'Pizza' from data/chars/misc/pizza.txt
Cacheing '1upR' from data/chars/misc/1upR.txt
Cacheing '1upG' from data/chars/misc/1upG.txt
Cacheing '1upB' from data/chars/misc/1upB.txt
Cacheing '1up' from data/chars/misc/1up.txt
Cacheing 'Money' from data/chars/misc/money.txt
Cacheing 'Time' from data/chars/misc/time.txt
Cacheing 'Gold' from data/chars/misc/gold.txt
Cacheing 'Box' from data/chars/misc/box.txt
Cacheing 'Table' from data/chars/misc/table.txt
Cacheing 'Chair' from data/chars/misc/chair.txt
Cacheing 'Fence' from data/chars/misc/fence.txt
Cacheing 'Drum' from data/chars/misc/drum.txt
Cacheing 'Phone' from data/chars/misc/Pbooth.txt
Cacheing 'Joe' from data/chars/joe/joe.txt
Cacheing 'Jones' from data/chars/jones/jones.txt
Cacheing 'K'' from data/chars/k/k.txt
Cacheing 'Cheng' from data/chars/Cheng/Cheng.txt
Cacheing 'Eiji' from data/chars/eiji/eiji.txt
Cacheing 'Lin' from data/chars/lin/lin.txt
Cacheing 'Shermie' from data/chars/enemies/shermie/shermie.txt
Cacheing 'Hwa' from data/chars/hwa/hwa.txt
Cacheing 'Max' from data/chars/max/max.txt
Cacheing 'Genjuro' from data/chars/genjuro/genjuro.txt
Cacheing 'Choi' from data/chars/choi/choi.txt
Cacheing 'Billy' from data/chars/billy/billy.txt
Cacheing 'Seth' from data/chars/seth/seth.txt
Cacheing 'Whip' from data/chars/whip/whip.txt
Cacheing 'Gato' from data/chars/gato/gato.txt
Cacheing 'Geese' from data/chars/Geese/Geese.txt
Cacheing 'no1' from data/chars/no1/no1.txt
Cacheing 'robot' from data/chars/robot/robot.txt
Cacheing 'Knife' from data/chars/misc/knife.txt
Cacheing 'Shot' from data/chars/misc/shot.txt
Cacheing 'Star' from data/chars/misc/star.txt
Cacheing 'light' from data/chars/misc/light.txt
Cacheing 'heli' from data/chars/misc/heli.txt
Cacheing 'rain' from data/chars/misc/rain.txt
Cacheing 'bridge' from data/chars/misc/bridge.txt
Cacheing 'Lucky' from data/chars/bosses/lucky/lucky.txt
Cacheing 'Garcia' from data/chars/enemies/garcia/garcia.txt
Cacheing 'Ruhut' from data/chars/enemies/ruhut/ruhut.txt
Cacheing 'TerryPortA' from data/chars/heroes/kof_2k3_terry_sprite.7z/terryporta.txt
Cacheing 'TerryPortB' from data/chars/heroes/kof_2k3_terry_sprite.7z/terryportb.txt
Cacheing 'TerryPortC' from data/chars/heroes/kof_2k3_terry_sprite.7z/terryportc.txt
Cacheing 'Mike' from data/chars/mike/src_mike.txt
Cacheing 'PhoneB1' from data/chars/misc/phoneb/phone.txt
Cacheing 'PhoneB' from data/chars/misc/phoneb/phoneb.txt
Cacheing 'PhoneA' from data/chars/misc/phoneb/phonea.txt
Cacheing 'birds' from data/chars/misc/birds/birds.txt
Cacheing 'scrSel' from data/bgs/select/scrSel.txt
Cacheing 'selection' from data/bgs/select/selection.txt
Cacheing 'bgmgrid' from data/bgs/select/bgmgrid.txt
Cacheing 'selectR' from data/bgs/select/selectr.txt
Cacheing 'selectG' from data/bgs/select/selectg.txt
Cacheing 'selectB' from data/bgs/select/selectb.txt
Cacheing 'arrowl' from data/chars/misc/arrowl.txt
Cacheing 'pillar' from data/bgs/3rave2/pillar.txt
Cacheing 'St2_Disco1' from data/bgs/3rave2/rave/disco1.txt
Cacheing 'St2_Disco2' from data/bgs/3rave2/rave/disco2.txt
Cacheing 'St2_Laser' from data/bgs/3rave2/rave/laser.txt
Cacheing 'St2_People' from data/bgs/3rave2/rave/people.txt

Loaded 'Flash' from data/chars/misc/flash.txt
Loaded 'Axel' from data/chars/heroes/Axel/axel.txt
Loaded 'Mai_Frost' from data/chars/mai/mai.txt
sound_load_sample can't load sample from file 'data/sounds/mai.wav'!
sound_load_sample can't load sample from file 'data/sounds/mai.wav'!
Loaded 'Terry' from data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt
Loaded 'TerryPortA' from data/chars/heroes/kof_2k3_terry_sprite.7z/terryporta.txt
Loaded 'TerryPortB' from data/chars/heroes/kof_2k3_terry_sprite.7z/terryportb.txt
Loaded 'TerryPortC' from data/chars/heroes/kof_2k3_terry_sprite.7z/terryportc.txt
Command 'if(openborvariant("in_selectscreen")){' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'int' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'int' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'int' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'int' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '/*' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'for(){' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '*/' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'if(getlocalvar("remapsfx")' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '/*if(' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '(press' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '||' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command ')' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '{' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'playsample(sfx01,' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'setlocalvar("remapsfx",' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}*/' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'if(map' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'playsample(sfx01,' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'setlocalvar("remapsfx",' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'if(map' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'playsample(sfx02,' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'setlocalvar("remapsfx",' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'if(map' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'playsample(sfx03,' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'setlocalvar("remapsfx",' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'if(getlocalvar("remapsfx")' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command 'setlocalvar("remapsfx",' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Command '@end_script' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt'!
Loaded 'powave' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/powave.txt
Loaded 'burnknuc' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt
Loaded 'bkdust' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/bkdust.txt
Loaded 'powdunk' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/powdunk.txt
Loaded 'pgeyser' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/pgeyser.txt
Loaded 'Aki' from data/chars/Aki/Aki.txt
Loaded 'Shinryu' from data/chars/heroes/KOF_099_Jhun_Sprite.7z/shinryu.txt
Loaded 'Clark' from data/chars/heroes/clark/clark.txt
WARNING: data/chars/heroes/clark/clark.txt tries to load a non-numeric value at cancel, where a number is expected!
erroneus string: a
Loaded 'Athena' from data/chars/heroes/athena/xi/athenaxi.txt
Loaded 'aten94' from data/chars/heroes/athena/aten94.txt
Loaded 'aten95' from data/chars/heroes/athena/aten95.txt
Loaded 'Kim' from data/chars/kim/kim.txt
sound_load_sample can't load sample from file 'data/sounds/diepla.wav'!
Loaded 'Evy' from data/chars/Vanessa/Vanessa.txt
Loaded 'Hanzo' from data/chars/heroes/hanzo/hanzo.txt
Loaded 'Athena94' from data/chars/heroes/athena/94/athena94.txt
Command 'if(frame==1){' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'void' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'int' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'int' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'int' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'if(hps==null()){' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'hps' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command '}' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'changeentityproperty(self,"maxhealth",' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'changeentityproperty(self,"health",' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'setglobalvar("hp"' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command '}' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command '@end_script' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'if(frame==1){' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'void' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'int' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'changeentityproperty(self,"maxhealth",' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command 'changeentityproperty(self,"health",' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command '}' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Command '@end_script' not understood in file 'data/chars/heroes/athena/94/athena94.txt'!
Loaded 'Atena95' from data/chars/heroes/athena/95/atena95.txt
Loaded 'coll1' from data/bgs/select/col1.txt
Loaded 'coll1b' from data/bgs/select/col1b.txt
Loaded 'coll2' from data/bgs/select/col2.txt
Loaded 'coll2b' from data/bgs/select/col2b.txt
Loaded 'coll3' from data/bgs/select/col3.txt
Loaded 'coll3b' from data/bgs/select/col3b.txt
Loaded 'coll4' from data/bgs/select/col4.txt
Loaded 'coll4b' from data/bgs/select/col4b.txt
Loaded 'coll5' from data/bgs/select/col5.txt
Loaded 'coll5b' from data/bgs/select/col5b.txt
Loaded 'TerrySel' from data/bgs/select/terrysel.txt

Loading models...............    Done!
Object engine init...........    Done!
Input init...................  
1 joystick(s) found!
UNKNOWN - 2 axes, 10 buttons, 0 hat(s)
Done!
Create blending tables.......    Done!
Save settings so far........    Done!



Can't play music file 'data/music/remix'

Can't play music file 'data/music/<VT_EMPTY>   Unitialized/title.bor'

Can't play music file 'data/music/remix'

Can't play music file 'data/music/menu'

Can't play music file 'data/music/remix'

Can't play music file 'data/music/<VT_EMPTY>   Unitialized/select.bor'
Loaded 'scrSel' from data/bgs/select/scrSel.txt
Loaded 'selection' from data/bgs/select/selection.txt
Loaded 'bgmgrid' from data/bgs/select/bgmgrid.txt
Loaded 'selectr' from data/bgs/select/selectr.txt
Loaded 'selectg' from data/bgs/select/selectg.txt
Loaded 'selectb' from data/bgs/select/selectb.txt

Can't play music file 'data/music/remix'

Can't play music file 'data/music/menu'

Can't play music file 'data/music/remix'
Loaded 'scrSel'Level Loading:   'data/levels/rave02.txt'
Total Ram: 4171603968 Bytes
 Free Ram: 369504256 Bytes
 Used Ram: 51507200 Bytes

Loaded '1up' from data/chars/misc/1up.txt
Loaded 'table' from data/chars/misc/table.txt
Loaded 'money' from data/chars/misc/money.txt
Loaded 'chair' from data/chars/misc/chair.txt
Loaded 'hotdog' from data/chars/misc/hotdog.txt
Loaded 'St2_People' from data/bgs/3rave2/rave/people.txt
Loaded 'pillar' from data/bgs/3rave2/pillar.txt
Loaded 'shermie' from data/chars/enemies/shermie/shermie.txt

Level Loaded:    'data/levels/rave02.txt'
Total Ram: 4171603968 Bytes
 Free Ram: 380915712 Bytes
 Used Ram: 55582720 Bytes
Total sprites mapped: 1246

Script function 'changeentityproperty' returned an exception, check the manual for details.
 parameters: #131641528, 109, 2,
 
********** An Error Occurred **********
*            Shutting Down            *

There's an exception while executing script 'Terry' data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txtTotal Ram: 4171603968 Bytes
 Free Ram: 426213376 Bytes
 Used Ram: 55631872 Bytes

Release level data...........
Level Unloading: 'data/levels/rave02.txt'
Total Ram: 4171603968 Bytes
 Free Ram: 426213376 Bytes
 Used Ram: 55631872 Bytes

RAM Status:
Total Ram: 4171603968 Bytes
 Free Ram: 426618880 Bytes
 Used Ram: 54071296 Bytes

Done!

Release graphics data........    Done!
Release game data............

Unload 'Flash' ............Done.
Unload 'Axel' ............Done.
Unload 'Mai_Frost' ............Done.
Unload 'Terry' ............Done.
Unload 'TerryPortA' ............Done.
Unload 'TerryPortB' ............Done.
Unload 'TerryPortC' ............Done.
Unload 'powave' ............Done.
Unload 'burnknuc' ............Done.
Unload 'bkdust' ............Done.
Unload 'powdunk' ............Done.
Unload 'PGeyser' ............Done.
Unload 'Aki' ............Done.
Unload 'Shinryu' ............Done.
Unload 'Clark' ............Done.
Unload 'Athena' ............Done.
Unload 'Aten94' ............Done.
Unload 'Aten95' ............Done.
Unload 'Kim' ............Done.
Unload 'Evy' ............Done.
Unload 'Hanzo' ............Done.
Unload 'Athena94' ............Done.
Unload 'Atena95' ............Done.
Unload 'coll1' ............Done.
Unload 'coll1b' ............Done.
Unload 'coll2' ............Done.
Unload 'coll2b' ............Done.
Unload 'coll3' ............Done.
Unload 'coll3b' ............Done.
Unload 'coll4' ............Done.
Unload 'coll4b' ............Done.
Unload 'coll5' ............Done.
Unload 'coll5b' ............Done.
Unload 'TerrySel' ............Done.
Unload 'scrSel' ............Done.
Unload 'selection' ............Done.
Unload 'bgmgrid' ............Done.
Unload 'selectR' ............Done.
Unload 'selectG' ............Done.
Unload 'selectB' ............Done.
Unload '1up' ............Done.
Unload 'Table' ............Done.
Unload 'Money' ............Done.
Unload 'Chair' ............Done.
Unload 'Hotdog' ............Done.
Unload 'St2_People' ............Done.
Unload 'pillar' ............Done.
Unload 'Shermie' ............Done.

Release game data............    Done!
Release timer................    Done!
Release input hardware.......    Done!
Release sound system.........    Done!
Release FileCaching System...    Done!

**************** Done *****************

There's an exception while executing script 'Terry' data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt
 
Solution
Reverting to mprate 1 with takedamagescript is easy, but reverting back to 1 for anim idle after certain attacks/moves/specials is hard. How can I revert its mprate back to 1 after it reaches to anim idle or finishes its last attack in an animation before moving to anim idle? Is there a way I could allow normal attacks to hit with default mprate 1 instead of retaining mprate 2 in all attacking animations after some certain attacking animations? For example, I have mprate 2 set in runattack and follow1 anims from my script of ondoattack and what I want is to revert back to mprate 1 in all normal attack animations. But after I finish with certain animations and start doing all attacking animation including grabattack, mprate 2 stays...
@maxman If I'm not wrong, the mprate can't be changed directly. You must use the mpset property and change the recovery rate instead.

1738272762798.png

Code:
changeentityproperty(self, "mpset", mp, stable type, stable, recover rate, drop rate, charge rate);
 
Thanks, @Kratus. What I'm trying to do is that I have mprate 1 set in the header and I wanna change it to 2 in the beginning of an attacking animation before using or during attack. But before the animation ends, I want it to revert back to the same value as the one given in the header, mprate 1. I only have mprate in the header, but not mpset. Do I have to put mpset in the header along with mprate? How do you set up the value for increasing or decreasing its mprate and then back to its original value using mpset property as an example with character animation?

Isn't it like this one?

C:
void mpset(int mp, int Type, int stable, float Rate, float Drop, float Charge){
   void self = getlocalvar("self");
   changeentityproperty(self, "mpset", mp, Type, stable, Rate, Drop, Charge);
}
 
Thanks, @Kratus. What I'm trying to do is that I have mprate 1 set in the header and I wanna change it to 2 in the beginning of an attacking animation before using or during attack. But before the animation ends, I want it to revert back to the same value as the one given in the header, mprate 1. I only have mprate in the header, but not mpset. Do I have to put mpset in the header along with mprate? How do you set up the value for increasing or decreasing its mprate and then back to its original value using mpset property as an example with character animation?
You can just put mprate at the header and let all the rest to scripts.
I suggest saving the original mprate value before any change, then you can always reset to default at any time.

The only thing I don't recommend is to put everything in animation scripts. It's because if the character is vulnerable to attacks, he will change the animation before the mprate backs to the default value.
Maybe using events like ondoattack, didhit or takedamage can be better depending on how the character is built.
 
Last edited:
I was testing with mpset in animation script and became shocked about not getting a crash at all. However, I have to agree with you on the result/behavior as I'm worried about its effect thru attacks you explained.

I'm quite uncertain about the altering values of the rate here. But for now, this is temporary. I will use one or a couple of those scripts you mentioned for better effects. Maybe either didhit/ondoattack (it could be one of them) or takedamage. Or maybe both.
Code:
anim attack
    offset 140 188
    delay 4
    cancel 2 4 1 a2 freespecial12 # L H
    bbox 126 94 42 94
    @cmd mpset 0 0 0 2 0 0 # Alter mprate to 2?
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/95_0.png
    attack 145 92 64 25 6 0 0 0 0 0
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/113_1.png
    attack 0
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/95_0.png
    @cmd mpset 0 0 0 1 0 0 #Return to original value?
    frame data/chars/heroes/KOF_2K3_Terry_Sprite.7z/95_0.png

I suggest saving the original mprate value before any change, then you can always reset to default at any time.
How am I going to save the original mprate value? By keeping its value in the header or reverting to its original form by the end of an animation after being altered in the beginning of an attacking animation?

In case I use takedamagescript for reverting back to its original form, maybe it could be set like this, right?

C:
void main(){
    void self = getlocalvar("self");
    void name = getentityproperty("defaultname");
    
    if(name == "Terry"){
        changeentityproperty(self, "mpset", 0, 0, 0, 1, 0, 0); // Returning to original form every time he's taken damage.
    }
}

But for didhitscript or ondoattackscript, I want to revert back to the original value in the last frame of an animation before going back to anim idle. I'd like to have it revert back when the attack box is 0 too. Do I have to specify an animation and a frame for altering and reverting back to mprate's values? How does that work?
 
Maybe either didhit/ondoattack (it could be one of them) or takedamage. Or maybe both.
I suggest ondoattack/didhit but need tests to see which one fits better for the purpose. I believe the ondoattack could be better due to working before some collision events.

How am I going to save the original mprate value?
You have some ways to do that. Example, you can fix a default mprate inside the scripts, or you can save the default header value into a variable at the first spawn but only when this variable is NULL (avoiding to save twice or more).
 
I'm not sure which one works, but what I want is for the MP rate to increase slightly before returning to its normal rate. You can try ondoattack or didhit, and see which one works better.

I just left the comments in the code to see how I want the character's mprate to remain before switching back to normal (mprate 1, as a default).
Code:
anim runattack
    loop    0
    delay    5
    offset    34 107
    move    1
    bbox    0 0 0 0
    followanim 1 # THIS WILL HAVE TO START WITH MPRATE 2 IN THIS FOLLOWING ANIMATION
    followcond 1
    fastattack 1
    sound   data/sounds/ryuratk.wav
        frame    data/chars/ryu/ratk00.gif
offset    19 103
        frame    data/chars/ryu/ratk01.gif
offset    -2 99
        attack  34 6 35 68 8
        frame    data/chars/ryu/ratk02.gif
        attack  0 0 0 0 0
offset    -2 100
        attack  34 6 35 68 8
        frame    data/chars/ryu/ratk03.gif
offset    -2 100
         frame    data/chars/ryu/ratk04.gif
offset    -6 100
        frame    data/chars/ryu/ratk05.gif
offset    2 99
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk06.gif
offset    20 99
        frame    data/chars/ryu/ratk07.gif

anim follow1
    jumpframe 35
    loop    0
    delay    3
    offset    26 101
    bbox    19 12 27 66
    move    0
    energycost 10
    fastattack 1
    sound   data/sounds/shoryuke.wav
        frame    data/chars/ryu/ratk08.gif
offset    24 93
        bbox    20 10 34 68
        frame    data/chars/ryu/ratk09.gif
offset    26 89
        bbox    25 10 32 55
        frame    data/chars/ryu/ratk10.gif
offset    27 82
        bbox    31 8 29 47
        frame    data/chars/ryu/ratk11.gif
offset    27 87
        frame    data/chars/ryu/ratk12.gif
offset    27 87
        frame    data/chars/ryu/ratk13.gif
offset    27 87
        attack  48 9 59 45 2
#GAIN MPRATE FROM 1 TO 2. NOW IT'S 2
        frame    data/chars/ryu/ratk14.gif
offset    28 88
        bbox    27 13 35 59
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk15.gif
offset    26 91
        bbox    21 10 37 61
        frame    data/chars/ryu/ratk16.gif
offset    26 91
        frame    data/chars/ryu/ratk18.gif
offset    28 88
        frame    data/chars/ryu/ratk19.gif
offset    27 87
        attack  48 9 59 45 2
#REMAIN MPRATE VALUE TO 2
        frame    data/chars/ryu/ratk20.gif
        attack  0 0 0 0 0
offset    28 88
        frame    data/chars/ryu/ratk19.gif
offset    26 91
        frame    data/chars/ryu/ratk18.gif
offset    24 93
        bbox    20 10 34 68
        frame    data/chars/ryu/ratk09.gif
offset    26 89
        bbox    25 10 32 55
        frame    data/chars/ryu/ratk10.gif
offset    27 87
        attack  48 9 59 45 2
#KEEP REMAINING IT TO 2
        frame    data/chars/ryu/ratk14.gif
offset    28 88
        bbox    27 13 35 59
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk15.gif
offset    26 91
        bbox    21 10 37 61
        frame    data/chars/ryu/ratk16.gif
offset    26 91
        frame    data/chars/ryu/ratk18.gif
offset    28 88
        frame    data/chars/ryu/ratk19.gif
offset    27 87
        attack  48 9 59 45 2
#STILL KEEP REMAINING TO 2
        frame    data/chars/ryu/ratk20.gif
        attack  0 0 0 0 0
offset    28 88
        frame    data/chars/ryu/ratk19.gif
offset    26 91
        frame    data/chars/ryu/ratk18.gif
offset    24 93
        bbox    20 10 34 68
        frame    data/chars/ryu/ratk09.gif
offset    26 89
        bbox    25 10 32 55
        frame    data/chars/ryu/ratk10.gif
offset    27 87
        bbox    27 13 35 59
        attack  48 9 59 45 2
#KEEP USING MPRATE 2
        frame    data/chars/ryu/ratk14.gif
offset    28 88
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk15.gif
offset    26 91
        frame    data/chars/ryu/ratk16.gif
offset    26 91
        frame    data/chars/ryu/ratk18.gif
offset    28 88
        frame    data/chars/ryu/ratk19.gif
offset    27 87
        attack  48 9 59 45 2
#KEEP REMAINING MPRATE VALUE TO 2 UNTIL IT REACHES THE LAST FRAME
        frame    data/chars/ryu/ratk20.gif
        attack  0 0 0 0 0
offset    27 85
        bbox    0 0 0 0
        delay   5
        frame    data/chars/ryu/free10.gif
offset    26 90
        frame    data/chars/ryu/free11.gif
offset    25 100
        attack  31 10 38 66 2
#KEEP USING MPRATE 2
        move    10
        frame    data/chars/ryu/free12.gif
offset    16 141
        attack  0 0 0 0
        move    0
        frame    data/chars/ryu/free13.gif
offset    10 138
        frame    data/chars/ryu/free14.gif
offset    13 138
        attack  6 0 28 107 15 1
#THIS IS THE LAST PART FOR USING MPRATE 1
        frame    data/chars/ryu/free15.gif
offset    13 138
        frame    data/chars/ryu/free16.gif
offset    25 135
        attack  0 0 0 0 0 0 
        frame    data/chars/ryu/free17.gif
offset    23 138
        frame    data/chars/ryu/free18.gif
offset    23 137
        frame    data/chars/ryu/free19.gif
#SWITCH BACK TO MPRATE 1 AFTER THE LAST ATTACK
offset    28 120
        frame    data/chars/ryu/free20.gif

If there's an attackbox or attack ID, that needs to apply its mprate to increase for hits in one animation, I think.
 
@Kratus You are right that I cannot use animationscript for mprate in script because iconmphigh/low disappears after activating mpset in animationscript. I don't know how to use "mpset" property but I made a didhit script for gaining twice the original value. I don't know if I'm using it right.

Here's my didhitscript.
C:
void main(){
    void self = getlocalvar("self");
    void ani = getentityproperty(self, "animationid");
    void name = getentityproperty(self, "defaultname");
    int frame = getentityproperty(self, "animpos");
    int mp = getentityproperty(self, "mp");

    if(name == "Ryu"){
        if(ani == openborconstant("ANI_FOLLOW1") && frame >= 0){
            changeentityproperty(self, "mpset", mp+1, 0, 0, 2, 0, 0); // Attempt to gain mprate value
        }
        if(ani == openborconstant("ANI_FOLLOW1") && frame >= 37){
            changeentityproperty(self, "mpset", 0, 0, 0, 1, 0, 0); // Attempt to revert mprate back to 1
        }
    }   
}

Code:
anim runattack
    loop    0
    delay    5
    offset    34 107
    move    1
    bbox    0 0 0 0
    followanim 1
    followcond 1
    fastattack 1
    sound   data/sounds/ryuratk.wav
        frame    data/chars/ryu/ratk00.gif
offset    19 103
        frame    data/chars/ryu/ratk01.gif
offset    -2 99
        attack  34 6 35 68 8
        frame    data/chars/ryu/ratk02.gif
        attack  0 0 0 0 0
offset    -2 100
        attack  34 6 35 68 8
        frame    data/chars/ryu/ratk03.gif
offset    -2 100
         frame    data/chars/ryu/ratk04.gif
offset    -6 100
        frame    data/chars/ryu/ratk05.gif
offset    2 99
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk06.gif
offset    20 99
        frame    data/chars/ryu/ratk07.gif

anim follow1
    jumpframe 35
    loop    0
    delay    3
    offset    26 101
    bbox    19 12 27 66
    move    0
    energycost 10
    fastattack 1
    sound   data/sounds/shoryuke.wav
        frame    data/chars/ryu/ratk08.gif
offset    24 93
        bbox    20 10 34 68
        frame    data/chars/ryu/ratk09.gif #0
offset    26 89
        bbox    25 10 32 55
        frame    data/chars/ryu/ratk10.gif #1
offset    27 82
        bbox    31 8 29 47
        frame    data/chars/ryu/ratk11.gif #2
offset    27 87
        frame    data/chars/ryu/ratk12.gif #3
offset    27 87
        frame    data/chars/ryu/ratk13.gif #4
offset    27 87
        attack  48 9 59 45 2
#@cmd mpset 0 0 0 2 0 0
        frame    data/chars/ryu/ratk14.gif #4
offset    28 88
        bbox    27 13 35 59
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk15.gif #5
offset    26 91
        bbox    21 10 37 61
        frame    data/chars/ryu/ratk16.gif #6
offset    26 91
        frame    data/chars/ryu/ratk18.gif #7
offset    28 88
        frame    data/chars/ryu/ratk19.gif#8
offset    27 87
        attack  48 9 59 45 2
        frame    data/chars/ryu/ratk20.gif#9
        attack  0 0 0 0 0
offset    28 88
        frame    data/chars/ryu/ratk19.gif#10
offset    26 91
        frame    data/chars/ryu/ratk18.gif#11
offset    24 93
        bbox    20 10 34 68
        frame    data/chars/ryu/ratk09.gif#12
offset    26 89
        bbox    25 10 32 55
        frame    data/chars/ryu/ratk10.gif#13
offset    27 87
        attack  48 9 59 45 2
        frame    data/chars/ryu/ratk14.gif#14
offset    28 88
        bbox    27 13 35 59
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk15.gif#15
offset    26 91
        bbox    21 10 37 61
        frame    data/chars/ryu/ratk16.gif#16
offset    26 91
        frame    data/chars/ryu/ratk18.gif#17
offset    28 88
        frame    data/chars/ryu/ratk19.gif#18
offset    27 87
        attack  48 9 59 45 2
        frame    data/chars/ryu/ratk20.gif#19
        attack  0 0 0 0 0
offset    28 88
        frame    data/chars/ryu/ratk19.gif#20
offset    26 91
        frame    data/chars/ryu/ratk18.gif#21
offset    24 93
        bbox    20 10 34 68
        frame    data/chars/ryu/ratk09.gif#22
offset    26 89
        bbox    25 10 32 55
        frame    data/chars/ryu/ratk10.gif#23
offset    27 87
        bbox    27 13 35 59
        attack  48 9 59 45 2
        frame    data/chars/ryu/ratk14.gif#24
offset    28 88
        attack  0 0 0 0 0
        frame    data/chars/ryu/ratk15.gif#25
offset    26 91
        frame    data/chars/ryu/ratk16.gif#26
offset    26 91
        frame    data/chars/ryu/ratk18.gif#27
offset    28 88
        frame    data/chars/ryu/ratk19.gif#28
offset    27 87
        attack  48 9 59 45 2
        frame    data/chars/ryu/ratk20.gif#29
        attack  0 0 0 0 0
offset    27 85
        bbox    0 0 0 0
        delay   5
        frame    data/chars/ryu/free10.gif#30
offset    26 90
        frame    data/chars/ryu/free11.gif#31
offset    25 100
        attack  31 10 38 66 2
        move    10
        frame    data/chars/ryu/free12.gif#32
offset    16 141
        attack  0 0 0 0
        move    0
        frame    data/chars/ryu/free13.gif#33
offset    10 138
        frame    data/chars/ryu/free14.gif#34
offset    13 138
        attack  6 0 28 107 15 1
        frame    data/chars/ryu/free15.gif#35
offset    13 138
        frame    data/chars/ryu/free16.gif#36
offset    25 135
        attack  0 0 0 0 0 0 
#@cmd mpset 0 0 0 1 0 0
        frame    data/chars/ryu/free17.gif#37
offset    23 138
        frame    data/chars/ryu/free18.gif#38
offset    23 137
        frame    data/chars/ryu/free19.gif#39
offset    28 120
        frame    data/chars/ryu/free20.gif#40

I'm also trying to revert back to mprate 1 after a certain animation is finished. I'm thinking about using takedamagescript for reverting the mprate value back to 1 every time a player gets damaged when it has bbox.
 
@Kratus You are right that I cannot use animationscript for mprate in script because iconmphigh/low disappears after activating mpset in animationscript. I don't know how to use "mpset" property but I made a didhit script for gaining twice the original value. I don't know if I'm using it right.
It looks correct but I suggest doing several tests to confirm if it's working as you want. My only suggestion is to put NULL() on the parameters you don't want to change.

Code:
changeentityproperty(self, "mpset", amount, NULL(), NULL(), recover, NULL(), NULL());

I'm also trying to revert back to mprate 1 after a certain animation is finished. I'm thinking about using takedamagescript for reverting the mprate value back to 1 every time a player gets damaged when it has bbox.
I suggest putting mandatory scripts in events where it will never fail, or maybe in multiple events to guarantee that it works.
Like I said before, animation scripts can fail in case the current animation is interrupted by other events, then skipping the frame where the @cmd tag is placed.
Maybe the takedamage can be a good place, but it need tests.
 
Just tested and modified this script for either didhit or doattack.

C:
void main(){
    void self = getlocalvar("self");
    void ani = getentityproperty(self, "animationid");
    void name = getentityproperty(self, "defaultname");
    int frame = getentityproperty(self, "animpos");
    int mp = getentityproperty(self, "mp");
    int amount; int recover;

    if(name == "Ryu"){
        if(ani == openborconstant("ANI_FOLLOW1") && frame >= 0 && frame <= 36){
            changeentityproperty(self, "mpset", amount, NULL(), NULL(), recover, NULL(), NULL());
            //changeentityproperty(entity, "mpset", mp, stable_type, stable, recovery_rate, drop_rate, charge_rate)
            amount = 1;
            recover = 2;
        }
        if(ani == openborconstant("ANI_FOLLOW1") && frame >= 37){
            changeentityproperty(self, "mpset", amount, NULL(), NULL(), recover, NULL(), NULL());
            amount = 0;
            recover = 1;
        }
    }   
}

Just created a new takedamage script file here.

C:
//Revert mprate back to 1

void main(){
    void self = getlocalvar("self");
    changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), 1, NULL(), NULL());
}

However, every time I use didhit or ondoattack with the script given above, the player's MP gains 1 per hit from my own debug. If I put mprate 2 in the character header (without script), the player's MP normally increases to 2 per hit. The recovery rate doesn't increase in script. (What I'm trying to do is to have its MP gain 1 point per hit in normal attacks while I want some attacking animations to gain 2 points per hit.)

I suggest putting mandatory scripts in events where it will never fail, or maybe in multiple events to guarantee that it works.
What type of script events should I use?

Am I missing something?
 
Am I missing something?
1. Why are you changing the current mp amount instead of leaving it NULL()?

1741143438044.png

2. You should define all variables before using it, the amount/recover lines must be moved to before the changeentityproperty line.

1741143682908.png

3. Here's a test using the same script but with some fixes. As you can see, the attack3 (kicks) changes the mprate to 2, but the attack1 changes it to 5.


Here's the code used in the video (inside the ondoattackscript event):
Code:
        void ani = getentityproperty(self, "animationid");
        int recover;

        if(ani == openborconstant("ANI_ATTACK1")){
            recover = 5;

            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
        }
        if(ani == openborconstant("ANI_ATTACK3")){
            recover = 2;

            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
        }
 
Cool! Thank you, Kratus. It seems that I'm not gonna rely on the entity name anymore for this. This is why it doesn't work. I'll be using your example and yours works perfectly. I will only create an ondoattack script for this depending on a specific character I will use and make a name for it.

1. Why are you changing the current mp amount instead of leaving it NULL()?
Because I thought using the MP could affect its recovery. I realized it doesn't after testing it with NULL() on the MP part.

How do you call mprate as part of the debug mode from your sample video? I made this only to call player 1's MP but I don't know how to call mprate. Should I call the mprate variable like this?

C:
getentityproperty(P1, "mprate")

Here's a debug I made:
C:
ondrawscript @script
void main(){
    if(openborvariant("in_level") == 1){
    int P1 = getplayerproperty(0, "entity");
    int MP1 = getentityproperty(P1, "mp");
    //int recover;
    //changeentityproperty(P1, "mpset", NULL(),NULL(),NULL(),recover,NULL(),NULL());

    drawstring(10, 40, 0, "MP:_"+MP1);
    }
}
@end_script
 
Reverting to mprate 1 with takedamagescript is easy, but reverting back to 1 for anim idle after certain attacks/moves/specials is hard. How can I revert its mprate back to 1 after it reaches to anim idle or finishes its last attack in an animation before moving to anim idle? Is there a way I could allow normal attacks to hit with default mprate 1 instead of retaining mprate 2 in all attacking animations after some certain attacking animations? For example, I have mprate 2 set in runattack and follow1 anims from my script of ondoattack and what I want is to revert back to mprate 1 in all normal attack animations. But after I finish with certain animations and start doing all attacking animation including grabattack, mprate 2 stays instead of going back to mprate 1. I have both anim attack1 and anim idle just fine in script because I called those certain animations to give its recovery rate to 1. I wanna return its recovery rate to 1 in all attacking animations, except those that will be specifically given.

C:
void main(){
    void self = getlocalvar("self");
    void ani = getentityproperty(self, "animationid");
    int frame = getentityproperty(self, "animpos");
    int recover;

        /*
        if(ani == openborconstant("ANI_follow1") && frame <= 37){
            recover = 2;
            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
            //changeentityproperty(entity, "mpset", mp, stable_type, stable, recovery_rate, drop_rate, charge_rate)

        }
        else{
            recover = 1;
            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
        }
        */

        if(ani == openborconstant("ANI_follow1")){
            if(frame <= 37){
                recover = 2;
                changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
            }
            if(frame >= 38){
                recover = 1;
                changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
            }
        }

        if(ani == openborconstant("ANI_ATTACK1") || ani == openborconstant("ANI_IDLE")){
            recover = 1;
            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
        }
}
 
Reverting to mprate 1 with takedamagescript is easy, but reverting back to 1 for anim idle after certain attacks/moves/specials is hard. How can I revert its mprate back to 1 after it reaches to anim idle or finishes its last attack in an animation before moving to anim idle? Is there a way I could allow normal attacks to hit with default mprate 1 instead of retaining mprate 2 in all attacking animations after some certain attacking animations? For example, I have mprate 2 set in runattack and follow1 anims from my script of ondoattack and what I want is to revert back to mprate 1 in all normal attack animations. But after I finish with certain animations and start doing all attacking animation including grabattack, mprate 2 stays instead of going back to mprate 1. I have both anim attack1 and anim idle just fine in script because I called those certain animations to give its recovery rate to 1. I wanna return its recovery rate to 1 in all attacking animations, except those that will be specifically given.

C:
void main(){
    void self = getlocalvar("self");
    void ani = getentityproperty(self, "animationid");
    int frame = getentityproperty(self, "animpos");
    int recover;

        /*
        if(ani == openborconstant("ANI_follow1") && frame <= 37){
            recover = 2;
            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
            //changeentityproperty(entity, "mpset", mp, stable_type, stable, recovery_rate, drop_rate, charge_rate)

        }
        else{
            recover = 1;
            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
        }
        */

        if(ani == openborconstant("ANI_follow1")){
            if(frame <= 37){
                recover = 2;
                changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
            }
            if(frame >= 38){
                recover = 1;
                changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
            }
        }

        if(ani == openborconstant("ANI_ATTACK1") || ani == openborconstant("ANI_IDLE")){
            recover = 1;
            changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
        }
}
You don't need to use the takedamage in case the mprate changes during attacks. Instead, just add some if/else for different rates, plus I added some different examples for multiple animations.

Code:
void ani = getentityproperty(self, "animationid");
int recover;

if(ani == openborconstant("ANI_ATTACK1") || ani == openborconstant("ANI_ATTACK2") || ani == openborconstant("ANI_ATTACK3")){
    recover = 5;

    changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
}
else
if(ani == openborconstant("ANI_RUNATTACK")){
    recover = 2;

    changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
}
else //ANY OTHER ATTACK ANIMATION THE MPRATE IS ALWAYS 1
{
    recover = 1;

    changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
}
 
Solution
I accidentally used didhitscript for the attacks. I could see why mprate 2 was used only when any first attack starts. LOL For example, after doing certain attacks with mprate 2 from the script, you start to attack first until you do the following attack. That's when it reverts back to 1 after the first attack. But your answer is totally clear and ondoattackscript does the job right! ;)(y)(y)

Nice to know that I don't have to use takedamagescript for this.

Thank you very much for this. It works perfectly as I thought!

P.S.: Here's my modification.
C:
void main(){
    void self = getlocalvar("self");
    void ani = getentityproperty(self, "animationid");
    int recover;

    if(ani == openborconstant("ANI_FOLLOW1") || ani == openborconstant("ANI_RUNATTACK")){
        recover = 2;
        changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
        //changeentityproperty(entity, "mpset", mp, stable_type, stable, recovery_rate, drop_rate, charge_rate)
    }
    else{
        recover = 1;
        changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
    }

}
 
Last edited:
I accidentally used didhitscript for the attacks. I could see why mprate 2 was used only when any first attack starts. LOL For example, after doing certain attacks with mprate 2 from the script, you start to attack first until you do the following attack. That's when it reverts back to 1 after the first attack. But your answer is totally clear and ondoattackscript does the job right! ;)(y)(y)
Yeah, in cases like that, the ondoattack is better because it works before the collision, then you can see the effect applied instantly.
The didhit/takedamage is useful more in cases where the effects must come after the collision.
In short, the didhit works in the next attack, and the ondoattack works in the current attack.
Glad the script works fine :)
 
@Kratus I have a question regarding the use of #import and #include if I want to use this ondoattack script I have through importing/including another ondoattack script. I get a crash every time I execute certain moves that are in ondoattack script.

This is one separate character's ondoattack script which I'm using but I want to include it with another ondoattack.

Code:
ondoattackscript data/chars/hero01/hero01attack.c

Take a look at the log I have in the attachments.

C:
#import "data/scripts/multihits.c"

void main(){
    void self = getlocalvar("self");
    void ani = getentityproperty(self, "animationid");
    int recover;

    if(ani == openborconstant("ANI_FREESPECIAL35") || ani == openborconstant("ANI_FREESPECIAL36") || ani == openborconstant("ANI_FREESPECIAL37")){
        recover = 2;
        changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
    }else{
        recover = 1;
        changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), recover, NULL(), NULL());
    }
}

Here's another ondoattack I want to include.
C:
#import "data/scripts/main_ondoattack.c"

void main()
{//Script to avoid "multihits" glitch, same as the original SOR2 (NOT USED FOR NOW...)

    //WORKS FOR ATTACKER ONLY
    if(!getlocalvar("which")){
        void self        = getlocalvar("self");
        void other        = getlocalvar("other");
        void atkType    = getlocalvar("attacktype");
        int atkId        = getentityproperty(self, "attackid");

        //AVOID SOME ATTACK TYPES
        if(    atkType != openborconstant("ATK_LAND")        &&
            atkType != openborconstant("ATK_LIFESPAN")    &&
            atkType != openborconstant("ATK_PIT")        &&
            atkType != openborconstant("ATK_TIMEOVER")    ){

            //THE CURRENT ATTACKBOX ID IS SAME AS THE PREVIOUS USED ONE?? DISABLE THE ENGINE HIT HANDLING
            if(atkId == getentityvar(self, "atkId"+other)){changeopenborvariant("lasthitc", 0);}

            //SAVE THE "LAST ATTACKBOX ID" + "CURRENT PLAYER" + "DAMAGED ENTITY"
            setentityvar(self, "atkId"+other, atkId);
        }
    }

    hitVar();
}

main_ondoattack:
C:
void hitVar()
{//Check variables before allow the "HITFX" function to runs in the didhit event
   
    //WORKS FOR ATTACKER ONLY
    if(!getlocalvar("which")){
        void self        = getlocalvar("self");
        void other        = getlocalvar("other");
        void atkType    = getlocalvar("attacktype");
        int atkId        = getlocalvar("attackid");
        float time        = openborvariant("elapsed_time")/2;
       
        //AVOID SOME ATTACK TYPES
        if(    atkType != openborconstant("ATK_NORMAL7")    &&
            atkType != openborconstant("ATK_NORMAL10")    &&
            atkType != openborconstant("ATK_LAND")        &&
            atkType != openborconstant("ATK_LIFESPAN")    &&
            atkType != openborconstant("ATK_PIT")        &&
            atkType != openborconstant("ATK_TIMEOVER")    ){

            //REGISTER THE CURRENT "ATKID+TIME+OTHER" TO AVOID TWO OR MORE SOUNDS AT SAME TIME
            //EVERY "OTHER" IS REGISTERED INTO A UNIQUE VARIABLE
            if(getentityvar(self, "other"+atkId+time) == NULL()){setentityvar(self, "other"+atkId+time, other);}

            //COMPARE THE PREVIOUS SAVED "OTHER" WITH THE CURRENT "OTHER", CONFIRM IF HAS TWO OR MORE AT SAME TIME
            //IF THE "TIME" IS DIFFERENT FOR EACH "OTHER", PROCEED WITH MULTIPLE SOUNDS NORMALLY
            if(other == getentityvar(self, "other"+atkId+time)){setentityvar(self, "hitConfirm", 1);}
        }
    }
}

I also tried making a copy of multihits.c and renamed it to a different name like multihits2.c. I changed the function name of main to something else in multihits2.c and included it that function name in a hero's main ondoattack script. I think I have a problem with #import/#include issues.

If I want to use one ondoattack I have and include these other ondoattack ones, how can I execute certain moves without a crash? (Whether I perform a certain attack, it crashes.) What I want is to have one individual to have some of its own attacks set up and execute without any crash.
 

Attachments

Last edited:
Back
Top Bottom