thmsndk / Screeps3D

A 3D client for the MMORTS Screeps.com
89 stars 17 forks source link

Support for PowerBanks #23

Open thmsndk opened 5 years ago

thmsndk commented 5 years ago

bonzaiferroni#5

https://docs.screeps.com/api/#StructurePowerBank https://docs.screeps.com/power.html#Power-Banks

official-powerbank Has the following description in the side panel

This structure emits bright light and splashes of sparks. Write more detailed tasklist

  • [x] Model
  • [ ] Animate taking damage
  • [ ] Animate return damage
  • [x] visualize capacity
  • [ ] visualize decay
thmsndk commented 5 years ago

KittyTack on slack suggested the following as visuals

The pBank could be a semitransparent parallelepiped with a red pulsing sphere in it,

thmsndk commented 5 years ago

Initial base model image

thmsndk commented 5 years ago

Added an "animated spherelike energy source" does not animate ingame / in unity though... does in blender. 🤔 😕

image Animation inside blender animated-powersource-powerbank

thmsndk commented 5 years ago

https://www.reddit.com/r/screeps/comments/6nuyx3/basic_question_about_power_banks/

As far as I can tell from the docs, you have to attack the power bank (and deal with the reflecting damage) to access the actual power resource. But once you "crack" the Power Bank does the power resource just drop onto the floor, does it need to then be "Harvested", does the broken Power Bank act as a container? What happens?

Its dropped on the floor in a resource pile. It decays like any other resource pile so u need creeps ready to pick it up.

thmsndk commented 5 years ago

Could do something like this to visualize hitpoints on ther powerBank? Glowing cracks: https://www.youtube.com/watch?v=UEdA5pP5Wrk Shattering objects: https://www.reddit.com/r/Unity3D/comments/65kcys/learn_to_realistically_shatter_game_objects_using/ https://www.youtube.com/watch?v=btagDVtChtg

thmsndk commented 5 years ago

When a powerBank is killed a resource containing power is dropped image this resource is rendered inside the wall and is not colored accordingly to the resource type (power) image image

thmsndk commented 5 years ago

I have trouble figuring out if the creep is hitting a powerBank, and when the creep is getting hit from the powerBank.

Basicly we recieve the following actions on the creep

We could let us inspire by the following and perhaps make a RayTrace.

EffectsUtility.Beam(_creep, _creep.Actions[beam.Key], beam.Value);
var endPos = PosUtility.Convert(target, origin.Room) + new Vector3(0, config.EndHeight, 0);

Alternatively we could lookup what items are currently on that position, will it work with creeps shooting creeps though? what if there is both a creep and a road tile, how do we determine what the creep is actually shooting at?

ssmith151 commented 5 years ago

This is a delicate issue. When the room is made all the objects are given IDs. Those IDs need saved while you are subscribed to a room. Those IDs also have room positions. A dictionary needs to constructed to store IDs at those positions. During the tick where something is attacked you have that action log for the attacking object to the position. That position gets looked up to find the IDs. Look at each ID and all of the data came in this tick to see if "hits" is in JSONobject. Solves most scenarios. Not the case for multiple aggressors attacking differing structures in the same space though. The renderer does no distinguish between these either. It might be best to make it ambiguous.

tl;dr Hits being reduced is a good way to solve most of this.

thmsndk commented 5 years ago

🤔 I guess we should make a new issue to handle targeting in general, I feel that the support for powerbanks are good enough or atleast on par with the official client now. i'll make a PR for it in its current state very soon unless someone do not agree :)

Gadjung commented 4 years ago

Decay is implemented (as per scaling particles amount) for showing doing/returning dmg i'm not sure it's possible

thmsndk commented 4 years ago

@Gadjung can't we find all creeps in range 3 of it and check if one of their actions was attack/rangedattack/rma on the powerbank? not sure we have other options, not sure on the data we recieve it is just a position, but doing the lookup might be feasable :)

Gadjung commented 4 years ago

one way would be to shift part of creep actions to the 'receiving end' like i've done with heal (that heal effect is played on creep that has healed action)