Goto https://www.stucuk.netGoto https://www.atlanticaonlinewiki.comGoto https://www.game-requirements.com


Menu


It is currently Sun Aug 19, 2018 1:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: SeeList
PostPosted: Mon Mar 08, 2010 1:02 pm 
Offline
Moderator
Moderator
User avatar

Joined: Fri Jan 13, 2006 6:20 pm
Posts: 2325
Location: Argentina
Function: SeeList(side:Integer units:plist)
Returns the units from a list that the specified side sees

Similar to See() except that handles more than 1 unit.

Code:
// Returns a list of those *units* which are seen by *side*.
// Similar to See() except that works with more than 1 unit.
export function SeeList(side, units);
var un;
begin
  result:=[];

  for un in units do
    if See(side, un) then
      result:=result^un;
end;



Note: The function has been improved by Radzio.

_________________
-Aleph.

THE Very active person

"You can only do well at something if you put the time in. Doesn't matter what subject it is. You can't make a master piece over night."
Wise man Stu-


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Sun Aug 22, 2010 4:37 pm 
Offline
Soldier level 0
Soldier level 0
User avatar

Joined: Thu Apr 02, 2009 4:29 pm
Posts: 29
Mhm I find it quite useful in my mod, thanks :)


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Thu May 19, 2011 3:44 pm 
Offline
Soldier level 0
Soldier level 0
User avatar

Joined: Thu May 19, 2011 12:48 pm
Posts: 6
I tried used this function for my mod but i have problem i want code which will be gived "true" if someone from side (1) seen someone from my side (3).

This code doesn't work (I change your code):
Code:
var uss;
Function Seen;
begin
uss=FilterAllUnits([[f_side,3]]);
If See(1,uss) then
begin
/// next code
end;end;


I think that I dont understand this piece of code
Code:
For x to list do
...


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Thu May 19, 2011 5:56 pm 
Offline
Moderator
Moderator
User avatar

Joined: Fri Jan 13, 2006 6:20 pm
Posts: 2325
Location: Argentina
Try this:

Code:
// Returns a list of the units seen.
// Similar to See() except that handles more than 1 unit.
Export Function SeeList(side,List);
var x,seen;
begin
Seen=[];
     For x in List do
         begin
              If See(side,x) then
              begin
                   Seen=Seen^x
              end
     end;
Result=Seen;
end;

var uss;
Function SeenOther;
begin
uss=FilterAllUnits([[f_side,3]]);
If SeeList(1,uss) or See(1,uss) then
begin
result=true;
end;end;


And use it like this:

Code:
    repeat
    wait(0$1);
    until SeenOther;


After the until, you place the code you want to execute.

I'm not an expert in SAIL, I hope if this isn't working fine someone experienced as McBenn could have a good answer.

Good luck.

_________________
-Aleph.

THE Very active person

"You can only do well at something if you put the time in. Doesn't matter what subject it is. You can't make a master piece over night."
Wise man Stu-


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Fri May 20, 2011 5:14 am 
Offline
OW Support Owner
OW Support Owner
User avatar

Joined: Wed Dec 28, 2005 11:13 pm
Posts: 5001
Location: UK, Scotland
An Every should be better than repeat/until.

_________________
Image
Free Map Editor - Game Requirements - Stucuk.Net
-Stu


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Fri May 20, 2011 7:06 am 
Offline
Original-War.Net Owner
Original-War.Net Owner
User avatar

Joined: Wed Jan 25, 2006 10:21 am
Posts: 2786
Location: Poland, Białystok
I would rewrite it even further:
Code:
// Returns a list of those *units* which are seen by *side*.
// Similar to See() except that works with more than 1 unit.
export function SeeList(side, units);
var un;
begin
  result:=[];

  for un in units do
    if See(side, un) then
      result:=result^un;
end;

var uss;
function Seen;
begin
  uss:=FilterAllUnits([[f_side, 3]]);
  if SeeList(1, uss) then
  begin
    // any code
  end;
end;


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Fri May 20, 2011 7:50 am 
Offline
Soldier level 0
Soldier level 0
User avatar

Joined: Thu May 19, 2011 12:48 pm
Posts: 6
Radzio ^doesn't work but i dont know what type characters must be on "result:=[];" ?


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Fri May 20, 2011 8:03 am 
Offline
Original-War.Net Owner
Original-War.Net Owner
User avatar

Joined: Wed Jan 25, 2006 10:21 am
Posts: 2786
Location: Poland, Białystok
Jeanks wrote:
Radzio ^doesn't work but i dont know what type characters must be on "result:=[];" ?

Hm, I don't really understand.
Could you share a bigger part of code there: viewforum.php?f=11 ?


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Fri May 20, 2011 9:47 pm 
Offline
Moderator
Moderator
User avatar

Joined: Mon Mar 17, 2008 6:03 pm
Posts: 1129
Location: Denmark
I see nobody has considered a filter with f_see.

Code:
FilterAllUnits( [ [f_side, 3], [f_see, 1] ] );

returns all units from side 3 which can be seen by units with fog number 1 (default side 1).

_________________
I have an if that has an else, but that if has another if with an else inside... My question is... If an if has an else, if there is more than one line in that if, should it have a begin and an end?


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Fri May 20, 2011 10:27 pm 
Offline
Moderator
Moderator
User avatar

Joined: Fri Jan 13, 2006 6:20 pm
Posts: 2325
Location: Argentina
O.o

*Impressed*

_________________
-Aleph.

THE Very active person

"You can only do well at something if you put the time in. Doesn't matter what subject it is. You can't make a master piece over night."
Wise man Stu-


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Sat May 21, 2011 7:51 am 
Offline
Original-War.Net Owner
Original-War.Net Owner
User avatar

Joined: Wed Jan 25, 2006 10:21 am
Posts: 2786
Location: Poland, Białystok
Whoa, I've just written another function doing the same as built-in ones.
Seems I cannot trust Aleph when it comes to need of specific code.


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Sat May 21, 2011 3:34 pm 
Offline
Moderator
Moderator
User avatar

Joined: Fri Jan 13, 2006 6:20 pm
Posts: 2325
Location: Argentina
Radzio wrote:
Seems I cannot trust Aleph when it comes to need of specific code.


lol

And I cannot trust you, because you write something and magically when I comment they are changed and I have a orangeish comment on my post... ;P

_________________
-Aleph.

THE Very active person

"You can only do well at something if you put the time in. Doesn't matter what subject it is. You can't make a master piece over night."
Wise man Stu-


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Sat May 21, 2011 4:37 pm 
Offline
Original-War.Net Owner
Original-War.Net Owner
User avatar

Joined: Wed Jan 25, 2006 10:21 am
Posts: 2786
Location: Poland, Białystok
gwren1 wrote:
And I cannot trust you, because you write something and magically when I comment they are changed and I have a orangeish comment on my post... ;P

Magic LOL


Top
 Profile  
 
 Post subject: Re: SeeList
PostPosted: Sun May 22, 2011 12:01 pm 
Offline
Soldier level 0
Soldier level 0
User avatar

Joined: Thu May 19, 2011 12:48 pm
Posts: 6
Heh lol That was easy :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Original War is an RTS / RPG game by Altar Games
Original War Support is not part of Altar Games but is maintaining Original War for Altar Games

Privacy Policy