OU_GOD.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OU_GOD.CPP
  21. //Description: God Unit
  22. #include <OSYS.h>
  23. #include <OGAME.h>
  24. #include <OBUTT3D.h>
  25. #include <OGODRES.h>
  26. #include <OF_BASE.h>
  27. #include <ORACERES.h>
  28. #include <OPOWER.h>
  29. #include <OU_MARI.h>
  30. #include <OU_GOD.h>
  31. #include <OWEATHER.h>
  32. #include <OTORNADO.h>
  33. //--------- Define static vars ----------//
  34. static Button3D button_cast, button_cast2;
  35. //--------- Begin of function UnitGod::init_derived --------//
  36. void UnitGod::init_derived()
  37. {
  38. // ##### patch begin Gilbert 22/1 ######//
  39. cast_power_type = 0;
  40. // ##### end begin Gilbert 22/1 ######//
  41. if(unit_id==UNIT_PERSIAN_HEALER || unit_id==UNIT_VIKING_GOD ||
  42. unit_id==UNIT_KUKULCAN || unit_id==UNIT_JAPANESE_GOD)
  43. can_attack_flag = 0; // unable to attack
  44. #ifdef AMPLUS
  45. if(unit_id==UNIT_EGYPTIAN_GOD || unit_id==UNIT_INDIAN_GOD ||
  46. unit_id==UNIT_ZULU_GOD)
  47. can_attack_flag = 0; // unable to attack
  48. #endif
  49. }
  50. //-------- End of function UnitGod::init_derived -------//
  51. //------- Begin of function UnitGod::pre_process -------//
  52. //
  53. void UnitGod::pre_process()
  54. {
  55. Unit::pre_process();
  56. if( game.game_mode == GAME_TEST )
  57. return;
  58. //---- set force_move_flag to 1 if the god does not have the ability to attack ----//
  59. if( god_id != GOD_CHINESE && god_id != GOD_NORMAN ) // only Chinese and Norman dragon can attack
  60. force_move_flag = 1;
  61. //-*********** simulate aat ************-//
  62. #ifdef DEBUG
  63. if(debug_sim_game_type)
  64. return;
  65. #endif
  66. //-*********** simulate aat ************-//
  67. //--- if the seat of power supporting this unit is destroyed, this unit dies ---//
  68. if( firm_array.is_deleted(base_firm_recno) )
  69. {
  70. hit_points=(float)0;
  71. set_die();
  72. return;
  73. }
  74. //---- this unit consume pray points as it exists ----//
  75. FirmBase* firmBase = (FirmBase*) firm_array[base_firm_recno];
  76. err_when( firmBase->firm_id != FIRM_BASE );
  77. firmBase->pray_points -= (float) god_res[god_id]->exist_pray_points / 200;
  78. if( firmBase->pray_points < 0 )
  79. firmBase->pray_points = (float) 0;
  80. //--------- update hit points --------//
  81. hit_points = (short) firmBase->pray_points;
  82. if( hit_points == 0 )
  83. set_die();
  84. }
  85. //-------- End of function UnitGod::pre_process -------//
  86. //--------- Begin of function UnitGod::process_attack --------//
  87. int UnitGod::process_attack()
  88. {
  89. if( !Sprite::process_attack() ) // return 1 if the unit just finished its current attack
  90. return 0;
  91. if( game.game_mode == GAME_TEST )
  92. return 1;
  93. //-*********** simulate aat ************-//
  94. #ifdef DEBUG
  95. if(debug_sim_game_type)
  96. return 1;
  97. #endif
  98. //-*********** simulate aat ************-//
  99. consume_power_pray_points();
  100. return 1;
  101. }
  102. //---------- End of function UnitGod::process_attack ----------//
  103. //--------- Begin of function UnitGod::disp_info ---------//
  104. //
  105. void UnitGod::disp_info(int refreshFlag)
  106. {
  107. disp_basic_info(INFO_Y1, refreshFlag);
  108. disp_unit_profile( INFO_Y1+54, refreshFlag );
  109. if( !is_own() )
  110. return;
  111. if( game.game_mode == GAME_TEST )
  112. return;
  113. if( god_res[god_id]->can_cast_power )
  114. {
  115. //-------- get the button name --------//
  116. char* buttonName;
  117. switch(god_id)
  118. {
  119. case GOD_PERSIAN:
  120. buttonName = "GODHEAL";
  121. break;
  122. case GOD_JAPANESE:
  123. buttonName = "GODMIND";
  124. break;
  125. case GOD_MAYA:
  126. buttonName = "GODINCCL";
  127. break;
  128. case GOD_VIKING:
  129. buttonName = "GODRAIN";
  130. break;
  131. #ifdef AMPLUS
  132. case GOD_EGYPTIAN:
  133. buttonName = "GODEGYPT";
  134. break;
  135. case GOD_INDIAN:
  136. buttonName = "GODMUGL";
  137. break;
  138. case GOD_ZULU:
  139. buttonName = "GODZULU";
  140. break;
  141. #endif
  142. default:
  143. err_here();
  144. }
  145. //----------- create the cast button -----------//
  146. button_cast.paint(INFO_X1, INFO_Y1+101, 'A', buttonName );
  147. if( hit_points >= god_res[god_id]->power_pray_points )
  148. button_cast.enable();
  149. else
  150. button_cast.disable();
  151. //------ The viking gods have two types of power ------//
  152. if( god_id == GOD_VIKING )
  153. {
  154. button_cast2.paint(INFO_X1+BUTTON_ACTION_WIDTH, INFO_Y1+101, 'A', "GODTORNA" );
  155. if( hit_points >= god_res[god_id]->power_pray_points )
  156. button_cast2.enable();
  157. else
  158. button_cast2.disable();
  159. }
  160. }
  161. }
  162. //---------- End of function UnitGod::disp_info ----------//
  163. //--------- Begin of function UnitGod::detect_info ---------//
  164. //
  165. void UnitGod::detect_info()
  166. {
  167. if( detect_basic_info() )
  168. return;
  169. if( detect_unit_profile() )
  170. return;
  171. if( !is_own() )
  172. return;
  173. if( game.game_mode == GAME_TEST )
  174. return;
  175. if( god_res[god_id]->can_cast_power )
  176. {
  177. // ###### begin Gilbert 14/10 ######//
  178. int rc=0;
  179. char castPowerType = 0;
  180. if( button_cast.detect() )
  181. {
  182. // cast_power_type = 1;
  183. castPowerType = 1;
  184. rc = 1;
  185. }
  186. if( button_cast2.detect() )
  187. {
  188. castPowerType = 2;
  189. //cast_power_type = 2;
  190. //cast_origin_x = cur_x_loc();
  191. //cast_origin_y = cur_y_loc();
  192. rc = 1;
  193. }
  194. //----------------------------------------//
  195. if( rc && castPowerType)
  196. {
  197. if( god_id == GOD_VIKING && castPowerType == 1 ) // summon rain, summon immediately, no need to select target
  198. go_cast_power(next_x_loc(), next_y_loc(), castPowerType, COMMAND_PLAYER);
  199. else
  200. power.issue_command(COMMAND_GOD_CAST_POWER, sprite_recno, castPowerType);
  201. }
  202. // ###### end Gilbert 14/10 ######//
  203. }
  204. }
  205. //---------- End of function UnitGod::detect_info ----------//
  206. //--------- Begin of function UnitGod::cast_power ---------//
  207. //
  208. // <int> castXLoc, castYLoc - the location which the power should
  209. // be casted on.
  210. //
  211. void UnitGod::cast_power(int xLoc, int yLoc)
  212. {
  213. err_when( !god_res[god_id]->can_cast_power );
  214. //------- consumer pray points --------//
  215. // consume_power_pray_points(); // let process_attack to consume
  216. //---- viking god does not need a range for casting power ----//
  217. if( god_id == GOD_VIKING )
  218. {
  219. if( cast_power_type == 1 )
  220. viking_summon_rain();
  221. else
  222. viking_summon_tornado();
  223. return;
  224. }
  225. //------ cast power on the selected area ------//
  226. GodInfo* godInfo = god_res[god_id];
  227. int xLoc1 = xLoc - godInfo->cast_power_range + 1;
  228. int yLoc1 = yLoc - godInfo->cast_power_range + 1;
  229. int xLoc2 = xLoc + godInfo->cast_power_range - 1;
  230. int yLoc2 = yLoc + godInfo->cast_power_range - 1;
  231. int t;
  232. int centerY = (yLoc1+yLoc2) / 2;
  233. Location* locPtr;
  234. for( yLoc=yLoc1 ; yLoc<=yLoc2 ; yLoc++ )
  235. {
  236. t=abs(yLoc-centerY)/2;
  237. locPtr = world.get_loc(xLoc1+t, yLoc);
  238. for( xLoc=xLoc1+t ; xLoc<=xLoc2-t ; xLoc++, locPtr++ )
  239. {
  240. if( xLoc>=0 && xLoc<MAX_WORLD_X_LOC &&
  241. yLoc>=0 && yLoc<MAX_WORLD_Y_LOC )
  242. {
  243. cast_on_loc(xLoc, yLoc);
  244. }
  245. }
  246. }
  247. }
  248. //---------- End of function UnitGod::cast_power ----------//
  249. //--------- Begin of function UnitGod::viking_summon_rain ---------//
  250. //
  251. void UnitGod::viking_summon_rain()
  252. {
  253. magic_weather.cast_rain(10, 8); // 10 days, rain scale 8
  254. magic_weather.cast_lightning(7 ); // 7 days
  255. }
  256. //---------- End of function UnitGod::viking_summon_rain ----------//
  257. //--------- Begin of function UnitGod::viking_summon_tornado ---------//
  258. //
  259. void UnitGod::viking_summon_tornado()
  260. {
  261. // ######## begin Gilbert 14/10 ########//
  262. short xLoc = next_x_loc();
  263. short yLoc = next_y_loc();
  264. char dir = final_dir % 8;
  265. // ######## end Gilbert 14/10 ########//
  266. // put a tornado one location ahead
  267. if( dir == 0 || dir == 1 || dir == 7 )
  268. if( yLoc > 0 )
  269. yLoc--;
  270. if( dir >= 1 && dir <= 3 )
  271. if( xLoc < MAX_WORLD_X_LOC-1 )
  272. xLoc++;
  273. if( dir >= 3 && dir <= 5 )
  274. if( yLoc < MAX_WORLD_Y_LOC-1)
  275. yLoc++;
  276. if( dir >= 5 && dir <= 7 )
  277. if( xLoc > 0 )
  278. xLoc--;
  279. tornado_array.add_tornado( xLoc, yLoc, 600 );
  280. magic_weather.cast_wind(10, 1, dir * 45 ); // 10 days
  281. }
  282. //---------- End of function UnitGod::viking_summon_tornado ----------//
  283. //--------- Begin of function UnitGod::cast_on_loc ---------//
  284. //
  285. void UnitGod::cast_on_loc(int castXLoc, int castYLoc)
  286. {
  287. Location* locPtr = world.get_loc( castXLoc, castYLoc );
  288. //--- if there is any unit on the location ---//
  289. if( locPtr->has_unit(UNIT_LAND) )
  290. {
  291. cast_on_unit( locPtr->unit_recno(UNIT_LAND), 1 );
  292. }
  293. else if( locPtr->has_unit(UNIT_SEA) )
  294. {
  295. Unit* unitPtr = unit_array[ locPtr->unit_recno(UNIT_SEA) ];
  296. //-- only heal human units belonging to our nation in ships --//
  297. if( unitPtr->nation_recno == nation_recno &&
  298. unit_res[unitPtr->unit_id]->unit_class == UNIT_CLASS_SHIP )
  299. {
  300. UnitMarine* unitMarine = (UnitMarine*) unitPtr;
  301. for( int i=0 ; i<unitMarine->unit_count ; i++ )
  302. {
  303. int divider = 4; // the size of a ship is 4 locations (2x2)
  304. cast_on_unit( unitMarine->unit_recno_array[i], divider ); // the effects are weaken on ship units, only 50% of the original effects
  305. }
  306. }
  307. }
  308. //--------- on firms ---------//
  309. else if( locPtr->is_firm() )
  310. {
  311. Firm* firmPtr = firm_array[ locPtr->firm_recno() ];
  312. int divider = (firmPtr->loc_x2-firmPtr->loc_x1+1) * (firmPtr->loc_y2-firmPtr->loc_y1+1);
  313. #ifdef AMPLUS
  314. if( god_id == GOD_ZULU )
  315. divider = 1; // range of zulu god is 1, no need to divide
  316. #endif
  317. if( firmPtr->overseer_recno )
  318. {
  319. cast_on_unit( firmPtr->overseer_recno, divider );
  320. }
  321. if( firmPtr->worker_array && firm_res[firmPtr->firm_id]->live_in_town==0 )
  322. {
  323. Worker* workerPtr = firmPtr->worker_array;
  324. for( int i=0 ; i<firmPtr->worker_count ; i++, workerPtr++ )
  325. {
  326. cast_on_worker(workerPtr, firmPtr->nation_recno, divider);
  327. }
  328. }
  329. }
  330. //--------- on towns ----------//
  331. else if( locPtr->is_town() )
  332. {
  333. Town* townPtr = town_array[ locPtr->town_recno() ];
  334. if( god_id == GOD_JAPANESE && townPtr->nation_recno != nation_recno)
  335. {
  336. int divider = STD_TOWN_LOC_WIDTH * STD_TOWN_LOC_HEIGHT;
  337. for( int i=0 ; i<MAX_RACE ; i++ )
  338. {
  339. if( townPtr->race_pop_array[i]==0 )
  340. continue;
  341. float changePoints = (float)7 + m.random(8); // decrease 7 to 15 loyalty points instantly
  342. if( townPtr->nation_recno )
  343. townPtr->change_loyalty(i+1, -changePoints/divider);
  344. else
  345. townPtr->change_resistance(i+1, nation_recno, -changePoints/divider);
  346. }
  347. }
  348. #ifdef AMPLUS
  349. else if( god_id == GOD_EGYPTIAN && townPtr->nation_recno == nation_recno)
  350. {
  351. int headCount;
  352. int raceId;
  353. for( headCount = 5; headCount > 0 && townPtr->population < MAX_TOWN_GROWTH_POPULATION
  354. && (raceId = townPtr->pick_random_race(1,1)); --headCount )
  355. {
  356. townPtr->inc_pop(raceId, 0, (int)townPtr->race_loyalty_array[raceId-1]);
  357. }
  358. }
  359. #endif
  360. }
  361. }
  362. //---------- End of function UnitGod::cast_on_loc ----------//
  363. //--------- Begin of function UnitGod::cast_on_unit ---------//
  364. //
  365. // <int> unitRecno - recno of the unit to cast on
  366. // <int> divider - divide the amount of effects by this number
  367. //
  368. void UnitGod::cast_on_unit(int unitRecno, int divider)
  369. {
  370. switch(god_id)
  371. {
  372. case GOD_PERSIAN:
  373. persian_cast_power( unitRecno, divider );
  374. break;
  375. case GOD_JAPANESE:
  376. japanese_cast_power( unitRecno, divider );
  377. break;
  378. case GOD_MAYA:
  379. maya_cast_power( unitRecno, divider );
  380. break;
  381. #ifdef AMPLUS
  382. case GOD_EGYPTIAN:
  383. egyptian_cast_power( unitRecno, divider);
  384. break;
  385. case GOD_INDIAN:
  386. indian_cast_power( unitRecno, divider);
  387. break;
  388. case GOD_ZULU:
  389. zulu_cast_power( unitRecno, divider);
  390. break;
  391. #endif
  392. default:
  393. err_here();
  394. }
  395. }
  396. //---------- End of function UnitGod::cast_on_unit ----------//
  397. //--------- Begin of function UnitGod::cast_on_worker ---------//
  398. //
  399. // <Worker*> workerPtr - pointer to the worker to be affected by the effect.
  400. //
  401. void UnitGod::cast_on_worker(Worker* workerPtr, int nationRecno, int divider)
  402. {
  403. switch(god_id)
  404. {
  405. case GOD_PERSIAN:
  406. persian_cast_power( workerPtr, nationRecno, divider );
  407. break;
  408. case GOD_JAPANESE:
  409. japanese_cast_power( workerPtr, nationRecno, divider );
  410. break;
  411. case GOD_MAYA:
  412. maya_cast_power( workerPtr, nationRecno, divider );
  413. break;
  414. #ifdef AMPLUS
  415. case GOD_EGYPTIAN:
  416. egyptian_cast_power(workerPtr, nationRecno, divider);
  417. break;
  418. case GOD_INDIAN:
  419. indian_cast_power(workerPtr, nationRecno, divider);
  420. break;
  421. case GOD_ZULU:
  422. zulu_cast_power(workerPtr, nationRecno, divider);
  423. break;
  424. #endif
  425. default:
  426. err_here();
  427. }
  428. }
  429. //---------- End of function UnitGod::cast_on_worker ----------//
  430. //--------- Begin of function UnitGod::persian_cast_power ---------//
  431. //
  432. void UnitGod::persian_cast_power(int unitRecno, int divider)
  433. {
  434. Unit* unitPtr = unit_array[unitRecno];
  435. //-- only heal human units belonging to our nation --//
  436. if( unitPtr->nation_recno == nation_recno && unitPtr->race_id > 0 )
  437. {
  438. float changePoints = (float) unitPtr->max_hit_points / (6+m.random(4)); // divided by (6 to 9)
  439. changePoints = max( changePoints, 10 );
  440. unitPtr->change_hit_points( changePoints/divider );
  441. }
  442. }
  443. //---------- End of function UnitGod::persian_cast_power ----------//
  444. //--------- Begin of function UnitGod::japanese_cast_power ---------//
  445. //
  446. void UnitGod::japanese_cast_power(int unitRecno, int divider)
  447. {
  448. Unit* unitPtr = unit_array[unitRecno];
  449. //-- only cast on enemy units -----//
  450. if( unitPtr->nation_recno != nation_recno && unitPtr->race_id > 0 )
  451. {
  452. int changePoints = 7 + m.random(8); // decrease 7 to 15 loyalty points instantly
  453. unitPtr->change_loyalty( -max(1, changePoints/divider) );
  454. }
  455. }
  456. //---------- End of function UnitGod::japanese_cast_power ----------//
  457. //--------- Begin of function UnitGod::maya_cast_power ---------//
  458. //
  459. void UnitGod::maya_cast_power(int unitRecno, int divider)
  460. {
  461. Unit* unitPtr = unit_array[unitRecno];
  462. //-- only cast on mayan units belonging to our nation --//
  463. if( unitPtr->nation_recno == nation_recno && unitPtr->race_id == RACE_MAYA )
  464. {
  465. int changePoints = 15 + m.random(10); // add 15 to 25 points to its combat level instantly
  466. int newCombatLevel = unitPtr->skill.combat_level + changePoints/divider;
  467. if( newCombatLevel > 100 )
  468. newCombatLevel = 100;
  469. float oldHitPoints = unitPtr->hit_points;
  470. unitPtr->set_combat_level(newCombatLevel);
  471. unitPtr->hit_points = oldHitPoints; // keep the hit points unchanged.
  472. }
  473. }
  474. //---------- End of function UnitGod::maya_cast_power ----------//
  475. //--------- Begin of function UnitGod::persian_cast_power ---------//
  476. //
  477. void UnitGod::persian_cast_power(Worker* workerPtr, int nationRecno, int divider)
  478. {
  479. //-- only heal human units belonging to our nation --//
  480. if( nationRecno == nation_recno && workerPtr->race_id > 0 )
  481. {
  482. int changePoints = workerPtr->max_hit_points() / (4+m.random(4)); // divided by (4 to 7)
  483. changePoints = max( changePoints, 10 );
  484. workerPtr->change_hit_points( max(1, changePoints/divider) );
  485. }
  486. }
  487. //---------- End of function UnitGod::persian_cast_power ----------//
  488. //--------- Begin of function UnitGod::japanese_cast_power ---------//
  489. //
  490. void UnitGod::japanese_cast_power(Worker* workerPtr, int nationRecno, int divider)
  491. {
  492. //-- only cast on enemy units -----//
  493. if( nationRecno != nation_recno && workerPtr->race_id > 0 )
  494. {
  495. int changePoints = 7 + m.random(8); // decrease 7 to 15 loyalty points instantly
  496. workerPtr->change_loyalty( -max(1, changePoints/divider) );
  497. }
  498. }
  499. //---------- End of function UnitGod::japanese_cast_power ----------//
  500. //--------- Begin of function UnitGod::maya_cast_power ---------//
  501. //
  502. void UnitGod::maya_cast_power(Worker* workerPtr, int nationRecno, int divider)
  503. {
  504. //-- only cast on mayan units belonging to our nation --//
  505. if( nationRecno == nation_recno && workerPtr->race_id == RACE_MAYA )
  506. {
  507. int changePoints = 15 + m.random(10); // add 15 to 25 points to its combat level instantly
  508. int newCombatLevel = workerPtr->combat_level + max(1, changePoints/divider);
  509. if( newCombatLevel > 100 )
  510. newCombatLevel = 100;
  511. workerPtr->combat_level = newCombatLevel;
  512. }
  513. }
  514. //---------- End of function UnitGod::maya_cast_power ----------//
  515. //--------- Begin of function UnitGod::consume_power_pray_points ---------//
  516. //
  517. void UnitGod::consume_power_pray_points()
  518. {
  519. FirmBase* firmBase = (FirmBase*) firm_array[base_firm_recno];
  520. err_when( firmBase->firm_id != FIRM_BASE );
  521. firmBase->pray_points -= god_res[god_id]->power_pray_points;
  522. if( firmBase->pray_points < 0 )
  523. firmBase->pray_points = (float) 0;
  524. hit_points = (short) firmBase->pray_points;
  525. }
  526. //---------- End of function UnitGod::consume_power_pray_points ----------//
  527. #ifdef AMPLUS
  528. //--------- Begin of function UnitGod::egyptian_cast_power ---------//
  529. //
  530. void UnitGod::egyptian_cast_power(int unitRecno, int divider)
  531. {
  532. // no effect
  533. }
  534. //---------- End of function UnitGod::egyptian_cast_power ----------//
  535. //--------- Begin of function UnitGod::indian_cast_power ---------//
  536. //
  537. void UnitGod::indian_cast_power(int unitRecno, int divider)
  538. {
  539. Unit* unitPtr = unit_array[unitRecno];
  540. if( unitPtr->is_visible() && nation_array.should_attack(nation_recno, unitPtr->nation_recno) )
  541. {
  542. unitPtr->change_loyalty(-30 + m.random(11));
  543. }
  544. }
  545. //---------- End of function UnitGod::indian_cast_power ----------//
  546. //--------- Begin of function UnitGod::zulu_cast_power ---------//
  547. //
  548. void UnitGod::zulu_cast_power(int unitRecno, int divider)
  549. {
  550. // no effect
  551. Unit* unitPtr = unit_array[unitRecno];
  552. if( nation_recno == unitPtr->nation_recno &&
  553. unitPtr->race_id == RACE_ZULU && unitPtr->rank_id != RANK_SOLDIER)
  554. {
  555. int changePoints = 30; // add 15 twice to avoid 130 becomes -126
  556. if( divider > 2 )
  557. {
  558. unitPtr->skill.skill_level += changePoints/divider;
  559. if( unitPtr->skill.skill_level > 100 )
  560. unitPtr->skill.skill_level = 100;
  561. }
  562. else
  563. {
  564. for(int t = 2; t > 0; --t )
  565. {
  566. unitPtr->skill.skill_level += changePoints/2/divider;
  567. if( unitPtr->skill.skill_level > 100 )
  568. unitPtr->skill.skill_level = 100;
  569. }
  570. }
  571. }
  572. }
  573. //---------- End of function UnitGod::zulu_cast_power ----------//
  574. //--------- Begin of function UnitGod::egyptian_cast_power ---------//
  575. //
  576. void UnitGod::egyptian_cast_power(Worker *workerPtr, int nationRecno, int divider)
  577. {
  578. // no effect
  579. }
  580. //---------- End of function UnitGod::egyptian_cast_power ----------//
  581. //--------- Begin of function UnitGod::indian_cast_power ---------//
  582. //
  583. void UnitGod::indian_cast_power(Worker *workerPtr, int nationRecno, int divider)
  584. {
  585. // no effect
  586. }
  587. //---------- End of function UnitGod::indian_cast_power ----------//
  588. //--------- Begin of function UnitGod::zulu_cast_power ---------//
  589. //
  590. void UnitGod::zulu_cast_power(Worker *workerPtr, int nationRecno, int divider)
  591. {
  592. // no effect
  593. }
  594. //---------- End of function UnitGod::zulu_cast_power ----------//
  595. #endif