• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Airdrop Trap
#1
Hello guys,

I have made a new mod for MW2, it's the airdrop trap from MW3 Nyan Cat

Here is a video of it:


The code:
C++ Code
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. init()
  6. {
  7. precacheShader("cardicon_thebomb");
  8. //Custom scripts are processed before built-in so we need to wait
  9. thread initType();
  10. }
  11.  
  12. initType()
  13. {
  14. while(!isDefined(level.lowSpawn))
  15. wait 0.2;
  16.  
  17. maps\mp\killstreaks\_airdrop::addCrateType("airdrop", "trap", 13/*Change this if you want to change the weight*/, ::TrapCrateThink);
  18. maps\mp\killstreaks\_airdrop::addCrateType("airdrop_mega", "trap", 12/*Change this if you want to change the weight*/, ::TrapCrateThink);
  19.  
  20. //regenerate the max weighted value
  21. //not needed if editing _airdrop.gsc
  22. foreach (dropType, crateTypes in level.crateTypes)
  23. {
  24. level.crateMaxVal[dropType] = 0;
  25. foreach ( crateType, crateWeight in level.crateTypes[dropType] )
  26. {
  27. if ( !crateWeight )
  28. continue;
  29.  
  30. level.crateMaxVal[dropType] += crateWeight;
  31. level.crateTypes[dropType][crateType] = level.crateMaxVal[dropType];
  32. }
  33. }
  34. }
  35.  
  36. TrapCrateThink(dropType)
  37. {
  38. self endon("death");
  39. self.usedBy = [];
  40. if(!isDefined(dropType))
  41. dropType = "airdrop";
  42. random = randomInt(12);
  43.  
  44. c = 0;
  45. fakeType = "ammo";
  46. foreach(crateType,crateWeight in level.crateTypes[dropType])
  47. {
  48. if(c==random)
  49. {
  50. fakeType = crateType;
  51. break;
  52. }
  53. c++;
  54. }
  55. if(!isDefined(game["strings"][fakeType + "_hint"]))
  56. fakeType = "ammo";
  57.  
  58. if (!level.teamBased)
  59. {
  60. maps\mp\killstreaks\_airdrop::crateSetupForUse(game["strings"][fakeType + "_hint"], "all", maps\mp\killstreaks\_killstreaks::getKillstreakCrateIcon(fakeType));
  61.  
  62. if(isDefined(self.owner))
  63. {
  64. self maps\mp\_entityheadIcons:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />etHeadIcon(self.owner, "cardicon_thebomb", (0,0,24), 10, 10);
  65. self disablePlayerUse( self.owner );
  66. }
  67. }
  68. else
  69. {
  70. maps\mp\killstreaks\_airdrop::crateSetupForUse(game["strings"][fakeType + "_hint"], "all", maps\mp\killstreaks\_killstreaks::getKillstreakCrateIcon(fakeType));
  71. self maps\mp\killstreaks\_airdrop:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />etUsableByTeam(getOtherTeam(self.team));
  72.  
  73. self maps\mp\_entityheadIcons:<img src="https://www.itsmods.com/forum/images/smilies/confused.gif" alt="Confused" title="Confused" class="smilie smilie_13" />etHeadIcon(self.team, "cardicon_thebomb", (0,0,24), 10, 10);
  74. }
  75. self thread crateEnemyCaptureThink();
  76.  
  77. self waittill("captured", player);
  78. self playsound("javelin_clu_lock");
  79. wait 1;
  80.  
  81. playfx(level.chopper_fx["explode"]["death"]["cobra"], self.origin, (0,0,1));
  82. self playSound("cobra_helicopter_crash");
  83.  
  84. if(isDefined(self.owner) && isPlayer(self.owner))
  85. self RadiusDamage(self.origin, 500, 200, 50, self.owner, "MOD_EXPLOSIVE", "bomb_site_mp");
  86. else
  87. self RadiusDamage(self.origin, 500, 200, 50, undefined, "MOD_EXPLOSIVE", "bomb_site_mp");
  88.  
  89. self maps\mp\killstreaks\_airdrop::deleteCrate();
  90. }
  91.  
  92. crateEnemyCaptureThink()
  93. {
  94. while(isDefined(self))
  95. {
  96. self waittill("trigger", player);
  97.  
  98. if(isDefined(self.owner) && player==self.owner)
  99. continue;
  100.  
  101. useEnt = self maps\mp\killstreaks\_airdrop::createUseEnt();
  102. result = useEnt maps\mp\killstreaks\_airdrop::useHoldThink(player);
  103.  
  104. if(isDefined(useEnt))
  105. useEnt delete();
  106.  
  107. if(!result)
  108. continue;
  109.  
  110. self notify("captured", player);
  111. }
  112. }


