ID:273540
 
do you guys know how to make a character go in to a battle stance when he get hit or is attacking something.and id like to make a time elay on the battle stance aswell.but when the moves he goes back to hes normal icon_state
The ComEdiAn wrote:
do you guys know how to make a character go in to a battle stance when he get hit or is attacking something.and id like to make a time elay on the battle stance aswell.but when the moves he goes back to hes normal icon_state

i wouldnt bother with the whole if an enemy moves away thing then stance returns to normal. Just for a state change i would just make it have a time delay then possibly a verb to change battle stance if the user wishes too.

Create a variable for your mobs called stance or summit and make it equal 0
mob
var
stance = 0


Then i would make a proc to sort out the process
mob
proc
bstance(mob/M)
if(src.stance == 1) //if stance equals 1
src.icon_state = "attack" //change icon state
sleep(100) //change this to however long you want the delay
src.stance = 0 //stance back to 0 after delay
src.bstance(M) //start the proc again
else if(src.stance == 0)
src.icon_state = ""


Then i would add some code to my attack verb watever it may be
mob
verb
attack(mob/M in oview(6))
// usual attack + damage code
if(usr.stance == 0) // if statement makes sure the proc dont get activated to many times cumulating the sleeps within the proc
usr.stance = 1
usr.bstance(M)
if(M.stance == 0)
M.stance = 1
M.bstance(usr)


and there we have it that should work a treat
In response to Tonyth
but how can i make it that if he runs away his icon state goes back to null, and stay in the battle stance
In response to PranCinMonki
You seem to need to learn the basics first.
In response to Darkjohn66
Adding a quick while loop into the proc will achieve what you need
mob
proc
bstance(mob/M)
if(src.stance == 1)
while(1)
if(M in oview(6))
src.icon_state = "attack"
for(M in oview (5))
if(M in oview(4))
break
else
src.stance = 0
src.icon_state = ""
src.bstance(M)
break
else
src.stance = 0
src.icon_state = ""
sleep(1)
else if(src.stance == 0)
src.icon_state = ""

Its not perfect and i kind of just added enough so it would work but i'll let you guys spend the time making it more efficient ;)