mob
Login()
HealthSystem = new(1, 1)
Attack = new(1)
var
HealthSystem/Health
CalculatedStat/Attack
proc
DeathCheck()
if(Health.IsDead())
world << "[src] dies!"
del(src)
// Monster procs & variables.
monster
var
Name
obj/spawnPoint/spawner
LootSystem/loots
New()
loots = new(1, list())
..()
Del()
spawner.AllowNewSpawn()
var/LootItem/rolledLoot = loots.RollForLoot()
if(rolledLoot == null)
..()
return
var/obj/chest/Chest = new (loc)
Chest.loot = rolledLoot
..()
proc
Copy()
var/mob/monster/result = new()
result.icon = icon
result.icon_state = icon_state
result.Health = Health
result.Attack = Attack
result.Name = Name
result.spawner = spawner
result.loots = loots
return result
// Bug - Basic monster.
monster/bug
Name = "Bug"
icon = 'bug.dmi'
New()
Health = new(15, 15)
Attack = new(1)
Attack.ChangeRandomBonus(1, 2)
var/LootItem/lootTable[] = list()
var/LootItem/goldDrop = new("Gold")
goldDrop.ChangeRandomQuantity(3, 5)
lootTable.Add(goldDrop)
// 50% loot chance of 3-5 Gold.
loots = new(9, lootTable)
..()
obj
spawnPoint/monsterSpawner
minSpawnOffset = 10
maxSpawnOffset = 100
var
// Map Maker's Note
// -------------------------------------
// When you place a monsterSpawner on a
// map, you must right-click/Edit...,
// and in the possibleMinerals field enter
// {mob/monster/[monsterName],...} to
// set this field up.
mob/monster/possibleMonsters[]
Spawn()
var/index = rand(1, possibleMonsters.len)
var/mob/monster/newMonster = possibleMonsters[index]
//var/mob/monster/newMonster = newMonsterPrototype.New(loc)
world.log << "Spawning [newMonster.Name] into world..."
world.log << "HP: [newMonster.Health.HP]/[newMonster.Health.MaxHP]"
newMonster.loc = loc
newMonster.spawner = src
..()
Problem description:
I'm working on creating a generic monster spawner. The idea is to supply a list of monster types (e.g. mob/monster/bug, mob/monster/goblin, mob/monster/mutant_taco), and have the spawner periodically spawn off unique instances of these monster mobs, assuming the previous one has been killed off.
One problem - I can spin off a monster once using a concrete type...
// This works, but limits me to just ever creating a single type of mob.
var/mob/monster/bugMonster/newMonster = new()
...But, it doesn't allow for me to specify which mobs the spawner can generate; I'm locked into only one hardcoded type of mob.
Another thing I tried, is to simply use the type passed into the possibleMonsters list declared on the spawner.
var/index = rand(1, possibleMonsters.len)
var/mob/monster/newMonster = possibleMonsters[index]
newMonster.loc = loc
The code I've got above does a slightly better job of spawning cosmetically distinct mobs, but doesn't copy their more complex stats, like Health Systems or Calculated Stats.
var/index = rand(1, possibleMonsters.len)
var/mob/monster/newMonsterPrototype = possibleMonsters[index]
// Copy is a method that returns a deep copy of the monster, supposedly.
var/mob/monster/newMonster = newMonsterPrototype.Copy()
newMonster.loc = loc
I've found this is functionally no different than what I had before.
Question - DreamMaker is a new language for me. I'm trying to apply patterns I'm familiar with, but it's certain that A) I don't know a great many things about DM, and B) my spawner setup as it currently is doesn't work in a way that DM supports. So, in what way can I write a more generic spawner?