Page 1 of 1

Helping with a Shapeshifting script

Posted: Tue Sep 05, 2006 11:33 pm
by Eliath
use uo;
use os;

include ":System:Include/Client";

program DotCommand( who)
var i;
var graphic, color;
// var splitText := array;
var shapeChanger;
var changeGraphic;
var normalGraphic;
var critterGraphic;
var humanGraphic;
var normalColor;
var critterColor;
var changeColor;
// var objtype;

shapeChanger := GetObjProperty( who, TGTOPT_NOCHECK_LOS );
if (GetObjProperty( who, "SubRaceName" ) == "Cat")
graphic := 0xC9 ;
color := 1113 ;
SendSysMessage( who, "You morph into a feline" );

elseif (GetObjProperty( who, "SubRaceName" ) == "Wolf")
graphic := 0xE1 ;
color := 1100 ;
SendSysMessage( who, "You morph into a wolf" );

elseif (GetObjProperty( who, "SubRaceName" ) == "Dragon")
graphic := 0x3B ;
color := 1128 ;
SendSysMessage( who, "You morph into a dragon" );

else return;
endif

SetObjProperty( shapeChanger, "normalgraphic", shapeChanger.graphic );
SetObjProperty( shapeChanger, "crittergraphic", graphic );
SetObjProperty( shapeChanger, "skincolor", shapeChanger.color );
SetObjProperty( who, "crittercolor", color );


normalGraphic := GetObjProperty( who, "normalgraphic" ) ;
critterGraphic := GetObjProperty( who, "crittergraphic" );
normalColor := GetObjProperty( who, "skincolor" );
critterColor := GetObjProperty( who, "critterColor" );


if ( who.graphic == critterGraphic );
changeGraphic := normalGraphic;
changeColor := normalColor;
who.color := changeColor;
who.graphic := changeGraphic;

SendSysMessage( who, "You morph into a human" );

else
changeGraphic := critterGraphic;
changeColor := critterColor;
who.graphic := changeGraphic;
who.color := changeColor;

SendSysMessage( who, "You morph into a animal" );

endif


endprogram
Basically the script does everything but turn the shapeshifted player back into human form. I've been messing withthis script for days and now i have hit a wall. Help please!

Posted: Wed Sep 06, 2006 1:37 am
by Yukiko
Try this revised version.

Code: Select all


use uo; 
use os; 

include ":System:Include/Client"; 


program DotCommand( who) 
    var i; 
    var graphic, color; 
    // var splitText := array; 
    var shapeChanger; 
    var changeGraphic; 
    var normalGraphic; 
    var critterGraphic; 
    var humanGraphic; 
    var normalColor; 
    var critterColor; 
    var changeColor; 
    // var objtype; 

//    shapeChanger := GetObjProperty( who, TGTOPT_NOCHECK_LOS ); 
    if (GetObjProperty( who, "SubRaceName" ) == "Cat") 
        graphic := 0xC9 ; 
        color := 1113 ; 
        SendSysMessage( who, "You morph into a feline" ); 
    
    elseif (GetObjProperty( who, "SubRaceName" ) == "Wolf") 
        graphic := 0xE1 ; 
        color := 1100 ; 
        SendSysMessage( who, "You morph into a wolf" ); 
    
    elseif (GetObjProperty( who, "SubRaceName" ) == "Dragon") 
        graphic := 0x3B ; 
        color := 1128 ; 
        SendSysMessage( who, "You morph into a dragon" ); 
        
    else
        return; 
    endif 
    if (!GetObjProperty ( who, "crittergraphic"))
        SetObjProperty( who, "normalgraphic", who.graphic ); 
        SetObjProperty( who, "crittergraphic", graphic); 
        SetObjProperty( who, "skincolor", who.color ); 
        SetObjProperty( who, "crittercolor", color );
    endif
        
    
        normalGraphic := CInt(GetObjProperty( who, "normalgraphic") ) ;
        critterGraphic := CInt(GetObjProperty( who, "crittergraphic" ));
        normalColor := GetObjProperty( who, "skincolor" ); 
        critterColor := GetObjProperty( who, "critterColor" ); 

    
    if ( who.graphic == critterGraphic ); 
        changeGraphic := normalGraphic; 
        changeColor := normalColor; 
        who.color := changeColor; 
        who.graphic := changeGraphic;
        EraseObjProperty( who, "normalgraphic"); 
        EraseObjProperty( who, "crittergraphic"); 
        EraseObjProperty( who, "skincolor"); 
        EraseObjProperty( who, "crittercolor");
        SendSysMessage( who, "You morph into a human" ); 
    
    else
        changeGraphic := critterGraphic; 
        changeColor := critterColor;
        who.graphic := changeGraphic; 
        who.color := changeColor; 
    
        SendSysMessage( who, "You morph into a animal" ); 
    
    endif 
    
    
endprogram

You were setting the normal graphic to the users current graphic upon entering the script. Which if they were already morphed just kept them morphed. Plus you have some references to the var "shapeChanger" instead of "who" in some of your objectproperty function calls.

