Home   Help Search Login Register  

Author Topic: Please a lil help with fairly simple Trigger Condition Script here/Rating  (Read 5490 times)

0 Members and 1 Guest are viewing this topic.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Ahh... ok. So re-reading your first post again, would you be able to re-state what you're trying to achieve?

You want something to happen to a player if they enter a trigger twice and their rating is below -2000?
What do you want to happen to them?

I've got a fair idea of how we can go about doing this, but I'll need a bit more info.
It'll save me from giving you more half arsed answers ;)

Mr.Pibb

  • Guest
glad to hear ur still with me on this lol :)


Quote:
You want something to happen to a player if they enter a trigger twice and their rating is below -2000?
What do you want to happen to them?


anytime the players leave the trigger, their rating is set back to normal. So, by making the town(s) they killed in a reference to each appropriate player, when they try to come back to those towns the trigger checks if the variable (badfactiontown0) refers to that player, and hence the trigger trips again and his rating is reduced to -100000 for the duration of his pleasant stay in the town. My only concern is, can u reference a variable to more than one player? (like badfactiontown0)

 and heres an overall overview:

 there will be like 10 towns on the map

 all of these towns will be res, freindly

 There will be say 9 players: all players ratings will be just above rogue satus

 Say a player walks into the radius of a town trigger- same trigger u made

 Of course, the checks start working, seeing if that player goes below -2000 rating (kills a freindly) within the radius of the trigger at THAT TOWN.- alike town0

 before I continue, suppose not just one player enters 1 town, but 3 or 4. Like i said, gotta be sure that trigger is gonna respond to any, or all of them if they commit a kill and go below -2000.

 Now. If one of them does commit the act, goes -2000, within that trigger, a variable is set to that player, the variable contains the Town(badfactiontown0)

 So, if a player gets that variable set to him for that town (badfactiontown0), it means if he comes back to that town the trigger will check if any player has the 'badfactiontown0' referencing them, that check seperated from the -2000 rating check by || (or). So either one will execute the script. And lastly in the script it will always set that player to -100000 rating.

 So u see, the whole point to checking to see if players go to -2000 in a town is to make that town hate that player, or players for good. Any time they try to come back after that, the trigger trips with the 'badfactiontown' variable set to them and the res will hate em every time.

 Only thing left aside from this is a de-activator for setting the players rating back to normal if they leave the radius of the trigger.

 hope ya get it

 basically about towns holding a grudge against players that kill in their town.

 Might just have to make this 'function' here availiable for download as a script addon if it finally works, at least then other people that might want to use it can and Id feel better about all u guys have done for me thus far. ;)

 
« Last Edit: 02 Dec 2004, 04:01:32 by Mr.Pibb »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
this is a roundabout way of doing this but it just might work better than the trigger so stay with me on this

in place of the trigger put a game logic in the same place
in its init line put:
[this, townsRadius, townName] exec "Town.sqs"

"Town.sqs"
Code: [Select]
_center = _this select 0
_radius = _this select 1
_town = _this select 2
unwanted0 = []
unwanted1 = []
unwanted2 = []
unwanted3 = []
unwanted4 = []
unwanted5 = []
unwanted6 = []
unwanted7 = []
unwanted8 = []
unwanted9 = []

?_town == town0:_Grudgelist = unwanted0
?_town == town1:_Grudgelist = unwanted1
?_town == town2:_Grudgelist = unwanted2
?_town == town3:_Grudgelist = unwanted3
?_town == town4:_Grudgelist = unwanted4
?_town == town5:_Grudgelist = unwanted5
?_town == town6:_Grudgelist = unwanted6
?_town == town7:_Grudgelist = unwanted7
?_town == town8:_Grudgelist = unwanted8
?_town == town9:_Grudgelist = unwanted9

#checkIn
_RatingChange = 0
?player distance _center <= _radius:goto "checkFriendlyKills"
goto "checkIn"

#checkFriendlyKills
?player in _GrudgeList:goto "LowRating"
_EntryRating = rating player
#CheckRatingDrop
?rating player < _EntryRating:_RatingChange = (_EntryRating - (rating player)); _GrudgeList = (_GrudgeList + [player]); goto "LowRating"
?player distance _center > _radius:goto "CheckIn"
goto "CheckRatingDrop"

#LowRating
player addrating -100000
#WhileIn
?player distance _center > _radius:player addrating 100000;player addrating _RatingChange;goto "checkIn"
?rating player != (_EntryRating - _RatingChange):_RatingChange = (_EntryRating - (rating player))
goto "WhileIn"

