Jump to content

Moving dead bodies


Ramibuk

Recommended Posts

I started learning how to manipulate with ingame objects, but im stuck at this :

 

I pick up body,it disappear completlly, but when i place it to new tile,it appear on old tile,but it have container icon and inventory on a new tile. Basically i need "redraw" dead body on new tile

 ...--pick up body from squareif instanceof(object, "IsoDeadBody") then                corpse=object                square:getStaticMovingObjects():remove(object)                end...--drop body on squaresquare:AddSpecialTileObject(corpse)--test with white colorlocal color=ColorInfo.new(0.7333333492279053,0.7333333492279053,0.7333333492279053, 1)corpse:render(square:getX(),square:getY(),square:getZ(),color,true)corpse:update()

I dont have any experience with this and im only  guessing how it could work so any advice is welcome

Link to comment
Share on other sites

The camping.lua has a good example of drawing sprites on tiles (If I remember when I get home I'll dig out the code). Each sprite will presumably have an identifier and you may be able to retrieve it from the IsoDeadBody. You can then use this to recreate the sprite in the new tile.

Link to comment
Share on other sites

I started learning how to manipulate with ingame objects, but im stuck at this :

 

I pick up body,it disappear completlly, but when i place it to new tile,it appear on old tile,but it have container icon and inventory on a new tile. Basically i need "redraw" dead body on new tile

 ...--pick up body from squareif instanceof(object, "IsoDeadBody") then                corpse=object                square:getStaticMovingObjects():remove(object)                end...--drop body on squaresquare:AddSpecialTileObject(corpse)--test with white colorlocal color=ColorInfo.new(0.7333333492279053,0.7333333492279053,0.7333333492279053, 1)corpse:render(square:getX(),square:getY(),square:getZ(),color,true)corpse:update()

I dont have any experience with this and im only  guessing how it could work so any advice is welcome

 

the colour info part of IsoGameCharacter is notoriously difficult.... couldn't get it to work myself but it looks like it wants the hash data from the ColorInfo object not the object itself. I'm not sure that render() line will work....

You will probably HAVE to copy the sprite directly from the original like Stormy is suggesting & let the Java handle that part

 

Edit:

 

If I'm wrong I would REALLY appreciate a heads up because:

zombie = getVirtualZombieManager():createRealZombieNow(gridx, gridy, gridz);zombie:setInf(ColorInfo.new(r, g, b));

was giving me all sorts of hassles :(

(there may have been an alpha in there but can't be arsed looking it up right now :D)

Link to comment
Share on other sites

IsoMovingObject has setX(), setY(), setZ() methods, maybe try:

 ...--pick up body from squareif instanceof(object, "IsoDeadBody") then                corpse=object                square:getStaticMovingObjects():remove(object)                end...--drop body on square--Ammendmentscorpse:setX(square:getX());corpse:setY(square:getY());corpse:setZ(square:getZ());square:AddSpecialTileObject(corpse)corpse:update()

I am of course assuming that those are different functions & square is updating on mouse move (dont take that the wrong way, I had to say it because of the code that I cant see. Not implying that you've done something wrong elsewhere :D)

 

Edit:

 

My reasoning behind this is, the corpse is a IsoMovingObject and all you have done is remove then add it without changing his fields.... Worth a try at any rate :)

Link to comment
Share on other sites

Good one ExcentricCreation,this actualy move sprite but only after restart and sprite is flying in middleair so i need to update it somehow.

 

this is working core of my test code  

TEST={}--storage for dead bodyTEST.Body=falsefunction TEST.menu(playerNum, _context, _worldObjects)    --_worldObjects contains only floors.windows,doors etc    local square=_worldObjects[#_worldObjects]:getSquare() or false    --test if moving with body and drop it    if TEST.Body then        _context:addOption("Drop",TEST.Body,TEST.onDrop,square)    else        --if not moving with body then pick some        local objects = square:getStaticMovingObjects();        for i=0, objects:size() - 1 do            if instanceof(objects:get(i), "IsoDeadBody") then                _context:addOption("Pick",objects:get(i),TEST.onPick, square)            end        end    endendfunction TEST.onPick (corpse,square)    TEST.Body=corpse    square:getStaticMovingObjects():remove(corpse)    square:getCell():Remove(corpse)endfunction TEST.onDrop(corpse,square)    corpse:setX(square:getX());    corpse:setY(square:getY());    corpse:setZ(Math.floor(square:getZ()));    square:AddSpecialTileObject(corpse)    TEST.Body=falseendEvents.OnFillWorldObjectContextMenu.Add(TEST.menu) 

Also im adding dead body as SpecialTileObject so its not in StaticMovingObjects but  in MovingObjects  and it cant be picked up again right now.

 

I will  try few more things later with updating corpse and adding different types of objects.

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...