Posts ID:169920 Favorites Creations Medals
ID:169920

Problem: My battle system isn't exactly the best, and its kinda *Cough*Gay*Cough*. But I need it were it works in the best way possible for a .Hack RPG game, and then on my monster A.I system, I need it were if a monster is attacking one person it wont go off attacking someone else it sees. Here are the codes:

Battle System:
 ```mob/verb/Attack(mob/M in oview(1))//This will be used to make the demo challenging var/damage = usr.Str/M.Def M<<"[src] attacked you for [damage] damage!" if(src.client) src<<"You attacked [M] for [damage] damage!" M.Hp -= damage src.deathcheck(M) if(src.client)//Only players can gain levels //adds random exp points//calls the levelup proc else return..()//normal actionmob/proc/deathcheck(mob/M as mob)//handles death if(M.Hp<=0)//checks health if(M.client)//if is a player M.loc = locate(11,4,1)//restarts M.Hp = M.Mhp//resets health M<<"[src] killed you!"//tells you, you were killed. src.Levelup() else//not a player src<<"You killed [M]!" del(M)//Tells you who you killed src.Exp+=rand(10,50) sleep(200) world.Repop() //random location after deathmob proc Levelup() if(usr.Exp>=src.MExp)//If your exp var equals, or passes your maxexp var usr.Lvl++//Add to your level usr.Exp=0//resets your exp to 0 usr.MExp+=rand(1,25)//makes your maxexp double usr.Str+=rand(1,10) usr.Def+=rand(4,5) usr<<"You gained a level!" else ..() ```

Monster A.I:
 ```mob/monster/Basilisk//Defines a /mob/NPC icon = 'Monsters.dmi' icon_state = "Basilisk" Hp = 100 Str = 15 Def = 10 proc/move()//Now, this proc handles NPC movement for(var/mob/M in oview())//loops over all mobs in view if(get_step_away(src,M,3))//checks distance if(!M.client)//Not a player continue//continues through the loop else//Player walk_to(src,M,1,4)//Move to the person else//4-or-more spaces away continue spawn(20) move()//loops the proc after 2 seconds proc/attackplayer()//Handles attacking for(var/mob/M in oview(1))//Within one space this time if(get_step_away(src,M,1)) if(!M.client) continue else src.Attack(M)//Calls the attack proc else return..() spawn(20) attackplayer() New()//When created attackplayer()//Calls the procs for it move() ```

~C
 #1 Apr 13 2005, 1:32 pm Maybe add a target variable, and when you attack make the one being attacked name the variable. Then you can do a while loop maybe.
 #2 Apr 13 2005, 3:15 pm No put usr in proc. Ungh. Lummox JR
In response to Lummox JR (#2)
Lummox JR wrote:
No put usr in proc. Ungh.

Lummox JR

What happens if you do:
 ```mob/proc/lololusr() usr=src world<
 #4 Apr 13 2005, 3:33 pm In response to Hell Ramen (#3) Hell Ramen wrote: Lummox JR wrote: No put usr in proc. Ungh. Lummox JR What happens if you do: This.
 #5 Apr 13 2005, 3:37 pm In response to Lummox JR (#2) Lummox JR wrote: No put usr in proc. Ungh. Lummox JR Found ~200 matches for "No put usr in proc. Ungh." That's starting to get a bit sad...
 #6 Apr 13 2005, 3:50 pm In response to Flick (#4) Flick wrote: Hell Ramen wrote: Lummox JR wrote: No put usr in proc. Ungh. Lummox JR What happens if you do: This. That has nothing on that. =/ Except; "The only time usr is assigned for you is when a player (in Dream Seeker) executes a verb, clicks something with the mouse, or any other such action." BUT, I still don't see why setting usr like that doesn't work. (I don't do it)