View Full Version: [Tutorial]Enemies Picking up Weapons and Using them

wolfers >>Coding Alliance >>[Tutorial]Enemies Picking up Weapons and Using them


<< Prev | Next >>

Andy3012- 03-05-2005
[Tutorial]Enemies Picking up Weapons and Using them
Hi, This is my First Ever Tutorial, that I have Written, so i can't garrentee that it will work, from what is written here, I have tested the code though and it worked fine to my knowledge, this will take up alot of space, (as you need to add a new enemy). If you use this please give credit to Andy3012, WSJ and the authors of the other tutorials which i used to write this tutorial (MCS + Areyep) Ok to start with were going to add a new enemy to do this use the tutorial from the site below: http://www.areyep.com/Codingtips/addenemy.html With that done, we are going to add the tutorial which allows guards to pick up items http://www.areyep.com/Codingtips/enemybonus1.html With that done we can now edit the enemy picking up bonus items tutorial, go to the very end of wl_act2.c which is where the main part of the code is. In this we'll make it so that the officer turns into officer2 (but you can always change the officer2 part the name of your enemy you added. And the end of this code case bo_firstaid: switch (ob->obclass) { case guardobj: case ssobj: case officerobj: RemoveObject (objpos); PlaySoundLocActor (HEALTH2SND,ob); ob->hitpoints += 25; objpos->flags &= ~FL_BONUS; break; add { case bo_machinegun: switch (ob->obclass) { case officerobj: RemoveObject (objpos); PlaySoundLocActor (GETMACHINESND,ob); objpos->flags &= ~FL_BONUS; ob->obclass = officer2obj; // officer becomes machinegun officer NewState (ob,&s_ofc2chase1); // go into machinegun chase frames break; make sure to add another } at the end of the end of wl_act2.c (under this code which is at the end) Hopefully that worked. If not than please say! What this tutorial does exactly, is makes the Machine gun a pickup, then when the officer picks it up, he changes into officer2 (The new enemy you added in Areyeps tutorial). More updates to come...

Flamer46- 03-31-2005

Andy it`s pretty good. But iit could easily be done using less memory. This code is still in development I will continue updating it later. But you can work on this first. I`ll make the officer as Andy has chosen above get the machinegun. Ok for this tutorial you only need MCS bonus tutorial that andy told you about above. Ok go in WL_DEF.H and find SPR_CHAINREADY. After add this SPR_OFC_MSHOOT1,SPR_OFC_MSHOOT2,SPR_OFC_MSHOOT3 Now open WL_ACT2.C Find extern statrtype s_ofcshoot4. After add extern statetype s_ofcmshoot1; extern statetype s_ofcmshoot2; extern statetype s_ofcmshoot3; Now scroll down until you find statetype s_ofcshoot3 = {false,SPR_OFC_SHOOT3,10,NULL,NULL,&s_ofcchase1}; After add statetype s_ofcmshoot1 = {false,SPR_OFC_MSHOOT1,6,NULL,NULL,&s_ofcshoot2}; statetype s_ofcmshoot2 = {false,SPR_OFC_MSHOOT2,20,NULL,T_Shoot,&s_ofcshoot3}; statetype s_ofcmshoot3 = {false,SPR_OFC_MSHOOT3,10,NULL,NULL,&s_ofcchase1}; Now i add Andy`s code but i removed a line. case bo_machinegun: switch (ob->obclass) { case officerobj: RemoveObject (objpos); PlaySoundLocActor (GETMACHINESND,ob); objpos->flags &= ~FL_BONUS; ob->weapon=2 // This is an important line for this code!! You will have to add a new variable in the ACtor structure. break; I`ll update it soon. 8)

Andy3012- 04-01-2005

If you use them merging enemy statetypes tutorial that could help reduce alot of wasted memory.

Flamer46- 04-01-2005

I thougt about that. Infact i just finished coding this. Maybe i`ll post it in a little bit. I`ll test it.

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.