Page 1 of 2

Added health for players only

Posted: Tue Dec 17, 2013 6:51 pm
by Lorul1
is there any way how i can make changes to my odf or lua to add health to a certian unit but only if that unit is a human :?
OKAY
this is what im trying to achieve
one of the the "computer players" (AI) selects the "jet trooper". The jet trooper is on the map and his maximum health points are 100.

One of the human players spawns as a "jet trooper" but because he's a human he now has 200 maximum health points.

I guess my question would be is there a way (through the odf or lua) that the computer can give different things (like extra maximum health) to a unit depending on if its a human or computer.

Re: Added health for players only

Posted: Wed Dec 18, 2013 9:29 am
by Locutus
Mhh, the only thing I can think of right now is using SetProperty() but that would crash in multiplayer.
You might want to take a look at Zerteds Holocron mode. From what I've heard all units have a shield there (but it's only 1 HP) and only the unit carrying the holocron gets their shield raised to a useful value.

Re: Added health for players only

Posted: Wed Dec 18, 2013 10:29 am
by Deviss
Lorul1 wrote:is there any way how i can make changes to my odf or lua to add health to a certian unit but only if that unit is a human :?
OKAY
this is what im trying to achieve
one of the the "computer players" (AI) selects the "jet trooper". The jet trooper is on the map and his maximum health points are 100.

One of the human players spawns as a "jet trooper" but because he's a human he now has 200 maximum health points.

I guess my question would be is there a way (through the odf or lua) that the computer can give different things (like extra maximum health) to a unit depending on if its a human or computer.
add the green part to your lua file :wink: :
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("legion50x")
ScriptCB_DoFile("ObjectiveConquest")

---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------

function ScriptPostLoad()

--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1-1"}
cp2 = CommandPost:New{name = "cp2-1"}
cp3 = CommandPost:New{name = "cp3-1"}
cp4 = CommandPost:New{name = "cp4-1"}
cp5 = CommandPost:New{name = "cp5-1"}
cp6 = CommandPost:New{name = "cp6-1"}


--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)

conquest:Start()

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
SetProperty(GetCharacterUnit(character), "AddHealth", 50)
end
end)

EnableSPHeroRules()

end

function ScriptInit()
StealArtistHeap(132*1024)
-- Designers, these two lines *MUST* be first.
SetPS2ModelMemory(3200000)
SetUberMode(1);
ReadDataFile("ingame.lvl")

-- Republic Attacking (attacker is always #1)
local REP = 1
local CIS = 2
-- These variables do not change
local ATT = 1
local DEF = 2

SetMemoryPoolSize("Music", 200)


ReadDataFile("sound\\fel.lvl;fel1cw")
ReadDataFile("dc:sound\\ABC.lvl;ABCcw")
SetMaxFlyHeight(53)
SetMaxPlayerFlyHeight (53)
ReadDataFile("SIDE\\rep.lvl",
"rep_hero_aalya")

ReadDataFile("dc:SIDE\\Republic.lvl",
"Republic_1",
"Republic_2",
"Republic_3",
"Republic_4",
"Republic_5",
"Republic_6",
"Republic_7",
"Republic_8",
"Republic_9")

ReadDataFile("dc:SIDE\\50X.lvl",
"rep_clone1",
"rep_clone2",
"rep_clone3",
"rep_clone4",
"rep_clone5",
"rep_clone6",
"rep_clone7",
"rep_clone8",
"rep_clone9")

ReadDataFile("dc:SIDE\\fed.lvl",
"cis_droid1",
"cis_droid2",
"cis_droid3",
"cis_droid4",
"cis_droid5",
"cis_droid6",
"cis_droid7",
"cis_droid9",
"cis_hero")

ReadDataFile("dc:SIDE\\veh.lvl",
"cis_tread_snailtank",
"rep_walk_oneman_atst")

SetAttackingTeam(ATT)
SetupTeams{
rep = {
team = REP,
units = 50,
reinforcements = 150,
soldier = { "rep_clone1",15, 20},
pilot = { "rep_clone2",4,5},
assault = { "rep_clone3",4,5},
sniper = { "rep_clone4",4,5},
marine = { "rep_clone5",4,5},
engineer = { "rep_clone6",4,5},
officer = { "rep_clone7",4,5},
special = { "rep_clone8",4,5},
commander = { "rep_clone9",2,3},

},
cis = {
team = CIS,
units = 50,
reinforcements = 150,
soldier = { "cis_droid1",10, 30},
pilot = { "cis_droid2",5,7},
assault = { "cis_droid3",5,7},
sniper = { "cis_droid4",5,7},
marine = { "cis_droid5",8,9},
engineer = { "cis_droid6",4,5},
officer = { "cis_droid7",4,5},
commander = { "cis_droid9",2,4},

},

}

SetHeroClass(REP, "rep_hero_aalya")
SetHeroClass(CIS, "cis_hero")


-- Level Stats
ClearWalkers()
-- AddWalkerType(0, 8)
--AddWalkerType(5, 2) -- 2 attes with 2 leg pairs each
--AddWalkerType(3, 1) -- 3 acklays with 3 leg pairs each
AddWalkerType(1, 2)
AddWalkerType(0, 4)
local weaponCnt = 1600
SetMemoryPoolSize("Aimer", 1024)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("CommandWalker", 1)
SetMemoryPoolSize("EntityHover", 4)
SetMemoryPoolSize("EntityLight", 33)
SetMemoryPoolSize("EntitySoundStream", 100)
SetMemoryPoolSize("EntitySoundStatic", 200)
SetMemoryPoolSize("EntityWalker", 5)
SetMemoryPoolSize("MountedTurret", 100)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoldierAnimation", 1024)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("Weapon", 1024)
SetMemoryPoolSize("FlagItem", 5)
SetMemoryPoolSize("AcklayData", 6)
SetMemoryPoolSize("EntityFlyer", 6)

SetSpawnDelay(10.0, 0.25)
ReadDataFile("fel\\fel1.lvl", "fel1_conquest")
SetDenseEnvironment("false")
SetAIViewMultiplier(0.65)
--AddDeathRegion("Sarlac01")

-- Birdies
SetNumBirdTypes(1)
SetBirdType(0,1.0,"bird")


-- Sound Stats

voiceSlow = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "cw_music")
OpenAudioStream("dc:sound\\ABC.lvl", "ABC_stream")
OpenAudioStream("sound\\fel.lvl", "fel1")
OpenAudioStream("sound\\fel.lvl", "fel1")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
-- OpenAudioStream("sound\\fel.lvl", "fel1_emt")

SetBleedingVoiceOver(REP, REP, "rep_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(REP, CIS, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, REP, "cis_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, CIS, "cis_off_com_report_us_overwhelmed", 1)

SetOutOfBoundsVoiceOver(1, "Repleaving")
SetOutOfBoundsVoiceOver(2, "Cisleaving")

SetAmbientMusic(REP, 1.0, "rep_fel_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_fel_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2,"rep_fel_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_fel_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_fel_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2,"cis_fel_amb_end", 2,1)

SetVictoryMusic(REP, "rep_fel_amb_victory")
SetDefeatMusic (REP, "rep_fel_amb_defeat")
SetVictoryMusic(CIS, "cis_fel_amb_victory")
SetDefeatMusic (CIS, "cis_fel_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")



-- Camera Stats
AddCameraShot(0.896307, -0.171348, -0.401716, -0.076796, -116.306931, 31.039505, 20.757469)
AddCameraShot(0.909343, -0.201967, -0.355083, -0.078865, -116.306931, 31.039505, 20.757469)
AddCameraShot(0.543199, 0.115521, -0.813428, 0.172990, -108.378189, 13.564240, -40.644150)
AddCameraShot(0.970610, 0.135659, 0.196866, -0.027515, -3.214346, 11.924586, -44.687294)
AddCameraShot(0.346130, 0.046311, -0.928766, 0.124267, 87.431061, 20.881388, 13.070729)
AddCameraShot(0.468084, 0.095611, -0.860724, 0.175812, 18.063482, 19.360580, 18.178158)



end

Re: Added health for players only

Posted: Wed Dec 18, 2013 3:41 pm
by Lorul1
is there any way how this can be done with locking up multiplier. can i put this...

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
SetProperty(GetCharacterUnit(character), "AddHealth", 50)
end
end)

in to the odf's of my units or something :?

Re: Added health for players only

Posted: Thu Dec 19, 2013 12:29 am
by Deviss
Lorul1 wrote:is there any way how this can be done with locking up multiplier. can i put this...

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
SetProperty(GetCharacterUnit(character), "AddHealth", 50)
end
end)

in to the odf's of my units or something :?
i dont know about multiplier sorry :S, maybe modifying it for cast if multiplayer or singleplayer but i am not sure about that

Re: Added health for players only

Posted: Thu Dec 19, 2013 11:23 am
by Locutus
There are a couple of SetProperty() values that will certainly crash multiplayer (like changing the weapon model) but I've also heard of cases where SetProperty() didn't crash.
Simplest thing for you to do: Try it out.

Re: Added health for players only

Posted: Wed Dec 25, 2013 5:18 pm
by Lorul1
The script that you gave me adds +50 once I lose heath. Thats not what i want. Im looking for something that gives human players +50 heath that adds on to the health they already have.

i just want to boost the max health if the player is a human

~ If a computer plays as jet trooper he gets 20 health

~ If a human plays as a jet trooper he gets 30 health

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
SetProperty(GetCharacterUnit(character),
"AddHealth", 50)
end
end
)


I think "AddHealth" needs to change to something else but I don't know what

Re: Added health for players only

Posted: Wed Dec 25, 2013 6:19 pm
by Deviss
Lorul1 wrote:The script that you gave me adds +50 once I lose heath. Thats not what i want. Im looking for something that gives human players +50 heath that adds on to the health they already have.

i just want to boost the max health if the player is a human

~ If a computer plays as jet trooper he gets 20 health

~ If a human plays as a jet trooper he gets 30 health

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
SetProperty(GetCharacterUnit(character),
"AddHealth", 50)
end
end
)


I think "AddHealth" needs to change to something else but I don't know what
mmm do you have a standard health for every? like 400 ? when you say human, you mean player, or every units with healthtype "human"?

Re: Added health for players only

Posted: Wed Dec 25, 2013 9:34 pm
by Lorul1
yes I have the standard health for every, and when I say human I mean player.

Re: Added health for players only

Posted: Wed Dec 25, 2013 9:36 pm
by Deviss
Lorul1 wrote:yes I have the standard health for every, and when I say human I mean player.
so change addhealt per maxhealth xx (xx = standard human health + 50 ) :)

Re: Added health for players only

Posted: Thu Dec 26, 2013 12:50 am
by Lorul1
Sorry, I don't understand
Deviss wrote: so change addhealt per maxhealth xx (xx = standard human health + 50 ) :)
May I please have an example. :mrgreen: You can use my Lua if you want to.

Re: Added health for players only

Posted: Thu Dec 26, 2013 10:06 am
by nobody3
try changing addhealth with MaxHealth
not sure if that would work but its worth the try

Re: Added health for players only

Posted: Thu Dec 26, 2013 10:12 am
by Deviss
Lorul1 wrote:Sorry, I don't understand
Deviss wrote: so change addhealt per maxhealth xx (xx = standard human health + 50 ) :)
May I please have an example. :mrgreen: You can use my Lua if you want to.
450 = Standard human health + 50 :)
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")

---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------

function ScriptPostLoad()

--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1-1"}
cp2 = CommandPost:New{name = "cp2-1"}
cp3 = CommandPost:New{name = "cp3-1"}
cp4 = CommandPost:New{name = "cp4-1"}
cp5 = CommandPost:New{name = "cp5-1"}
cp6 = CommandPost:New{name = "cp6-1"}


--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)

