iconposition entityproperty

O Ilusionista

Captain 100K
I'm trying to work with the "iconposition" entity property, and I noticed that you can't change the icon's position using "changeentityproperty"—you use the command and nothing happens. So I think—at least in version 3—"iconproperty" seems to be read-only.

However, I tried to get the iconproperty value using getentityproperty()
C-like:
void self = getlocalvar("self");
    int iconPos = getentityproperty(self, "iconposition");
    settextobj(1, 240,  150, 2, 999999999, iconPos, 300+openborvariant("elapsed_time"));

but the engine closes with the following error:
Script function 'getentityproperty' returned an exception, check the manual for details.
parameters: #245495040, 79,

Am I doing something wrong?
 
Solution
I'm trying to work with the "iconposition" entity property, and I noticed that you can't change the icon's position using "changeentityproperty"—you use the command and nothing happens.
You can change that "iconposition" entity property just fine, but you have to have iconposition in your character header. Doing it in script without that one in the header, leaving only icon line there, is not gonna work. By default, I placed it off screen in the header. But with script, I let it show on screen.

Code:
name Ken
type player
health 100
gfxshadow    1
speed   15
nolife 1
nodieblink 2
turndelay 9999999999999999999999999999999
atchain 1 #Light Punch
com a2 freespecial #Medium Punch
com a3 freespecial2 #Heavy Punch
com j...
I'm trying to work with the "iconposition" entity property, and I noticed that you can't change the icon's position using "changeentityproperty"—you use the command and nothing happens. So I think—at least in version 3—"iconproperty" seems to be read-only.

However, I tried to get the iconproperty value using getentityproperty()
C-like:
void self = getlocalvar("self");
    int iconPos = getentityproperty(self, "iconposition");
    settextobj(1, 240,  150, 2, 999999999, iconPos, 300+openborvariant("elapsed_time"));

but the engine closes with the following error:


Am I doing something wrong?

Looking at the 3.0 code, there is indeed no "get" code for icon position. Must have been a silly oversight. There is however, code to change icon position, so I'm not sure why that aspect isn't working for you.

C:
 case _ep_iconposition:
    {
        if(SUCCEEDED(ScriptVariant_IntegerValue(varlist[2], &ltemp)))
        {
            ent->modeldata.icon.position.x = (LONG)ltemp;
        }
        if(paramCount > 3 && SUCCEEDED(ScriptVariant_IntegerValue(varlist[3], &ltemp)))
        {
            ent->modeldata.icon.position.y = (LONG)ltemp;
        }
        break;
    }

I'll need to dig a little deeper. I can't do it today, this is our big application deployment (the thing keeping me busy I mentioned in PM), but after that I should have more time.

DC
 
I'm trying to work with the "iconposition" entity property, and I noticed that you can't change the icon's position using "changeentityproperty"—you use the command and nothing happens.
You can change that "iconposition" entity property just fine, but you have to have iconposition in your character header. Doing it in script without that one in the header, leaving only icon line there, is not gonna work. By default, I placed it off screen in the header. But with script, I let it show on screen.

Code:
name Ken
type player
health 100
gfxshadow    1
speed   15
nolife 1
nodieblink 2
turndelay 9999999999999999999999999999999
atchain 1 #Light Punch
com a2 freespecial #Medium Punch
com a3 freespecial2 #Heavy Punch
com j freespecial3 #Light Kick
com s freespecial4 #Medium Kick
com a4 freespecial5 #Heavy Kick
blockpain 1
falldie 2
ondrawscript data/scripts/playerhp.c
ondeathscript data/scripts/death.c
script data/chars/ken/ken.c
animationscript data/scripts/script.c
icon data/profiles/ken.png 1
onpainscript data/chars/ken/kenonpain.c
ondoattackscript data/chars/ken/kenondoattack.c
takedamagescript data/scripts/guard.c
onblockpscript data/scripts/collision.c
subject_to_platform 1
load KHadoken
load black-fade-out
#load fsrk
load fsrk1
load fsrk2
load shoryukenh
load ken_continue
com d f a freespecial11 #Light Hadoken
com d f a2 freespecial12 #Medium Hadoken
com d f a3 freespecial13 #High Hadoken
com f d f a freespecial14 #Light Shoryuken
com f d f a2 freespecial15 #Medium Shoryuken
com f d f a3 freespecial16 #High Shoryuken
com d b j freespecial17 #Low Tatsumaki Senpuu Kyaku
com d b s freespecial18 #Medium Tatsumaki Senpuu Kyaku
com d b a4 freespecial19 #High Tatsumaki Senpuu Kyaku
com d b a freespecial21 #Forward dodge?
com d b a2 freespecial22
com d b a3 freespecial23
com b d b j freespecial24 #Moratta!
com b d b s freespecial25 #Moratta!
com b d b a4 freespecial26 #Moratta!

