I cant seem to get my piece of coding to work so i deleted it.
If somebody would be so kind and to code it for me or show me a easy trick i would appreciate it.
Ok. I want it to create a new mob at random when u walk over the turf, my real problem is the random part i can not seem to get it 2 work and the creating a new mob. Should i code a proc for it or not? or just code what i want it to do under the turf?
ID:159458
Mar 9 2009, 11:05 am
|
|
Mar 9 2009, 3:25 pm
|
|
You need a far better description of what you want.
|
So when you walk over a cetain turf you want a random mob to appear? You could use this if I understand you correctly:
turf something along those lines? You'll need to tweek that of course so it knows where to put the mobs and such, but the idea around the random part is the rand() proc there. The 1,3 I put is that it chooses between setting the value between 1 and 3. You can make it anything you want though. I think that's what you're looking for. |
In response to Fugsnarf
|
|
thanx a lot that's exactly what i needed. I guess i was just forgetting the Entered() proc.
|
In response to Fugsnarf
|
|
A more effecient way to do the random mobs part is this, just so you don't have to write 20 lines of code for 10 mobs, only 2.
var/t = pick(mob/bob,/mob/george,mob/jim)//Put all mobs here |
In response to Bakasensei
|
|
Bakasensei wrote:
var/t = pick(mob/bob,/mob/george,mob/jim)//Put all mobs here You could even use typesof, if you have all if the possibilities defined under a node. var/p = pick(typesof(/mob/random_enemy)-"/mob/random_enemy") |
In response to Schnitzelnagler
|
|
thanx for all the help and siggestions but im getting a runtime error everytime the mob walks over the turf.
runtime error: Cannot read 0.loc proc name: Entered (/turf/pokegrass/Entered) usr: 0 src: the pokegrass (1,10,1) (/turf/pokegrass) call stack: the pokegrass (1,10,1) (/turf/pokegrass): Entered(the charmander (/obj/enemy/charmander), the pokegrass (1,11,1) (/turf/pokegrass)) the charmander (/obj/enemy/charmander): look() the charmander (/obj/enemy/charmander): New(the pokegrass (1,11,1) (/turf/pokegrass)) the pokegrass (1,11,1) (/turf/pokegrass): Entered(the asdfsadf (/mob), the pokegrass (1,12,1) (/turf/pokegrass)) got any suggestions? |
In response to Blip182
|
|
Could you post the related snippet of your code, please?
|
In response to Schnitzelnagler
|
|
turf |
In response to Blip182
|
|
turf Using usr in proc(edures) isn't save. Edit: You(r code) might profit from looking up switch. |
In response to Schnitzelnagler
|
|
thanx so much for the help i dont get the runtime error anymore
Heres my code. turf |
In response to Blip182
|
|
You didn't really improve the code one bit, and you're still using usr. Copying usr into another var has no effect, as both vars are then identical, and if usr was wrong/invalid, your new var is as well. So it's still usr-abuse. Essentially you don't have to try accessing what entered the turf (which would be appropriate to do by Entered() argument, not usr. You need to look all of these up, as well as src.) to begin with here, since you're only wanting to use the turf, which is already available seeing as the proc is defined on it, so it's the source of the proc.
|
In response to Schnitzelnagler
|
|
Why do you subtract a text string like that? I don't see how it helps :\ Please explain?
|
In response to Spunky_Girl
|
|
I was actually going to comment on that, but didn't deem it worthy of an extra post. The text string is indeed a mistake; it shouldn't have been one, and just the type path (so, no quotes). Incidentally, a text string would've been fine inside the parentheses there.
The reason this is often needed is because the list typesof(Type) includes Type itself (or, the base parent type you've used), and such types are often not meant to be directly used but exist for inheritance purposes. For example, you could have types such as /obj/item or /mob/monster that aren't actual full prototypes with icons and all, in contrast to /obj/item/apple or /mob/monster/rat. Schnitzel presented a similar thing with the "mob/random_enemy" ancestor type. |
In response to Kaioken
|
|
I'm afraid I still don't fully understand it... So he adds everything that's got the parent type of "/mob/random_enemy", but each iteration will remove the parent type, leaving only the child? So if you have...
mob/random_enemy ...you'll only be adding "rat", "mole", and "wurm" to the list? |
In response to Spunky_Girl
|
|
Pretty much, though I don't know what iteration you're talking about, as there is none here. It's pretty simple like you've said though - removing Type from the result of typesof(Type) leaves you with only the descendants of Type in the list (so without Type itself).
|
In response to Kaioken
|
|
Sorry, Schnitzel used pick() while I used a for() loop on my end xD
So what would be the benefit of only adding descendants of the typepath to a list? When you go to reference it, how would it know to reference that specific mob? Or are you just removing the textual representation of the typepath, so the full pth is still there, but it only shows the child? Kind of like an associative list... "rat" = /mob/radom_enemy/rat |
In response to Spunky_Girl
|
|
There's nothing special or any special benefit here, and note it's not text or associative list related either. You simply may not want the main type to be included in the list, in which case you remove it, so it isn't.
mob/monster |
In response to Kaioken
|
|
Oh! I see! I was thinking of it differently! xD
var/list/type_paths = list() |