scripting..
scripting..
dose anyone know any good tips or tricks nor guides on learning to 'Escript' ? i looked at some and i just done undertsand them =(, i keep getting lost so could someone please help?
If you have no previous experience with programming it will be harder for you than those of us who have done programming before. I recommend looking at the smaller <dot> commands found in \pol\scripts\textcmd
Read the guides on the POL homepage under documentation.
Unfortunately the docs assume some previous experience with programming. You should have a basic understanding of variables, program structure, program flow control and object oriented programming. But take heart that it is possible to learn without any previous knowledge. My son was able to learn and he had no experience before. You just need someone to go to with basic questions. Feel free to ask them here.
Read the guides on the POL homepage under documentation.
Unfortunately the docs assume some previous experience with programming. You should have a basic understanding of variables, program structure, program flow control and object oriented programming. But take heart that it is possible to learn without any previous knowledge. My son was able to learn and he had no experience before. You just need someone to go to with basic questions. Feel free to ask them here.
ok cool thanks
i started with a little easy script ^_^, world chat but i wonna know how can i change the color? i tested it in game and it works but it comes up grey
i wont it to be like green or something
this is what I've done so far:
use uo;
program textcmd_wc( who, text )
var ppl := EnumerateOnlineCharacters();
foreach x in ppl
if (x.cmdlevel > 0)
SendSysMessage(x, "World Chat From " + who.name + ": " + text);
endif
endforeach
endprogram
i started with a little easy script ^_^, world chat but i wonna know how can i change the color? i tested it in game and it works but it comes up grey
this is what I've done so far:
use uo;
program textcmd_wc( who, text )
var ppl := EnumerateOnlineCharacters();
foreach x in ppl
if (x.cmdlevel > 0)
SendSysMessage(x, "World Chat From " + who.name + ": " + text);
endif
endforeach
endprogram
Change the:
to:
uo.em module is good place to look how to use most of functions.
Code: Select all
SendSysMessage(x, "World Chat From " + who.name + ": " + text);
Code: Select all
SendSysMessage(x, "World Chat From " + who.name + ": " + text, 3, 67);
use os;
use uo;
use boat;
include "include/client";
include "include/attributes";
program textcmd_kill( who )
var tgt := Target( who);
var mob := tgt.mobile;
PlayFlameStrikeEffect( tgt);
PlaySoundEffect( tgt, SFX_SPELL_FLAMESTRIKE );
RevokePrivilege( tgt, "invul" );
SetObjProperty(tgt, "guardkill", 1)
ApplyRawDamage( tgt, GetMaxHp(tgt) );
endprogram
What version of POL are you using? I do not remember seeing the " PlayFlameStrikeEffect( tgt); " anyplace. Is this a function you created or is it part of the newer cores?
I have something close to this but I use the example below to generate the effects.
This plays the effects and sounds for the target. Then again I am using POL95 core.
I have something close to this but I use the example below to generate the effects.
Code: Select all
PlayStationaryEffect(tgt.x, tgt.y, tgt.z, 0x3709, 0x0a, 0x1e);
PlaySoundEffect(tgt, SFX_SPELL_FLAME_STRIKE);Just a bit of advice on the SendSysMessage and other function calls that have default parameters. I usually specify the values by reference in the function call. Like this:
Using the references for the various options makes it more readable when trying to debug code but more importantly doing it that way you can change the colour or font without affecting the other default values used by that function.
Code: Select all
SendSysMessage (who, "This message will be in green with a wide font.", font := 2, color := 66);
The former POL wiki... this is the development copy I maintained. I would work here before I would make changes to the official one.
Well the official one has been MIA for a long time, so figured I might aswell share the link to this one.
http://polwiki.winterboard.com/index.ph ... =Main_Page
And this is slightly related and may help you too... these are the coding standards I always adheared too:
http://www.winterboard.com/nightscape/c ... dards.html
Well the official one has been MIA for a long time, so figured I might aswell share the link to this one.
http://polwiki.winterboard.com/index.ph ... =Main_Page
And this is slightly related and may help you too... these are the coding standards I always adheared too:
http://www.winterboard.com/nightscape/c ... dards.html
-
Marilla
Just a note; What you have done there is called using Named Arguments/Parameters, by including the name before the value in the parameter list of the function call.Yukiko wrote:Just a bit of advice on the SendSysMessage and other function calls that have default parameters. I usually specify the values by reference in the function call. Like this:
Using the references for the various options makes it more readable when trying to debug code but more importantly doing it that way you can change the colour or font without affecting the other default values used by that function.Code: Select all
SendSysMessage (who, "This message will be in green with a wide font.", font := 2, color := 66);
I say that, because the term 'reference' has a completely different meaning for function parameters; A parameter passed by reference is the opposite of passing it by value, and is similar to passing a pointer. It does not have anything to do with naming the parameter when calling the function.
When you pass a parameter by value, you are passing a copy of the value to the function. When you pass a parameter by reference, you pass instead a 'reference' to the memory location of the variable.
The main difference between the two is that when you pass a reference, any changes the function does to that reference affect the original variable. When you pass by value (the default), no changes carry through.
Consider the following simple code:
Code: Select all
use uo;
program test(who)
var victim := target(who);
SendSysMessage(who, victim.name);
GetNewVictim(victim, who);
SendSysMessage(who, victim.name);
endprogram
function GetNewVictim(what, who)
what := target(who);
endfunction
However, do this one simple change:
Code: Select all
use uo;
program test(who)
var victim := target(who);
SendSysMessage(who, victim.name);
GetNewVictim(victim, who);
SendSysMessage(who, victim.name);
endprogram
function GetNewVictim(byref what, who)
what := target(who);
endfunction
When you run this code this time, and target two different things, you will get each of their separate names printed.
Another example:
Code: Select all
use uo;
program test(who)
var one := "1";
SendSysMessage(who, one);
Testing(one);
SendSysMessage(who, one);
endprogram
function Testing(what)
what := "2";
endfunction
1
1
Do the same simple change as noted above:
Code: Select all
use uo;
program test(who)
var one := "1";
SendSysMessage(who, one);
Testing(one);
SendSysMessage(who, one);
endprogram
function Testing(byref what)
what := "2";
endfunction
1
2
The default, by value, makes a 'copy' of the variable, which will not affect the original variable. Marking a parameter as 'byref' or by reference, means that the ADDRESS of the variable is passed, and so any assignments you do to the variable WILL carry through back in the original caller, if the original caller uses that variable again.
There's one place where this is very important: In Packet Hook scripts. You may have noticed packet hook functions are declared like so:
Code: Select all
function HandleB9(who, byref packet)
....
endfunction
Generally speaking, byref parameters aren't really needed all that often, particularly with parameters that are object references. Now, this might get confusing, but object references can themselves be passed by reference, or by value.
That is, you have to keep in mind that an 'object reference' or 'object variable' is itself a memory location that merely points to an instance of an object. That might sound confusing, but you actually already know this fact intuitively, because you know what this code does:
Code: Select all
program DotCommand(who)
who := target(who);
endprogram
Code: Select all
program DotCommand(who)
who.color := 100;
endprogram
eScript variables are completely flexible - they can hold a reference one moment, and a value the next. Like so:
Code: Select all
program DotCommand(who)
who := 1;
endprogram
=========================
So, we have variables that can be values and references. We also have function parameters that can be passed by value or by reference. What's the relation here? Does one type of variable demand a certain type of function parameter? No, it doesn't. You can pass either type of variable in either way: You can pass a reference variable byref or byval, and you can pass a value variable byref or byval (I'm not sure if there is a literal 'byval' keyword, but it's not needed; remember: the default, if you don't specify, is byval.)
Though it may have been subtle, my first two examples showed passing references byval and byref. I alternated between how to pass 'what', but in both cases, 'who' (the reference to the dot-command-user) was always byval. However, we know that 'who' refers to an object - your PC. That's perfectly valid.
What this means is when I pass 'who' to that function, a local copy of the value of 'who' is created on the stack for the function. The 'value' of that variable happens to be a reference. Confused yet? Yes.. a reference is, itself, a value.
If you pass that reference BY reference, any changes you do to that reference also 'pass back' to the caller, just as you saw with the 'what' parameter when we had the 'byref'. But when you pass the reference by value, no changes you do to the reference will pass back to the caller - the caller's "who" reference will remain safely pointed at you.
Errr... anyway; I know we didn't need all of that just now... but I did think it was important not to confuse the issue of 'reference' parameters/arguments to functions, because there is a specific meaning to that. You were using named arguments and in fact, NOT using reference parameters (because the function you are calling does not define its parameters as references, but instead as values.)
i've tryed to make a 'Flame Tile' but it wont work, so i dont know if or were there might be an error
----------------------------------------------
item 0xfa09
{
Name flametile
Desc Flame Tile
color 1176
Graphic 6173
WalkOnScript fstrike
Movable 0
}
----------------------------------------------
use os;
use uo;
include "include/client";
const EFFECT_FSTRIKE := 0x3709;
const SOUND_EFFECT_RES := 0x215;
program resfield(mobile)
set_critical(1);
if(mobile.dead)
return;
endif
endprogram
----------------------------------------------
----------------------------------------------
item 0xfa09
{
Name flametile
Desc Flame Tile
color 1176
Graphic 6173
WalkOnScript fstrike
Movable 0
}
----------------------------------------------
use os;
use uo;
include "include/client";
const EFFECT_FSTRIKE := 0x3709;
const SOUND_EFFECT_RES := 0x215;
program resfield(mobile)
set_critical(1);
if(mobile.dead)
return;
endif
endprogram
----------------------------------------------
Well, you have to actually do the flamestrike animation and play the sound effect as well as doing the damage to the mobile.
See PlayObjectCenteredEffect, PlaySoundEffect and ApplyDamage under UO.EM in the POL docs section of the website. I'd recommend looking at the flamestrike spell script as well to determine the amount of damage it applies and to determine how resisting spells skill affects damage, if you want to take spell resistance into effect on this tile that is.
See PlayObjectCenteredEffect, PlaySoundEffect and ApplyDamage under UO.EM in the POL docs section of the website. I'd recommend looking at the flamestrike spell script as well to determine the amount of damage it applies and to determine how resisting spells skill affects damage, if you want to take spell resistance into effect on this tile that is.
how do i go when it comes adding a new loot group to 'nlootgroup.cfg' ?
i wont to add something like
Group VampireArmor
{
Item 1 vampiregloves
Item 1 vampireArms
Item 1 vampirelegs
Item 1 vampiretunic
Item 1 vampirehelm
}
but when i do add that there, add it to a monster as a loot, you can never pick any bit of it up
i wont to add something like
Group VampireArmor
{
Item 1 vampiregloves
Item 1 vampireArms
Item 1 vampirelegs
Item 1 vampiretunic
Item 1 vampirehelm
}
but when i do add that there, add it to a monster as a loot, you can never pick any bit of it up
thats ok, you've been a great help to me 
i fort ill just post a part of the vampire armor up here, mayb i could of put an error there
-------------------------------------------------------------------
Armor 0x1d93
{
Name vampiretunic
Desc Vampire Tunic
AR 40
Graphic 5199
Color 1996
Coverage Body
MaxHP 41
strrequired 40
medloss 2000
movable 1
equipscript equip
unequipscript unequip
controlscript itemControl
destroyscript destroy
}
-------------------------------------------------------------------
i fort ill just post a part of the vampire armor up here, mayb i could of put an error there
-------------------------------------------------------------------
Armor 0x1d93
{
Name vampiretunic
Desc Vampire Tunic
AR 40
Graphic 5199
Color 1996
Coverage Body
MaxHP 41
strrequired 40
medloss 2000
movable 1
equipscript equip
unequipscript unequip
controlscript itemControl
destroyscript destroy
}
-------------------------------------------------------------------