Map Database  •  FAQ  •  RSS  •  Register  •  Login

How fix Invalid parameter(s) passed to States.HouseDestroyed

<<

Emotion 98.3

Farmer

Posts: 20

Joined: 30 Oct 2014, 20:56

KaM Skill Level: Expert

Post 19 Mar 2017, 13:20

How fix Invalid parameter(s) passed to States.HouseDestroyed

Hi,

How i can fix this code?

  Code:
procedure OnTick;
//FOG REVEAL CIRCLE
begin
   If States.HouseDestroyed(States.HouseAt(120, 162)) then //Team 3 Barrack location is x120, y162
   begin
      Actions.FogRevealCircle(0, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
      Actions.FogRevealCircle(1, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
   end;   
end;


download/file.php?mode=view&id=3361
You do not have the required permissions to view the files attached to this post.
- Try my two player campaign: Co-op Knights I http://www.knightsandmerchants.net/forum/viewtopic.php?f=5&t=2877
- Try my two player campaign: Co-op Knights II http://www.knightsandmerchants.net/forum/viewtopic.php?f=5&t=3400
<<

Esthlos

User avatar

Knight

Posts: 672

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 19 Mar 2017, 16:12

Re: How fix Invalid parameter(s) passed to States.HouseDestr

  Code:
procedure OnTick;
//FOG REVEAL CIRCLE
begin
   If States.HouseAt(120, 162) < 0 then //Team 3 Barrack location is x120, y162
   begin
      Actions.FogRevealCircle(0, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
      Actions.FogRevealCircle(1, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
   end;   
end;


States.HouseAt returns -1 if there's no house there - and if it's destroyed, then it's not there.

(Though I'd have used OnHouseDestroyed instead in this case... OnTick means it will be done 10 times per second after the barracks is destroyed, which is quite cpu intensive)
  Code:
procedure OnHouseDestroyed(aHouse: Integer; aDestroyerIndex: Integer);
//FOG REVEAL CIRCLE
begin
   If (States.HousePositionX(aHouse) = 120) AND (States.HousePositionY(aHouse) = 162) then //Team 3 Barrack location is x120, y162
   begin
      Actions.FogRevealCircle(0, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
      Actions.FogRevealCircle(1, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
   end;   
end;
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

Emotion 98.3

Farmer

Posts: 20

Joined: 30 Oct 2014, 20:56

KaM Skill Level: Expert

Post 19 Mar 2017, 17:54

Re: How fix Invalid parameter(s) passed to States.HouseDestr

Esthlos wrote:
  Code:
procedure OnTick;
//FOG REVEAL CIRCLE
begin
   If States.HouseAt(120, 162) < 0 then //Team 3 Barrack location is x120, y162
   begin
      Actions.FogRevealCircle(0, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
      Actions.FogRevealCircle(1, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
   end;   
end;


States.HouseAt returns -1 if there's no house there - and if it's destroyed, then it's not there.

(Though I'd have used OnHouseDestroyed instead in this case... OnTick means it will be done 10 times per second after the barracks is destroyed, which is quite cpu intensive)
  Code:
procedure OnHouseDestroyed(aHouse: Integer; aDestroyerIndex: Integer);
//FOG REVEAL CIRCLE
begin
   If (States.HousePositionX(aHouse) = 120) AND (States.HousePositionY(aHouse) = 162) then //Team 3 Barrack location is x120, y162
   begin
      Actions.FogRevealCircle(0, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
      Actions.FogRevealCircle(1, 122, 167, 30); //PlayerId, LocationX, LocationY, Radius
   end;   
end;



Thank you very much! It worked now :)
- Try my two player campaign: Co-op Knights I http://www.knightsandmerchants.net/forum/viewtopic.php?f=5&t=2877
- Try my two player campaign: Co-op Knights II http://www.knightsandmerchants.net/forum/viewtopic.php?f=5&t=3400

Return to Dynamic Scripting

Who is online

Users browsing this forum: No registered users and 3 guests