conquest:Start()

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
SetProperty(GetCharacterUnit(character), "MaxHealth", 450)
end
end)

EnableSPHeroRules()

end

function ScriptInit()
StealArtistHeap(132*1024)
-- Designers, these two lines *MUST* be first.
SetPS2ModelMemory(3200000)
SetUberMode(1);
ReadDataFile("ingame.lvl")

Re: Added health for players only

Posted: Fri Dec 27, 2013 12:03 am
by Lorul1
Is there a way how I can add 50 health like this

SetProperty(GetCharacterUnit(character), "MaxHealth", +50)

I'm thinking about adding the wookies and I don't want them to have the same health as the clones

When the computers play as the clones: HEALTH = 100
When the human player plays as the clones: HEALTH = 150
When the computer plays as the wookies: HEALTH = 200
When the human player plays as the wookies: HEALTH = 250

The script you gave me is good but when I add the wookies I need a script that can add 50 not change all the classes to one health number. How do I do that?

Re: Added health for players only

Posted: Fri Dec 27, 2013 12:07 pm
by AQT

Code: Select all

onfirstspawn = OnCharacterSpawn(
function(character)
	if IsCharacterHuman(character) and GetEntityClass(character) == "whatever_your_wookiee_class_is_called" then
		SetProperty(GetCharacterUnit(character), "MaxHealth", 250)
	elseif IsCharacterHuman(character) and GetEntityClass(character) == "whatever_your_clone_class_is_called" then
		SetProperty(GetCharacterUnit(character), "MaxHealth", 150)		
	end
end)
Make sure you are able clearly explain how this code works.

Re: Added health for players only

Posted: Sun Dec 29, 2013 1:37 pm
by Lorul1
yeah this code doesn't work I also tried just narrowing it down to just one, like this

Code: Select all

Onfirstspawn = OnCharacterSpawn(
   function(character)
      if IsCharacterHuman(character) and GetEntityClass(character) == "all_inf_wookiee" then
         SetProperty(GetCharacterUnit(character), "MaxHealth", 999999)      
      end
   end
)
and it still doesn't work. :sick: any ideas why

Re: Added health for players only

Posted: Sun Dec 29, 2013 3:16 pm
by kinetosimpetus
Try CurHealth.

It's not a value you'll see in any ODF, but it's the value the game uses to store the unit's current health.

If the ODF's MaxHealth is 100, you can set CurHealth to 200 and it will work, but once the player is damaged below 100 they can't heal to above 100, and if damaged but still above 100 they also can't heal.

If you set the ODF MaxHealth to 200 and whenever a Jettrooper spawns or is damaged or healed, check if its CurHealth is above 100 and set it to 100, ignoring all players in the calculation.

Re: Added health for players only

Posted: Mon Dec 30, 2013 3:03 pm
by Lorul1
the CurHealth thing is what I want. I tested it using this code and it worked

Code: Select all

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
SetProperty(GetCharacterUnit(character),"CurHealth", 950)
end
end
)
that was ONLY A TEST

I need it to work with the code AQT gave me

Code: Select all

Onfirstspawn = OnCharacterSpawn(
   function(character)
      if IsCharacterHuman(character) and GetEntityClass(character) == "all_inf_wookiee" then
         SetProperty(GetCharacterUnit(character),"CurHealth", 990)      
      end
   end
)
for some reason the code wont work with "CurHealth", "MaxHealth", or "AddHealth" wont work with the code above.

I think it has some thing to do with this line
AQT wrote:if IsCharacterHuman(character) and GetEntityClass(character) == "all_inf_wookiee" then


were REALLY close to figuring this out can some one find the problem with AQT's code ?

Re: Added health for players only

Posted: Mon Dec 30, 2013 6:12 pm
by Nedarb7
Try this

Code: Select all

if IsCharacterHuman(character) and ( GetEntityClass(character) == "all_inf_wookiee" ) then

Re: Added health for players only

Posted: Mon Dec 30, 2013 10:52 pm
by Locutus
It should be
GetEntityClassName(character)
instead of
GetEntityClass(character)
.