Im really going crazy...

Post your scripting questions / solutions here

Moderator: Moderators

simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Im really going crazy...

Post by simsalabim »

i hope ill find some help here... (im a n00b btw)

Game:
MOHAA

What i want:
If a player reaches a certain height, i.e. 1st floor, his health slowely decreases until he reaches the ground again.
>> if player is above (0 0 100) -> slowely decrease health
>> if he is beneath (0 0 100) -> stop decreasing

What i tried (ideas i got from here:)
trigger - i tried the trigger first (no success at all btw), then i saw somewher on this board, that if 1 player is allrdy "triggering", it wouldnt effect on a 2nd one -> discarded

Fire - i think if i put an area this big under fire, i would get major lags - or am i wrong?



Any other solutions? Is it possible to query the height-position?

thx in advance,
simsala
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

24 views and noone has an idea? i mean, is it really THAT hard?

dont get me wrong, im just wondering - no offense at all
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Welcome to .Map simsalabim :wink: ... it sometimes takes a while but the good news is that hardly any problem goes unsolved here :)

I think the main reason why you didn't get a reply yet is because you didn't post any code you tried, but are basically asking others to make the script for you. People here often like you to try things, and then will help out when you run into problems.

Now on to the actual problem, something like this will work.

Code: Select all

main:
  // the usual
  
  // launch 'painful_up_there' as a seperate process
  // so it doesn't interfere with rest of script
  thread painful_up_there

end // ! this 'end' is often forgotten !

painful_up_there:

  // loop forever
  while(1)
  {
    // 'browse' through all players
    // and subtract health if they are too high

    for(local.i = 1; local.i <= $player.size; local.i++)
    {
      local.p = $player[local.i]
    
      // check if player is alive, and not spectating
      // there is a slight 'hole' here, as players that have 
      // joined a team but not yet selected a weapon
      // are technically alive and not a 'spectator'
      // but have not spawned yet and are still
      // spectating the map.
      // this is mostly a bug / inconvenience in mohaa
      // that is not impossible but hard to get around
      // I'm not sure if spectating players can be hurt
      // if they can, then this is a potential problem

      if(isAlive local.p && local.p.dmteam != "spectator")
      {
        // z-coordinate check
        // 100.0 would be the actual radiant z-coord
        if(local.p.origin[2] >= 100.0) 
        {
          // hurt a bit
          local.p hurt 0.05 // 1 hp per secod
        }
      }
    }
    // wait 1 frame (50 msec) before going through the loop again
    waitframe
  }
end
Image
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

First of all - thank you very much! I'll try this one out asap.

The reason why i didn't post any code is that none of them worked AND the code i made was absolutely useless, since a trigger can only be activated by one player at a time.
So i really didnt know where to start. But believe me - i actually spent a lot of time on that problem :) I mean, you can see from the topic how desperate i really was... :P

Anyhow - ill try this one out and tell you if it works.

Thx,
simsalabim
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

IT WORX - I LUV YOU! :D

What i would like to add:
1. A delay of aprox. 5 secounds before it starts to kill. (I'll try that on my own first ;) )
2. A warning message for the Player alone "Get to Groundzero - You have 5 secounds!" - is that possible? i mean a message that only the player will see?

T i a,
simsalabim
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

:)

A warning message for 1 player only can be done like this:

local.p iprint "Get to Groundzero - You have 5 secounds!" 1

The '1' makes this a white, clicking message. If you put a 0, you'll get a silent yellow message.
Image
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

Problem:

Code: Select all

//initialising sound
local.master = spawn ScriptMaster
local.master aliascache fin_count sound/items/final_countdown.wav soundparms 0.7 0.0 1.0 0.0 10000 10000 local loaded maps "dm moh obj"

Want to play it here:
for(local.timer=0; local.timer<10; local.timer++)
		  {
		   if(local.p.origin[2] >= 20.0)
		    {
		     wait 1
		     local.p hurt 5.0 playsound fin_count  // 1 hp per secound + play sound
		      if(local.timer < 1)
		        {
		         local.p iprint "I'm so n00bish u won't believe! :)" 1 
	                 local.p iprint "Whatever!" 1
		        }
		     }
	          }
Any suggestions??

Thx in Advance,
simsalabim
LeBabouin
Lance Corporal
Posts: 22
Joined: Tue Jun 21, 2005 11:10 pm

Post by LeBabouin »

simsalabim wrote:Problem:

Code: Select all

//initialising sound
local.master = spawn ScriptMaster
local.master aliascache fin_count sound/items/final_countdown.wav soundparms 0.7 0.0 1.0 0.0 10000 10000 local loaded maps "dm moh obj"

Want to play it here:
for(local.timer=0; local.timer<10; local.timer++)
		  {
		   if(local.p.origin[2] >= 20.0)
		    {
		     wait 1
		     local.p hurt 5.0 playsound fin_count  // 1 hp per secound + play sound
		      if(local.timer < 1)
		        {
		         local.p iprint "I'm so n00bish u won't believe! :)" 1 
	                 local.p iprint "Whatever!" 1
		        }
		     }
	          }
Any suggestions??

Thx in Advance,
simsalabim
maybe:

Code: Select all

for(local.timer=0; local.timer<10; local.timer++)
		  {
		   if(local.p.origin[2] >= 20.0)
		    {
		     wait 1
		     local.p hurt 5.0 playsound fin_count  // 1 hp per secound + play sound
		      if(local.timer =4)
		        {
		         local.p iprint "Get to Groundzero - You have 5 secounds!" 1 		        }

		      if(local.timer < 1)
		        {
		         local.p iprint "I'm so n00bish u won't believe! :)" 1 
	                 local.p iprint "Whatever!" 1
		        }
		     }
	          }
GiffE1118
Warrant Officer
Posts: 137
Joined: Fri Aug 05, 2005 12:14 am
Contact:

Post by GiffE1118 »

cant have spaces in ur thread name

Code: Select all

Want to play it here: 
www.95thDivision.com
Image

BOTTOM 125th Poster! lol
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

Oh, lol, missunderstanding.

Want to play it here: isnt a thread...

What i meant was, that i cant get the sound to work.
Its not playing.
I used the ubersound-bypass by jv_map to work arround those tiki files, cuz i have no idea what they really are... :P

So there must be a syntax-error or something, when i try to play the sound in:

Code: Select all

local.p hurt 5.0 playsound fin_count
Sorry :)
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

Okay nevermind...
Sorted it out.

Code: Select all

local.p hurt 5.0
local.p playsound fin_count 
Did it!
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

Another question: (< no thread :P)

The particular player has been given this variable: local.p

How can i put his name in...
iprintln "$player?" <this doesnt work

Thx again,
simsalabim
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

local.p = $player[local.i]

So you could replace local.p with $player[local.i].

$player[local.i] iprint "I'm so n00bish u won't believe! :)" 1
Image
simsalabim
Lance Corporal
Posts: 17
Joined: Wed Jan 18, 2006 6:58 pm

Post by simsalabim »

/me slams head on desk...

Thank you...
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Awww poor desk :(

You're welcome, good luck with the script :wink:
Image
Post Reply