That one was a hard one. You will need to do this for each of your 10 towns, and your towns must be named town0 - town9 for it to work

basically it maintains a list for each town of who has lost a rating a in that town, and then when that person enters the town and they are in the list related to that town, their rating drops a lot, and when they leave, it returns to normal.

just copy and paste this into notepad and save it as town.sqs
« Last Edit: 02 Dec 2004, 04:59:50 by Triggerhappy »

Mr.Pibb

  • Guest
 wow

 looks like it was a hard one Triggerhappy ;) thanks

 gettin to testing in a moment

 

Mr.Pibb

  • Guest
@Triggerhappy

 ok, did a few test runs with the radius around town0 at 100, made sure starting pos was outside of radius and started with players rating set to -1999.

 Ran in the town, killed an res, then of course I was denoted as enemy.
 Ran back out of town radius and indeed, I returned to freindly (could see my icon on map go from red to green)
 hate to say this part, when I ran back thro town radius, my freindly status remained the same, it didnt switch back over to enemy. :(
 now, the only thing I can say is I did only make one town with the game logic unit just to test. Do I need to make all 10 of them for it to work?
 I will go ahead and make all ten of em, if anything different occurs I'll post it but its 12:30 am so I gotta hit it soon.

 I can see right now if this mission does actually get done someday I will have to include u guys in the credits, not gonna take credit for someone elses hard work ;).


 
« Last Edit: 02 Dec 2004, 06:12:41 by Mr.Pibb »

Mr.Pibb

  • Guest
 I went ahead and put up all the towns, and it seemed to make no difference.
 It does seem to properly switch players back over to freindly every time I leave the town radius after a kill, but it never holds the 'grudge' to the player from the town, I can always come back in as freindly.
 
« Last Edit: 02 Dec 2004, 06:54:35 by Mr.Pibb »

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Ahhh... ok. I get it now :)

I reckon you can do it with two triggers and an array (per town).
No scripts required. Let me have a think about it, and try some things out in the editor ;)

Mr.Pibb

  • Guest
 hey Sui

 Great to hear, look forward to seeing what you come up with and testing it.

 Got a ton of housework to do today, but I will look in here throughout the day, and be able to do more testing this evening if u come up with something.


 Too bad I cant change the Topic Title here, lol, think the 'fairly simple' part is a lil off  :o

 Thanks all, will be around
« Last Edit: 02 Dec 2004, 21:01:47 by Mr.Pibb »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
you can change the topic, edit you very first post and change the subject

now, i think this will fix the problem, it doesn't matter how many towns you use, as long as there are no more than 10

"Town.sqs"
Code: [Select]
_center = _this select 0
_radius = _this select 1
_town = _this select 2
unwanted0 = []
unwanted1 = []
unwanted2 = []
unwanted3 = []
unwanted4 = []
unwanted5 = []
unwanted6 = []
unwanted7 = []
unwanted8 = []
unwanted9 = []

?_town == town0:_Grudgelist = [unwanted0]
?_town == town1:_Grudgelist = [unwanted1]
?_town == town2:_Grudgelist = [unwanted2]
?_town == town3:_Grudgelist = [unwanted3]
?_town == town4:_Grudgelist = [unwanted4]
?_town == town5:_Grudgelist = [unwanted5]
?_town == town6:_Grudgelist = [unwanted6]
?_town == town7:_Grudgelist = [unwanted7]
?_town == town8:_Grudgelist = [unwanted8]
?_town == town9:_Grudgelist = [unwanted9]

#checkIn
_RatingChange = 0
?player distance _center <= _radius:goto "checkFriendlyKills"
goto "checkIn"

#checkFriendlyKills
?player in (_GrudgeList select 0):goto "LowRating"
_EntryRating = rating player
#CheckRatingDrop
?rating player < _EntryRating:_RatingChange = (_EntryRating - (rating player)); (_GrudgeList select 0) = ((_GrudgeList select 0) + [player]); goto "LowRating"
?player distance _center > _radius:goto "CheckIn"
goto "CheckRatingDrop"

#LowRating
player addrating -100000
#WhileIn
?player distance _center > _radius:player addrating 100000;player addrating _RatingChange;goto "checkIn"
?rating player != (_EntryRating - _RatingChange):_RatingChange = (_EntryRating - (rating player))
goto "WhileIn"

