Jump to content
Ramibuk

which objects are on square

Recommended Posts

I need to know it on square is wall,window.door or zombie 

 

This works for wall:  if _square:Has(IsoObjectType.FromString("wall")) then print ("here is wall")

 

but not so good for windows or doors so I'm looking for better way

Share this post


Link to post
Share on other sites

That throws me true for every square and same for "SmellySocks" so i guess it was only luck with it worked good with wall.

 

But i found another way thanks to RoboMat Utility mod

 

Function:

        for _, movingObject in pairs(_square:getLuaMovingObjectList()) do            if Utility.contains(movingObject:toString(), "zombie.characters.IsoZombie") then                print("Zombie");           end        end        for _, object in pairs(_square:getLuaTileObjectList()) do            if Utility.contains(object:toString(), "zombie.iso.objects.IsoDoor") then                print("Doors");            elseif Utility.contains(object:toString(), "zombie.iso.objects.IsoWindow") then                --TODO smash window                print("Window");            elseif _square:Has(IsoObjectType.FromString("wall")) then               print ("wall");            else                print("Free");            end        end 

 

ingame; http://www.youtube.com/watch?v=6euaBA7roQg&list=PLhG390Kr3upJbGtzFWu-V88Ig_Ep-G2Op

 

 

but now i need grab wall and damage it.Same for window and door

Share this post


Link to post
Share on other sites

The only way of getting a list of clicked objects is via the "OnFillWorldObjectContextMenu" Event which returns a list of all worldobject on the clicked grid.

I imagine you could find the code to get all those in the function which fires that event ... I'm not sure though if that happens on the lua or on the java side - Sorry :-/

Share this post


Link to post
Share on other sites

Thanks,but i need this function to be triggered by item flying through this square.

 

like this kill zombies on _square;

 for _, movingObject in pairs(_square:getLuaMovingObjectList()) do       if Utility.contains(movingObject:toString(), "zombie.characters.IsoZombie") then                movingObject:Kill(nil);

 

and something like that for damaging windows,doors and walls as they don't work in my function,only detection of wall.

Share this post


Link to post
Share on other sites

For IsoWindow there is setSmashed(true):

  public void setSmashed(boolean destroyed)  {    if (destroyed)    {      this.destroyed = true;      this.sprite = this.smashedSprite;      this.closedSprite = this.smashedSprite;    } else {      this.destroyed = false;      this.sprite = getSprite();    }  }

Besides that you could fake an attack on the window and door like I did in my lockpicking mod - Well you'd have to find a workaround ... maybe create a temporary item or sth like that:

	if ZombRand(chance) == 0 then		-- We store the original door damage in a temporary variable.		-- Then we set it to a high level to make sure the window is smashed.		-- Finally we reset it to its original value.		local temp = weapon:getDoorDamage();		weapon:setDoorDamage(100);		window:WeaponHit(player, weapon);		weapon:setDoorDamage(temp);		-- Add sound to the world so zombies get attracted.		addSound(window, window:getSquare():getX(), window:getSquare():getY(), window:getSquare():getZ(), 12, 20);	else
Might be worth checking the IsoDoor.class for a similar function too.

Lastly for the walls you should check how the sledgehammer is used to destroy walls ;)

Share this post


Link to post
Share on other sites

Thanks man! I used fake weapon hit for doors and windows but no luck with walls yet

 

EDIT so i removed all objects on square as spear cannot damage wall anyway and it looks weird when explosion destroy wall but objects around stay intact.

 

 _square:ClearTileObjectsExceptFloor();
 _square:RecalcAllWithNeighbours(true);   -to make it walkable,transparent etc
 
but this looks  performance hungry and im afraid than it can cause some bugs.but i didnt found any
 
.I go to play a little i guess.
Edited by Ramibuk

Share this post


Link to post
Share on other sites

performance hungry and im afraid than it can cause some bugs.but i didnt found any

I'd say just try it out. I catch myself worrying about performance too often instead of just making it work ;)

This way you at least have something that works which you still can improve later on.

EDIT: It would be cool if you could mark the thread as answered if you feel the problem has been solved.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...