Jump to content
  • 0

unitattack issue


Kurofly

Question


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Hello rathena people !
I'm simply trying to make two monsters fight amongst themselves with the following script :

prontera,155,175,4 script test 46,{

mes "[test]";
mes "Je vais invoquer deux monstres et tenter de les faire combattre ."; //I'm gonna spawn 2 mobs and make them fight each other
if (select("ok:non") == 2) end;

@gid1 = monster ("prontera",153,170,"poring",1002,1);
@gid2 = monster ("prontera",155,170,"drops",1113,1);
unitattack @gid1 , @gid2 , 1;
unitattack @gid2 , @gid1 , 1;
}

When the monsters spawn, they run into each other. When they're on the same square they stop and turn into "I don't give a damn" mode, doing what they want again. /hum

 

I already followed this guide to have the GID based functions working and so the unitattack command returns 1(success).

I also downloaded this patch as it seemed to be able to solve my problem but when I compiled my server I got errors (I'm running on rA 17706).

 

If anyone could help me, I'd really appreciate it  /no1

Edited by Kurofly
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

I solved my problem /no1

 

If anyone ever wants to make monsters fight amongst themselves, here is what you need in order to do so:

 

 

-open your server folder trunk/src/map/script.c and look for the monster function : 

BUILDIN_FUNC(monster) {

look for this line :

int mobid = mob_once_spawn(sd, m, x, y, str, class_, 1, event, size, ai);

 

then replace it to these :

int mobid = mob_once_spawn(sd, m, x, y, str, class_, 1, event, size, ai);
script_pushint(st,mobid);

 

Now the monster command returns the GID of the monster created

 

-make two monster, one with an IA of 0 and the other with an IA of 1, and save their GID to use it later :

.gid1 = monster ("prontera",153,170,"poring",1002,1,"",0,0);
.gid2 = monster ("prontera",154,170,"drops",1113,1,"",0,1);

You can now use all of the GID based commands and make an epic fight between a poring and a drops  :D

 

viewer.php?id=892067screen.jpg

Edited by Kurofly
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  265
  • Reputation:   95
  • Joined:  09/30/14
  • Last Seen:  

I was also unable to make units attack each other. I got unitwalk and setunitdata working just fine, so it wasn't the GID being messed up.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Monster command already return the gid in $@mobid array

mapreg_setreg(reference_uid(add_str("$@mobid"), i), mobid);
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

I guess it's simplier to get it directly from the monster command itself but thank you anyway, I'd have saved some time if I had known that .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...