Few questions
Moderator: POL Developer
Few questions
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?
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?
Function and Program parameters are always passed by order; the variable name is irrelevant.
can just as well be writtenjust 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 )
Code: Select all
program textcmdFoo(who, text)
Code: Select all
program monkeyHead(xbox, database)
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 )
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
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
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
in the game, the script castspell.ecl is called. Inside it should contain
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
so if I did
Code: Select all
.castspell flamestrike
Code: Select all
program castspell(who, text)
The list of script types and parameters is here http://docs.polserver.com/pol096/scripttypes.php
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.CWO wrote:a .command only passes 2 parameters.
--
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
"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: }"
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.
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.
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.
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.
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
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