ID:273709
 
Well.. Im making a pokemon game and im up to the Wild Pokemon part..


I made it so it does a poke-rand summon..

But inorder to summon the pokemon I did this as my code:

mob
proc
PokeRand()
var/pokerand=rand(1,31)
if(pokerand==1)
for(var/mob/Pokemon1st/Pikachu/P in world)
P.loc=usr.loc

Now.. it does summon the pokemon, but It only summons the pokemon that I add to the map, if its not in the map then it doesnt summon the pokemon period..

I had to make a full map full of pokemon in-order to allow it to summon and that cuases a large amount of lagg.. Anyone can help me with that


"in world" part? Is there another way I can just create a freshly new made mob thats not in the map?
var/mob/npc/Pikachu/M = new

I guess thats what u want.
new. Also, 31 if's is going to look silly.

var/list/PokeList = new // Make a list
for(var/M in typesof(/mob/Pokemon1st)-/mob/Pokemon1st) PokeList+=M // Add all pokemon from /mob/Pokemon1st to the list
var/PokePath = pick(PokeList) // Pick a random pokemon out of the list
new PokePath(loc) // Create it at whoever's location
In response to SinMaster1996 (#1)
Alright I tried that but now i get an error:

This is the code I finished off with


mob
proc
PokeRand()
var/pokerand=rand(1,31)
if(pokerand==1)
var/mob/Pokemon1st/Pikachu/P= new
P.loc=usr.loc

if(pokerand==2)
var/mob/Pokemon1st/Oddish/O= new
O.loc=usr.loc

if(pokerand==3)
var/mob/Pokemon1st/Shaymin/S= new
S.loc=usr.loc

if(pokerand==4)
var/mob/Pokemon1st/NidoranM/NM= new
NM.loc=usr.loc



I got an error that says:


Programming\Pokemon.dm:15:error: : missing expression
Programming\Pokemon.dm:19:error: : missing expression
Programming\Pokemon.dm:23:error: : missing expression
Programming\Pokemon.dm:27:error: : missing expression


Those errors highlight these codes:

P.loc=usr.loc
O.loc=usr.loc
S.loc=usr.loc
NM.loc=usr.loc


In response to Emasym (#2)
TY so much!


Also do you know the code to make the chances/odds higher?

Like:


mob
proc
PokeRand()
var/list/PokeList = new // Make a list
for(var/M in typesof(/mob/Pokemon1st)-/mob/Pokemon1st) PokeList+=M // Add all pokemon from /mob/Pokemon1st to the list
var/pokerand=rand(1,5)
if(pokerand==1)
var/PokePath = pick(PokeList) // Pick a random pokemon out of the list
new PokePath(loc) // Create it at whoever's location
if(pokerand==2)
return
if(pokerand==3)
return
if(pokerand==4)
return



I want to make the rand from 2-4 a higher chance than rand 1.
In response to Yukay Karyuu (#4)
1) There is no "the code", there are just ways to achieve a goal
2) Math. Simplest would be to use the prob() function.

if(prob(25)) // 25% chance
// do stuff
else
// do other stuff
In response to Yukay Karyuu (#4)
Pick would work, though I'm not too fond of your implementation here.

Store the paths of the Pokemon in a list and pick them from the list using the pick(). Using the stored path varible, create a new instance.
In response to Pirion (#6)
In theory that is more effective CPU wise, as the list is already there, but who fancies hard-coding a list with 151 paths, which you've got to update every time you change paths/add pokemon/delete pokemon?

That's just silly.
In response to Emasym (#7)
A generated list of paths is more what I was thinking.

In response to Pirion (#8)
Like in my example?
In response to Emasym (#9)
yes, your one I like. It's the op one I do not. Sorry if that wasn't clear.

I ment just adding pick to it, and the weights.
In response to Emasym (#2)
Personally, I think it'd be better to make a bunch of different areas that have a list of possible wild pokemon that will appear in whatever patch of grass to achieve the same thing as the actual pokemon games, with their associated values the percentage chance that they will appear.

area/wild
var/list/wilds
proc/Step(mob/a)
for(var/Type in src.wilds)
if(prob(src.wilds[Type])
new Type(a.loc)
route110
wilds = list(/mob/pokemon/caterpie=60,/mob/pokemon/pikachu=10,/mob/pokemon/wurmple=60)

client/Move()
if(..()) //if movement was successful
var/turf/t = src.mob.loc
var/area/a = t.loc
if(istype(a,/area/wild))
var/area/wild/w = a
w.Step(src.mob)
In response to Yukay Karyuu (#3)
I ran that error through my computer and found that when it says "missing expression" it means that the if statements have nothing to do. Though you gave them something to do you put it in the wrong place.
Every time from the left of the screen you put a tab it signifies the position in which you want your code to be under.

                 // This Is your code.
if(pokerand==1) // This checks to see wether or not this pokemon was picked.
var/mob/Pokemon1st/Pikachu/P= new //This line makes a new pokemon of the /Pikachu type in the varible P
P.loc=usr.loc //this line was suppost to take that new pokemon symbolised by the varible P
//This /\ is where you went wrong.
//This space here tells the computer you want the code "P.loc=usr.loc" under your varible "P"
//But what you really wanted was "P.loc=usr.loc" under the if statemant where it can be executed if(picked).
//to fix this we take out the extra space/tab.

// This Is my code.
if(pokerand==1) // This checks to see wether or not this pokemon was picked.
var/mob/Pokemon1st/Pikachu/P= new //This line makes a new pokemon of the /Pikachu type in the varible P
P.loc=usr.loc //This puts the pokemon in the varible "P" at the usr's location
//Yes a little white space can mess you up that much and more.
//It even baffled me for a sec!


Try taking out the extra tab/space before the code on each of those broken lines and see if I am wrong.
If I am right then remember to keep your tabs under the place there suppose to be executed at.
In response to Cat of blades (#12)
I do not know if you are still having problems but this library can help
Random Battles
In the NewBattle proc edit
if(T.y==2&&B<=9)
var/mob/E = new/mob/Mon/bug(T)
E.lv = B
E.HP = 50*B
E.Def = rand(1,5)*E.lv
E.NoM += 1
for(var/mob/Mon/Mo in world)
if(Mo==E)continue
Mo.NoM+=1
E.NoM += 1

to
if(T.y==2)
if(B==1)
var/mob/E = new/mob/Pokemon1st/Pikachu(T)
E.lv = 1
E.HP = 50
E.Atk = 25
E.Def = 25
E.Sth = 2

repeat for all your pokemon
B+=1//Make B 1 high for each pokemon


For chances/odds
turf/Mon/Entered(mob/A)
if(ismob(A))
var/RAND=rand(1,10)
if(RAND==5)
A.MZ=world.maxz+1
NewBattle("NB[A.MZ]",src.B)
for(var/mob/Player/P in world)
P.LX=P.x
P.LY=P.y
P.LZ=P.z
P.MZ=A.MZ
P.loc = locate(P.PN,1,A.MZ)
P.dir = NORTH
P.verbs+=/mob/proc/Attack
P.verbs+=/mob/proc/Attack00
P.verbs+=/mob/proc/Attack99

and for random pokemon like in the Nintendo games
<DM>proc/NewBattle(map as text,B as num)
......//lines I cut out
for(var/turf/T in block(locate(M.x1,M.y1,M.z1),locate(usr.TN,2,M.z2)))
new/turf/grass(T)
if(T.y==2)
if(B==1)
var/mob/E = pick(/mob/Pokemon1st/Pikachu,/mob/Pokemon1st/Oddish)
E.loc = T
E.lv = 1
E.HP = 50
E.Atk = 25
E.Def = 25
E.Sth = 2