PenUltima Online

It is currently Fri Sep 05, 2008 1:43 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Still in practice
PostPosted: Tue Jul 01, 2008 8:20 am 
Offline

Joined: Sat Apr 08, 2006 4:09 am
Posts: 28
Yeah hey it's me again. I've been continuing my self-learning in Escript, but it seems I have gotten myself stuck at trying to create a cloak that when equipped will hide you and let you stealth 2d6+13 steps.

The method I thought I'd use is this:


I'll have an item that when is equipped calls the script "invis_cloak.src", and when unequipped calls the script "invis_cloak_off.src".

The equipscript looks like this:


Code:
use uo;
use util;


program InvisibilityCloakOn(player, cloak)

var Time := ReadGameClock();
var WaitTime := GetObjProperty(player, "InvisCloakTime");
if (Time < WaitTime)
var TimeLeft := (WaitTime - Time);
PrintTextAbovePrivate(player, ("The cloak needs to recharge. You feel it will take " + TimeLeft + " seconds before you can use it.), player);
return;
endif

var orcolor := GetObjProperty(cloak, "color");
SetObjProperty(cloak, "originalcolor", orcolor);
SetObjProperty(cloak, "color", 1);
SetObjProperty(player, "hidden", 1);
SetObjProperty(player, "stealthsteps", (2d6+13));
SetObjProperty(player, "InvisCloakTime", (ReadGameClock() + 60));


endprogram


And the unequip code looks like this:

Code:
use uo;
use util;

program InvisibilityCloakOff(player, cloak)

var orcolor := GetObjProperty(cloak, "originalcolor");
cloak.color := orcolor;

endprogram



The itemdesc.cfg file in the config folder has this code:


Code:
Item 0x5002
{
   Name      inviscloak
   Desc      Invisibility Cloak
   Graphic      0x1515
   maxhp      20
   AR      4
   Script      
   controlscript   :combat:itemControl
   destroyscript   :combat:destroy
   equipscript   invis_cloak
   unequipscript   invis_cloak_off
}




Both the .src files are located in ...\scripts\custom


Help would be greatly appreciated.
Thank you / Lunne


Top
 Profile  
 
 Post subject: Re: Still in practice
PostPosted: Tue Jul 01, 2008 8:33 am 
Offline

Joined: Sun Feb 05, 2006 4:35 pm
Posts: 160
Location: Poland
invis_cloak.src :

Code:
use uo;
use util;


program InvisibilityCloakOn(player, cloak)

var WaitTime := GetObjProperty(player, "InvisCloakTime")
if(!WaitTime)
  SetObjProperty(player, "InvisCloakTime", ReadGameClock());
endif
if (ReadGameClock() < WaitTime)
var TimeLeft := WaitTime - ReadGameClock();
PrintTextAbovePrivate(player, "The cloak needs to recharge. You feel it will take " + TimeLeft + " seconds before you can use it.", player);
return 0;
endif

var orcolor := GetObjProperty(cloak, "color");
SetObjProperty(cloak, "originalcolor", orcolor);
SetObjProperty(cloak, "color", 1);
player.stealthsteps := RandomDiceRoll(2d6)+13;
SetObjProperty(player, "InvisCloakTime", ReadGameClock() + 60);


endprogram



Where do you set properties originalcolor and color ? what do you want them to do? And just one tip: don't type all operations in brackets

_________________
Shutdown();


Last edited by qrak on Tue Jul 01, 2008 8:36 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 8:35 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 209
You have misunderstood the concept of (custom) properties.

See, each object has its own properties: character, in example, has "hidden", "stealthsteps", which you'll want to alter. Scriptwise you reach them like this: object.property. Simple as that.

Code:
// Hide player and give him some stealthsteps.
who.hidden := 1;
who.stealthsteps := 5 + RandomInt(10);

// Print how many steps he got:
print(who.name + " has " + who.stealthsteps + " stealthsteps");


Object's properties are currently handled by core, and are thus hardcoded. See the possible objects' properties and values from here: http://docs.polserver.com/pol097/objref.php.

Custom properties (CProps), on the other hand, allow scripter to create own properties in addition to the normal properties each object of the same type has. You can use those with either GetObjProperty(object, property), SetObjProperty(object, property, value) or EraseObjProperty(object, property), or using methods: object.GetProp(property), object.SetProp(property, value), object.EraseProp(property). GetObjPropertyNames(object) and object.PropNames() allow you to list existing custom properties.

It looked like you already knew how to play with those.

In the end, you just need to be careful when to use custom property and when object's property.


(Edit: fix: added object parameter to functions)


Last edited by ncrsn on Wed Jul 02, 2008 4:48 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 02, 2008 4:42 am 
Offline

Joined: Sat Apr 08, 2006 4:09 am
Posts: 28
qrak:
I wanted the cloak to be able to spawn with different colors, but always go black when equipped and activated.


ncrsn:
I think I understand what you mean. I will alter all the properties to the object.property form. Results coming soon.
Thank you very much.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 02, 2008 5:02 am 
Offline

Joined: Sat Apr 08, 2006 4:09 am
Posts: 28
The script seems to be functioning now, at least I can compile it.
There's a problem though:

When I create the inviscloak ingame, and try to equip it, it just drops into my backpack. The server window says:

Warning! scripts/control/invis_cloak.ecl does not exist!
Exception caught while loading script scripts/control/invis_cloak.ecl: Unable to open scripts/control/invis_cloak.ecl for reading.
Unable to read script 'scripts/control/invis_cloak.ecl'
Error reading script scripts/control/invis_cloak.ecl


I do understand that the cloak needs a control script, but I can't figure out:
1. What a control script is.
2. Why the normal cloak located in the tailoring skill package can use the script :combat:itemControl, and not my cloak. I've tried not setting a controlscript, and tried setting it to the :combat:itemControl one, but neither works.





I also have another question, on another item I tried to make.
I asked a friend for ideas on what to try to make, and he said:
A football!

So I tried. I made an item that when stepped upon moves one tile in your direction, but there are two problems:

1. I want to use the small bagball graphic, but when I do, my character cannot walk on that tile. Until I can solve that, I used the bone graphic for it, and it worked just fine. What should I do about this?
2. I need the ball to make sure there is noone on the tile it's about to jump to. Is there a simple way to check if there is a playermobile standing on a tile?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 3:36 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 209
Your compiled script is not in the place where it should be, according the itemdesc config file. To help you out, I have to ask you to tell where did you put the file invis_cloak.ecl? Is it in [pol]/scripts/control? Or packaged somewhere?

About the football: if the height of the graphic of ball is too much, either on client or server side, the character is refused to step onto it. You can check the server side value using .getprop height and targetting the item. Values are read by POL from [pol]/config/tiles.cfg file, so you may be able to change it in there (into something like 2) and get it to work. If client refuses to walk onto it you'd have to update every players client files to get it to work, which is not an easy thing.

To check mobiles on tile, you can use function ListMobilesNearLocation (link to docs: http://docs.polserver.com/pol097/singlefunc.php?funcname=ListMobilesNearLocation&xmlfile=uoem.xml). There are also other usable functions in the UO module, I suggest you to check them out.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 4:40 am 
Offline

Joined: Sat Apr 08, 2006 4:09 am
Posts: 28
The script used to be in scripts/items, but I moved it to scripts/control. Now, when I equip it it doesn't give an error message in the server window, and I get hidden and stealthy, but it still wont equip. It goes to my backpack as soon as I try to equip it.


You were right about the football, it must be clientwise, because I changed the small bagball information to Blocking 0 and Height 1, and I still can't walk through it. I'll have to search for a better graphic. Ideas?

I tried using the ListMobilesNearLocation command, but I couldn't figure out HOW exactly to use it.

Thank you very much for your help, you're the best.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 5:06 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 209
In the case of (un)equipscript, if the return value is 0, the (un)equip fails. So while you get the benefits of equipping the item, in the end the script tells core to not allow it. So add this as the last line (before the very last line of "endprogram", that is):

Code:
return 1;


Do the same to the unequip script, if necessary.

This information can also be found in the documentations, should you ever forget how it went: http://docs.polserver.com/pol097/scripttypes.php. Scroll down to equipscript and unequipscript. I suggest reading all the other things in there, too.

I cannot think of any ball-like graphic, but that doesn't mean there isn't any. Just keep searching. And use your imagination if search goes in vain.

Usage example of ListMobilesNearLocation coming through;

Code:
// We want to know all the players on the same tile as the ball.
// Remember, x, y, z and realm are properties every UObject has.
// range is 0 so no other tiles around the item are checked.
var playerlist := ListMobilesNearLocation(ball.x, ball.y, ball.z, 0, ball.realm);

foreach player in playerlist
    Print(player.name + " in on the same tile as the ball!");
endforeach


As is, ListMobilesNearLocation only lists visible and alive mobiles (both players and npcs) near the x, y, z location. Documentations mention this, too, just think carefully what you really need when you are about to use this. If you want to include also hidden or dead or concealed people you have to use ListMobilesNearLocationEX-function instead. -- Yeah, not going too deep into that, now.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 11:46 am 
Offline

Joined: Sat Apr 08, 2006 4:09 am
Posts: 28
Okey! Thanks a lot for all your help, both items' scripts are finished and functioning.

Now, I have yet ANOTHER question for you, because I just know you love helping me out.

As I said, I wanted the inviscloak to be able to spawn in different colors, and always return to the original color when unequipped. The change-color system works, but what I want to know is:

How do I make an item spawn in a random color?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 6:18 pm 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 209
You can use the item' createscript to set a randomized color to the cprop. Thus, every time the item is created, it will get a all random color which never changes again.

Createscript documentation: http://docs.polserver.com/pol097/scripttypes.php#CreateScript.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 04, 2008 1:32 am 
Offline

Joined: Sat Apr 08, 2006 4:09 am
Posts: 28
Okey the random color script was easy to make, but another problem has occured.


The cloak seems to get bugged, or something. When I equip it, and then unequip it, the next time it is moved or equipped it "disappears", as if it was picked up, but not visible at the cursor. When this happens you can't do anything else that you can't do when carrying something.

Ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 05, 2008 5:22 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 209
I can't really help you with that one.

I know things like that has happen before, even to me, but what I cannot recall is the reasons behind that.

If you cannot solve it out yourself, I suggest that you tell more of the scripts and settings so possible volunteers could try and hopefully tell what's the reason behind that.

And if you do, it would be nice to know what was the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl