ID:150956
 
I want to know how to spawn a mob/dragon in an area every time the die() command runs. The die() command is when the dragon dies. To do this I wrote
die()
if(/mob/dragon)

What should I do?
On 6/26/01 11:31 am Robot100 wrote:
I want to know how to spawn a mob/dragon in an area every time the die() command runs. The die() command is when the dragon dies. To do this I wrote
die()
if(/mob/dragon)

What should I do?

That's um, really, uh, lower-level understanding there.

I'll give you a hint:
- use locate() to find a certain turf.
- use new() to create a new dragon.
On 6/26/01 11:31 am Robot100 wrote:
I want to know how to spawn a mob/dragon in an area every time the die() command runs. The die() command is when the dragon dies. To do this I wrote
die()
if(/mob/dragon)

What should I do?

You should either start doing your homework, or find another hobby. Seriously. I told you, just this morning, I think, that you do not refer to objects like "/mob/whatever". That's the type of a thing, not the thing itself. And wasn't it you that I had the whole "If WHAT?" exchange with? Here again, "if(/mob/dragon)" isn't a question!

READ THE FRIGGING GUIDE. READ THE FRIGGING FAQ. DO THE FRIGGING TUTORIALS.
In response to Spuzzum

I'll give you a hint:
- use locate() to find a certain turf.
- use new() to create a new dragon.

I all ready tryed the new command and what turf would I use?
like locate(turf/dragon)
and how would I use that?
In response to Robot100
On 6/26/01 1:17 pm Robot100 wrote:
I'll give you a hint:
- use locate() to find a certain turf.
- use new() to create a new dragon.

I all ready tryed the new command and what turf would I use?
like locate(turf/dragon)
and how would I use that?

first thing is first. eather get your hands on a bunch of other coders work to look around in(like me), or read the guide or the book(like those other coders)
In response to jobe
On 6/26/01 2:16 pm jobe wrote:
first thing is first. eather get your hands on a bunch of other coders work to look around in(like me), or read the guide or the book(like those other coders)

Hehee, that's the best thing to scare him into reading the guide I could ever have thought up. Great work, Jobe.
In response to Shadowdarke
and lexy what if you all ready read all those Like i have and yes still don't know what to do on it. I have been trying every frekin thing.
In response to Robot100
Read them again. When I first started I had to read through the guide and what few other help files there were at the time at least two or three times before I grasped the concept of there being a difference between object prototypes and actual objects. Curse my days of non-OO programming. (I can't really tell since you have so little code here, but it appears you may be making the same mistake.)
Anyway, as Lexy graciously pointed out, if(/mob/dragon) doesn't mean anything. For the most part, you'll be using if to compare two statements, ie.
if(statement1==statement2)
As has been pointed out in another thread, if actually evaluates the entire statement and runs its code if it is true, or doesn't if it is false, but you can kinda ignore that for the time being.
What I think you want to check is if the mob type is /mob/dragon which is accomplished through this code
if(type==/mob/dragon)
assuming that its run from a mob proc (which it kinda has to be, or from a proc where the dying mob is passed as an argument, but its just easier this way). What this does is look at the mob's type var (which is set automatically, and you can't change), and compare's it to /mob/dragon. If it is equal to it, it'll perform the code in the if statement, otherwise it won't.

[Edit:] I used comparing type for simplicity, but on second thought, it'd be better to do it this was:
if(istype(src,/mob/dragon))
Which will catch /mob/dragon and all subclasses thereof.

-AbyssDragon
In response to AbyssDragon
Die()
if(type==/mob/GM)
world << "[usr.name] died."
if(istype(src,/mob/dragon))
new_dragon = new /mob/dragon(locate(23,8,2))
del(src)

I have that code but when my HP = 0
the text says dragon died.
Why does it think the usr is the dragon when I die?
In response to Robot100
I'm not sure why, but usr is dragon. I'd have to see more code to understand why (note: it probably shouldn't be that way, so something else might be wrong. I'm not certain though.). Src would be the GM in that case.
-AbyssDragon
In response to AbyssDragon
here is the whole Battle System code
mob
var/mob/new_dragon

hit_points = 20

var
strength = 5

lifecycle_delay = 10 // How long between actions for an NPC?
movement_probability = 50 // How likely to move in a lifecycle?

verb
attack(mob/victim as mob in oview(1))
Attack(victim)

