Off topic: 10,000th topic!!!
A weapon that dispenses AI? [Solved]
Moderator: Moderators
-
woner11
- Sith

- Posts: 1361
- Joined: Tue Sep 18, 2007 10:17 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: The lost world of pickels
- Contact:
A weapon that dispenses AI? [Solved]
I'm not sure how many of you have played negative zone city or whatever, but I noticed a weapon which puzzled me how to make. The wampa on there had a weapon which when pressed made four unplayer controlled wampas spawn around him and I was wondering how it was done. Thanks in advance.
Off topic: 10,000th topic!!!

Off topic: 10,000th topic!!!
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: A question...
What you do is insert coding similar to this:
Into the ScriptPostLoad of your .lua. Then add a third team with the to-be-spawned unit, like this:
Then create a null dispenser weapon (note that the weapon is called rep_weap_summon, but it's the powerup that it dispenses - rep_item_powerup_cura - that triggers the actual code) - it does nothing, it's just used to trigger the .lua code above.

It's not difficult to do, if you can get around the several things you need to do to make it work. It's discussed at great length in this thread:
http://www.gametoast.com/forums/viewtop ... =27&t=6916
Code: Select all
TroopSpawnerWeapon = "rep_item_powerup_cura"
OnCharacterDispensePowerup(
function(character,powerup)
if GetEntityClass(powerup) == GetEntityClassPtr(TroopSpawnerWeapon) then
local SupportTeam = 3 --Team the new spawned character is in (change this)
local teamSize = GetTeamSize(SupportTeam)
for i = 0, teamSize-1 do
local characterIndex = GetTeamMember(SupportTeam, i)
local charUnit = GetCharacterUnit(characterIndex)
if not charUnit then
local destination = GetEntityMatrix(GetCharacterUnit(character))
SpawnCharacter(characterIndex,destination)
end
end
end
end
--User team (change this)
)Code: Select all
SetTeamName (3, "summon")
AddUnitClass (3, "rep_inf_ep2rifleman", 3,4)
SetClassProperty("rep_inf_ep2rifleman", "AddHealth", -100)
SetUnitCount (3, 4)
AddAIGoal(3, "Deathmatch", 100)
SetTeamAsFriend(ATT,3)
SetTeamAsFriend(3,ATT)
SetTeamAsEnemy(DEF,3)
SetTeamAsEnemy(3,DEF)
SetTeamName(3, ATT)rep_weap_summon.odf wrote:[WeaponClass]
ClassLabel = "dispenser"
[Properties]
//IconTexture = "HUD_powerup_icon"
//MuzzleFlash = "small_muzzle_flash"
//Discharge = "small_smoke_effect"
HUDTag = ""
GeometryName = ""
RoundsPerClip = "1"
ReloadTime = "1.0"
LockOnRange = "80.0"
LockTime = "0.4"
HeatPerShot = "0.25" // only allow player to fire every 5 seconds
HeatRecoverRate = "0.033"
HeatThreshold = "0.5"
HideOnFire = 0
InstantPlayFireAnim = 1
OffhandWeapon = 1
TrackingSound = ""
WEAPONSECTION = 1
ModeTexture = "HUD_weap_health"
ReticuleTexture = "reticule_00"
OrdnanceName = "rep_item_powerup_cura"
ShotDelay = "0.0"
MaxItems = "4.0"
AutoAimSize = "1.0"
SalvoCount = "1"
SalvoDelay = "0.0"
InitialSalvoDelay = "0.5"
MinStrength = "0.3"
MaxStrength = "0.4"
MaxPressedTime = "0.0"
FireSound = "com_weap_throw"
FireEmptySound = "com_weap_inf_ammo_empty"
FireLoopSound = ""
ReloadSound = "com_weap_inf_equip_sm"
ChargeSound = ""
ChangeModeSound = "com_weap_inf_equip_sm"
WeaponChangeSound = "com_weap_inf_equip_sm"
JumpSound = "com_weap_inf_pistol_mvt_jump"
LandSound = "com_weap_inf_pistol_mvt_land"
RollSound = "com_weap_inf_pistol_mvt_roll"
//ProneSound = "com_weap_inf_pistol_mvt_lie"
SquatSound = "com_weap_inf_pistol_mvt_squat"
//StandSound = "com_weap_inf_pistol_mvt_getup"
And voila:rep_item_powerup_cura wrote:[GameObjectClass]
ClassLabel = "powerupitem"
GeometryName = "ffx_weap_inf_grenadethermal.msh"
GeometryScale = 0.15
[Properties]
GeometryName = "ffx_weap_inf_grenadethermal"
SoldierHealth = 0
SoldierAmmo = 0
Lifespan = 0.1
Powerupsound = "com_weap_powerup_pickup defer"
Velocity = "0.0"
Gravity = "1.0"
Rebound = "0.0"
Friction = "1.0"
//CollisionOtherSound = "com_weap_mine_land defer"
It's not difficult to do, if you can get around the several things you need to do to make it work. It's discussed at great length in this thread:
http://www.gametoast.com/forums/viewtop ... =27&t=6916
-
woner11
- Sith

- Posts: 1361
- Joined: Tue Sep 18, 2007 10:17 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: The lost world of pickels
- Contact:
Re: A question...
Thanks, I just have one more question. How do I make a weapon that heals the users freinds as it hurts the enemy. I tried, and here are my odfs.
The original odf:
Ord1:
Ord2:
The original odf:
Hidden/Spoiler:
Hidden/Spoiler:
Hidden/Spoiler:
-
MasterSaitek009
- Black Sun Slicer
- Posts: 619
- Joined: Wed Aug 23, 2006 4:10 pm
Re: A question...
Code: Select all
OnObjectDamage(
function(object, damager)
if damager == nil then return end
if GetCharacterTeam(damager) == DEF then
if GetCharacterClass(damager) == 2 then
local unit = GetCharacterUnit(damager)
if unit == nil then return end
SetProperty(unit, "CurHealth", GetObjectHealth(unit) + 1)
end
end
end
)Something like that? Except you would need to change the team condition to a GetLastHitWeapon() condition.
-
woner11
- Sith

- Posts: 1361
- Joined: Tue Sep 18, 2007 10:17 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: The lost world of pickels
- Contact:
Re: A question...
Does this still do damage to the target, because if so, then its perfect!
-
MasterSaitek009
- Black Sun Slicer
- Posts: 619
- Joined: Wed Aug 23, 2006 4:10 pm
Re: A question...
You set the damage in your ODF.
Make sure to credit Zerted for it. He really did most of it.
Make sure to credit Zerted for it. He really did most of it.
-
woner11
- Sith

- Posts: 1361
- Joined: Tue Sep 18, 2007 10:17 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: The lost world of pickels
- Contact:
Re: A question...
I'll give it a try and see how it all works out. Just a few quick questions about it as I am not good with most of this lua stuff other than characters, mainly because I hardly ever do it.
What does the 2 part mean?
What does the 2 part mean?
Whre in the whole code do I insert my character name? Lets say its cis_hero_darth and he is the sniper does it work like this?MasterSaitek009 wrote: if GetCharacterClass(damager) == 2 then
Code: Select all
[quote="MasterSaitek009"]OnObjectDamage(
function(object, damager)
if damager == nil then return end
if GetCharacterTeam(cis_hero_darth) == DEF then
if GetCharacterClass(cis_hero_darth) == 2 then
local unit = GetCharacterUnit(cis_hero_darth)
if unit == nil then return end
SetProperty(unit, "CurHealth", GetObjectHealth(unit) + 1)
end
end
end
)[/quote]-
MasterSaitek009
- Black Sun Slicer
- Posts: 619
- Joined: Wed Aug 23, 2006 4:10 pm
Re: A question...
Code: Select all
OnObjectDamage(
function(object, damager)
if damager == nil then return end
if GetCharacterTeam(damager) == DEF then
if GetCharacterClass(damager) == 2 then
local unit = GetCharacterUnit(damager)
if unit == nil then return end
SetProperty(unit, "CurHealth", GetObjectHealth(unit) + 1)
end
end
end
)Code: Select all
if GetCharacterTeam(damager) == DEF thenCode: Select all
if GetCharacterClass(damager) == 2 thenI had this setup for a unit with only one weapon, so I didn't have to check for the last hit weapon. You'll have to.
Try this:
Code: Select all
OnObjectDamage(
function(object, damager)
if damager == nil then return end
if GetObjectLastHitWeaponClass(object) ~= "YOUR_WEAPON_NAME" then return end -- ~= means not equal to
local unit = GetCharacterUnit(damager)
if unit == nil then return end
SetProperty(unit, "CurHealth", GetObjectHealth(unit) + 1) --adjust + 1 to your preference
end
)-
woner11
- Sith

- Posts: 1361
- Joined: Tue Sep 18, 2007 10:17 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: The lost world of pickels
- Contact:
Re: A question...
Okay, I think I got it, I'll try it.
