Jump to content

which objects are on square


Ramibuk

Recommended Posts

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

Link to comment
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 :-/

Link to comment
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.
Link to comment
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 ;)

Link to comment
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
Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...