Helping with a Shapeshifting script

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Eliath
New User
Posts: 14
Joined: Sun Aug 27, 2006 6:12 pm

Helping with a Shapeshifting script

Post 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!
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post 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.
Eliath
New User
Posts: 14
Joined: Sun Aug 27, 2006 6:12 pm

Post 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.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post 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.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post 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
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post 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
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post 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
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

Liar, you just want to sail the stars in malas, don't lie. :)
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post 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*
User avatar
Tritan
Grandmaster Poster
Posts: 147
Joined: Sat Feb 04, 2006 8:17 am

Post 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.
Eliath
New User
Posts: 14
Joined: Sun Aug 27, 2006 6:12 pm

Post by Eliath »

sorry guys, thanks for your help. But i had this solved a few hours after my last post.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

That's alright. I need all the practice I can get with gumps.
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post 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 :)
Post Reply