if sui's solution works then i would suggest using it, though
« Last Edit: 03 Dec 2004, 00:45:47 by Triggerhappy »

Mr.Pibb

  • Guest
 Thanks Triggerhappy,

 Will give it a go.


 btw, maybe I should leave the topic title as is, to reflect the difference between what I thought was a simple script and what it really is :P

Mr.Pibb

  • Guest
 Got an error after killing an res (after rating drop)

'(_GrudgeList select 0) |#|= ((GrudgeList select 0) + [player]); goto "LowRating": Error Unknown Operator

 Also the freindly status never gets switched back after leaving town now.

 Did have script file in a "Main" folder (exec "Main\Town.sqs") and moved it with mission just to eliminate any possible problems it might cause before typing this response, and results the same.

 Honestly not sure if this is pertanent, but just picked up this bug indication from Editors depot, command topics:

OFP BUG ALERT

Finding this one out was a real PITA:
Apparently, OFP runs code in init fields BEFORE it creates arrays. Thus, if you try to, say, execute a script from a unit's init field, and pass that script an array that you also create in an init field, that script will be passed a null variable, which will stay null.

So basically, when executing scripts with arrays in their params, run them from a trigger, or after a delay in init.sqs.


Prolly isnt at all the problem, dont really know enough yet to understand it all, the conditions just looked similiar, just tryin to help in any measily way I can. :)
« Last Edit: 03 Dec 2004, 01:13:45 by Mr.Pibb »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
found out a better way to do it any way

Code: [Select]
_center = _this select 0
_radius = _this select 1
_town = _this select 2
_Grudge = []

#checkIn
_RatingChange = 0
?player distance _center <= _radius:goto "checkFriendlyKills"
goto "checkIn"

#checkFriendlyKills
?_town in _Grudge:goto "LowRating"
_EntryRating = rating player
#CheckRatingDrop
?rating player < _EntryRating:_RatingChange = (_EntryRating - (rating player)); _Grudge = [_town]; goto "LowRating"
?player distance _center > _radius:goto "CheckIn"
goto "CheckRatingDrop"

#LowRating
player addrating -100000
#WhileIn
?player distance _center > _radius:player addrating 100000;player addrating _RatingChange;goto "checkIn"
?rating player != (_EntryRating - _RatingChange):_RatingChange = (_EntryRating - (rating player))
goto "WhileIn"

another way of doing it if that doesn't work or this might work better:
Code: [Select]
_center = _this select 0
_radius = _this select 1
_town = _this select 2
_Grudge = false

#checkIn
_RatingChange = 0
?player distance _center <= _radius:goto "checkFriendlyKills"
goto "checkIn"

#checkFriendlyKills
?_Grudge:goto "LowRating"
_EntryRating = rating player
#CheckRatingDrop
?rating player < _EntryRating:_RatingChange = (_EntryRating - (rating player)); _Grudge = true); goto "LowRating"
?player distance _center > _radius:goto "CheckIn"
goto "CheckRatingDrop"

#LowRating
player addrating -100000
#WhileIn
?player distance _center > _radius:player addrating 100000;player addrating _RatingChange;goto "checkIn"
?rating player != (_EntryRating - _RatingChange):_RatingChange = (_EntryRating - (rating player))
goto "WhileIn"

so you know, this script needs to be run on all players computer when playing this, because it works locally, using player which is just the unit that player is
« Last Edit: 03 Dec 2004, 02:59:48 by Triggerhappy »

Mr.Pibb

  • Guest
 Ok Triggerhappy, but is there anything I need to do besides just using the GameLogic unit for the second script to run it on all players computers?

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
all of these have to run on all computers, which it should anyway, because the gamelogic obviously is not local, so its init will exec the script on all computers, afaik

Mr.Pibb

  • Guest
 ok

 tried the first script.

First time got an error after kill that showed a parenthesis was needed becasue there is only one parenthesis at _Grude = [_town]) <<<

#CheckRatingDrop
?rating player < _EntryRating:_RatingChange = (_EntryRating - (rating player)); _Grudge = [_town])|#|; goto "LowRating"
                           

 So i went ahead and removed it, assuming it was a typo?

 Ran the script and the same exact results as first script, wont set the town grudge, u can still walk right back in as freindly after a kill, but leaving the town worked, as before.

 Testing second script
« Last Edit: 03 Dec 2004, 02:59:30 by Mr.Pibb »