Skip to content
Browse files

Adds dust vortex monster. Several issues: still called a "recreant" i…

…n the UI, looks wrong.
  • Loading branch information...
1 parent aef9297 commit 5307b5de0e4d56c00cf570c91b77bec08bab947b @clanehin committed Feb 1, 2011
View
1 roguestar-engine/src/Building.hs
@@ -16,7 +16,6 @@ import Plane
import Position
import TerrainData
import Control.Monad.Error
-import CreatureData
import NodeData
import CharacterAdvancement
View
11 roguestar-engine/src/Species.hs
@@ -16,7 +16,7 @@ import TerrainData
player_race_names :: [String]
player_race_names = map (map toLower . show) player_species
-data SpeciesData = SpeciesData {
+data SpeciesData = SpeciesData {
species_recurring_attributes :: CreatureAttribute,
species_starting_attributes :: [CreatureAttributeGenerator] }
@@ -36,15 +36,15 @@ speciesInfo Anachronid = SpeciesData (Speed & Mindfulness & SpotSkill) [
gender 0.8
[aptitudeBlock 1 10 [Speed,Mindfulness],
attributeStatic 2 SpotSkill]
- [aptitudeBlock 10 25 [Speed,Mindfulness],
+ [aptitudeBlock 10 25 [Speed,Mindfulness],
attributeStatic 15 SpotSkill,
surpriseAptitudes],
attributeStatic 1 $ FavoredClass Barbarian,
attributeStatic 1 $ FavoredClass Pirate]
speciesInfo Androsynth = SpeciesData (Strength & Intellect) [
aptitudeBlock 12 17 [Strength,Intellect],
- attributeStatic 1 $ FavoredClass Engineer]
+ attributeStatic 1 $ FavoredClass Engineer]
speciesInfo Ascendant = SpeciesData (Strength & Mindfulness) [
gender 0.45 [] [],
@@ -60,6 +60,11 @@ speciesInfo Caduceator = SpeciesData (Strength & Charisma) [
surpriseAptitudes,
attributeStatic 1 $ FavoredClass Consular]
+speciesInfo DustVortex = SpeciesData (Speed & Mindfulness) [
+ aptitudeBlock 3 5 [Speed,Mindfulness],
+ attributeStatic 10 JumpSkill,
+ attributeStatic 1 $ FavoredClass Barbarian]
+
speciesInfo Encephalon = SpeciesData (Constitution & Intellect) [
gender 0.95 [] [],
aptitudeBlock 3 20 [Constitution,Intellect],
View
1 roguestar-engine/src/SpeciesData.hs
@@ -9,6 +9,7 @@ data Species =
| Androsynth
| Ascendant
| Caduceator
+ | DustVortex
| Encephalon
| Goliath
| Hellion
View
32 roguestar-engine/src/Turns.hs
@@ -61,20 +61,34 @@ dbFinishPlanarAITurns plane_ref =
planar_turn_frequency :: Integer
planar_turn_frequency = 100
+monster_spawns :: [(TerrainPatch,Species)]
+monster_spawns = [(RecreantFactory,Recreant), (Dirt,DustVortex)]
+
dbPerform1PlanarAITurn :: PlaneRef -> DB ()
-dbPerform1PlanarAITurn plane_ref =
+dbPerform1PlanarAITurn plane_ref =
do creature_locations <- dbGetContents plane_ref
player_locations <- filterRO (liftM (== Player) . getCreatureFaction . child) creature_locations
- native_locations <- filterRO (liftM (/= Player) . getCreatureFaction . child) creature_locations
- should_randomly_generate_monster <- liftM (<= 10) $ linearRoll planar_turn_frequency
- when (length native_locations < length player_locations * 2 && should_randomly_generate_monster) $
- do p <- pickM $ map parent player_locations
- m_spawn_position <- pickRandomClearSite_withTimeout (Just 2) 7 0 0 p (== RecreantFactory) plane_ref
- maybe (return () )
- (\spawn_position -> newCreature Pirates Recreant (Standing plane_ref spawn_position Here) >> return ()) $
- m_spawn_position
+ num_npcs <- liftM length $ filterRO (liftM (/= Player) . getCreatureFaction . child) creature_locations
+ when (num_npcs < length player_locations * 2) $
+ do (terrain_type,species) <- pickM monster_spawns
+ _ <- spawnNPC terrain_type species plane_ref $ map parent $ player_locations
+ return ()
dbAdvanceTime plane_ref (1%planar_turn_frequency)
+-- |
+-- Spawn a non-player creature on the specified terrain type (or fail if not finding that terrain type)
+-- and of the specified species, on the specified plane, near one of the specified positions
+-- (presumably the list of positions of all player characters).
+spawnNPC :: TerrainPatch -> Species -> PlaneRef -> [Position] -> DB Bool
+spawnNPC terrain_type species plane_ref player_locations =
+ do p <- pickM player_locations
+ m_spawn_position <- pickRandomClearSite_withTimeout (Just 2) 7 0 0 p (== terrain_type) plane_ref
+ case m_spawn_position of
+ Nothing -> return False
+ Just spawn_position ->
+ do _ <- newCreature Pirates species (Standing plane_ref spawn_position Here)
+ return True
+
dbPerform1CreatureAITurn :: CreatureRef -> DB ()
dbPerform1CreatureAITurn creature_ref = liftM (const ()) $ atomic (flip dbBehave creature_ref) $
P.runPerception creature_ref $ liftM (fromMaybe Vanish) $ runMaybeT $
View
2 roguestar-gl/roguestar-gl.cabal
@@ -26,7 +26,7 @@ Library
PrintTextData, Animation,
Actions, Limbs, Tables, CommandLine,
Models.Androsynth, Models.QuestionMark, Models.Terrain, Models.RecreantFactory,
- Models.Recreant, Models.Ascendant, Models.Materials, Models.Reptilian,
+ Models.Recreant, Models.Glows, Models.Materials, Models.Reptilian,
Models.Library, Models.MachineParts, Models.LibraryData, Models.Caduceator,
Models.Tree, Models.Encephalon, Models.PhaseWeapons, RenderingControl,
Keymaps.BuiltinKeymaps, Keymaps.CommonKeymap, Keymaps.NumpadKeymap,
View
2 roguestar-gl/src/Animation.hs
@@ -43,7 +43,6 @@ import RSAGL.Scene hiding (std_scene_layer_hud,
std_scene_layer_local,
std_scene_layer_infinite)
import RSAGL.Animation
-import RSAGL.FRP.RecombinantState
import Control.Monad.State
import Control.Arrow
import Control.Arrow.Operations
@@ -61,7 +60,6 @@ import Data.List
import Data.Ord
import Strings
import Globals
-import PrintText
import PrintTextData
import Statistics
import Control.Concurrent.STM
View
70 roguestar-gl/src/AnimationCreatures.hs
@@ -8,6 +8,7 @@ import RSAGL.FRP
import RSAGL.Math
import RSAGL.Animation
import RSAGL.Color.RSAGLColors
+import RSAGL.Color
import Animation
import Control.Arrow
import Data.Maybe
@@ -29,10 +30,11 @@ creatureAvatar = proc () ->
returnA -< Nothing
where switchTo "encephalon" = encephalonAvatar
switchTo "recreant" = recreantAvatar
- switchTo "androsynth" = androsynthAvatar
- switchTo "ascendant" = ascendantAvatar
- switchTo "caduceator" = caduceatorAvatar
- switchTo "reptilian" = reptilianAvatar
+ switchTo "androsynth" = androsynthAvatar
+ switchTo "ascendant" = ascendantAvatar
+ switchTo "caduceator" = caduceatorAvatar
+ switchTo "reptilian" = reptilianAvatar
+ switchTo "dustvortex" = dustVortexAvatar
switchTo _ = questionMarkAvatar
genericCreatureAvatar :: (FRPModel m) => FRP e (CreatureAvatarSwitch m) () CreatureThreadOutput -> CreatureAvatar e m
@@ -69,39 +71,49 @@ androsynthAvatar = genericCreatureAvatar $ proc () ->
glower :: (FRPModel m, FRPModes m ~ RoguestarModes,
ThreadIDOf m ~ Maybe Integer) =>
- Point3D -> Vector3D -> FRP e m () ()
-glower p_init v_init = proc () ->
+ LibraryModel -> Point3D -> FRP e m () ()
+glower library_model p_init = proc () ->
do local_origin <- exportToA root_coordinate_system -< origin_point_3d
- transformA
- (accelerationModel fps120 (p_init,perSecond $ v_init)
- (proc () ->
- do a <- derivative <<< derivative <<< exportToA root_coordinate_system -< origin_point_3d
- returnA -< concatForces [quadraticTrap 10 p_init,
- drag 1.0,
- \_ _ _ -> scalarMultiply (-1) a,
- \_ _ _ -> perSecond $ perSecond v_init,
- \_ p _ -> perSecond $ perSecond $ vectorNormalize $
- vectorToFrom origin_point_3d p `crossProduct` v_init])
- (proc (_,()) -> libraryPointAtCamera -< (scene_layer_local,AscendantGlow))) -<
- (translateToFrom local_origin origin_point_3d $ root_coordinate_system,())
+ transformA (accelerationModel fps120 (p_init,zero)
+ (proc () ->
+ do a <- derivative <<< derivative <<< exportToA root_coordinate_system -< origin_point_3d
+ returnA -< concatForces [quadraticTrap 10 p_init,
+ drag 1.0,
+ \_ _ _ -> scalarMultiply (-1) a,
+ \_ p _ -> perSecond $ perSecond $ vectorNormalize $
+ vectorToFrom p_init p `crossProduct` (Vector3D 0 1 0)])
+ (proc (_,()) -> libraryPointAtCamera -< (scene_layer_local,library_model))) -<
+ (translateToFrom local_origin origin_point_3d $ root_coordinate_system,())
-ascendantAvatar :: (FRPModel m) => CreatureAvatar e m
-ascendantAvatar = genericCreatureAvatar $ proc () ->
- do glower (Point3D 0 0.5 0) zero -< ()
- glower (Point3D 0 0.5 0.35) (Vector3D 0 0 (-1)) -< ()
- glower (Point3D 0 0.5 (-0.35)) (Vector3D 0 0 1) -< ()
- glower (Point3D 0.35 0.5 0) (Vector3D (-1) 0 0) -< ()
- glower (Point3D (-0.35) 0.5 0) (Vector3D 1 0 0) -< ()
+particleAvatar :: (FRPModel m) => LibraryModel -> (Maybe RGB) -> CreatureAvatar e m
+particleAvatar library_model m_color = genericCreatureAvatar $ proc () ->
+ do glower library_model (Point3D 0 0.8 0.8) -< ()
+ glower library_model (Point3D 0 0.15 (-0.15)) -< ()
+ glower library_model (Point3D 0.21 0.21 0) -< ()
+ glower library_model (Point3D (-0.26) 0.26 0) -< ()
+ glower library_model (Point3D 0 0.3 0.3) -< ()
+ glower library_model (Point3D 0 0.33 (-0.33)) -< ()
+ glower library_model (Point3D 0.35 0.35 0) -< ()
+ glower library_model (Point3D (-0.36) 0.36 0) -< ()
accumulateSceneA -< (scene_layer_local,
- lightSource $ PointLight (Point3D 0 0.5 0)
- (measure (Point3D 0 0.5 0) (Point3D 0 0 0))
- light_blue
- light_blue)
+ lightSource $
+ case m_color of
+ Just color -> PointLight (Point3D 0 0.5 0)
+ (measure (Point3D 0 0.5 0) (Point3D 0 0 0))
+ color
+ color
+ Nothing -> NoLight)
t <- threadTime -< ()
wield_point <- exportCoordinateSystem -< translate (rotateY (fromRotations $ t `cyclical'` (fromSeconds 3)) $ Vector3D 0.25 0.5 0)
returnA -< CreatureThreadOutput {
cto_wield_point = wield_point }
+ascendantAvatar :: (FRPModel m) => CreatureAvatar e m
+ascendantAvatar = particleAvatar (SimpleModel AscendantGlow) $ Just light_blue
+
+dustVortexAvatar :: (FRPModel m) => CreatureAvatar e m
+dustVortexAvatar = particleAvatar (SimpleModel DustPuff) Nothing
+
caduceatorAvatar :: (FRPModel m) => CreatureAvatar e m
caduceatorAvatar = genericCreatureAvatar $ proc () ->
do libraryA -< (scene_layer_local,Caduceator)
View
1 roguestar-gl/src/AnimationExtras.hs
@@ -16,7 +16,6 @@ import RSAGL.Math
import RSAGL.FRP
import RSAGL.Scene
import Control.Arrow
-import RSAGL.Math.Types
import Data.List ((\\))
import qualified Data.ByteString.Char8 as B
View
1 roguestar-gl/src/Initialization.hs
@@ -5,7 +5,6 @@ module Initialization
Initialization(..))
where
-import System.IO
import PrintText
import Data.Maybe
import Control.Monad
View
1 roguestar-gl/src/Limbs.hs
@@ -14,7 +14,6 @@ import Control.Arrow
import RSAGL.Scene
import RSAGL.FRP
import EventUtils
-import RSAGL.Math.Types
-- | Animate an arbitrary articulated joint.
libraryJointAnimation :: (FRPModel m, FRPModes m ~ RoguestarModes) =>
View
14 roguestar-gl/src/Models/Ascendant.hs
@@ -1,14 +0,0 @@
-module Models.Ascendant
- (ascendant_glow)
- where
-
-import RSAGL.Modeling
-import RSAGL.Color.RSAGLColors
-import RSAGL.Math
-import Quality
-
-ascendant_glow :: Quality -> Modeling ()
-ascendant_glow _ =
- do closedDisc (Point3D 0 0 0) (Vector3D 0 1 0) 0.25
- material $ emissive $ scalarMultiply (1/5) <$> pattern (spherical (Point3D 0 0 0) 0.25 ) [(0.0,pure white),(0.25,pure light_blue),(1.0,pure blackbody)]
- affine $ translate (Vector3D 0 0.25 0)
View
29 roguestar-gl/src/Models/Glows.hs
@@ -0,0 +1,29 @@
+module Models.Glows
+ (ascendant_glow,
+ dust_puff)
+ where
+
+import RSAGL.Modeling
+import RSAGL.Color
+import RSAGL.Color.RSAGLColors
+import RSAGL.Math
+import Quality
+
+ascendant_glow :: Quality -> Modeling ()
+ascendant_glow _ = model $
+ do closedDisc (Point3D 0 0 0) (Vector3D 0 1 0) 0.25
+ material $ emissive $ scalarMultiply (1/3) <$> pattern (spherical (Point3D 0 0 0) 0.25 )
+ [(0.0,pure white),(0.25,pure light_blue),(1.0,pure blackbody)]
+ affine $ translate (Vector3D 0 0.25 0)
+
+dust_puff :: Quality -> Modeling ()
+dust_puff _ = model $
+ do closedDisc (Point3D 0 0 0) (Vector3D 0 1 0) 0.25
+ material $
+ do emissive $ scalarMultiply (1/5) <$> pattern (spherical (Point3D 0 0 0) 0.25 )
+ [(0.0,pure light_pink),(0.25,pure light_brown),(1.0,pure blackbody)]
+ transparent $ pattern (spherical (Point3D 0 0 0) 0.25)
+ [(0.0,pure $ alpha 1.0 $ transformColor light_brown),
+ (1.0,pure $ alpha 0.0 $ transformColor light_brown)]
+ affine $ translate (Vector3D 0 0.25 0)
+
View
3 roguestar-gl/src/Models/Library.hs
@@ -25,7 +25,7 @@ import Models.Tree
import Models.Encephalon
import Models.Recreant
import Models.Androsynth
-import Models.Ascendant
+import Models.Glows
import Models.Caduceator
import Models.Reptilian
import Models.PhaseWeapons
@@ -55,6 +55,7 @@ toModel (SimpleModel Androsynth) = androsynth
toModel (SimpleModel Caduceator) = caduceator
toModel (SimpleModel Reptilian) = reptilian
toModel (SimpleModel AscendantGlow) = ascendant_glow
+toModel (SimpleModel DustPuff) = dust_puff
toModel (SimpleModel PhasePistol) = phase_pistol
toModel (SimpleModel Phaser) = phaser
toModel (SimpleModel PhaseRifle) = phase_rifle
View
1 roguestar-gl/src/Models/LibraryData.hs
@@ -21,6 +21,7 @@ data SimpleModel =
| Recreant
| Androsynth
| AscendantGlow
+ | DustPuff
| Caduceator
| Reptilian
-- Tools
View
4 rsagl-frp/RSAGL/FRP/FRP.hs
@@ -388,9 +388,9 @@ ioAction :: (InputOutputOf m ~ Enabled) => (j -> IO p) -> FRP e m j p
ioAction action = frpxOf $ \_ j -> lift $ action j
-- | Send tagged information.
-outgoingBy :: (j -> j -> Bool) ->
+outgoingBy :: (j -> j -> Bool)
-- ^ Equality predicate as described in 'newTransmitterBy'.
- FRP e m j (Message j)
+ -> FRP e m j (Message j)
outgoingBy f = FRP $ \_ -> FactoryArrow $
do t <- newTransmitterBy f
return $ Kleisli $ lift . transmit t
View
76 rsagl-frp/RSAGL/FRP/RK4.hs
@@ -10,23 +10,23 @@ import RSAGL.FRP.Time
-- | Generic implementation of one time-step of the RK4 algorithm.
genericRK4 :: (AbstractVector v) =>
- (Time -> p -> v -> p) ->
+ (Time -> p -> v -> p)
-- ^ Addition function. Adds a vector to a point using
-- a time-diff. The input vector (@v@) to this function
-- is already scaled to represent the time interval,
-- so the time-diff should be ignored unless this
-- function is to have non-linear with respect to
-- frame rate.
- (Time -> p -> Rate v) ->
+ -> (Time -> p -> Rate v)
-- ^ The differential equation, representing velocity
-- in terms of position at an absolute time.
- p ->
+ -> p
-- ^ Initial value.
- Time ->
+ -> Time
-- ^ Starting time.
- Time ->
+ -> Time
-- ^ Ending time.
- p
+ -> p
genericRK4 addPV diffF p0 t0 t1 =
addPV h p0 $ (scalarMultiply (recip 6)
(abstractSum [k1,k2,k2,k3,k3,k4])
@@ -42,35 +42,35 @@ genericRK4 addPV diffF p0 t0 t1 =
-- | Implementation of RK4 that time steps a system in which velocity is
-- a function of absolute time and position.
rk4 :: (AbstractVector v) =>
- (p -> v -> p) ->
+ (p -> v -> p)
-- ^ Definition of vector addition.
- (Time -> p -> Rate v) ->
+ -> (Time -> p -> Rate v)
-- ^ Differential equation, representing velocity in terms
-- of position at an absolute time.
- p ->
+ -> p
-- ^ Initial value.
- Time ->
+ -> Time
-- ^ Starting time.
- Time ->
+ -> Time
-- ^ Ending time.
- p
+ -> p
rk4 addPV = genericRK4 (const addPV)
-- | Implementation of RK4 that time steps a system in which acceleration
-- is a function of absolute time, position and velocity.
rk4' :: (AbstractVector v) =>
- (p -> v -> p) ->
+ (p -> v -> p)
-- ^ Definition of vector addition.
- (Time -> p -> Rate v -> Acceleration v) ->
+ -> (Time -> p -> Rate v -> Acceleration v)
-- ^ Differential equation, representing acceleration in
-- terms of position and velocity at an absolute time.
- (p,Rate v) ->
+ -> (p,Rate v)
-- ^ Initial value.
- Time ->
+ -> Time
-- ^ Starting time.
- Time ->
+ -> Time
-- ^ Ending time.
- (p,Rate v)
+ -> (p,Rate v)
rk4' addPV diffF = genericRK4
(\t (p,old_v) delta_v -> let new_v = old_v `add` delta_v
in (addPV p $ (scalarMultiply (recip 2) $
@@ -79,18 +79,18 @@ rk4' addPV diffF = genericRK4
(\t (p,v) -> diffF t p v)
-- | Integrate a system of multiple time steps.
-genericIntegrate :: (p -> Time -> Time -> p) ->
+genericIntegrate :: (p -> Time -> Time -> p)
-- ^ Description of a single time step,
-- given position, initial time, and ending time.
- p ->
+ -> p
-- ^ Initial value.
- Time ->
+ -> Time
-- ^ Starting time.
- Time ->
+ -> Time
-- ^ Ending time.
- Integer ->
+ -> Integer
-- ^ Number of time steps.
- p
+ -> p
genericIntegrate _ pn _ _ 0 = pn
genericIntegrate f p0 t0 tn n = genericIntegrate f p1 t1 tn (n-1)
where t1 = t0 `add` (scalarMultiply (recip $ fromInteger n) $ tn `sub` t0)
@@ -99,38 +99,38 @@ genericIntegrate f p0 t0 tn n = genericIntegrate f p1 t1 tn (n-1)
-- | Implementation of RK4 that repeatedly time steps a system in which velocity
-- is a function of absolute time and position.
integrateRK4 :: (AbstractVector v) =>
- (p -> v -> p) ->
+ (p -> v -> p)
-- ^ Definition of vector addition.
- (Time -> p -> Rate v) ->
+ -> (Time -> p -> Rate v)
-- ^ Differential equation, representing velocity in terms
-- of position at an absolute time.
- p ->
+ -> p
-- ^ Initial value.
- Time ->
+ -> Time
-- ^ Starting time.
- Time ->
+ -> Time
-- ^ Ending time.
- Integer ->
+ -> Integer
-- ^ Number of time steps.
- p
+ -> p
integrateRK4 addPV diffF = genericIntegrate $ rk4 addPV diffF
-- | Implementation of RK4 that repeatedly time steps a system in which
-- acceleration is a function of absolute time, position and velocity.
integrateRK4' :: (AbstractVector v) =>
- (p -> v -> p) ->
+ (p -> v -> p)
-- ^ Definition of vector addition.
- (Time -> p -> Rate v -> Acceleration v) ->
+ -> (Time -> p -> Rate v -> Acceleration v)
-- ^ Differential equation, representing acceleration in
-- terms of position and velocity at an absolute time.
- (p,Rate v) ->
+ -> (p,Rate v)
-- ^ Initial value.
- Time ->
+ -> Time
-- ^ Starting time.
- Time ->
+ -> Time
-- ^ Ending time.
- Integer ->
+ -> Integer
-- ^ Number of time steps.
- (p,Rate v)
+ -> (p,Rate v)
integrateRK4' addPV diffF = genericIntegrate $ rk4' addPV diffF
View
4 rsagl/RSAGL/Modeling/Noise.hs
@@ -8,9 +8,9 @@ import Data.Array.Unboxed
import Data.Fixed
import RSAGL.Math.Types
--- | Turbulence function.
+-- | Turbulence function. Accepts an amplitude, which determines
+-- how intense turbulence will be. 'perlinTurbulence 0 == id'
perlinTurbulence :: RSdouble ->
- -- ^ Amplitude of the turbulence function.
Point3D ->
Point3D
perlinTurbulence s (Point3D x y z) = Point3D (x + s*perlinNoise x') (y + s*perlinNoise y') (z + s*perlinNoise z')

0 comments on commit 5307b5d

Please sign in to comment.
Something went wrong with that request. Please try again.