proc
Attack(mob/victim)
var/potential_damage = strength
victim.TakeDamage(src, potential_damage)

TakeDamage(mob/attacker, potential_damage)
// Can't kill me if I'm already dead.
if (isDead())
view(src) << "[attacker] hits [src]'s dead body!"
return

// Damage is reduced based on my armor class and defense.
var/defense_modifier = armor_class + defense
potential_damage -= defense_modifier

if (potential_damage > 0)
hit_points -= potential_damage
view(src) << "[attacker] hit [src] for [potential_damage] points damage!"

if (isDead())
view(src) << "[attacker] killed [src]!"
Die()
return
else
view(src) << "[attacker]'s attack bounces harmlessly off [src]."

Die()
if(type==/mob/GM)
world << "[usr.name] died."
if(istype(src,/mob/dragon))
new_dragon = new /mob/dragon(locate(23,8,2))
del(src)

isDead()
if (hit_points <= 0)
return 1
return 0

LifeCycle()
// For handling NPC behavior, so if this mob has a client (player), skip this.
if (client || isDead())
return

// By default just have them walk around.
if (prob(movement_probability))
step_rand(src)

spawn(lifecycle_delay)
LifeCycle()

mob/dragon
icon = 'dragon1.dmi'

New()
// First do default stuff.
..()

// Start my lifecycle at a random point.
spawn(rand(10))
LifeCycle()
return

LifeCycle()
if (client || isDead())
return

var/action_taken

// Before moving, NPC cops see if there is someone to attack within 1 space.
for (var/mob/other_mob in oview(1, src))
// But don't attack if it's another cop or they are dead...
if (istype(other_mob, /mob/dragon) || istype(other_mob, /mob/InnMaster) || istype(other_mob, /mob/SalesItems) || istype(other_mob, /mob/SalesWeapons) || istype(other_mob, /mob/Storyline) || other_mob.isDead())
continue

Attack(other_mob)
action_taken = 1

// No one to attack, so see if a non-cop is within 5 spaces to move toward.
for (var/mob/other_mob in oview(5, src))
if (istype(other_mob, /mob/dragon) || istype(other_mob, /mob/InnMaster) || istype(other_mob, /mob/SalesItems) || istype(other_mob, /mob/SalesWeapons) || istype(other_mob, /mob/Storyline) || other_mob.isDead())
continue

view(src) << "[src] is going after [other_mob]!"
step_towards(src, other_mob)
action_taken = 1

if (action_taken)
spawn(lifecycle_delay)
LifeCycle()
return

// No one around, so do the default behavior.
..()

Then here is the mob/GM code
mob/GM
icon='KniM.dmi'
strength = 8
hit_points = 100
var
gold = 1000
Z = 0

var/turf/new_turf
var/obj/new_obj

New()
..()
new_obj = new /obj/TreeTopLeft(usr.loc)

Stat()
statpanel("Stats")
stat("Name:",usr.name)
stat("HP:",hit_points)
stat("Attack:",strength)
stat("Gold:",gold)
statpanel("Inventory",contents)
statpanel("Build")
stat(new_obj)

verb
say(msg as text)
set category = "Comunaction"
view() << "[usr] says, \"[msg]\""

shout(msg as text)
set category = "Comunaction"
world << "[usr] shouts, \"[msg]\""

whisper(msg as text)
set category = "Comunaction"
view(1) << "[usr] whispers, \"[msg]\""

tell(M as mob in world, msg as text)
set category = "Comunaction"
BlackFloor()
set category = "Floors"
Z += 1

Is that enough code?
In response to Robot100
Okay, usr should be the dragon in that case, assuming its the dragon that killed you. src, however, is the mob that dies.

-AbyssDragon
In response to AbyssDragon
Wow it worked thanks alot AbyssDragon.
Can you go down to the Building trouble now and solve that one?
In response to Robot100
On 6/26/01 6:02 pm Robot100 wrote:
Wow it worked thanks alot AbyssDragon.
Can you go down to the Building trouble now and solve that one?

You know, you should check out DBZ Ultriment, under Games Live! That guy did a lot of the same things you're wanting to... and he's pretty new, too. He might be able to help you out.
In response to LexyBitch
haha very funny I have all ready been there and that's not funny! actually it is :) heheehe but Can you help me out with my building problem now!