Few questions

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 096.
Note: Core 096 is no longer officially supported.

Moderator: POL Developer

Post Reply
kong
New User
Posts: 7
Joined: Tue Jul 29, 2008 10:44 am
Location: Mexico!

Few questions

Post by kong »

Hi,

I'd like to know how parameters are managed. As an exemple I create a new dot command which will cast a spell on somebody such as flamestrike. As I can see, when you create the dot command script program, you can add the parameters you want. Like who, parms. How are these binded to the calling method? By name, order etc?

Also when I type my command, I'd like to see a target apear. When I took a look at the flamestrike spell, It doens't seem to manage the target, it seems to be done on a higher level, where is that code so I can use it as a reference.

Thank

EDIT : Btw is there anywhere I can find information on function such as maincast. I can open the source and read it, but that would be just faster to read few comments on it. Specially that the source doens't contain comments on the parameters. So Is there a website that show it all?
Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Post by Luth »

Function and Program parameters are always passed by order; the variable name is irrelevant.

Code: Select all

program textcmdFoo(who, text)
can just as well be written

Code: Select all

program monkeyHead(xbox, database)
just be sure to pass the parameters in the correct order. :)

The spells all make use of similar code, so lots of that is scurried away in the common include files. If you just want to bring up a target, UO.EM has a Target() function.
( http://docs.polserver.com/pol097/single ... e=uoem.xml )
kong
New User
Posts: 7
Joined: Tue Jul 29, 2008 10:44 am
Location: Mexico!

Post by kong »

Ya I'm already using the TargetCoordinates command but I just wanted to see how it was done in the upper levels.

So it is pass as order, then how do I find the passed parameters when I do a .command?
Justae
Expert Poster
Posts: 79
Joined: Thu May 24, 2007 2:12 pm
Location: South Africa

Post by Justae »

In matters of spellcasting, you don't really want to be using TargetCoordinates unless you want to cast Walls or Firefields etc.

The normal command would be Target(mobile)

program SpellCommand( who, spellname )

if ( !spellname )
SendSysMessage( who, "No spell specified." );
return;
endif

var victim := target( who );

You would then do your other checks to ensure target (victim) is a mobile (NPC or player). When all your checks are done, fire-off the spell script you need with something like

var params := { };
params [1] := who;
params [2] := victim;

StartSscript ("full defined scriptname of spell", params);

Most spell scripts need a "Caster" parameter, that would be you in this case, and a "Cast_on" parameter, that would be your victim.

You might find say the fireball.src script might start something like :

program FireBall(params)

var Caster := params[1];
var Cast_on := params[2];
.......rest of the script.

Enjoy.
Justae
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Post by CWO »

a .command only passes 2 parameters. The first parameter is a character reference to the person who is doing the .command and the second parameter is a string containing the text done after the command.

so if I did

Code: Select all

.castspell flamestrike
in the game, the script castspell.ecl is called. Inside it should contain

Code: Select all

program castspell(who, text)
the variable "who" would be the reference to me and the variable "text" would be the string "flamestrike" because that's what I typed after the command. As they have said, you can name them what you want but the order of the parameters will always remain the same. If I did (text, who) the text would be the reference to me and who would then be the text I typed. In this case, you might pass them as (caster, spelltype)... or whatever you feel comfortable with.

The list of script types and parameters is here http://docs.polserver.com/pol096/scripttypes.php
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

CWO wrote:a .command only passes 2 parameters.
Close, but not quite. It may only be useful for those having more than basic letters, but it's still worth knowing that text command script really has four parameters, the unmentioned two being text in unicode array and the langcode.

--

And to summarize this and that, .textcommand example that hopefully explains also how to support unicodes. And splits text just for the fun of it.

Code: Select all

program textcommand( who, text, uc_text, langcode )

    print("text: " + text);
    print("uc text: " + CChrZ(uc_text);
    print("split words: " + SplitWords(text));

endprogram
1. ".textcommand test" would print
"text: test"
"uc text: test"
"split words: { test }"

2. ".textcommand this is longer text":
"text: this is longer text"
"uc text: this is longer text"
"split words: { this, is, longer, text }"

3. ".textcommand unicode letters: äÄöÖ":
"text: unicode letters: "
"uc text: unicode letters: äÄöÖ"
"split words: { unicode, letters: }"
kong
New User
Posts: 7
Joined: Tue Jul 29, 2008 10:44 am
Location: Mexico!

Post by kong »

Thank everyone for your helpfull informations. I still have 3 question.

Where can I find information about the calling method of .command.
Where do I find information about the WHO object that is pass to my command (It's attributes etc)
How do I find out what coordinate (or what direction) my char is looking. I tried out get_direction but this is not enought.
kong
New User
Posts: 7
Joined: Tue Jul 29, 2008 10:44 am
Location: Mexico!

Post by kong »

Ok I found out the anwer to my question 3. I actually already found out before but when I was trying to show it, I forgot to CStr it.

I have another question, how can I check If I have LOS between two coordinate (they are not in a UObject, but I have 4 int (x,y) x2.
Justae
Expert Poster
Posts: 79
Joined: Thu May 24, 2007 2:12 pm
Location: South Africa

Post by Justae »

You can use the standard UO.EM functions.

CheckLineOfSight( object1, object2 );
CheckLosAt( character, x, y, z );

I think in your case you would use the CheckLineOfSight function.

As for facing, you would have var MobileFacing := mobile.facing;
That will return a number which relates to each of the valid directions, N, NE, E, SE, S, SW, W, NW.
kong
New User
Posts: 7
Joined: Tue Jul 29, 2008 10:44 am
Location: Mexico!

Post by kong »

Yes I want to use CheckLineOfSight but I don't know how to pass my parameters to it. I have 4 int. Origin X and Y, and Destination X and Y. If you could tell me how to store them into an object to pass it that would be perfect.

Thank
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

There is no way to check LOS between just coordinates. You have to create or move an object into the end and use CheckLosAt function. The feature has been requested, but is yet to be done.
kong
New User
Posts: 7
Joined: Tue Jul 29, 2008 10:44 am
Location: Mexico!

Post by kong »

Oh great, so I guess I could create two object both invisible and check based on that?
kong
New User
Posts: 7
Joined: Tue Jul 29, 2008 10:44 am
Location: Mexico!

Post by kong »

Just wondering, are there any invisible object yet, because I fear that between the time I create it and make it invisible that It apear on the screen.

Also, where can I find the object with their number and what they look like?

So for now I create a temporary Object, but When I check LOS between them, if Object A is let say before a wall, and B is after the wall, CheckLineOfSight still return true, any idea or is there something I'm doing wrong.

EDIT : I Kinda found what I was doing wrong. When creating my item I would create it over the wall, thus there was really a LOS. But I dunno how to correct this, if anyone has an idea. Thank
Post Reply