Advertisement
ZoriaRPG

ghost_zh/other.zh for 2.55

Jan 29th, 2019
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.16 KB | None | 0 0
  1. // ghost.zh
  2. // Version 2.8.1
  3.  
  4.  
  5. int FindSpawnPoint(bool landOK, bool wallsOK, bool waterOK, bool pitsOK)
  6. {
  7.     int tileRatings[176];
  8.     int checkCombo;
  9.     int checkX;
  10.     int checkY;
  11.     int bestRating;
  12.     int bestCount;
  13.     int counter;
  14.     int choice;
  15.     int tries;
  16.     npc otherNPC;
  17.    
  18.     // First, rate each tile for suitability. Lower is better,
  19.     // but negative means it's strictly off-limits.
  20.    
  21.     // Tiles too close to other enemies are undesirable
  22.     for(int i=Screen->NumNPCs(); i>0; i--)
  23.     {
  24.         otherNPC=Screen->LoadNPC(i);
  25.         checkCombo=ComboAt(otherNPC->X, otherNPC->Y);
  26.         tileRatings[checkCombo]+=100;
  27.        
  28.         if(checkCombo>15)
  29.             tileRatings[checkCombo-16]+=1;
  30.         if(checkCombo<160)
  31.             tileRatings[checkCombo+16]+=1;
  32.         if(checkCombo%16>0)
  33.             tileRatings[checkCombo-1]+=1;
  34.         if(checkCombo%16<15)
  35.             tileRatings[checkCombo+1]+=1;
  36.     }
  37.    
  38.     // Mark prohibited tiles
  39.     for(int i=0; i<176; i++)
  40.     {
  41.         // Screen edges in NES dungeon
  42.         if((Screen->Flags[SF_ROOMTYPE]&010b)!=0 && (i<32 || i>143 || i%16<2 || i%16>13))
  43.             tileRatings[i]=-1;
  44.         // Water
  45.         else if(IsWater(i))
  46.         {
  47.             if(!waterOK)
  48.                 tileRatings[i]=-1;
  49.         }
  50.         // Pits
  51.         else if(__IsPit(i))
  52.         {
  53.             if(!pitsOK)
  54.                 tileRatings[i]=-1;
  55.         }
  56.         // "No enemy" flag and combos
  57.         else if(Screen->ComboF[i]==CF_NOENEMY || Screen->ComboI[i]==CF_NOENEMY ||
  58.                 Screen->ComboT[i]==CT_NOENEMY || Screen->ComboT[i]==CT_NOFLYZONE ||
  59.                 Screen->ComboT[i]==CT_NOJUMPZONE)
  60.             tileRatings[i]=-1;
  61.         // Too close to Link
  62.         else if(Abs(ComboX(i)-Link->X)<32 && Abs(ComboY(i)-Link->Y)<32)
  63.             tileRatings[i]=-1;
  64.         // All other combos
  65.         else
  66.         {
  67.             // If land is okay, but not walls (i.e. walkable only)
  68.             if(landOK && !wallsOK)
  69.             {
  70.                 checkX=ComboX(i);
  71.                 checkY=ComboY(i);
  72.                
  73.                 if(Screen->isSolid(checkX, checkY) ||
  74.                    Screen->isSolid(checkX+8, checkY) ||
  75.                    Screen->isSolid(checkX, checkY+8) ||
  76.                    Screen->isSolid(checkX+8, checkY+8))
  77.                     tileRatings[i]=-1;
  78.             }
  79.             // If walls are okay, but not land (i.e. unwalkable only)
  80.             else if(!landOK && wallsOK)
  81.             {
  82.                 checkX=ComboX(i);
  83.                 checkY=ComboY(i);
  84.                
  85.                 if(!Screen->isSolid(checkX, checkY) ||
  86.                    !Screen->isSolid(checkX+8, checkY) ||
  87.                    !Screen->isSolid(checkX, checkY+8) ||
  88.                    !Screen->isSolid(checkX+8, checkY+8))
  89.                     tileRatings[i]=-1;
  90.             }
  91.             // Neither land nor walls are okay
  92.             else if(!landOK && !wallsOK)
  93.                 tileRatings[i]=-1;
  94.         }
  95.     }
  96.    
  97.     // Find the best rating and count the number of tiles with that rating
  98.     bestRating=10000;
  99.     bestCount=0;
  100.     for(int i=0; i<176; i++)
  101.     {
  102.         if(tileRatings[i]<0)
  103.             continue;
  104.        
  105.         if(tileRatings[i]==bestRating)
  106.             bestCount++;
  107.         else if(tileRatings[i]<bestRating)
  108.         {
  109.             bestRating=tileRatings[i];
  110.             bestCount=1;
  111.         }
  112.     }
  113.    
  114.     // The loop below might hang if every tile is unusable
  115.     if(bestCount==0)
  116.         return 0;
  117.    
  118.     // Pick at random from the best rated tiles
  119.     counter=Rand(bestCount)+1;
  120.     for(choice=0; counter>0; choice++)
  121.     {
  122.         if(tileRatings[choice]==bestRating)
  123.             counter--;
  124.     }
  125.    
  126.     // Subtract 1 because the for loop overshot
  127.     return choice-1;
  128. }
  129.  
  130. int FindSpawnPoint(int type, int flag)
  131. {
  132.     int tileRatings[176];
  133.     int checkCombo;
  134.     int checkX;
  135.     int checkY;
  136.     int bestRating;
  137.     int bestCount;
  138.     int counter;
  139.     int choice;
  140.     int tries;
  141.     npc otherNPC;
  142.    
  143.     // Too close to other enemies
  144.     for(int i=Screen->NumNPCs(); i>0; i--)
  145.     {
  146.         otherNPC=Screen->LoadNPC(i);
  147.         checkCombo=ComboAt(otherNPC->X, otherNPC->Y);
  148.         tileRatings[checkCombo]+=100;
  149.        
  150.         if(checkCombo>15)
  151.             tileRatings[checkCombo-16]+=1;
  152.         if(checkCombo<160)
  153.             tileRatings[checkCombo+16]+=1;
  154.         if(checkCombo%16>0)
  155.             tileRatings[checkCombo-1]+=1;
  156.         if(checkCombo%16<15)
  157.             tileRatings[checkCombo+1]+=1;
  158.     }
  159.    
  160.     // Mark prohibited tiles
  161.     for(int i=0; i<176; i++)
  162.     {
  163.         // Wrong combo type
  164.         if(type>=0)
  165.         {
  166.             if(Screen->ComboT[i]!=type)
  167.                 tileRatings[i]=-1;
  168.         }
  169.        
  170.         // Flag isn't present
  171.         if(flag>=0)
  172.         {
  173.             if(Screen->ComboF[i]!=flag && Screen->ComboI[i]!=flag)
  174.                 tileRatings[i]=-1;
  175.         }
  176.        
  177.         // Too close to Link
  178.         else if(Abs(ComboX(i)-Link->X)<32 && Abs(ComboY(i)-Link->Y)<32)
  179.             tileRatings[i]=-1;
  180.     }
  181.    
  182.     // Find the best rating and count the tiles
  183.     bestRating=10000;
  184.     bestCount=0;
  185.     for(int i=0; i<176; i++)
  186.     {
  187.         if(tileRatings[i]<0)
  188.             continue;
  189.        
  190.         if(tileRatings[i]==bestRating)
  191.             bestCount++;
  192.         else if(tileRatings[i]<bestRating)
  193.         {
  194.             bestRating=tileRatings[i];
  195.             bestCount=1;
  196.         }
  197.     }
  198.    
  199.     if(bestCount==0)
  200.         return 0;
  201.    
  202.     // Pick one at random
  203.     counter=Rand(bestCount)+1;
  204.     for(choice=0; counter>0; choice++)
  205.     {
  206.         if(tileRatings[choice]==bestRating)
  207.             counter--;
  208.     }
  209.    
  210.     return choice-1;
  211. }
  212.  
  213. npc SpawnNPC(int id)
  214. {
  215.     npc theNPC;
  216.    
  217.     int spawnCombo=FindSpawnPoint(true, false, false, false);
  218.    
  219.     theNPC=Screen->CreateNPC(id);
  220.     theNPC->X=ComboX(spawnCombo);
  221.     theNPC->Y=ComboY(spawnCombo);
  222.     return theNPC;
  223. }
  224.  
  225. int FindUnusedFFC()
  226. {
  227.     return FindUnusedFFC(0);
  228. }
  229.  
  230. int FindUnusedFFC(int startingFrom)
  231. {
  232.     ffc f;
  233.    
  234.     for(int i=Max(startingFrom+1, AUTOGHOST_MIN_FFC); i<=AUTOGHOST_MAX_FFC; i++)
  235.     {
  236.         f=Screen->LoadFFC(i);
  237.        
  238.         if((f->Data==0 || f->Data==GH_INVISIBLE_COMBO) &&
  239.            f->Script==0 &&
  240.            !f->Flags[FFCF_CHANGER])
  241.             return i;
  242.     }
  243.    
  244.     // Couldn't find one
  245.     return 0;
  246. }
  247.  
  248. void Ghost_SpawnAnimationPuff(ffc this, npc ghost)
  249. {
  250.     // This function doesn't work too well when scripts are suspended.
  251.     // This isn't an ideal solution, but it's better than nothing.
  252.     if((__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_SUSPEND)!=0)
  253.         return;
  254.    
  255.     lweapon graphic;
  256.     int combo=this->Data;
  257.     bool collDet=ghost->CollDetection;
  258.     int xOffset=ghost->DrawXOffset;
  259.    
  260.     if(this->TileWidth!=Ghost_TileWidth)
  261.     {
  262.         this->TileWidth=Ghost_TileWidth;
  263.         ghost->TileWidth=Ghost_TileWidth;
  264.         ghost->HitWidth=16*Ghost_TileWidth;
  265.         ghost->HitXOffset=0;
  266.     }
  267.    
  268.     if(this->TileHeight!=Ghost_TileHeight)
  269.     {
  270.         this->TileHeight=Ghost_TileHeight;
  271.         ghost->TileHeight=Ghost_TileHeight;
  272.         ghost->HitHeight=16*Ghost_TileHeight;
  273.         ghost->HitYOffset=0;
  274.     }
  275.    
  276.     Ghost_SetPosition(this, ghost);
  277.    
  278.     this->Data=0;
  279.     ghost->CollDetection=false;
  280.     ghost->DrawXOffset=32768;
  281.    
  282.     for(int i=0; i<this->TileWidth; i++)
  283.     {
  284.         for(int j=0; j<this->TileHeight; j++)
  285.         {
  286.             graphic=Screen->CreateLWeapon(LW_SCRIPT10);
  287.             graphic->CollDetection=false;
  288.             graphic->UseSprite(GH_SPAWN_SPRITE);
  289.             graphic->X=this->X+16*i;
  290.             graphic->Y=this->Y+16*j;
  291.            
  292.             if(graphic->NumFrames==0)
  293.                 graphic->NumFrames=3;
  294.             if(graphic->ASpeed==0)
  295.                 graphic->ASpeed=4;
  296.            
  297.             graphic->DeadState=graphic->NumFrames*graphic->ASpeed;
  298.         }
  299.     }
  300.  
  301.    
  302.     for(int i=graphic->NumFrames*graphic->ASpeed; i>0; i--)
  303.     {
  304.         Ghost_SetPosition(this, ghost);
  305.         Ghost_WaitframeLight(this, ghost);
  306.     }
  307.    
  308.     this->Data=combo;
  309.     ghost->CollDetection=collDet;
  310.     ghost->DrawXOffset=xOffset;
  311. }
  312.  
  313. void Ghost_SpawnAnimationFlicker(ffc this, npc ghost)
  314. {
  315.     if((__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_SUSPEND)!=0)
  316.         return;
  317.    
  318.     int combo=this->Data;
  319.     bool collDet=ghost->CollDetection;
  320.     int xOffset=ghost->DrawXOffset;
  321.    
  322.     if(this->TileWidth!=Ghost_TileWidth)
  323.     {
  324.         this->TileWidth=Ghost_TileWidth;
  325.         ghost->TileWidth=Ghost_TileWidth;
  326.         ghost->HitWidth=16*Ghost_TileWidth;
  327.         ghost->HitXOffset=0;
  328.     }
  329.    
  330.     if(this->TileHeight!=Ghost_TileHeight)
  331.     {
  332.         this->TileHeight=Ghost_TileHeight;
  333.         ghost->TileHeight=Ghost_TileHeight;
  334.         ghost->HitHeight=16*Ghost_TileHeight;
  335.         ghost->HitYOffset=0;
  336.     }
  337.    
  338.     Ghost_SetPosition(this, ghost);
  339.     ghost->CollDetection=false;
  340.    
  341.     // Alternate drawing offscreen and in place for 64 frames
  342.     for(int i=0; i<32; i++)
  343.     {
  344.         this->Data=0;
  345.         ghost->DrawXOffset=32768;
  346.         Ghost_SetPosition(this, ghost);
  347.         Ghost_WaitframeLight(this, ghost);
  348.        
  349.         this->Data=combo;
  350.         ghost->DrawXOffset=xOffset;
  351.         Ghost_SetPosition(this, ghost);
  352.         Ghost_WaitframeLight(this, ghost);
  353.     }
  354.    
  355.     this->Data=combo;
  356.     ghost->CollDetection=collDet;
  357.     ghost->DrawXOffset=xOffset;
  358. }
  359.  
  360. bool Ghost_GotHit()
  361. {
  362.     return (__Ghost_InternalFlags&__GHFI_GOT_HIT)!=0;
  363. }
  364.  
  365. bool Ghost_WasFrozen()
  366. {
  367.     return (__Ghost_InternalFlags&__GHFI_WAS_FROZEN)!=0;
  368. }
  369.  
  370. void Ghost_DeathAnimation(ffc this, npc ghost, int type)
  371. {
  372.     if(type==GHD_EXPLODE)
  373.         __Ghost_Explode(this, ghost, false);
  374.     else if(type==GHD_EXPLODE_FLASH)
  375.         __Ghost_Explode(this, ghost, true);
  376.     else if(type==GHD_SHRINK)
  377.         __Ghost_ShrinkAway(this, ghost);
  378.     else
  379.     {
  380.         if(ghost->isValid())
  381.         {
  382.             ghost->TileWidth=1;
  383.             ghost->TileHeight=1;
  384.             ghost->X=Ghost_X+8*(Ghost_TileWidth-1);
  385.             ghost->Y=Ghost_Y+8*(Ghost_TileHeight-1);
  386.             ghost->Z=Ghost_Z;
  387.         }
  388.         this->Data=0;
  389.         Ghost_Data=0;
  390.     }
  391. }
  392.  
  393. void Ghost_MarkAsInUse(npc ghost)
  394. {
  395.     ghost->Misc[__GHI_NPC_DATA]|=0x10000;
  396. }
  397.  
  398. bool Ghost_IsInUse(npc ghost)
  399. {
  400.     return (ghost->Misc[__GHI_NPC_DATA]&0x10000)!=0;
  401. }
  402.  
  403. float Ghost_GetAttribute(npc ghost, int index, float theDefault, float min, float max)
  404. {
  405.     if(index<0 || index>11)
  406.         return 0;
  407.    
  408.     float attr=ghost->Attributes[index];
  409.    
  410.     if(attr==0)
  411.         return theDefault;
  412.     if(attr<min)
  413.         return min;
  414.     if(attr>max)
  415.         return max;
  416.     return attr;
  417. }
  418.  
  419. float Ghost_GetAttribute(npc ghost, int index, float theDefault)
  420. {
  421.     if(index<0 || index>11)
  422.         return 0;
  423.    
  424.     float attr=ghost->Attributes[index];
  425.    
  426.     if(attr==0)
  427.         return theDefault;
  428.     return attr;
  429. }
  430.  
  431. void Ghost_AddCombo(int combo, float x, float y, int width, int height)
  432. {
  433.     // Already at the limit?
  434.     if(__Ghost_AdditionalCombos[__GHI_AC_COUNT]==__GH_AC_MAX_ADDITIONAL_COMBOS)
  435.         return;
  436.    
  437.     // Store its data
  438.     int start=__Ghost_AdditionalCombos[0]*__GH_AC_DATA_SIZE+1;
  439.    
  440.     __Ghost_AdditionalCombos[start+__GH_AC_COMBO]=combo;
  441.     __Ghost_AdditionalCombos[start+__GH_AC_X]=x;
  442.     __Ghost_AdditionalCombos[start+__GH_AC_Y]=y;
  443.     __Ghost_AdditionalCombos[start+__GH_AC_WIDTH]=width;
  444.     __Ghost_AdditionalCombos[start+__GH_AC_HEIGHT]=height;
  445.     __Ghost_AdditionalCombos[__GHI_AC_COUNT]+=1;
  446. }
  447.  
  448. void Ghost_AddCombo(int combo, float x, float y)
  449. {
  450.     Ghost_AddCombo(combo, x, y, 1, 1);
  451. }
  452.  
  453. void Ghost_ClearCombos()
  454. {
  455.     // No need to clear all the data
  456.     __Ghost_AdditionalCombos[__GHI_AC_COUNT]=0;
  457. }
  458.  
  459. bool ClockIsActive()
  460. {
  461.     __ghzhData[__GHI_CLOCK_TIMER]!=0;
  462. }
  463.  
  464. void SuspendGhostZHScripts()
  465. {
  466.     __ghzhData[__GHI_GLOBAL_FLAGS]|=__GHGF_SUSPEND;
  467. }
  468.  
  469. void ResumeGhostZHScripts()
  470. {
  471.     __ghzhData[__GHI_GLOBAL_FLAGS]&=~__GHGF_SUSPEND;
  472. }
  473.  
  474. void __Ghost_Explode(ffc this, npc ghost, bool flash)
  475. {
  476.     lweapon explosion;
  477.     int baseX=Ghost_X+ghost->DrawXOffset;
  478.     int baseY=(Ghost_Y+ghost->DrawYOffset)-(Ghost_Z+ghost->DrawZOffset);
  479.    
  480.     __DeathAnimStart(this, ghost);
  481.     __DeathAnimSFX(ghost->ID, ghost->X);
  482.    
  483.     if(flash)
  484.         __Ghost_FlashCounter=10000;
  485.     else
  486.         __Ghost_FlashCounter=0;
  487.    
  488.     // One explosion every 16 frames, 15 times
  489.     for(int i=0; i<15; i++)
  490.     {
  491.         explosion=Screen->CreateLWeapon(LW_BOMBBLAST);
  492.         explosion->X=baseX+Rand(16*Ghost_TileWidth)-8;
  493.         explosion->Y=baseY+Rand(16*Ghost_TileHeight)-8;
  494.         explosion->CollDetection=false;
  495.        
  496.         for(int j=0; j<16; j++)
  497.         {
  498.             Ghost_SetPosition(this, ghost); // Make sure it doesn't wander off
  499.             if(flash)
  500.                 __Ghost_UpdateFlashing(this, ghost);
  501.             Ghost_WaitframeLight(this, ghost);
  502.         }
  503.     }
  504.    
  505.     __DeathAnimEnd(this, ghost);
  506. }
  507.  
  508. void __Ghost_ShrinkAway(ffc this, npc ghost)
  509. {
  510.     lweapon explosion;
  511.     int baseX=Ghost_X+ghost->DrawXOffset;
  512.     int baseY=(Ghost_Y+ghost->DrawYOffset)-(Ghost_Z+ghost->DrawZOffset);
  513.     int baseWidth=Ghost_TileWidth*16;
  514.     int baseHeight=Ghost_TileHeight*16;
  515.     int tile=ghost->Tile; // Only needed for invisible combo enemies
  516.     int layer;
  517.     int opacity;
  518.    
  519.     if(this->Flags[FFCF_OVERLAY])
  520.         layer=4;
  521.     else if((Screen->Flags[SF_VIEW]&10000b)!=0) // Layer 2 is background
  522.         layer=1;
  523.     else
  524.         layer=2;
  525.    
  526.     if((ghost->MiscFlags&100000000b)!=0 || this->Flags[FFCF_TRANS])
  527.         opacity=OP_TRANS;
  528.     else
  529.         opacity=OP_OPAQUE;
  530.    
  531.     __DeathAnimStart(this, ghost);
  532.     ghost->DrawXOffset=1024;
  533.     __Ghost_FlashCounter=0;
  534.    
  535.     for(int i=0; i<120; i++)
  536.     {
  537.         float scale=Cos(i-30)/Cos(30);
  538.         float xSize=baseWidth*scale;
  539.         float ySize=baseHeight*scale;
  540.        
  541.         if(i==30)
  542.             __DeathAnimSFX(ghost->ID, ghost->X);
  543.        
  544.         if(Ghost_Data==GH_INVISIBLE_COMBO)
  545.         {
  546.             Screen->DrawTile(layer,
  547.               baseX-(xSize-baseWidth)/2,
  548.               baseY-(ySize-baseHeight)/2,
  549.               tile, Ghost_TileWidth, Ghost_TileHeight, Ghost_CSet,
  550.               xSize, ySize, 0, 0, 0, 0, true, opacity);
  551.         }
  552.         else
  553.         {
  554.             Screen->DrawCombo(layer,
  555.               baseX-(xSize-baseWidth)/2,
  556.               baseY-(ySize-baseHeight)/2,
  557.               Ghost_Data, Ghost_TileWidth, Ghost_TileHeight, Ghost_CSet,
  558.               xSize, ySize, 0, 0, 0, 0, 0, true, opacity);
  559.         }
  560.        
  561.         Ghost_WaitframeLight(this, ghost);
  562.     }
  563.    
  564.     __DeathAnimEnd(this, ghost);
  565. }
  566.  
  567. void __DeathAnimStart(ffc this, npc ghost)
  568. {
  569.     this->CSet=Ghost_CSet;
  570.     this->Vx=0;
  571.     this->Vy=0;
  572.     this->Ax=0;
  573.     this->Ay=0;
  574.     ghost->HP=1;
  575.     ghost->CollDetection=false;
  576.     ghost->SFX=0;
  577. }
  578.  
  579. void __DeathAnimEnd(ffc this, npc ghost)
  580. {
  581.     if(ghost->isValid())
  582.     {
  583.         ghost->HP=HP_SILENT;
  584.         ghost->DrawXOffset=1024;
  585.         ghost->X+=(Ghost_TileWidth-1)*8;
  586.         ghost->Y+=(Ghost_TileHeight-1)*8;
  587.     }
  588.    
  589.     __GhCleanUp(this);
  590.     Ghost_Data=0;
  591.     Ghost_ClearCombos();
  592. }
  593.  
  594. // The enemy has to stay alive until the end of the animation, but the death
  595. // sound generally has to play sooner. There isn't a good way to do that, so
  596. // here's a stupid way, instead. Make another of the same enemy, hide it, and
  597. // kill it. After the animation finishes, the real one will be killed silently.
  598. void __DeathAnimSFX(int id, int x)
  599. {
  600.     npc deathSFXNPC=Screen->CreateNPC(id);
  601.     deathSFXNPC->X=x; // For panning
  602.     deathSFXNPC->Y=176;
  603.     deathSFXNPC->ItemSet=0;
  604.     deathSFXNPC->HP=0;
  605.     deathSFXNPC->Misc[__GHI_NPC_DATA]=0x10000;
  606. }
  607.  
  608. // Used in Ghost_WaitframeLight() to determine whether the enemy needs drawn
  609. bool __Ghost_IsFlickering(npc ghost)
  610. {
  611.     // "Is Flickering" flag is set
  612.     if((ghost->MiscFlags&10000000b)!=0)
  613.         return true;
  614.    
  615.     // Enemy is flickering from being hit
  616.     if(GH_ENEMIES_FLICKER!=0 && __Ghost_FlashCounter>0)
  617.         return true;
  618.    
  619.     // Nothing left to check, must not be flickering
  620.     return false;
  621. }
  622.  
  623. // Reset most of the FFC's data to default. Stuff that's not likely to
  624. // cause problems if the FFC is reused isn't included.
  625. void __GhCleanUp(ffc this)
  626. {
  627.     this->Data=0;
  628.     this->Vx=0;
  629.     this->Vy=0;
  630.     this->Ax=0;
  631.     this->Ay=0;
  632.     this->TileWidth=1;
  633.     this->TileHeight=1;
  634.     this->EffectWidth=16;  // Some of these are unlikely to have been used,
  635.     this->EffectHeight=16; // but sure, let's clear them out.
  636.     this->Link=0;
  637.     for(int i=0; i<11; i++)
  638.         this->Flags[i]=false;
  639. }
  640.  
  641. void SetEnemyProperty(npc enemy, int property, float newValue)
  642. {
  643.     if((enemy->Misc[__GHI_NPC_DATA]&0x10000)!=0)
  644.     {
  645.         float array=enemy->Misc[__GHI_NPC_DATA]&0xFFFF;
  646.         array[property]=newValue;
  647.     }
  648.    
  649.     if(property==ENPROP_X)
  650.         enemy->X=newValue;
  651.     else if(property==ENPROP_Y)
  652.         enemy->Y=newValue;
  653.     else if(property==ENPROP_Z)
  654.         enemy->Z=newValue;
  655.     else if(property==ENPROP_JUMP)
  656.         enemy->Jump=newValue;
  657.     else if(property==ENPROP_DIR)
  658.         enemy->Dir=newValue;
  659.     else if(property==ENPROP_HP)
  660.         enemy->HP=newValue;
  661.     else //ENPROP_CSET
  662.         enemy->CSet=newValue;
  663. }
  664.  
  665. float GetEnemyProperty(npc enemy, int property)
  666. {
  667.     if((enemy->Misc[__GHI_NPC_DATA]&0x10000)!=0)
  668.     {
  669.         float array=enemy->Misc[__GHI_NPC_DATA]&0xFFFF;
  670.         return array[property];
  671.     }
  672.     else
  673.     {
  674.         if(property==ENPROP_X)
  675.             return enemy->X;
  676.         else if(property==ENPROP_Y)
  677.             return enemy->Y;
  678.         else if(property==ENPROP_Z)
  679.             return enemy->Z;
  680.         else if(property==ENPROP_JUMP)
  681.             return enemy->Jump;
  682.         else if(property==ENPROP_DIR)
  683.             return enemy->Dir;
  684.         else if(property==ENPROP_HP)
  685.             return enemy->HP;
  686.         else //ENPROP_CSET
  687.             return enemy->CSet;
  688.     }
  689. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement