-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
227 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Skills/src/main/java/cz/neumimto/effects/negative/Blindness.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cz.neumimto.effects.negative; | ||
|
||
import cz.neumimto.rpg.ClassGenerator; | ||
import cz.neumimto.rpg.effects.*; | ||
import org.spongepowered.api.effect.potion.PotionEffect; | ||
import org.spongepowered.api.effect.potion.PotionEffectTypes; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Created by NeumimTo on 9.7.2017. | ||
*/ | ||
@ClassGenerator.Generate(id = "name") | ||
public class Blindness extends EffectBase<Long> implements IEffectContainer<Long, Blindness> { | ||
|
||
public static final String name = "Blindness"; | ||
|
||
public Blindness(IEffectConsumer consumer, long duration, String value) { | ||
this(consumer, duration); | ||
setValue(duration); | ||
setDuration(duration); | ||
getPotions().add(getEffect()); | ||
} | ||
|
||
public Blindness(IEffectConsumer consumer, long duration) { | ||
super(name, consumer); | ||
} | ||
|
||
|
||
@Override | ||
public Set<Blindness> getEffects() { | ||
return new HashSet<>(Arrays.asList(this)); | ||
} | ||
|
||
@Override | ||
public Long getStackedValue() { | ||
return getDuration(); | ||
} | ||
|
||
@Override | ||
public void setStackedValue(Long aLong) { | ||
setDuration(aLong); | ||
} | ||
|
||
@Override | ||
public void stackEffect(Blindness blindness, IEffectSourceProvider effectSourceProvider) { | ||
setStackedValue(getStackedValue() + blindness.getStackedValue()); | ||
} | ||
|
||
private PotionEffect getEffect() { | ||
return PotionEffect.builder() | ||
.potionType(PotionEffectTypes.BLINDNESS) | ||
.particles(false) | ||
.duration((int) (20 * getStackedValue() / 1000)) | ||
.build(); //miliseconds to minecraft ticks | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
Skills/src/main/java/cz/neumimto/skills/active/Despair.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package cz.neumimto.skills.active; | ||
|
||
import com.flowpowered.math.vector.Vector3d; | ||
import cz.neumimto.Decorator; | ||
import cz.neumimto.ParticleUtils; | ||
import cz.neumimto.core.ioc.Inject; | ||
import cz.neumimto.effects.negative.Blindness; | ||
import cz.neumimto.rpg.IEntity; | ||
import cz.neumimto.rpg.ResourceLoader; | ||
import cz.neumimto.rpg.damage.SkillDamageSource; | ||
import cz.neumimto.rpg.damage.SkillDamageSourceBuilder; | ||
import cz.neumimto.rpg.effects.EffectService; | ||
import cz.neumimto.rpg.entities.EntityService; | ||
import cz.neumimto.rpg.players.IActiveCharacter; | ||
import cz.neumimto.rpg.skills.*; | ||
import cz.neumimto.rpg.utils.Utils; | ||
import org.spongepowered.api.effect.particle.ParticleEffect; | ||
import org.spongepowered.api.effect.particle.ParticleOptions; | ||
import org.spongepowered.api.effect.particle.ParticleTypes; | ||
import org.spongepowered.api.entity.Entity; | ||
import org.spongepowered.api.entity.living.Living; | ||
import org.spongepowered.api.event.cause.entity.damage.DamageTypes; | ||
import org.spongepowered.api.util.Color; | ||
import org.spongepowered.api.util.Direction; | ||
import org.spongepowered.api.world.Location; | ||
import org.spongepowered.api.world.World; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Set; | ||
|
||
/** | ||
* Created by NeumimTo on 15.7.2017. | ||
*/ | ||
@ResourceLoader.Skill | ||
public class Despair extends ActiveSkill { | ||
|
||
@Inject | ||
private EntityService entityService; | ||
|
||
@Inject | ||
private EffectService effectService; | ||
|
||
public Despair() { | ||
setName("Despair"); | ||
setDamageType(DamageTypes.MAGIC); | ||
SkillSettings settings = new SkillSettings(); | ||
settings.addNode(SkillNodes.DURATION, 1000L, 500); | ||
settings.addNode(SkillNodes.DAMAGE, 10L, 1.5f); | ||
settings.addNode(SkillNodes.RADIUS, 7L, 2); | ||
super.settings = settings; | ||
} | ||
|
||
@Override | ||
public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, SkillModifier modifier) { | ||
int k = getIntNodeValue(info, SkillNodes.RADIUS); | ||
Set<Entity> nearbyEntities = Utils.getNearbyEntities(character.getEntity().getLocation(), k); | ||
double damage = getDoubleNodeValue(info, SkillNodes.DAMAGE); | ||
long duration = getLongNodeValue(info, SkillNodes.DURATION); | ||
|
||
for (Entity nearbyEntity : nearbyEntities) { | ||
if (Utils.isLivingEntity(nearbyEntity)) { | ||
Living l = (Living) nearbyEntity; | ||
if (Utils.canDamage(character, l)) { | ||
IEntity iEntity = entityService.get(l); | ||
SkillDamageSource build = new SkillDamageSourceBuilder() | ||
.fromSkill(this) | ||
.setTarget(iEntity) | ||
.setCaster(character).build(); | ||
l.damage(damage, build); | ||
Blindness blindness = new Blindness(iEntity, duration); | ||
effectService.addEffect(blindness, character, this); | ||
} | ||
} | ||
} | ||
|
||
Vector3d vec = new Vector3d(0,1,0); | ||
Decorator.circle(character.getEntity().getLocation(), 36, k, location -> { | ||
ParticleEffect build = ParticleEffect.builder() | ||
.type(ParticleTypes.SPELL) | ||
.option(ParticleOptions.COLOR, Color.GRAY) | ||
.build(); | ||
character.getEntity().getLocation().getExtent().spawnParticles(build, location.getPosition().add(vec)); | ||
build = ParticleEffect.builder() | ||
.type(ParticleTypes.MOB_SPELL) | ||
.option(ParticleOptions.COLOR, Color.GRAY) | ||
.build(); | ||
character.getEntity().getLocation().getExtent().spawnParticles(build, location.getPosition().add(vec)); | ||
}); | ||
|
||
return SkillResult.OK; | ||
} | ||
} |