If you use 4d1, you can just put the code in a custom gsc script. Otherwise you can easily insert it in _airdrop.gsc. And if you want to change the weight of the trap you can just change the number I marked in the code.

Thanks to @Rendflex for testing and helping
[Image: azuw.jpg]
[-] The following 11 users say Thank You to zxz0O0 for this post:
  • alvarogt95, Arteq, Bloodfocus, d0h!, estebespt, Nekochan, RaZ, Rendflex, SuperNovaAO, surtek, Yamato
  Reply
#2
can we make a code together ? i mean me and you , (thats my dream , to make a code with you , yamato , OrangePL , Rendflex) :B
  Reply
#3
edited php tag, please dont use this tag for such kind of code because it mixes /\ up

nice release, +rep
[-] The following 1 user says Thank You to d0h! for this post:
  • zxz0O0
  Reply
#4
can itsMods make a cod 4 section ?
  Reply
#5
(06-13-2012, 19:15)Bloodfocus Wrote: can itsMods make a cod 4 section ?

perhaps yes but i have no idea if its worth it
  Reply
#6
What should we post in there? I guess it will be dead section :S
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]
  Reply
#7
@d0h! trust me , it will be cool
  Reply
#8
back to mw2 ?
C++/Obj-C developer. Neko engine wip
Steam: Click
  Reply
#9
what this do:

if(c==random)
{
fakeType = crateType;
break;
}
c++;
}
if(!isDefined(game["strings"][fakeType + "_hint"]))
fakeType = "ammo";

?
  Reply
#10
C++ Code
  1. random = randomInt(12);
  2. c = 0;
  3. fakeType = "ammo";
  4. foreach(crateType,crateWeight in level.crateTypes[dropType])
  5. {
  6. if(c==random)
  7. {
  8. fakeType = crateType;
  9. break;
  10. }
  11. c++;
  12. }
  13. if(!isDefined(game["strings"][fakeType + "_hint"]))
  14. fakeType = "ammo";

This takes a random airdrop type (chopper, ac130, etc.) and at the end it checks if a localized string for that type exists, if not it takes ammo (but that should never happen).
[Image: azuw.jpg]
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Request] Airdrop Heaven mod The_Reaper_1 0 1,270 09-10-2013, 14:13
Last Post: The_Reaper_1
  Help WTF? FX trap [HARD] Tony. 11 2,196 02-22-2013, 19:32
Last Post: DidUknowiPwn
Video Preview Trap with FX [Z00MBY] Alex 19 4,019 01-27-2013, 15:49
Last Post: abidullah
  [Release] New trap and juggernaut carepackege Puffiamo 11 3,716 10-26-2012, 23:43
Last Post: islamsaab
Thumbs Up Preview Trap for Zombies in game [Z00MBY] Alex 1 1,352 09-21-2012, 19:13
Last Post: House
  Preview Plugin "A trap for the Zombie" [Z00MBY] Alex 10 2,537 09-15-2012, 18:51
Last Post: Yamato

Forum Jump:


Users browsing this thread: 1 Guest(s)