Advertisement
ZoriaRPG

CollisionDX() for ffscript.cpp

Jan 27th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.74 KB | None | 0 0
  1.  
  2.     case CREATELWPNDX:
  3.     {
  4.         //Z_message("Trying to get Link->SetExtend().\n");
  5.         long ID = (ri->d[0] / 10000);
  6.         int itemid = (ri->d[1]/10000);
  7.         itemid = vbound(itemid,0,255);
  8.        
  9.         Lwpns.add(new weapon((fix)0,(fix)0,(fix)0,ID,0,0,0,itemid,Link.getUID()));
  10.         ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
  11.        
  12.         Z_scripterrlog("CreateLWeaponDx ri->d[0] is (%i), trying to use for '%s'\n", ID, "ID");
  13.         Z_scripterrlog("CreateLWeaponDx ri->d[1] is (%i), trying to use for '%s'\n", itemid, "itemid");
  14.         Z_scripterrlog("CreateLWeaponDx ri->lwpn is (%i), trying to use for '%s'\n", ri->lwpn, "ri->lwpn");
  15.        
  16.         ret = ri->lwpn;
  17.     }
  18.     break;
  19.    
  20.     //Screen->CollisionDx(int enemy_index, int lweapon_type, int power, int x, int y, int weapon_dir, int parent_item);
  21.     //Handles collision between an npc at screen index 'enemy_index', and an arbitrary lweapon that may or may not exist.
  22.     //Does damage, and returns true a value collision is valid. Returns a different value otherwise.
  23.    
  24.     // take damage or ignore it
  25.     // -1: damage (if any) dealt
  26.     // 1: blocked
  27.     // 0: weapon passes through unhindered
  28.     // 2: heal enemy? -ZoriaRPG
  29.    
  30.     //THis function should automatically check for shields blocking the weapon, and calculate enemy defences.
  31.     //In theory, scritped swords, and other melee weapons could use this, as coudl any weapon, and it may simplify
  32.     //collision routines.
  33.     case COLLISIONDX:
  34.     {
  35.         //Z_message("Trying to get Link->SetExtend().\n");
  36.         int index = (ri->d[0] / 10000);
  37.         long lweapon_type = (ri->d[1] / 10000);
  38.         int power = (ri->d[2]/10000);
  39.        
  40.         int wpnx = ri->4[3]/10000, wpny = ri->d[4]/10000;
  41.         int dir = ri->d[5]/10000;
  42.         int parentitem = (ri->d[6]/10000);
  43.         lweapon_type = vbound(lweapon_type,0,40); //Are we at 40, or higher now>
  44.         parentitem = vbound(itemid,0,255);
  45.        
  46.         //Log the stack events:
  47.         Z_scripterrlog("CollisionDx ri->d[0] is (%i), trying to use for '%s'\n", index, "index");
  48.         Z_scripterrlog("CollisionDx ri->d[1] is (%i), trying to use for '%s'\n", lweapon_type, "lweapon_type");
  49.         Z_scripterrlog("CollisionDx ri->d[2] is (%i), trying to use for '%s'\n", power, "power");
  50.         Z_scripterrlog("CollisionDx ri->d[3] is (%i), trying to use for '%s'\n", wpnx, "wpnx");
  51.         Z_scripterrlog("CollisionDx ri->d[4] is (%i), trying to use for '%s'\n", wpny, "wpny");
  52.         Z_scripterrlog("CollisionDx ri->d[5] is (%i), trying to use for '%s'\n", dir, "dir");
  53.         Z_scripterrlog("CollisionDx ri->d[0] is (%i), trying to use for '%s'\n", parentitem, "parentitem");
  54.        
  55.         weapon *w = new weapon((fix)wpnx,(fix)wpny,(fix)0,lweapon_type,0,power,dir,parentitem,-1,false);
  56.         int retval = ((enemy*)guys.spr(index))->takehit(w);
  57.             //TakeHit, as I recall, applies damage and returns the hit status. Gold.
  58.         delete w;
  59.         ret = retval;
  60.     }
  61.     break;
  62.    
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement