ID:170241
 
How would code it so that if a mob has an armor such as suit of flame, that it shoots something like a fireball randomly as long as its equipped? Or like a shield that drains your health? thanks in advance
Give those individual items procedures that do that. Like, flame shield:

obj/FlameShield
proc/RandomFireBall()
var/obj/FireBall/FB=new
walk(FB,pick(EAST,WEST,NORTH,SOUTH))
spawn(rand(100,500))RandomFireBall()

In response to Crashed
Thanx crashed
Reinhartstar wrote:
How would code it so that if a mob has an armor such as suit of flame, that it shoots something like a fireball randomly as long as its equipped? Or like a shield that drains your health? thanks in advance

The best way to do this is something general:

obj/item
// effect while equipped; called periodically by a master event loop
proc/EquippedEffect()

obj/item/armor/flame
name = "suit of flame"
icon_state = "flame"

EquippedEffect()
if(!loc) return
if(prob(5))
// create a new fireball
// loc.loc is the wearer's loc
// loc is the wearer, hence the owner of the fireball
// supply a random direction
new /obj/projectile/fireball(loc.loc, loc, turn(1, rand(0,7)*45))

obj/item/shield/drain
name = "shield of death"
icon_state = "death"

EquippedEffect()
var/mob/M = loc
if(!ismob(M)) return // sanity check
M.health = max(M.health-1, 0)
M.DeathCheck(src) // killed by the shield; note this is not a mob


Then you'd want some code like this to periodically call equipment procs:

mob/Login()
..()
spawn() ProcessEffects()

mob/proc/ProcessEffects()
while(src)
// simple equipment system with just weapon, armor, shield
if(weapon) weapon.EquippedEffect()
if(armor) armor.EquippedEffect()
if(shield) shield.EquippedEffect()
// repeat once per second
sleep(10)


Lummox JR