Not sure what this line at the beginning was for either "shapeChanger := GetObjProperty( who, TGTOPT_NOCHECK_LOS )".

Anyway, I think it works now.

Oh and try to use tabs when creating source code. It makes it so much more readable. Also the code button works better for posting source code than the quote button.

Posted: Wed Sep 06, 2006 2:11 am
by Eliath

Code: Select all

use uo; 
use os; 

include ":System:Include/Client"; 


program DotCommand( who) 
    var i; 
    var graphic, color; 
    var changeGraphic; 
    var normalGraphic; 
    var critterGraphic; 
    var normalColor; 
    var critterColor; 
    var changeColor; 
 


    if (GetObjProperty( who, "SubRaceName" ) == "Cat") 
        graphic := 0xC9 ; 
        color := 1113 ; 

    
    elseif (GetObjProperty( who, "SubRaceName" ) == "Wolf") 
        graphic := 0xE1 ; 
        color := 1100 ; 

    
    elseif (GetObjProperty( who, "SubRaceName" ) == "Dragon") 
        graphic := 0x3B ; 
        color := 1128 ; 

        
    else 
        return; 
    endif 
    if (!GetObjProperty ( who, "crittergraphic")) 
        SetObjProperty( who, "normalgraphic", who.graphic ); 
        SetObjProperty( who, "crittergraphic", graphic); 
        SetObjProperty( who, "normalcolor", who.color ); 
        SetObjProperty( who, "crittercolor", color ); 
    endif 
        
    
        normalGraphic := CInt(GetObjProperty( who, "normalgraphic") ) ; 
        critterGraphic := CInt(GetObjProperty( who, "crittergraphic" )); 
        normalColor := GetObjProperty( who, "normalcolor" ); 
        critterColor := GetObjProperty( who, "critterColor" ); 

    
    if ( who.graphic == critterGraphic );
 
        EraseObjProperty( who, "crittergraphic"); 

        EraseObjProperty( who, "crittercolor");  
        changeGraphic := normalGraphic; 
        changeColor := normalColor; 
        who.color := changeColor; 
        who.graphic := changeGraphic; 

        SendSysMessage( who, "You morph into a human" ); 
    
    else
        changeGraphic := critterGraphic; 
        changeColor := critterColor; 
        who.graphic := changeGraphic; 
        who.color := changeColor; 
    
        SendSysMessage( who, "You morph into a animal" ); 
    
    endif 
    
    
endprogram
This is the revised scriptset i came up with, after trying yukiko's revised version. However none of these work and the original problem is still there. Where i can't revert back to human mode. It does go through the human if statement, and obviously something is wrong in there.

Posted: Wed Sep 06, 2006 3:43 am
by Yukiko
I have tested my version with all three categories of SubRaceName and it works fine for me switching back and forth from human to critter.

The only difference between my version on my machine and the one I posted is my client.inc file's location. However I commented out the include statement for that and got a good compile. So apparently there is no need to include the client.inc anyway.

Posted: Wed Sep 06, 2006 2:42 pm
by Yukiko
Just a quick note:

You will have to start from a normal graphic in order for my script to work. It assumes that you are not morphed the first time you use it. So if you are testing it with a character that was morphed with your version you won't change back to human. First set your proper graphic (0x191 for female or 0x190 for male) and your proper colour. Then test my script.

Uhm...well, it was supposed to be a quick note.
:P

Posted: Wed Sep 06, 2006 2:47 pm
by MuadDib
ANd it may be a really good idea, to make it just "undo" them back to human if they are already morphed, and cast it again. That is a good way to keep the info straight on them

Posted: Wed Sep 06, 2006 4:37 pm
by Yukiko
Yes you're right Maud. Had I given more time to the script I would have rewritten it entirely but I was trying to get it operational for them AQAP (As Quickly As Possible). Might do a revised version anyway as I am going to implement something like this on my shard *cough* when I get a chance.

:P

Posted: Wed Sep 06, 2006 5:03 pm
by MuadDib
Liar, you just want to sail the stars in malas, don't lie. :)

Posted: Wed Sep 06, 2006 8:17 pm
by Yukiko
Nah! I just want to stay the top poster on the Penultima OnLine Forums.

*grins*


Well, sailing the stars would be really sweet too.

*giggles*

Posted: Thu Sep 07, 2006 2:48 am
by Tritan
I just got back to this topic and there is already a script made for this. It was created by Mithril for Sanctuary and would need some slight modifications for what you need here.

But it appears that it is already done so good luck.

Posted: Thu Sep 07, 2006 3:26 am
by Eliath
sorry guys, thanks for your help. But i had this solved a few hours after my last post.

Posted: Thu Sep 07, 2006 6:03 pm
by Yukiko
That's alright. I need all the practice I can get with gumps.

Posted: Thu Sep 07, 2006 6:29 pm
by MuadDib
You post spammer! You are just trying to build your post count! I KNEW IT!

Ok, so maybe I am to, eat me :)