Page 1 of 1

Few questions

Posted: Tue Jul 29, 2008 10:47 am
by kong

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.


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?

Posted: Tue Jul 29, 2008 11:00 am
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.
( ... e=uoem.xml )

Posted: Tue Jul 29, 2008 11:33 am
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?

Posted: Tue Jul 29, 2008 1:15 pm
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." );

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]; of the script.


Posted: Tue Jul 29, 2008 9:25 pm
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

Posted: Wed Jul 30, 2008 3:37 am
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));

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: }"

Posted: Wed Jul 30, 2008 5:58 am
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.

Posted: Wed Jul 30, 2008 10:51 am
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.

Posted: Wed Jul 30, 2008 11:41 am
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.

Posted: Wed Jul 30, 2008 11:50 am
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.


Posted: Wed Jul 30, 2008 12:02 pm
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.

Posted: Wed Jul 30, 2008 12:06 pm
by kong
Oh great, so I guess I could create two object both invisible and check based on that?

Posted: Wed Jul 30, 2008 12:30 pm
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