palette data/profiles/ken.png
alternatepal data/chars/ken/alt1.png
alternatepal data/chars/ken/alt2.png
alternatepal data/chars/ken/alt3.png
alternatepal data/chars/ken/alt4.png
alternatepal data/chars/ken/alt5.png
alternatepal data/chars/ken/alt6.png
alternatepal data/chars/ken/alt7.png

diesound data/sounds/fighters/ken/SND_PL01_0.wav

iconposition 62 -121
lifebarstatus 100 7 1 1 0 -9999 -9999 -9999 -9999 # lifebarstatus {width} {height} {noborder} {type} {orientation} {border} {shadow} {graph} {backfill}
lifeposition 80 -44
nameposition 155 -83

C:
void health() // Player health
{//Update script with player lifebar
//Calling main player
    void self = getlocalvar("self");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void P1Name = getentityproperty(P1, "name");
    void P2Name = getentityproperty(P2, "name");
    int P1HP = getentityproperty(P1, "health");
    int P2HP = getentityproperty(P2, "health");
    int P1MaxHP = getentityproperty(P1, "maxhealth");
    int P2MaxHP = getentityproperty(P2, "maxhealth");
    int P1Health = 114*P1HP/P1MaxHP;
    int P2Health = 114*P2HP/P2MaxHP;

    int P1MP = getentityproperty(P1, "mp");
    int P2MP = getentityproperty(P2, "mp");
    int P1MaxMP = getentityproperty(P1, "maxmp");
    int P2MaxMP = getentityproperty(P2, "maxmp");
    int P1Mana = 70*P1MP/P1MaxMP;
    int P2Mana = 70*P2MP/P2MaxMP;

    int P1Score = getplayerproperty(0, "score");
    int P2Score = getplayerproperty(1, "score");

    int hres = openborvariant("hresolution");
    void Branch = openborvariant("current_branch");

    void T1 = findtarget(P1);
    void T2 = findtarget(P2);

    int THP1 = getentityproperty(T1, "health");
    int THP2 = getentityproperty(T2, "health");
   

    if(getentityvar(self, "playerOne") == NULL()){setentityvar(self, "playerOne", P1Health);} // SET FOR PLAYER'S HEALTH BAR SMOOTH REDUCTION INDEPENDENTLY
    if(getentityvar(self, "playerTwo") == NULL()){setentityvar(self, "playerTwo", P2Health);}

    if(getglobalvar("hpBar1") == NULL()){
        setglobalvar("hpBar1", loadsprite("data/sprites/hud.png"));
    }

    void hpBar1 = getglobalvar("hpBar1");

    if(!hpBar1){

    hpBar1 = loadsprite("data/sprites/hud.gif");
    setglobalvar("hpBar1", hpBar1);
    }
   
    if(P1 != NULL() && Branch != "Strength_Training"){
        drawbox((150-P1Health),6,P1Health,2,1800,rgbcolor(255,234,41),0);
        drawbox((150-P1Health),8,P1Health,1,1800,rgbcolor(255,226,0),0);
        drawbox((150-P1Health),9,P1Health,1,1800,rgbcolor(255,206,24),0);
        drawbox((150-P1Health),10,P1Health,1,1800,rgbcolor(246,194,0),0);
        drawbox((150-P1Health),11,P1Health,1,1800,rgbcolor(230,141,0),0);
        drawbox((150-P1Health),12,P1Health,1,1800,rgbcolor(222,92,0),0);

        drawbox((150-getentityvar(self, "playerOne")),6,getentityvar(self, "playerOne"),7,1700,rgbcolor(181,26,0),0);

        drawstring(33, 55, 1, P1Name);
        drawstring(66, 43, 1, P1Score);
        changeentityproperty(P1, "iconposition", -56, 21);

   
    }if(P2 != NULL() && Branch != "Strength_Training"){
        drawbox(176,6,P2Health,2,1800,rgbcolor(255,234,41),0);
        drawbox(176,8,P2Health,1,1800,rgbcolor(255,226,0),0);
        drawbox(176,9,P2Health,1,1800,rgbcolor(255,206,24),0);
        drawbox(176,10,P2Health,1,1800,rgbcolor(246,194,0),0);
        drawbox(176,11,P2Health,1,1800,rgbcolor(230,141,0),0);
        drawbox(176,12,P2Health,1,1800,rgbcolor(222,92,0),0);
        drawbox(176,6,getentityvar(self, "playerTwo"),7,1700,rgbcolor(181,26,0),0);
        drawstring(hres-27-strwidth(P2Name, 0), 55, 0, P2Name);
        drawstring(175, 43, 0, P2Score);
    }
   
    if(Branch == "Strength_Training"){
        if(P1 != NULL()){
            drawstring(33, 55, 1, P1Name);
            drawstring(66, 43, 1, P1Score);
            changeentityproperty(P1, "iconposition", -56, -41);
            drawbox((150-P1Health),-106,P1Health,2,1800,rgbcolor(255,234,41),0);
            drawbox((150-P1Health),-108,P1Health,1,1800,rgbcolor(255,226,0),0);
            drawbox((150-P1Health),-109,P1Health,1,1800,rgbcolor(255,206,24),0);
            drawbox((150-P1Health),-110,P1Health,1,1800,rgbcolor(246,194,0),0);
            drawbox((150-P1Health),-111,P1Health,1,1800,rgbcolor(230,141,0),0);
            drawbox((150-P1Health),-112,P1Health,1,1800,rgbcolor(222,92,0),0);
            drawbox((150-getentityvar(self,0)),-106,getentityvar(self,0),7,1700,rgbcolor(181,26,0),0);
        }
        if(P2 != NULL()){
            drawbox(176,-106,P2Health,2,1800,rgbcolor(255,234,41),0);
            drawbox(176,-108,P2Health,1,1800,rgbcolor(255,226,0),0);
            drawbox(176,-109,P2Health,1,1800,rgbcolor(255,206,24),0);
            drawbox(176,-110,P2Health,1,1800,rgbcolor(246,194,0),0);
            drawbox(176,-111,P2Health,1,1800,rgbcolor(230,141,0),0);
            drawbox(176,-112,P2Health,1,1800,rgbcolor(222,92,0),0);
            drawbox(176,-106,getentityvar(self,0),6,1700,rgbcolor(181,26,0),-1);
            changeentityproperty(P2, "iconposition", 262, -41);
            drawstring(hres-27-strwidth(P2Name, 0), 55, 0, P2Name); // drawstring(x,y,font,text,z);
            drawstring(175, 43, 0, P2Score);
        }
    }
   
    if(P1Health < getentityvar(self, "playerOne")){ // if hp box smaller then damage box
        if(getentityvar(self,1)==NULL()){
            setentityvar(self,1,0); //set entity var 1 to zero if null this is a timer
        }
        setentityvar(self,1,getentityvar(self,1)+1); //add 1 to timer this will run every game tick
        if(getentityvar(self,1) > 7){ //if timer over 7
            setentityvar(self, "playerOne",getentityvar(self, "playerOne")-1); //reduce displayed damage by 1
            setentityvar(self,1,0); //reset timer to zero this will cause a loop untill damage is the same as hp
        }
    }

    if(P2Health < getentityvar(self, "playerTwo")){
        if(getentityvar(self,1)==NULL()){
            setentityvar(self,1,0);
        }
        setentityvar(self,1,getentityvar(self,1)+1);
        if(getentityvar(self,1) > 7){
            setentityvar(self, "playerTwo",getentityvar(self, "playerTwo")-1);
            setentityvar(self,1,0);
        }
    }
}

In levels.txt, I did place p1icon offscreen for iconposition to show in script but did leave p2icon on screen for some reason. You don't see "iconposition" for the player 2 side under the line that's not for the bonus stage, but it's exclusively off screen with script for that. It's about having a special case on my part like you see bonus stages in the classic SF2 game where you don't see characters' lifebars above them at all.

Code:
p1icon -56 -100 #-56 21
p2icon 262 21
 
Solution
Back
Top Bottom