Restriction in magic.inc!

For questions relating to POL scripting (not necessarily related to WoD)

Moderators: Siobhan, Sebastian, Drocket

Restriction in magic.inc!

Postby Arcane on Wed Sep 03, 2003 10:51 pm

How can I put in my magic.inc 1 restriction.
If a player move 15 titles he lost his concetration and miss the spell.

My wrong code:

var X, Y;
var number;
number := 15;
x := caster.x;
y := caster.y;
if( GetEquipmentByLayer( caster, 25 ))
if( !x > number or !y > number)
return 0;
else
endif
else
endif
Arcane
Newbie
 
Posts: 7
Joined: Mon Aug 04, 2003 8:54 pm

Postby Kardall on Wed Nov 12, 2003 6:42 am

At the very very beginning of the magic.inc, put something like:

Code: Select all
var oldx := caster.x;
var oldy := caster.y;


then where you do the skill check to see if they cast it... do something like:

Code: Select all
if( coordDist( caster.x, caster.y, oldx, oldy ) >= 15 )
  // Put Fail Stuff here cause they went too far.
else
   // skillcheck code
   if( checkSkill(who......
...
endif


I hope you have the coordDist() function. It basically checks distance between a set of x/y points... it doesn't check Z so... if you want to do that, do an: || CheckZ(caster.z, oldz)

type of thing and write a Z checking function like that.
Kardall
Newbie
 
Posts: 8
Joined: Mon Jan 06, 2003 6:27 am

Postby Arcane on Fri Dec 26, 2003 1:33 pm

thanxs
it´s works...
Now this restriction it´s not working:

var prevtime := ReadGameClock() + 5;
if(ReadGameClock() > prevtime)
SendSysMessage(caster, "Voce demorou demais e perdeu o focus.",3,70);
return 0;
endif


what´s wrong? =(
Arcane
Newbie
 
Posts: 7
Joined: Mon Aug 04, 2003 8:54 pm

Postby Fistandantilus on Mon Dec 29, 2003 4:11 pm

Your code is ok, it should compile. But you are not performing anything between prevtime and next line (readgameclock) so that enough time can pass. As it is, restriction will never take place.

Just to check it is ok, change code to this:

Code: Select all
var prevtime := ReadGameClock();
sleep 1;
if(ReadGameClock() > prevtime)
SendSysMessage(caster, "Voce demorou demais e perdeu o focus.",3,70);
return 0;
endif


This should always print the message.
Fistandantilus
Jr. Newbie
 
Posts: 2
Joined: Mon Dec 29, 2003 4:08 pm

Postby Drocket on Mon Dec 29, 2003 10:20 pm

That really wouldn't help either, since it would simply always print the message, making the checks rather pointless. The big thing that you need to do is...

var prevtime := ReadGameClock() + 5;

--> Do something here <--

if(ReadGameClock() > prevtime)
SendSysMessage(caster, "Voce demorou demais e perdeu o focus.",3,70);
return 0;
endif

It looks like you want a 5 second time limit for the player to do something, but you never give them a chance to do anything. You save the time, then immediately check the time with no opportunity for the player to do anything.
Drocket
Site Admin
 
Posts: 820
Joined: Mon Oct 07, 2002 2:54 am

Postby Fistandantilus on Tue Dec 30, 2003 8:03 am

Drocket, the code i posted was supposed to do so.. it was just to show Arcane that it worked ;)
Fistandantilus
Jr. Newbie
 
Posts: 2
Joined: Mon Dec 29, 2003 4:08 pm


Return to Scripting Forum

Who is online

Users browsing this forum: No registered users and 0 guests

cron