This maybe too far fetched but..

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

This maybe too far fetched but..

Post by AnthonyBF2 »

Is there any lua code that can make objects follow the player?
etc; props, cps, an ordnance like a mine, maybe other things like destructible props.

Anything? :?
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: This maybe too far fetched but..

Post by razac920 »

Sure, why not? Just teleport an object behind the player, and update its position continually.
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: This maybe too far fetched but..

Post by MileHighGuy »

razac already wrote the code. It is AWESOME.

viewtopic.php?f=27&t=29436&p=496275&hil ... ck#p496275
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: This maybe too far fetched but..

Post by AnthonyBF2 »

That's a nice lua stuff there but not quite what I wanted to obtain. I don't need choking or anything.

My idea is this:

player spawns, in the script a defined object will follow on constantly on player coordinate.
I suppose the object would act as a shield, if it were to follow around the player.

edit: studying Razac's code, getting an idea
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: This maybe too far fetched but..

Post by razac920 »

Okay I don't know if you want in front of player or behind -- suppose it is in front, then have something like:

Code: Select all

object = [whatever object you want to have around player]
human = nil -- for now just assume only 1 human, this is a SP game
update = CreateTimer("update")
SetTimerValue(update,0.2) -- updates every .2 seconds, adjust as you want
OnTimerElapse(function(timer)
  if human and GetCharacterUnit(human) and IsObjectAlive(GetCharacterUnit(human)) then -- human is alive, move object and restart timer
    SetEntityMatrix(object, CreateMatrix(0,0,0,0,0,0,1,GetEntityMatrix(GetCharacterUnit(human)))) -- adjust the 1 based on how much in front/behind
    SetTimerValue(update,0.2) -- updates every .2 seconds, adjust as you want
    StartTimer(update)
  end
end,
update)
OnCharacterSpawn(function(player)
if IsCharacterHuman(player) then
  human = player
  SetEntityMatrix(object, CreateMatrix(0,0,0,0,0,0,1,GetEntityMatrix(GetCharacterUnit(human)))) -- adjust the 1 based on how much in front/behind
  StartTimer(update)
end
end)
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: This maybe too far fetched but..

Post by AnthonyBF2 »

that's some great stuff thanks for your work :D
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: This maybe too far fetched but..

Post by razac920 »

I haven't tested it, does it work?
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: This maybe too far fetched but..

Post by AnthonyBF2 »

I have not tested it yet. I am trying to create an invisible command post using the geometry of the collision blocks.

That is the object I want to constantly follow the player. The goal is to have enemies spawn around the player constantly.

After I test it I will post back.
User avatar
Locutus
1st Lieutenant
1st Lieutenant
Posts: 420
Joined: Fri Jun 04, 2010 10:08 am
Projects :: Stargate Battlefront Pegasus
Location: Germany
Contact:

Re: This maybe too far fetched but..

Post by Locutus »

You are aware that units spawn at paths/nodes around a command post and not around the command post prop itself?
Moving the prop won't change their spawn location. Instead, simply spawn your units around the player by using a matrix based on the players position with a certain offset.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: This maybe too far fetched but..

Post by razac920 »

You could try teleporting a command walker whose spawn points are just offset from the vehicle itself, or alternatively just teleport players next to human after spawning. But I agree, simply moving the location of a command post will not work
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: This maybe too far fetched but..

Post by AnthonyBF2 »

I am aware of moving a cp object and the spawns itself.
When I get around to it I am going to mess with the SpawnPointLocation values found on command vehicles
Post Reply