Im gonna start this message thread for Conversion compiler warnings and errors and how to fix them.
Every time I get a warning or error. I will demonstrate how to fix that warning or error. If you have a warning or error you can not figure out. Leave me a note of the exact error or warning from the compiler
and I will address the message. Also, if any other shard needs help in conversion to 098. Please Let me know. I will help any shard to convert to 098. If you want it "private" email me at jaceace01@sbcglobal.net or if its ok for others to download your "shard script set" then just let all of us know and upload your script set. I will help convert the files. I dont fix "all" the bugs but I will help to get it up and running in 098.
Conversions to 098 Corner
Re: Conversions to 098 Corner
Anyone using the compiled script sets. If you ran into a character riding horse bug. I fixed it. I will explain what I did now before I forget.
The bug: Character dies, and remains on horse. Character can choose a different Horse while on an existing horse. Mount disappears when logging back in. etc
The problem exists when the script looks for the LAYER_MOUNT.
********************************************************************************************************************
Example from tamed.src
the old style of code looked like this in the scripts/ai/tamed.src
********************************************************************************************************************
//make sure they aren't already mounted
if (GetEquipmentByLayer (master, LAYER_MOUNT))
return;
endif
********************************************************************************************************************
The code really says if there is an item in the LAYER_MOUNT slot to exit (which prevents users from riding a second mount while on a first mount)
The problem with this code in 098 is that the return value for GetEquipmentByLayer is always a "true" value. Thus we need to change the way we check for whether character is mounted.
********************************************************************************************************************
New Code:
//make sure they aren't already mounted
var isMounted := ListEquippedItems( master );
foreach item in ( isMounted )
if ( item.objtype == 0xf021 )
return;
endif
endforeach
********************************************************************************************************************
This code does the same thing as the old code, but now it looks for objtype 0xf021. Fixed.
Now for World of Dreams and any other script set having problems.
We are still in the tamed.src file
********************************************************************************************************************
Old code looked like this:
if (mounttype)
if (MoveCharacterToLocation (master, me.x, me.y, me.z, 0))
drop();
set_critical (1);
master.facing := me.facing;
var mount := CreateItemAtLocation (5288, 1176, 0, UOBJ_MOUNT, 1);
if (!mount)
set_critical(0);
return;
endif
mount.color := me.color;
mount.graphic := mounttype;
foreach property in GetObjPropertyNames (me)
if (property != "master")
var value := GetObjProperty (me, property);
SetObjProperty (mount, property, value);
endif
endforeach
SetObjProperty (mount, "petname", me.name);
SetObjProperty (mount, "npctemplate", me.npctemplate);
SetObjProperty (mount, "pethp", CINT (GetVital (me, "Life")/100));
SetObjProperty (mount, "petmana", CINT (GetVital (me, "Mana")/100));
SetObjProperty (mount, "petgraphic", me.graphic);
SetObjProperty (mount, "freetime", freetime);
if (Getobjproperty (me, "summoned"))
SetObjProperty (mount, "summoned", 1);
endif
if (!EquipItem (master, mount))
DestroyItem (mount);
set_critical(0);
return;
endif
KillMe ();
set_critical(0);
following := 0;
guarding := 0;
sleep (5);
endif
endif
********************************************************************************************************************
Notice we assigned "horse data" to the mount so we can revive the "horse".
********************************************************************************************************************
Fix:
if (mounttype)
if (MoveObjectToLocation( master, me.x, me.y, me.z, realm := _DEFAULT_REALM,
flags := MOVEOBJECT_NORMAL ))
drop();
set_critical (1);
master.facing := me.facing;
var mount := CreateItemAtLocation (5288, 1176, 0, UOBJ_MOUNT, 1);
if (!mount)
set_critical(0);
return;
endif
var saddle := CreateItemInBackpack( master, 0x1F13, amount := 1 );
if ( !saddle )
set_critical(0);
return;
endif
saddle.movable := 0;
saddle.weight := 0;
saddle.desc := "a saddle";
saddle.name := "a saddle";
SetObjProperty(master, "saddle", saddle.serial);
mount.color := me.color;
mount.graphic := mounttype;
foreach property in GetObjPropertyNames (me)
if (property != "master")
var value := GetObjProperty (me, property);
SetObjProperty (saddle, property, value);
endif
endforeach
SetObjProperty (saddle, "petname", me.name);
SetObjProperty (saddle, "npctemplate", me.npctemplate);
SetObjProperty (saddle, "pethp", CINT (GetVital (me, "Life")/100));
SetObjProperty (saddle, "petmana", CINT (GetVital (me, "Mana")/100));
SetObjProperty (saddle, "petgraphic", me.graphic);
SetObjProperty (saddle, "freetime", freetime);
if (Getobjproperty (me, "summoned"))
SetObjProperty (saddle, "summoned", 1);
endif
if (!EquipItem (master, mount))
DestroyItem (mount);
set_critical(0);
return;
endif
KillMe ();
set_critical(0);
following := 0;
guarding := 0;
sleep (5);
endif
endif
********************************************************************************************************************
Note: I set a new object property on the owner called saddle. I created a new "non movable" item in the players backpack called a "saddle". I then transfered all the "horse" data to the "saddle".
This will produce the similar effects that the older code did without errors.
Now, Lets look at how we bring the horse back to life after say "a death event".
From the file: :drocket:dismount.src
********************************************************************************************************************
the old code:
if (!mount)
mount := GetEquipmentByLayer (character, LAYER_MOUNT);
if (!mount)
mount := TryToFindMount (character);
if (!mount)
return 0;
endif
endif
endif
if (!GetObjProperty (mount, "npctemplate"))
SendGMErrorMessage ("Dismount: Doing old dismount thing for " + character.name, 1);
return DoOldDismount (character, mount);
endif
********************************************************************************************************************
what it does: if the mount var is not supplied to check the LAYER_MOUNT if its not there then try to find it elsewhere. keep looking... if it cant find it exit.... if it can recreate the horse.
********************************************************************************************************************
new code:
if (!mount)
// verify character is mounted
var results := 0;
var isMounted := ListEquippedItems( character );
foreach item in ( isMounted )
if ( item.objtype == 0xf021 )
results := 1;
endif
endforeach
if (!results)
return 0;
endif
var mountserial := GetObjProperty(character, "saddle");
if (!mountserial)
return 0;
endif
mount := SystemFindObjectBySerial( mountserial, sysfind_flags := 0 );
if(!mount)
return 0;
endif
// actually destroy the mounted item 0xf021
var mounted := GetEquipmentByLayer( character, LAYER_MOUNT );
DestroyItem(mounted);
// remove the "saddle" property
EraseObjProperty(character, "saddle");
endif
if (!GetObjProperty (mount, "npctemplate"))
SendGMErrorMessage ("Dismount: Doing old dismount thing for " + character.name, 1);
return DoOldDismount (character, mount);
endif
********************************************************************************************************************
What it does: Now we again use the new method for checking for a mount. we check the character for the "saddle" serialnumber. We do a system find for the serial number (which produces the mount)
Destroy the LAYER_MOUNT (which actually dismounts the character). Erase the "saddle" property off the character.
Once we have the "mount" and have created the horse, etc.
we just destroyitem(mount);
This should point you on your way to fixing this bug if you have this bug....
Happy Gaming!
The bug: Character dies, and remains on horse. Character can choose a different Horse while on an existing horse. Mount disappears when logging back in. etc
The problem exists when the script looks for the LAYER_MOUNT.
********************************************************************************************************************
Example from tamed.src
the old style of code looked like this in the scripts/ai/tamed.src
********************************************************************************************************************
//make sure they aren't already mounted
if (GetEquipmentByLayer (master, LAYER_MOUNT))
return;
endif
********************************************************************************************************************
The code really says if there is an item in the LAYER_MOUNT slot to exit (which prevents users from riding a second mount while on a first mount)
The problem with this code in 098 is that the return value for GetEquipmentByLayer is always a "true" value. Thus we need to change the way we check for whether character is mounted.
********************************************************************************************************************
New Code:
//make sure they aren't already mounted
var isMounted := ListEquippedItems( master );
foreach item in ( isMounted )
if ( item.objtype == 0xf021 )
return;
endif
endforeach
********************************************************************************************************************
This code does the same thing as the old code, but now it looks for objtype 0xf021. Fixed.
Now for World of Dreams and any other script set having problems.
We are still in the tamed.src file
********************************************************************************************************************
Old code looked like this:
if (mounttype)
if (MoveCharacterToLocation (master, me.x, me.y, me.z, 0))
drop();
set_critical (1);
master.facing := me.facing;
var mount := CreateItemAtLocation (5288, 1176, 0, UOBJ_MOUNT, 1);
if (!mount)
set_critical(0);
return;
endif
mount.color := me.color;
mount.graphic := mounttype;
foreach property in GetObjPropertyNames (me)
if (property != "master")
var value := GetObjProperty (me, property);
SetObjProperty (mount, property, value);
endif
endforeach
SetObjProperty (mount, "petname", me.name);
SetObjProperty (mount, "npctemplate", me.npctemplate);
SetObjProperty (mount, "pethp", CINT (GetVital (me, "Life")/100));
SetObjProperty (mount, "petmana", CINT (GetVital (me, "Mana")/100));
SetObjProperty (mount, "petgraphic", me.graphic);
SetObjProperty (mount, "freetime", freetime);
if (Getobjproperty (me, "summoned"))
SetObjProperty (mount, "summoned", 1);
endif
if (!EquipItem (master, mount))
DestroyItem (mount);
set_critical(0);
return;
endif
KillMe ();
set_critical(0);
following := 0;
guarding := 0;
sleep (5);
endif
endif
********************************************************************************************************************
Notice we assigned "horse data" to the mount so we can revive the "horse".
********************************************************************************************************************
Fix:
if (mounttype)
if (MoveObjectToLocation( master, me.x, me.y, me.z, realm := _DEFAULT_REALM,
flags := MOVEOBJECT_NORMAL ))
drop();
set_critical (1);
master.facing := me.facing;
var mount := CreateItemAtLocation (5288, 1176, 0, UOBJ_MOUNT, 1);
if (!mount)
set_critical(0);
return;
endif
var saddle := CreateItemInBackpack( master, 0x1F13, amount := 1 );
if ( !saddle )
set_critical(0);
return;
endif
saddle.movable := 0;
saddle.weight := 0;
saddle.desc := "a saddle";
saddle.name := "a saddle";
SetObjProperty(master, "saddle", saddle.serial);
mount.color := me.color;
mount.graphic := mounttype;
foreach property in GetObjPropertyNames (me)
if (property != "master")
var value := GetObjProperty (me, property);
SetObjProperty (saddle, property, value);
endif
endforeach
SetObjProperty (saddle, "petname", me.name);
SetObjProperty (saddle, "npctemplate", me.npctemplate);
SetObjProperty (saddle, "pethp", CINT (GetVital (me, "Life")/100));
SetObjProperty (saddle, "petmana", CINT (GetVital (me, "Mana")/100));
SetObjProperty (saddle, "petgraphic", me.graphic);
SetObjProperty (saddle, "freetime", freetime);
if (Getobjproperty (me, "summoned"))
SetObjProperty (saddle, "summoned", 1);
endif
if (!EquipItem (master, mount))
DestroyItem (mount);
set_critical(0);
return;
endif
KillMe ();
set_critical(0);
following := 0;
guarding := 0;
sleep (5);
endif
endif
********************************************************************************************************************
Note: I set a new object property on the owner called saddle. I created a new "non movable" item in the players backpack called a "saddle". I then transfered all the "horse" data to the "saddle".
This will produce the similar effects that the older code did without errors.
Now, Lets look at how we bring the horse back to life after say "a death event".
From the file: :drocket:dismount.src
********************************************************************************************************************
the old code:
if (!mount)
mount := GetEquipmentByLayer (character, LAYER_MOUNT);
if (!mount)
mount := TryToFindMount (character);
if (!mount)
return 0;
endif
endif
endif
if (!GetObjProperty (mount, "npctemplate"))
SendGMErrorMessage ("Dismount: Doing old dismount thing for " + character.name, 1);
return DoOldDismount (character, mount);
endif
********************************************************************************************************************
what it does: if the mount var is not supplied to check the LAYER_MOUNT if its not there then try to find it elsewhere. keep looking... if it cant find it exit.... if it can recreate the horse.
********************************************************************************************************************
new code:
if (!mount)
// verify character is mounted
var results := 0;
var isMounted := ListEquippedItems( character );
foreach item in ( isMounted )
if ( item.objtype == 0xf021 )
results := 1;
endif
endforeach
if (!results)
return 0;
endif
var mountserial := GetObjProperty(character, "saddle");
if (!mountserial)
return 0;
endif
mount := SystemFindObjectBySerial( mountserial, sysfind_flags := 0 );
if(!mount)
return 0;
endif
// actually destroy the mounted item 0xf021
var mounted := GetEquipmentByLayer( character, LAYER_MOUNT );
DestroyItem(mounted);
// remove the "saddle" property
EraseObjProperty(character, "saddle");
endif
if (!GetObjProperty (mount, "npctemplate"))
SendGMErrorMessage ("Dismount: Doing old dismount thing for " + character.name, 1);
return DoOldDismount (character, mount);
endif
********************************************************************************************************************
What it does: Now we again use the new method for checking for a mount. we check the character for the "saddle" serialnumber. We do a system find for the serial number (which produces the mount)
Destroy the LAYER_MOUNT (which actually dismounts the character). Erase the "saddle" property off the character.
Once we have the "mount" and have created the horse, etc.
we just destroyitem(mount);
This should point you on your way to fixing this bug if you have this bug....
Happy Gaming!